MCP协议服务器

一个基于FastAPI的模块化服务器,实现MCP协议,用于连接AI模型与外部工具。

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

使用说明

cd/Volumes/jetdrive/git/iacuriman/mcp bootstrap&&&cat>README.md<<'EOF'

MCP引导🚀

一个简单的模块化FastAPI服务器,实现了模型上下文协议(MCP),用于将AI模型连接到外部工具。

快速开始

只需3个简单步骤,即可让您的MCP服务器运行并连接到Groq:

1.️⃣ 启动MCP服务器

# Install dependencies
pip install -r requirements.txt

# Start the server
uvicorn main:app --reload

✅ 您的服务器现在正在运行 http://localhost:8000

2.️⃣ 通过Cloudflare隧道进行公开

# Install cloudflared (if needed)
brew install cloudflare/cloudflare/cloudflared

# Expose your server
cloudflared tunnel --url http://localhost:8000

✅ 你会得到一个公共URL,比如: https://abc123.trycloudflare.com

3.️⃣ 连接到Groq

  1. 首选 Groq游乐场
  2. 添加您的MCP服务器:
    • 服务器名称: MCP Weather Server
    • 服务器URL: https://your-url.trycloudflare.com (您的Cloudflare URL)
  3. 选择一个型号 函数调用/工具使用 支持
  4. 问:“西班牙穆尔西亚的天气怎么样?”

建筑

┌─────────────┐
│   Your App  │
│  (FastAPI)  │
└──────┬──────┘
       │
       │ MCP Protocol
       │ (/tools/list, /tools/call)
       │
┌──────▼──────────┐
│ Cloudflare      │
│ Tunnel          │
│ (Public URL)    │
└──────┬──────────┘
       │
       │ HTTPS
       │
┌──────▼──────────┐
│   Groq API      │
│   (LLM)         │
└─────────────────┘

包含内容

  • ✅ 天气工具 -通过Open-Meteo API实时天气数据
  • ✅ MCP协议 -完整的JSON-RPC 2.0实现
  • ✅ 模块化设计 -易于添加新工具
  • ✅ Groq兼容 -与Groq的MCP支持无缝协作

添加新工具

看 docs/aux-add-tool.md 有关添加新工具的完整指南。

文档

需求

  • Python 3.9+
  • 快速API
  • Cloudflare隧道(供公众访问)

许可证

开源-随意使用和修改!


准备好建造了吗? 从上面的第一步开始,几分钟后你就可以跑了! 🎉 文件结束