这是一个基于 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 服务器的实现更加便捷。
# 克隆仓库
git clone https://github.com/yourusername/remote - mcp - server.git
cd remote - mcp - server
# 安装依赖
npm install
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'
]
};
对于生产环境,你需要配置 KV 命名空间来存储 OAuth 令牌:
wrangler.jsonc 中的 KV 配置部分,并添加你的命名空间 ID:"kv_namespaces": [
{
"binding": "OAUTH_KV",
"id": "你的 KV 命名空间 ID"
}
]
# 运行开发服务器
npm run dev
# 构建并部署
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 配置
/tools - 获取可用工具列表。/api/mcp - MCP API 端点。/oauth/gmail - OAuth 登录路径。/oauth/callback - OAuth 回调处理路径。wrangler.jsonc 中填写了正确的 KV 命名空间 ID。本项目使用 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.
感谢您对本项目的关注与支持!如果有任何问题或建议,请随时联系项目维护人员。