Remote Mcp

Remote Mcp

🚀 远程 MCP 服务器

这是一个基于 Cloudflare Worker 的 MCP(Model Context Protocol)服务器,主要用于提供各类工具 API,涵盖 Gmail、Google Calendar 等实用功能。此项目采用 TypeScript 进行开发,并借助 @remote - mcp/server 库简化 MCP 服务器的实现过程。

🚀 快速开始

本项目是基于 Cloudflare Worker 的 MCP 服务器,为你提供 Gmail、Google Calendar 等工具 API。使用 TypeScript 开发,结合 @remote - mcp/server 库,让 MCP 服务器的实现更加便捷。

✨ 主要特性

  • 采用基于 Cloudflare Workers 的无服务架构,无需管理服务器基础设施。
  • 提供 Gmail 邮件发送和读取功能,方便处理邮件事务。
  • 支持 Google Calendar 事件创建和列表功能,轻松管理日程安排。
  • 集成 OAuth2 认证,保障系统安全。
  • 使用 Durable Objects 进行状态管理,确保数据的一致性和可靠性。

📦 安装指南

# 克隆仓库
git clone https://github.com/yourusername/remote - mcp - server.git
cd remote - mcp - server

# 安装依赖
npm install

📚 详细文档

配置

OAuth 配置

  1. Google Cloud Console 创建一个项目。
  2. 启用 Gmail API 和 Google Calendar API。
  3. 创建 OAuth 客户端 ID 和密钥。
  4. 修改 src/config.ts 文件中的 OAuth 配置。
export const GOOGLE_OAUTH_CONFIG = {
clientId: '你的客户端 ID',
clientSecret: '你的客户端密钥',
redirectUri: 'https://your - worker.your - subdomain.workers.dev/oauth/gmail/callback',
scopes: [
'https://www.googleapis.com/auth/gmail.send',
'https://www.googleapis.com/auth/gmail.readonly',
'https://www.googleapis.com/auth/calendar',
'https://www.googleapis.com/auth/calendar.events'
]
};

Cloudflare KV 命名空间配置

对于生产环境,你需要配置 KV 命名空间来存储 OAuth 令牌:

  1. 在 Cloudflare Dashboard 创建 KV 命名空间。
  2. 获取 KV 命名空间 ID。
  3. 取消注释 wrangler.jsonc 中的 KV 配置部分,并添加你的命名空间 ID:
"kv_namespaces": [
{
"binding": "OAUTH_KV",
"id": "你的 KV 命名空间 ID"
}
]

构建和部署

本地开发

# 运行开发服务器
npm run dev

部署到 Cloudflare Workers

# 构建并部署
npm run deploy

项目结构

remote - mcp - server/
├── src/                  # 源代码
│   ├── index.ts          # 主入口文件
│   ├── config.ts         # 配置文件
│   ├── services/         # 服务实现
│   │   └── google.ts     # Google 服务 (Gmail, Calendar)
│   └── utils.ts          # 工具函数
├── dist/                 # 编译后的文件
├── static/               # 静态资源
├── build.js              # 构建脚本
└── wrangler.jsonc        # Cloudflare Workers 配置

API 端点

  • /tools - 获取可用工具列表。
  • /api/mcp - MCP API 端点。
  • /oauth/gmail - OAuth 登录路径。
  • /oauth/callback - OAuth 回调处理路径。

故障排除

常见问题

  1. 部署错误:检查 KV 命名空间是否正确配置。
  2. OAuth 错误:确保重定向 URI 和 Google Cloud Console 中的设置一致。
  3. Durable Objects 问题:确认 Durable Objects 已正确初始化且有权限。

解决方案

  1. 部署错误:
    • 确保在 wrangler.jsonc 中填写了正确的 KV 命名空间 ID。
    • 检查 Cloudflare 账户是否启用 KV 存储服务。
  2. OAuth 错误:
    • 在 Google Cloud Console 中,确保允许的重定向 URI 包含你设置的路径。
    • 检查客户端 ID 和密钥是否正确填写。
  3. Durable Objects 问题:
    • 确保在代码中正确初始化了 Durable Object,并且有权限访问相关资源。

贡献指南

  1. Fork 仓库:在 GitHub 上 Fork 此项目。
  2. 创建功能分支:基于主分支创建新功能或修复的分支。
  3. 提交代码:提交你的更改并推送至远程仓库。
  4. 创建 Pull Request:在原项目的仓库中,发起 Pull Request。

📄 许可证

本项目使用 MIT 许可证,具体内容如下:

MIT License

Copyright (c) [年份] [作者姓名]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

感谢您对本项目的关注与支持!如果有任何问题或建议,请随时联系项目维护人员。

  • 0 关注
  • 0 收藏,24 浏览
  • system 提出于 2025-10-03 17:09

相似服务问题

相关AI产品