MCP本地开发平台

一个完整的MCP托管平台,具有OAuth身份跟踪功能,可在本地机器上运行。

  • by VamshiAluwala
  • HTML
  • 本地部署
  • 更新于
在 GitHub 查看 VamshiAluwala/mcp-platform

使用说明

🚀 MCP平台——本地开发设置

您的完整MCP托管平台,具有OAuth身份跟踪功能。 100%免费。完全在本地计算机上运行。


🏗️ 建筑

┌─────────────────────────────────────────────────┐
│  Developer uploads MCP code                      │
│           ↓                                      │
│  Platform deploys → generates URL               │
│           ↓                                      │
│  User connects URL in Claude Code               │
│           ↓                                      │
│  YOUR OAuth (Keycloak) verifies identity        │
│           ↓                                      │
│  Every tool call tracked → audit log            │
└─────────────────────────────────────────────────┘

📦 什么在跑

服务 URL 目的
后端API http://localhost:8000 FastAPI——核心平台
API文件 http://localhost:8000/docs 自动生成的Swagger用户界面
前端 http://localhost:3000 Next.js仪表板
钥匙锁 http://localhost:8080 身份和OAuth(免费Cognito)
MinIO http://localhost:9001 文件存储仪表板(免费S3)
PostgreSQL 本地主机:5433 主数据库
瑞迪斯 本地主机:6379 会话和缓存

🚀 启动一切(一个命令)

# 1. Make sure Docker Desktop is running
# 2. Clone this repo
# 3. Run:


docker-compose up -d


# Check everything is running:
docker-compose ps

🔐 设置钥匙斗篷(一次-10分钟)

  1. 打开http://localhost:8080
  2. 登录: 管理员/admin123
  3. 创建新领域: mcp-platform
  4. 创建客户端:
    • 客户端ID: mcp-backend
    • 客户端协议: openid-connect
    • 访问类型: confidential
  5. 创建测试用户:
    • 用户名: testuser
    • 电子邮件: test@example.com
    • 密码: test123
  6. 添加自定义属性 tenant_id 对于用户

📡 API快速参考

部署MCP服务器

curl -X POST http://localhost:8000/api/mcp/deploy \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "invoice-processor",
    "description": "AI Invoice Processing MCP",
    "server_code": "# your MCP code here"
  }'

# Returns:
# {
#   "endpoint_url": "http://localhost:8000/mcp/abc123/invoice-processor",
#   "instructions": "Add this URL to Claude Code..."
# }

列出您的MCP服务器

curl http://localhost:8000/api/mcp/ \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

启动会话

curl -X POST http://localhost:8000/api/sessions/start \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{"mcp_server_id": "your-server-id"}'

查看审核日志

curl http://localhost:8000/api/audit/ \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

检查您的身份

curl http://localhost:8000/me \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

📁 项目结构

mcp-platform/
├── docker-compose.yml          ← Start everything here
├── backend/
│   ├── app/
│   │   ├── main.py             ← FastAPI entry point
│   │   ├── auth/
│   │   │   └── middleware.py   ← JWT per-call identity
│   │   ├── mcp/
│   │   │   ├── host.py         ← Deploy MCP servers
│   │   │   └── session.py      ← Multi-session manager
│   │   ├── api/
│   │   │   ├── deploy.py       ← Deploy endpoints
│   │   │   ├── sessions.py     ← Session endpoints
│   │   │   └── audit.py        ← Audit log endpoints
│   │   ├── models/
│   │   │   └── database.py     ← DB models
│   │   └── core/
│   │       └── config.py       ← Settings
│   └── requirements.txt
├── frontend/                   ← Next.js dashboard (add later)
├── mcps/
│   └── invoice-mcp/
│       └── server.py           ← Sample vertical MCP
└── infrastructure/
    └── init-db.sh              ← DB initialization

🔄 本地→ AWS迁移(准备就绪时)

现在(免费本地) 稍后(AWS) 需要更改
Keycloak AWS Cognito 仅交换环境变量
PostgreSQL Docker AWS RDS 零变化
Redis Docker AWS ElastiCache 零变化
MinIO AWS S3 零变化(与boto3相同)
Docker Compose AWS ECS Fargate 地形脚本

🧪 测试全流量

# 1. Start everything
docker-compose up -d

# 2. Get a JWT token from Keycloak
curl -X POST http://localhost:8080/realms/mcp-platform/protocol/openid-connect/token \
  -d "client_id=mcp-backend&username=testuser&password=test123&grant_type=password"

# 3. Use the token to deploy an MCP
TOKEN="your-token-here"
curl -X POST http://localhost:8000/api/mcp/deploy \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "test-mcp", "description": "Test", "server_code": "# MCP code"}'

# 4. See your identity tracked
curl http://localhost:8000/me -H "Authorization: Bearer $TOKEN"

# 5. Open API docs
open http://localhost:8000/docs

💡 后续步骤

  1. ✅ 在本地运行此程序
  2. ✅ 部署示例发票MCP
  3. ✅ 将端点URL连接到Claude Code
  4. 🔜 构建Next.js仪表板
  5. 🔜 添加您的第一个真正的垂直MCP
  6. 🔜 准备就绪后部署到AWS