Auth0 OAuth MCP Server

by pratham-svg

Integrations

  • Handles user authentication through Auth0, enabling secure access to protected APIs by requesting user credentials, managing OAuth flows, and handling tokens.

  • Enables deployment of the MCP server to Cloudflare Workers, utilizing KV storage for OAuth tokens and providing environment configurations for secure operation.

模型上下文协议 (MCP) 服务器

这是一个 MCP 服务器,需要用户先进行身份验证。然后,MCP 服务器才能代表用户调用受保护的 API。

配置

待办事项 API

在使用 MCP 服务器之前,您需要按照此处的说明部署 Todos API。

Auth0 配置

在 Auth0 仪表板中,在应用程序部分创建一个新的应用程序(类型:“常规 Web 应用程序”)。

应用创建完成后,配置以下URL作为本地开发时的回调URL:

http://localhost:8788/callback

设置KV命名空间

  • 创建 KV 命名空间: wrangler kv:namespace create "OAUTH_KV"
  • 使用 KV ID 更新 Wrangler 文件

环境变量

此 MCP 服务器需要配置一些环境变量:

环境描述
AUTH0_DOMAIN您的 Auth0 租户的域名(例如, acme.auth0.com
AUTH0_CLIENT_ID您创建的 Auth0 应用程序的客户端 ID
AUTH0_CLIENT_SECRET您创建的 Auth0 应用程序的客户端密钥
AUTH0_AUDIENCE您在 Auth0 仪表板中注册的 API 的唯一标识符(例如urn:todos-api
AUTH0_SCOPEMCP 服务器请求的范围。这里我们请求基本个人资料信息( openid email profile )、刷新令牌功能( offline_access )以及 API 访问权限( read:todos )。
NODE_ENV环境设置-使用development进行本地开发
API_BASE_URL运行 Todos API 的基本 URL

发展

在项目根目录中创建一个具有以下结构的.dev.vars文件:

AUTH0_DOMAIN=yourdomain.us.auth0.com AUTH0_CLIENT_ID=The Client ID of the application you created in Auth0 AUTH0_CLIENT_SECRET=The Client Secret of the application you created in Auth0 AUTH0_AUDIENCE=urn:todos-api AUTH0_SCOPE=openid email profile offline_access read:todos NODE_ENV=development API_BASE_URL=http://localhost:8789

测试 MCP 服务器

要启动 MCP 服务器,您可以使用以下命令:

npm run dev

使用 MCP Inspector,您可以连接到 MCP 服务器,列出可用的工具并调用它们。请确保将传输类型设置为sse ,并将 URL 设置为http://localhost:8788/sse

将 MCP 服务器部署到 Cloudflare

要将 MCP 服务器部署到 Cloudflare,您首先需要设置以下机密:

wrangler secret put AUTH0_DOMAIN wrangler secret put AUTH0_CLIENT_ID wrangler secret put AUTH0_CLIENT_SECRET wrangler secret put AUTH0_AUDIENCE wrangler secret put AUTH0_SCOPE wrangler secret put API_BASE_URL

设置秘密后,您可以使用以下命令部署 API:

npm run deploy

在 Auth0 仪表板中,还要确保为已部署的 MCP 服务器添加新的回调 URL,例如:

https://mcp-auth0-oidc.<your-subdomain>.workers.dev/callback

要测试这一点,您现在可以使用 Workers AI LLM Playground。导航至https://playground.ai.cloudflare.com/并使用以下 URL 模式连接到左下角的 MCP 服务器:

https://mcp-auth0-oidc.<your-subdomain>.workers.dev/sse

这将打开一个弹出窗口,您可以在其中登录,然后就可以使用所有工具。

故障排除

如果您在设置或使用 MCP 服务器时遇到任何问题,请按照以下故障排除步骤操作:

检查工人日志

访问仪表板中的Cloudflare Workers Logs

Auth0 仪表板日志

  • 导航到 Auth0 仪表板中的“日志”部分
  • 查看身份验证尝试和失败

常见问题

  • 如果身份验证失败,请验证您的 Auth0 配置和机密
  • 对于连接问题,请确保您的 Worker 已部署并且域正确
  • 检查所有回调 URL 是否在 Auth0 中正确配置
  • 验证 API_BASE_URL 是否与您部署的 API 端点匹配
-
security - not tested
F
license - not found
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

模型上下文协议服务器需要通过 Auth0 进行用户身份验证,然后才能代表经过身份验证的用户启用安全 API 访问。

  1. 配置
    1. 待办事项 API
    2. Auth0 配置
    3. 设置KV命名空间
  2. 环境变量
    1. 发展
      1. 测试 MCP 服务器
    2. 将 MCP 服务器部署到 Cloudflare
      1. 故障排除

        Related MCP Servers

        • A
          security
          F
          license
          A
          quality
          A Model Context Protocol server implementation for interacting with Salesforce through its REST API.
          Last updated -
          4
          10
          TypeScript
        • -
          security
          A
          license
          -
          quality
          A Model Context Protocol server that enables seamless execution of commands, Python code, web content fetching, and reusable task management with secure credentials handling.
          Last updated -
          2
          Python
          MIT License
          • Apple
        • -
          security
          A
          license
          -
          quality
          A Model Context Protocol server designed for testing backend APIs for security vulnerabilities like authentication bypass, injection attacks, and data leakage.
          Last updated -
          1
          TypeScript
          MIT License
        • A
          security
          F
          license
          A
          quality
          A Model Context Protocol server implementation that provides endpoints for wallet-based authentication, cluster management, and name registration services.
          Last updated -
          TypeScript

        View all related MCP servers

        ID: ltli48vbh2