一款双模式(有状态/无状态)的MCP回显服务器,内置21种全面的调试工具,基于FastMCP 2.0构建。
# 使用pip安装
pip install mcp-http-echo-server
# 或从源码安装
git clone https://github.com/atrawog/mcp-http-echo-server.git
cd mcp-http-echo-server
pip install -e .
# 使用自动检测模式运行
mcp-http-echo-server
# 在无状态模式下运行生产环境
mcp-http-echo-server --mode stateless --port 8080
# 在有状态模式下运行并启用调试日志
mcp-http-echo-server --mode stateful --debug
# 列出所有可用工具
mcp-http-echo-server --list-tools
echo - 返回带有上下文信息的消息replayLastEcho - 重播最后一条回显消息(仅限有状态模式)printHeader - 显示请求中的所有HTTP头部requestTiming - 显示请求计时和性能指标corsAnalysis - 分析CORS配置environmentDump - 显示环境配置bearerDecode - 解码JWT Bearer令牌(不验证签名)authContext - 显示完整的认证上下文whoIStheGOAT - AI驱动的编程卓越分析器healthProbe - 对服务进行深度健康检查sessionInfo - 显示会话信息和统计stateInspector - 深度检查状态存储sessionHistory - 显示会话事件历史stateManipulator - 调试状态下操作状态sessionCompare - 比较多个会话sessionTransfer - 导出/导入/克隆会话stateBenchmark - 基准测试状态操作sessionLifecycle - 显示会话生命周期信息stateValidator - 验证状态一致性requestTracer - 追踪请求流程和上下文modeDetector - 检测并解释操作模式根据环境自动检测最佳模式:
MCP_ECHO_HOST=0.0.0.0 # 绑定到的主机
MCP_ECHO_PORT=3000 # 绑定到的端口
MCP_ECHO_DEBUG=true # 启用调试日志
MCP_MODE=auto # 服务器模式(自动/有状态/无状态)
MCP_SESSION_TIMEOUT=3600 # 会话超时时间(秒)
MCP_PROTOCOL_VERSIONS=2025-06-18 # 支持的协议版本
MCP_STATELESS=false # 强制无状态模式
选项:
--host HOST 绑定到的主机(默认:0.0.0.0)
--port PORT 绑定到的端口(默认:3000)
--mode {auto,stateful,stateless} 服务器模式(默认:自动)
--stateless 在无状态模式下运行
--stateful 在有状态模式下运行
--protocol-versions VERSIONS 逗号分隔的协议版本
--session-timeout SECONDS 有状态模式下的会话超时时间
--transport {http,stdio,sse} 传输类型(默认:http)
--debug 启用调试模式
--log-file PATH 日志文件路径
--list-tools 列出所有可用工具
--version 显示版本
FROM python:3.11-slim
RUN pip install mcp-http-echo-server
EXPOSE 3000
CMD ["mcp-http-echo-server", "--host", "0.0.0.0", "--mode", "stateless"]
# 构建并运行
docker build -t m
cp-echo-server .
docker run -p 3000:3000 mcp-echo-server
# 初始化会话
curl -X POST http://localhost:3000/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2025-06-18"},"id":1}'
# 调用回显工具
curl -X POST http://localhost:3000/mcp \
-H "Content-Type: application/json" \
-H "Mcp-Session-Id: <session-id>" \
-d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"echo","arguments":{"message":"Hello!"}},"id":2}'
{
"mcpServers": {
"echo-server": {
"url": "http://localhost:3000/mcp",
"transport": "http",
"stateless": false
}
}
}
FastMCP框架
├── 服务器核心
│ ├── 双模式支持
│ ├── 会话管理
│ └── 状态适配器
├── 工具(21)
│ ├── 回显工具(2)
│ ├── 调试工具(4)
│ ├── 认证工具(3)
│ ├── 系统工具(2)
│ └── 状态工具(10)
└── 传输
├── HTTP(带SSE)
├── STDIO
└── SSE(遗留)
欢迎贡献!请随时提交问题或拉取请求。
Apache-2.0
Andreas Trawoeger (atrawog@gmail.com)