Token导航 LogoToken导航

MCP Server · AI代理

MCP Simple Server

一个基于FastMCP的Model Context Protocol服务器参考实现,支持流式HTTP传输和远程部署,适用于开发MCP服务器和AI助手集成。

stdio官方级别未说明来源级核验工具 0
服务器实现PythonClaude远程部署Claude Desktop

快速开始

作者 / 组织
oleksandrsirenko
提供方
oleksandrsirenko
运行时
Python

工具数量

0

来源目录标注

资源数量

0

来源目录标注

提示词数量

0

来源目录标注

GitHub Star

1

仓库热度

收录来源

2 个

MCP World

选型结论

MCP Simple Server 属于AI代理类 MCP Server,公开资料标注 0 个工具,通过stdio 本地进程接入,适配 Claude Desktop、Claude,有可以直接复制的安装命令;接入前要先准备 会话凭据。

分类

AI代理

传输方式

stdio

认证方式

会话凭据

部署方式

支持远程部署

安装与配置

安装命令

python main.py

客户端配置示例

{
  "mcpServers": {
    "mcp-simple-server": {
      "command": "python",
      "args": [
        "main.py"
      ]
    }
  }
}

按公开安装命令拼出来的示例,字段名和参数以仓库 README 为准;带 YOUR_API_KEY 这类占位符的位置记得换成自己的值。

上手步骤

  1. 1

    准备运行环境

    stdio 服务在本地起进程,需要先装好 Python,再按安装命令拉取依赖。

  2. 2

    安装服务

    复制下面的安装命令执行;命令里带占位符的位置换成自己的密钥或路径。

  3. 3

    写入客户端配置

    在客户端的 MCP 配置里填启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4

    验证是否可用

    连接成功后客户端会列出 0 个工具,随便调一个只读工具确认能返回结果。

接入前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

详细介绍

MCP简单服务器

具有流式HTTP传输的模型上下文协议服务器的最小参考实现。按照官方Anthropic MCP规范2025-06-18使用FastMCP构建。构建远程MCP服务器的完美起点。

🎯 目的

该项目为想要以下目的的开发人员提供了一个简单、有据可查的参考:

  • 构建他们的第一个MCP服务器
  • 将MCP服务器部署到云平台(Railway、Heroku、Render)
  • 了解MCP协议实现
  • 为更复杂的MCP解决方案奠定基础

特性

  • ✅ 两个数学工具: add 和 multiply 函数
  • ✅ 可流式HTTP传输:支持SSE的现代MCP协议
  • ✅ 会话管理:正确的MCP初始化流程
  • ✅ 远程部署:铁路、Heroku、渲染部署配置
  • ✅ 自动化测试:完整的协议验证和调试工具
  • ✅ Claude桌面集成:已准备好集成AI助手
  • ✅ 参考实现:记录良好的学习代码

快速开始

地方发展

git clone https://github.com/oleksandrsirenko/mcp-simple-server.git
cd mcp-simple-server
uv sync
source .venv/bin/activate
python main.py

服务器启动时间: http://localhost:8000/mcp/

测试服务器

python test_server.py

预期产量:

🧪 Starting MCP Server Tests
✅ Initialize successful - Server: Simple Server
✅ Initialized notification sent
✅ Found 2 tools: add, multiply  
✅ Add tool returned correct result
✅ Multiply tool returned correct result
🎉 All tests passed!

可用工具

add(a, b)

将两个数字相加。

例子:

{"name": "add", "arguments": {"a": 25, "b": 17}}
→ Returns: 42

multiply(a, b)

将两个数字相乘。

例子:

{"name": "multiply", "arguments": {"a": 8, "b": 6}}
→ Returns: 48

使用curl进行手动测试

本地测试(开发)

用于测试在上运行的本地开发服务器 localhost:8000:

1.初始化会话
curl -X POST http://localhost:8000/mcp/ \
  -H "Content-Type: application/json" \
  -H "MCP-Protocol-Version: 2025-06-18" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{"tools":{}},"clientInfo":{"name":"test-client","version":"1.0.0"}}}'
2.发送初始化通知
curl -X POST http://localhost:8000/mcp/ \
  -H "Content-Type: application/json" \
  -H "MCP-Protocol-Version: 2025-06-18" \
  -H "Accept: application/json, text/event-stream" \
  -H "Mcp-Session-Id: YOUR_SESSION_ID" \
  -d '{"jsonrpc":"2.0","method":"notifications/initialized"}'
3.列出工具
curl -X POST http://localhost:8000/mcp/ \
  -H "Content-Type: application/json" \
  -H "MCP-Protocol-Version: 2025-06-18" \
  -H "Accept: application/json, text/event-stream" \
  -H "Mcp-Session-Id: YOUR_SESSION_ID" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'
4.调用添加工具
curl -X POST http://localhost:8000/mcp/ \
  -H "Content-Type: application/json" \
  -H "MCP-Protocol-Version: 2025-06-18" \
  -H "Accept: application/json, text/event-stream" \
  -H "Mcp-Session-Id: YOUR_SESSION_ID" \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"add","arguments":{"a":25,"b":17}}}'

远程测试(生产)

为了测试部署的服务器,请替换 localhost:8000 使用您的部署URL:

# Example with Railway deployment
curl -X POST https://your-app.railway.app/mcp/ \
  -H "Content-Type: application/json" \
  -H "MCP-Protocol-Version: 2025-06-18" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{"tools":{}},"clientInfo":{"name":"test-client","version":"1.0.0"}}}'

备注:要进行全面的远程测试,请使用自动化测试脚本:

python test_deployment.py your-app.railway.app

部署

铁路(推荐)

  1. 推送到GitHub:
   git add .
   git commit -m "ready for deployment"
   git push origin main
  1. 部署到铁路:

- 首选 railway应用程序 - 点击“从GitHub仓库部署” - 选择您的存储库 - 铁路自动检测Dockerfile并部署

  1. 测试您的部署:
   python test_deployment.py your-app-name.up.railway.app
  1. 您的MCP URL: https://your-app.railway.app/mcp/

Heroku

heroku create your-mcp-server
git push heroku main

您的MCP URL: https://your-mcp-server.herokuapp.com/mcp/

渲染

  1. 将GitHub存储库连接到Render
  2. 渲染自动检测 render.yaml 和Dockerfile
  3. 自动部署

您的MCP URL: https://your-service.onrender.com/mcp/

码头工人

docker build -t mcp-simple-server .
docker run -p 8000:8000 mcp-simple-server

Claude桌面集成

本地服务器配置

{
  "mcpServers": {
    "simple-server": {
      "command": "python",
      "args": ["main.py"],
      "cwd": "/path/to/mcp-simple-server"
    }
  }
}

远程服务器配置(推荐)

对于部署到Railway、Heroku或Render的远程服务器,请使用 mcp-remote 包裹:

{
  "mcpServers": {
    "simple-server-remote": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://your-app.railway.app/mcp/",
        "--allow-http",
        "--header",
        "Accept: application/json, text/event-stream"
      ]
    }
  }
}

关键配置说明:

  • 使用 npx 随着 -y 标记为自动安装 mcp-remote
  • 在URL中包含尾随斜线: /mcp/
  • 添加 --allow-http HTTP连接标志
  • 包含Accept标头以获得适当的SSE支持

替代方案:直接Python代理(高级)

对于高级用户或调试目的,您可以创建自定义Python代理:

{
  "mcpServers": {
    "simple-server-proxy": {
      "command": "python",
      "args": ["claude_mcp_proxy.py"],
      "cwd": "/path/to/mcp-simple-server"
    }
  }
}

备注:这需要 claude_mcp_proxy.py 脚本来自存储库,主要用于调试目的。使用 mcp-remote 用于生产。

配置文件位置:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • 视窗: %APPDATA%\Claude\claude_desktop_config.json

与克劳德一起测试

整合后,问克劳德:

  • “你能给我加42和18吗?”
  • “7乘以9是多少?”
  • “你们有什么工具?”

Claude将使用您的MCP服务器进行计算! 🎉

发展

添加新工具

@mcp.tool()
def subtract(a: float, b: float) -> float:
    """Subtract two numbers"""
    return a - b

@mcp.tool()
def divide(a: float, b: float) -> float:
    """Divide two numbers"""
    if b == 0:
        raise ValueError("Cannot divide by zero")
    return a / b

环境变量

  • HOST:服务器主机(默认值:127.0.0.1,部署时使用0.0.0.0)
  • PORT:服务器端口(默认值:8000,Railway会自动设置此端口)
HOST=0.0.0.0 PORT=3000 python main.py

注意:对于铁路部署,FastMCP将自动绑定到 0.0.0.0:$PORT.

项目结构

mcp-simple-server/
├── main.py                    # MCP server (~25 lines)
├── test_server.py             # Local server tests (~300 lines)
├── test_deployment.py         # Remote deployment tests
├── test_host_binding.py       # Host binding tests
├── test_proxy_script.py       # Proxy testing script
├── test_streamable_app.py     # Streamable HTTP tests
├── test_tool_verification.py  # Tool verification tests
├── debug_railway_server.py    # Railway debugging utilities
├── debug_fastmcp.py           # FastMCP debugging utilities
├── claude_mcp_proxy.py        # Claude Desktop proxy (optional)
├── start.sh                   # Shell startup script
├── pyproject.toml             # Project configuration
├── README.md                  # This documentation
├── uv.lock                    # Dependency lock file
├── .gitignore                 # Git ignore patterns
├── .python-version            # Python version specification
├── Dockerfile                 # Docker deployment
├── railway.toml               # Railway configuration
├── Procfile                   # Heroku configuration
└── render.yaml                # Render configuration

建筑

  • FastMCP:Anthropic的高层MCP实施
  • 流式HTTP:支持SSE流媒体的现代传输
  • 会话管理:具有会话ID的有状态连接
  • JSON-RPC 2.0:消息交换的标准协议
  • 第2025-06-18号议定书:最新MCP规范
  • 端口8000:默认FastMCP服务器端口(可通过port env var配置)

技术细节

服务器实现

  • 框架:FastMCP(官方人类学图书馆)
  • 运输:带有服务器发送事件的流式HTTP
  • 协议:MCP 2025-06-18规范
  • 依赖项: httpx>=0.28.1, mcp>=1.9.4

MCP协议流

  1. 客户端发送 initialize 请求
  2. 服务器以功能和会话ID进行响应
  3. 客户端发送 initialized 通知
  4. 正常操作开始(工具/列表、工具/调用等)

工具响应格式

工具返回简单的Python值(float、int、str),FastMCP会自动将其包装成正确的MCP响应格式。

故障排除

服务器无法启动

# Check if port is in use
lsof -i :8000

# Try different port
PORT=3000 python main.py

MCP协议错误

# Run automated test
python test_server.py

# Check server logs for detailed errors

克劳德桌面未连接

  1. 验证JSON配置语法 -使用JSON验证器
  2. 检查服务器URL可访问性 -测试用 curl 或浏览器
  3. 重新启动克劳德桌面 配置更改后
  4. 确保MCP端点路径正确 -使用 /mcp/ 带有尾随斜线
  5. 使用 mcp-remote 用于远程服务器 -不要使用 curl 用于远程连接

测试远程部署

使用提供的脚本测试部署的服务器:

# Test your deployed server (replace with your URL)
python test_deployment.py your-app.railway.app

# Or with full URL
python test_deployment.py https://your-app.railway.app

这将对您的远程服务器运行完整的MCP协议测试套件。

常见问题

  • 端点错误:使用 /mcp/ (带尾随斜线)
  • 缺少标题:包括所有必需的MCP标题
  • 会话管理:必须发送 initialized 通知后 initialize
  • 远程连接:使用 mcp-remote,不 curl 克劳德桌面
  • 端口绑定:使用 0.0.0.0:$PORT 对于部署,不是 127.0.0.1

依赖项

dependencies = [
    "httpx>=0.28.1",   # HTTP client for testing
    "mcp>=1.9.4",      # Official Anthropic MCP library
]

该项目使用:

  • 主控程序:官方Anthropic MCP Python SDK
  • httpx:用于自动测试的现代HTTP客户端
  • python:需要Python>=3.10

贡献

  1. 分叉存储库
  2. 进行更改
  3. 运行测试: python test_server.py
  4. 测试部署: python test_deployment.py your-test-url
  5. 确保所有测试通过
  6. 提交拉取请求

许可证

MIT许可证

资源

工具与能力

工具数量

0

资源数量

0

提示词数量

0

能力标签

MCP协议Python本地部署服务器实现AI集成远程部署流式传输

支持客户端

Claude DesktopClaude

数量来自来源目录的标注,具体工具清单以官方文档为准。

典型使用场景

多步任务编排

把拆解、检索、执行串成一条链,模型按步骤调用工具。

长期上下文

把会话、笔记和知识放到外部存储,换个会话还能接着做。

接自有流程

把内部系统和模型连起来,让助手调用已有的工作流。

选择建议

值得选的地方

  • 只提供 0 个工具,职责集中,接入后不容易误操作。
  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 已经适配 Claude Desktop、Claude,换客户端不用重新研究配置。

先想清楚的地方

  • stdio 方式要求本地装好 Python,换机器要重新装一遍。
  • 需要自备会话凭据,没有凭据没法直接试。
  • 第三方目录整理,版本更新和行为细节以官方仓库为准。

更适合

  • 需要在AI代理场景里让模型直接调用外部能力的人。
  • 已经在用 Claude Desktop 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 暂时拿不到会话凭据的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

5 个同类
MCP Server工具数传输方式安装命令收录来源最后核验
MCP Simple Server

MCP World · 本页

0stdio有2 个2026-05-17
Everything Claude Code

MCP World

0stdio有1 个2026-05-17
Filesystem 560c4363

MCP World

13未说明未标注2 个2026-05-17
Time 7365cb6d

MCP.so

2SSE有2 个2026-05-17
Server Everything (everything)

MCP World

11stdio有1 个2026-05-17

按同分类和工具数量挑出最接近的几条,字段以各自详情页为准。

常见问题

5 条

MCP Simple Server 怎么安装?

公开资料给出的安装命令是 python main.py,运行环境为 Python。装完后按客户端要求写进 MCP 配置,重启客户端生效。

MCP Simple Server 怎么在 Claude Desktop、Cursor 里配置?

它是stdio 本地进程,客户端配置里要写启动命令和参数,运行环境是 Python;保存后完全退出客户端再打开,配置才会生效。

MCP Simple Server 收费吗?

本站只整理公开资料,不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

MCP Simple Server 需要 API Key 吗?

公开资料标注的认证方式是会话凭据,也就是要先拿到凭据才能连上;凭据只填在自己本地的配置里,不要写进公开仓库。

MCP Simple Server 支持哪些客户端?

公开资料标注支持 Claude Desktop、Claude;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

来源信息

继续浏览同类 MCP