OAuth MCP服务器
一个符合OAuth标准的MCP(模型上下文协议)服务器,旨在与Claude Web的“连接”按钮配合使用。
目标
让Claude Web通过“连接”按钮连接,并显示“已连接”状态。
建筑
- 平台:Cloudflare员工
- 运输:服务器发送事件(SSE)
- 认证OAuth 2.0 与 PKCE
- 协议:MCP(模型上下文协议)
项目结构
oauth-mcp-server/
├── src/
│ ├── index.ts # Main worker entry point
│ ├── oauth/ # OAuth implementation
│ │ ├── endpoints.ts # OAuth endpoints (/authorize, /token, etc.)
│ │ └── utils.ts # JWT utilities, crypto functions
│ ├── mcp/ # MCP protocol implementation
│ │ ├── protocol.ts # MCP message handling
│ │ ├── tools.ts # Minimal tools (echo, ping)
│ │ └── transport.ts # SSE transport layer
│ └── types.ts # TypeScript type definitions
├── wrangler.toml # Cloudflare Workers configuration
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── deployment.md # Deployment instructions for Windsurf开发设置
- 安装依赖项:
npm install- 设置Cloudflare环境:
npx wrangler login- 设置秘密:
npx wrangler secret put JWT_SECRET- 在本地运行:
npm run dev- 部署:
npm run deploy使用Claude Web进行测试
- 部署worker以获取您的URL
- 在Claude Web中,单击“连接”
- 使用您的工作URL作为服务器端点
- 完整的OAuth流程
- 验证是否显示“已连接”状态
Windsurf的下一步
看 deployment.md 了解详细的部署和测试说明。
