MCP服务器

一个支持STDIO和HTTP传输模式的MCP服务器,适用于Claude Desktop、Web应用和云部署。

  • by MaxSmithy
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 MaxSmithy/FordMCP

使用说明

我很棒的服务器

MCP服务器内置 ChukMCP服务器.

运输方式

此服务器支持两种传输模式:

  • STDIO(默认):适用于Claude Desktop和MCP客户。通过stdin/stdout进行通信。
  • 超文本传输协议:用于web应用程序、API和云部署。支持流媒体的RESTful端点。

快速开始

选项1:克劳德桌面(STDIO模式)

1.安装依赖项

# Install globally
uv pip install --system chuk-mcp-server

# Or in a virtual environment (recommended)
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
uv pip install chuk-mcp-server

2.测试服务器

# Default mode is stdio - perfect for Claude Desktop
echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | python server.py

3.配置克劳德桌面

添加到 ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):

{
  "mcpServers": {
    "my-awesome-server": {
      "command": "uv",
      "args": ["--directory", "/mnt/c/Users/MaxSmith/Desktop/Ford/fordMCP/my-awesome-server", "run", "server.py"]
    }
  }
}

重新启动Claude Desktop,您的服务器将可用!

选项2:Web/API(HTTP模式)

非常适合web应用程序和云部署。

# Start HTTP server on port 8000
python server.py --http

# Or specify custom port/host
python server.py --port 8000 --host 0.0.0.0

卷曲测试:

curl http://localhost:8000/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"tools/list","id":1}'

选项3:Docker(生产部署)

Docker自动以HTTP模式运行服务器,非常适合生产部署。

使用docker compose(最简单)

docker-compose up

或手动构建

# Build the image
docker build -t my-awesome-server .

# Run the container
docker run -p 8000:8000 my-awesome-server

测试部署

curl http://localhost:8000/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"tools/list","id":1}'

您应该看到:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "tools": [
      {"name": "hello", "description": "Say hello to someone."},
      {"name": "add_numbers", "description": "Add two numbers together."},
      {"name": "calculate", "description": "Safely evaluate a mathematical expression."}
    ]
  }
}

非常适合部署到AWS、GCP、Azure或Kubernetes等云平台!

可用工具

  • 你好:向某人问好
  • add_numbers:将两个数字相加
  • 计算:安全地计算数学表达式

可用资源

  • config://info:获取服务器信息

发展

运行测试

uv run pytest

类型检查

uv run mypy server.py

代码检查

uv run ruff check .

命令行选项

服务器会自动检测最佳传输模式,但您可以覆盖:

# Force STDIO mode (default)
python server.py --stdio
python server.py --transport=stdio

# Force HTTP mode
python server.py --http
python server.py --port 8000
python server.py --host 0.0.0.0
python server.py --transport=http

定制

编辑 server.py 添加您自己的工具和资源:

from chuk_mcp_server import tool, resource, run

@tool
def my_custom_tool(param: str) -> str:
    """Your custom tool description."""
    return f"Result: {param}"

@resource("custom://data")
def my_resource() -> dict:
    """Your custom resource."""
    return {"data": "value"}

if __name__ == "__main__":
    run(transport="stdio")  # or just run() for auto-detection

看 ChukMCPServer文档 了解更多示例和高级功能。