Python MCP服务器入门
最低限度 mcp使用 Python服务器模板。
快速开始
pip install -r requirements.txt
python server.py服务器运行在 http://localhost:8000/mcp.
示例工具
greet(name)-返回问候语add(a, b)-将两个数字相加get_current_time()-返回当前时间戳
添加工具
@server.tool()
def my_tool(arg: str) -> str:
"""Tool description shown to clients."""
return f"Result: {arg}"文档
查看完整 mcp使用Python文档.
