HTTP认证服务器

MCP HTTP认证服务器是一个基于OAuth协议的认证服务,支持Google OAuth客户端认证和资源发现。

  • by The-Cortex-Hub
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 The-Cortex-Hub/mcp-demo-streamable-http-with-auth

使用说明

MCP HTTP认证服务器

快速开始

启动服务器

uv run main.py

使用MCP检查员进行测试

npx @modelcontextprotocol/inspector http://127.0.0.1:5000/mcp

测试终点

# Test MCP endpoint
curl -i http://127.0.0.1:5000/mcp

# Test OAuth protected resource discovery
curl -s http://127.0.0.1:5000/.well-known/oauth-protected-resource | jq

# Test OAuth authorization server discovery
curl -s http://127.0.0.1:5000/.well-known/oauth-authorization-server | jq

OAuth测试工作流程

  1. 运行上述明确方法之一
  2. 完全关闭光标
  3. 重新打开光标
  4. 尝试再次连接到MCP服务器
  5. 身份验证流程将重新开始

配置

服务器使用以下环境变量(默认值):

  • MCP_HOST:服务器主机(默认值:“127.0.0.1”)
  • MCP_PORT:服务器端口(默认值:5000)
  • MCP_PATH:MCP端点路径(默认值:“/MCP”)
  • GOOGLE_CLIENT_ID:谷歌OAuth客户端ID
  • GOOGLE_CLIENT_SECRET:谷歌OAuth客户端机密
  • REQUIRED_SCOPES:OAuth作用域(默认值:“openidhttps://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile")