Vercel MCP Python Server

Vercel MCP Python Server

A serverless MCP server deployed on Vercel that provides basic utility tools including echo, time retrieval, arithmetic operations, and mock weather information. Includes an interactive client application for testing and demonstration purposes.

Category
访问服务器

README

AI Generated

Vercel MCP Python Server

A Model Context Protocol (MCP) server built with Python and FastMCP, designed to run on Vercel's serverless platform.

Project Structure

vercel-mcp-python/
├── api/
│   └── index.py          # Main Vercel function
├── src/
│   └── mcp_server.py     # Your MCP server logic
├── client-app/           # Interactive MCP client
│   ├── mcp_client.py     # Rich client application
│   ├── requirements.txt  # Client dependencies
│   ├── setup.py          # Setup script
│   ├── README.md         # Client documentation
│   └── run_client.bat    # Windows launcher
├── requirements.txt       # Server dependencies
├── vercel.json           # Vercel configuration
└── README.md

Features

This MCP server provides the following tools:

  • echo: Echo back a provided message
  • get_time: Get the current server time
  • add_numbers: Add two numbers together
  • get_weather_info: Get mock weather information for a location

And the following resources:

  • config://server: Server configuration information

Prerequisites

Before setting up the project, you'll need to install the Vercel CLI:

Installing Vercel CLI

For Git Bash on Windows:

  1. Install Node.js (if not already installed):

  2. Install Vercel CLI globally:

    npm install -g vercel
    
  3. Verify installation:

    vercel --version
    

If you encounter PATH issues:

# Find npm global directory
npm config get prefix

# Add to PATH (add this to your ~/.bashrc)
export PATH=$PATH:$(npm bin -g)
source ~/.bashrc

Alternative methods:

# Using npx (no global installation)
npx vercel

# Using yarn
yarn global add vercel

Setup

  1. Create and activate virtual environment (Recommended):

    # Create virtual environment
    python -m venv venv
    
    # Activate virtual environment
    # On Windows PowerShell:
    .\venv\Scripts\Activate.ps1
    
    # On Windows Git Bash:
    source venv/Scripts/activate
    
    # On macOS/Linux:
    source venv/bin/activate
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Login to Vercel:

    vercel login
    
  4. Deploy to Vercel:

    vercel --prod
    

Local Development

To test locally, you can use Vercel's development server:

vercel dev

Troubleshooting Windows Issues

Note: Local development with vercel dev may have issues on Windows due to runtime initialization errors. This is a known limitation and doesn't affect production deployment.

If you encounter issues with vercel dev:

Solution 1: Deploy directly (Recommended)

vercel --prod

Your server will be available at the provided Vercel URL and works perfectly in production.

Solution 2: Test locally with Python (in virtual environment)

# Activate virtual environment first
.\venv\Scripts\Activate.ps1  # Windows PowerShell
# or
source venv/Scripts/activate  # Windows Git Bash

# Test MCP server functionality
python -c "
import sys, os
sys.path.append('src')
from mcp_server import mcp
import json

# Test echo tool
request = {
    'jsonrpc': '2.0',
    'id': 1,
    'method': 'tools/call',
    'params': {'name': 'echo', 'arguments': {'message': 'Hello from venv!'}}
}
response = mcp.handle_request(request)
print(json.dumps(response, indent=2))
"

Solution 3: Use the deployed version Your server will be available at your Vercel domain after deployment.

You can test it by:

  1. Opening the URL in your browser
  2. Using a tool like Postman or curl
  3. Connecting with an MCP client

Solution 4: Run as Administrator (if needed)

  1. Close your terminal
  2. Right-click on Git Bash/PowerShell and select "Run as administrator"
  3. Navigate back to your project: cd /d/repos/vercel-mcp-python
  4. Try vercel dev again

API Endpoints

  • GET /: Returns server information and status
  • POST /: Handles MCP protocol requests
  • OPTIONS /: Handles CORS preflight requests

Dependencies

  • fastmcp>=0.15.0: FastMCP framework for building MCP servers
  • uvicorn>=0.24.0: ASGI server for Python web applications
  • python-json-logger>=2.0.0: JSON logging for Python applications

Configuration

The server is configured through vercel.json with:

  • Python runtime using @vercel/python
  • 30-second maximum execution time
  • CORS enabled for cross-origin requests
  • Automatic routing to the main handler

Usage

Once deployed, your MCP server will be available at your Vercel domain. You can connect to it using any MCP-compatible client.

Using the Included Client App

A rich, interactive client application is included in the client-app/ directory:

# Navigate to client directory
cd client-app

# Setup (first time only)
python setup.py

# Configure environment (optional)
cp .env.example .env
# Edit .env to customize server URL and settings

# Run the client
python mcp_client.py

The client provides:

  • 🔌 Connection testing
  • 🔧 Interactive tool calling
  • 📚 Resource management
  • 🧪 Automated testing of all tools
  • 🎨 Beautiful console interface

See client-app/README.md for detailed usage instructions.

Additional Resources

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选