M

MCP服务端

@AntDX316/MCP-Server
1 Stars 619 次浏览 AntDX316 更新于 2026-08-23

一个集成了Cursor IDE的模型上下文协议服务器,通过SSE和WebSocket连接提供实时通信、现代网页仪表盘和可扩展工具。

该服务暂未提供标准配置,请参考 README 手动接入

服务介绍

MCP Server for Cursor

为 Cursor IDE 集成实现的 Model Context Protocol (MCP) 服务器,通过 SSE(Server-Sent Events)和 WebSocket 连接提供现代的 Web 仪表板和工具。

特性

  • 支持 WebSocket 的实时连接监控
  • 用于服务器管理的现代 Web 仪表板
  • 与 Cursor IDE 基于 SSE 的通信
  • 内置测试工具以验证连接性
  • Google Drive 集成以进行文件管理
  • 可扩展架构,便于添加新工具
  • 连接历史可视化
  • 客户端管理界面
  • 服务配置 UI
  • 可自定义的服务器设置

先决条件

  • Python 3.8 或更高版本
  • Node.js 18 或更高版本
  • npm (Node.js 包管理器)
  • pip (Python 包管理器)
  • Cursor IDE

安装

  1. 克隆仓库:
git clone <repository-url>
cd MCP-Server
  1. 安装依赖项:
# Install all dependencies (both backend and frontend)
npm run install-all

# Or install separately:
# Backend dependencies
pip install -r requirements.txt

# Frontend dependencies
cd frontend
npm install
cd ..

开发

启动开发服务器:

# Start both backend and frontend in development mode
npm run dev   # This will start both servers concurrently

服务器将在以下地址启动:

  • 后端:http://localhost:8765
  • 前端:http://localhost:3000(如果端口 3000 已被占用,则尝试 3001)

您也可以分别启动这些服务器:

# Backend (in one terminal)
python mcp_server.py

# Frontend (in another terminal)
cd frontend
npm run dev

开发服务器提供:

  • 前端更改的热重载
  • API 请求自动代理到后端
  • WebSocket 连接处理
  • 并行的后端和前端开发

如果您运行了其他使用端口 3000 的应用程序,前端将自动尝试端口 3001 并递增直到找到可用端口。实际 URL 将在您运行 npm run dev 时显示在终端中。

项目结构

MCP-Server/
├── frontend/                # Frontend application
│   ├── src/                # Source code
│   │   ├── api/           # API clients
│   │   ├── pages/         # React components
│   │   └── main.tsx       # Entry point
│   ├── package.json       # Frontend dependencies
│   └── vite.config.ts     # Vite configuration
├── mcp_server.py          # Main server implementation
├── services.py            # Service management
├── test_client.py         # Test client implementation
├── requirements.txt       # Python dependencies
├── package.json           # Root package.json
└── services_config.json   # Service configurations

可用端点

HTTP 端点

  • /api/status - 获取服务器状态
  • /api/connections/history - 获取连接历史
  • /api/clients - 获取活跃客户端
  • /api/services/{service_id} - 服务配置
  • /api/settings - 服务器设置

WebSocket 端点

  • /ws/{client_id} - 实时更新和 ping/pong

SSE 端点

  • /sse - 用于 Cursor IDE 的 Server-Sent Events

工具端点

  • /invoke/test - 测试工具
  • /invoke/google_drive - Google Drive 操作

生产环境部署

构建并启动生产服务器:

# Build frontend and start production server
npm run prod

# Or build frontend separately:
npm run build
python mcp_server.py

配置

初始设置

  1. 复制模板配置:
cp services_config.template.json services_config.json
  1. 使用您的服务凭据更新 services_config.json
    • 对于 Google Drive:
      • 在 Google Cloud Console 中创建一个项目
      • 启用 Google Drive API
      • 创建 OAuth 2.0 凭据
      • 添加您的 client_idclient_secret

服务器设置

通过 Web 仪表板配置服务器设置:

  • 调试模式
  • SSL 设置
  • 连接限制
  • Ping 超时
  • 协议设置

测试

使用提供的测试客户端测试服务器:

python test_client.py

测试客户端将:

  • 连接到 SSE 和 WebSocket 端点
  • 发送周期性的 ping
  • 测试可用工具
  • 监控连接状态

故障排除

请根据实际情况填写或替换代码块中的内容(例如 #0, #1, ...)。

  1. 连接问题

    • 检查后端和前端日志
    • 在浏览器 DevTools 中验证 WebSocket 连接
    • 确保 vite.config.ts 中的代理设置正确
    • 检查端口冲突
  2. 前端问题

    • 清除浏览器缓存
    • 检查浏览器控制台中的错误
    • 验证 Node.js 和 npm 版本
    • 检查 TypeScript 编译错误
  3. 后端问题

    • 检查 mcp_server.log 中的错误
    • 验证 Python 依赖项是否已安装
    • 检查端口可用性
    • 确保服务配置有效

安全注意事项

  • 开发环境中服务器接受所有来源 (CORS *)
  • WebSocket 连接使用客户端 ID 进行基本标识
  • 服务凭据存储在 services_config.json
  • 生产环境中应使用环境变量来存储敏感数据

贡献

  1. 分叉仓库
  2. 创建一个功能分支
  3. 进行更改
  4. 运行测试
  5. 提交拉取请求

许可证

[在此处添加您的许可证信息]

相关 MCP 服务