FastAPI与FastMCP集成服务

通过FastAPI和FastMCP集成,提供LLM友好的API服务,支持工具添加和测试。

  • by jeffrade
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 jeffrade/mcp-demo

使用说明

mcp演示

使用FastAPI和FastMCP(来自https://gofastmcp.com/integrations/fastapi#offering-一个llm友好的api和https://gofastmcp.com/integrations/fastapi#combining-寿命)

安装

poetry install

将MCP添加到Claude Code CLI

claude mcp remove demo-mcp || true && claude mcp add demo-mcp --transport http http://localhost:8000/llm/mcp && claude mcp list

然后启动Claude Code,确认它看到并测试了添加工具:

> Now you should see the add numbers tool in the demo-mcp MCP server 

● I can see that you've successfully reconnected to the demo-mcp MCP server. Let me verify that the add numbers tool is available by checking the MCP resources.

● listMcpResources(List MCP resources from server "demo-mcp")
  ⎿  (No resources found)                                                                                                                                                                                

● Great! The demo-mcp server is connected. I can confirm that the mcp__demo-mcp__add_nums tool is available in the function tools, which means it's been successfully exposed through the MCP server.

  Let me test it by adding two numbers:

● demo-mcp - add_nums (MCP)(a: 5, b: 3)
  ⎿  {            
       "result": 8
     }

● Perfect! The add numbers tool from the demo-mcp MCP server is working correctly. When I called it with a=5 and b=3, it returned the correct result of 8.

  The MCP integration is working as expected. You can now use this tool (and any other tools exposed by the demo-mcp server) throughout your Claude Code session.

跑步

make run