 ](https://nodejs.org/) ](https://www.npmjs.com/package/@auth0/auth0-mcp-server) ](https://www.npmjs.com/package/@auth0/auth0-mcp-server)
📚 文档 • 🚀 入门指南 • 💻 支持的工具 • 💬 反馈
MCP(模型上下文协议) 是Anthropic引入的一种开放协议,它规范了大型语言模型如何与外部工具、资源或远程服务进行通信。
将Claude、Cursor或Windsurf连接到您的Auth0租户,以创建应用程序、部署操作、调试日志和管理用户,所有这些都无需触摸仪表板。
\[!小心\] Beta软件通知:此软件目前处于测试阶段,按原样提供,不提供任何保证。 - 特性、API和功能可能随时更改,恕不另行通知 - 不建议用于生产或关键工作负载 - 测试期间的支持有限 - 问题和反馈可以通过以下方式报告 使用此测试版软件即表示您承认并接受这些条件。
Auth0 MCP服务器与LLM和AI代理集成,允许您使用自然语言执行各种Auth0管理操作。例如,您可以简单地让Claude Desktop执行Auth0管理操作:
- > 创建新的Auth0应用程序并获取域和客户端ID
- > 创建并部署新的Auth0操作以生成JWT令牌
- > 您能检查来自192.108.92.3 IP地址的登录的Auth0日志吗?
🚀 入门指南
先决条件:
- 身份验证0 具有适当权限的帐户
安装Auth0 MCP服务器
安装Auth0 MCP服务器并将其配置为与首选MCP客户端一起工作。这 --tools 参数指定哪些工具应该可用(默认为 * 如果没有提供)。
带所有工具的Claude桌面
npx @auth0/auth0-mcp-server init带只读工具的Claude桌面
npx @auth0/auth0-mcp-server init --read-only您还可以明确选择只读工具:
npx @auth0/auth0-mcp-server init --tools 'auth0_list_*,auth0_get_*'帆板运动
npx @auth0/auth0-mcp-server init --client windsurf光标
第一步:

第二步:
npx @auth0/auth0-mcp-server init --client cursor工具访问受限的光标
npx @auth0/auth0-mcp-server init --client cursor --tools 'auth0_list_applications,auth0_get_application'VS Code
npx @auth0/auth0-mcp-server init --client vscode您可以为全局或工作区范围配置VS代码:
- 全球:适用于所有VS Code实例
- 工作区:仅在特定项目/存储库中可用
该命令将提示您选择首选范围并自动配置相应的范围 mcp.json 文件。
VS代码,工具访问受限
npx @auth0/auth0-mcp-server init --client vscode --tools 'auth0_list_*,auth0_get_*' --read-onlyGemini CLI
为gemini CLI初始化gemini MCP服务器
npx @auth0/auth0-mcp-server init --client gemini安装Gemini扩展
gemini extensions install https://github.com/auth0/auth0-mcp-server
其他MCP客户端
要将Auth0 MCP服务器与任何其他MCP客户端一起使用,您可以手动将此配置添加到客户端,然后重新启动以使更改生效:
{
"mcpServers": {
"auth0": {
"command": "npx",
"args": ["-y", "@auth0/auth0-mcp-server", "run"],
"capabilities": ["tools"],
"env": {
"DEBUG": "auth0-mcp"
}
}
}
}您可以添加 --tools ' ' 访问args数组以控制哪些工具可用。看 安全最佳实践 对于推荐的模式。
使用Auth0进行授权
您的浏览器将自动打开以启动OAuth 2.0设备授权流。登录您的Auth0帐户并授予请求的权限。
\[!注意\] 凭据安全地存储在系统的密钥链中。您可以选择通过密钥链管理工具验证存储。结账 认证 了解更多信息。
验证您的集成
重新启动MCP客户端(Claude Desktop、Windsurf、Cursor等),并让它帮助您管理Auth0租户
🛠️ 支持的工具
Auth0 MCP服务器为Claude提供了以下工具,以便与您的Auth0租户进行交互:
应用程序
| 工具 | 说明 | 使用示例 |
|---|---|---|
auth0_list_applications | 列出Auth0租户中的所有应用程序或按名称搜索 | - Show me all my Auth0 applications |
- Find applications with 'api' in their name - What applications do I have in my Auth0 tenant? | | auth0_get_application |获取特定Auth0应用程序的详细信息|- Show me details for the application called 'Customer Portal' - Get information about my application with client ID abc123 - What are the callback URLs for my 'Mobile App'? | | auth0_create_application |创建新的Auth0应用程序|- Create a new single-page application called 'Analytics Dashboard' - Set up a new native mobile app called 'iOS Client' - Create a machine-to-machine application for our background service | | auth0_update_application |更新现有的Auth0应用程序|- Update the callback URLs for my 'Web App' to include https://staging.example.com/callback - Change the logout URL for the 'Customer Portal' - Add development environment metadata to my 'Admin Dashboard' application |
资源服务器
| 工具 | 说明 | 使用示例 |
|---|---|---|
auth0_list_resource_servers | 列出Auth0租户中的所有资源服务器(API) | - Show me all the APIs in my Auth0 tenant |
- List my resource servers - What APIs have I configured in Auth0? | | auth0_get_resource_server |获取特定Auth0资源服务器的详细信息|- Show me details for the 'User API' - What scopes are defined for my 'Payment API'? - Get information about the resource server with identifier https://api.example.com" | | auth0_create_resource_server |新建Auth0资源服务器(API)|- Create a new API called 'Inventory API' with read and write scopes - Set up a resource server for our customer data API - Create an API with the identifier https://orders.example.com" | | auth0_update_resource_server |更新现有的Auth0资源服务器|- Add an 'admin' scope to the 'User API' - Update the token lifetime for my 'Payment API' to 1 hour - Change the signing algorithm for my API to RS256 |
申请资助
| 工具 | 说明 | 使用示例 |
|---|---|---|
auth0_create_application_grant | 创建客户端授权,授权Auth0应用程序访问具有已定义作用域的特定API | - Grant my 'Backend Service' application access to the 'User API' |
- Create a client grant for my M2M app to call the payments API - Authorize my application to access the inventory API with read and write scopes |
行动
| 工具 | 说明 | 使用示例 |
|---|---|---|
auth0_list_actions | 列出Auth0租户中的所有操作 | - Show me all my Auth0 actions |
- What actions do I have configured? - List the actions in my tenant | | auth0_get_action |获取特定Auth0操作的详细信息|- Show me the code for my 'Enrich User Profile' action - Get details about my login flow action - What does my 'Add Custom Claims' action do? | | auth0_create_action |创建新的Auth0操作|- Create an action that adds user roles to tokens - Set up an action to log failed login attempts - Create a post-login action that checks user location | | auth0_update_action |更新现有的Auth0操作|- Update my 'Add Custom Claims' action to include department information - Modify the IP filtering logic in my security action - Fix the bug in my user enrichment action | | auth0_deploy_action |部署Auth0操作|- Deploy my 'Add Custom Claims' action to production - Make my new security action live - Deploy the updated user enrichment action |
日志
| 工具 | 说明 | 使用示例 |
|---|---|---|
auth0_list_logs | 列出Auth0租户的日志 | - Show me recent login attempts |
- Find failed logins from the past 24 hours - Get authentication logs from yesterday - Show me successful logins for user john@example.com | | auth0_get_log |按ID获取特定日志条目|- Show me details for log entry abc123 - Get more information about this failed login attempt - What caused this authentication error? |
表单
| 工具 | 说明 | 使用示例 |
|---|---|---|
auth0_list_forms | 列出Auth0租户中的所有表单 | - Show me all my Auth0 forms |
- What login forms do I have configured? - List the custom forms in my tenant | | auth0_get_form |获取特定Auth0表单的详细信息|- Show me the details of my 'Corporate Login' form - What does my password reset form look like? - Get the configuration for my signup form | | auth0_create_form |创建新的Auth0表单|- Create a new login form with our company branding - Set up a custom signup form that collects department information - Create a password reset form with our logo | | auth0_update_form |更新现有的Auth0表单|- Update the colors on our login form to match our new brand guidelines - Add a privacy policy link to our signup form - Change the logo on our password reset form | | auth0_publish_form |发布Auth0表单|- Publish my updated login form - Make the new signup form live - Deploy the password reset form to production |
🔒 工具访问的安全最佳实践
配置Auth0 MCP服务器时,根据您的特定需求限制工具访问,遵循安全最佳实践非常重要。服务器提供灵活的配置选项,让您控制AI助手可以访问哪些工具。
您可以使用以下工具轻松限制工具访问 --tools 和 --read-only 启动服务器时的标志:
# Enable only read-only operations
npx @auth0/auth0-mcp-server run --read-only
# Alternative way to enable only read-only operations
npx @auth0/auth0-mcp-server run --tools 'auth0_list_*,auth0_get_*'
# Limit to just application-related tools
npx @auth0/auth0-mcp-server run --tools 'auth0_*_application*'
# Limit to read-only application-related tools
# Note: --read-only takes priority when used with --tools
npx @auth0/auth0-mcp-server run --tools 'auth0_*_application*' --read-only
# Restrict to only log viewing capabilities
npx @auth0/auth0-mcp-server run --tools 'auth0_list_logs,auth0_get_log'
# Run the server with all tools enabled
npx @auth0/auth0-mcp-server run --tools '*'\[!重要\] 当两者都--read-only和--tools旗帜一起使用--read-only为了确保安全,该标志具有优先权。这意味着即使你--tools模式与非只读工具匹配,只有只读操作可用。这确保您可以信赖--read-only旗帜作为安全护栏。
对于无法传递CLI标志的环境(例如,MCP捆绑包安装),可以使用相同的控件作为环境变量:
| 变量 | 等效标志 | 示例 |
|---|---|---|
AUTH0_MCP_READ_ONLY | --read-only | AUTH0_MCP_READ_ONLY=true |
AUTH0_MCP_TOOLS | --tools | AUTH0_MCP_TOOLS=auth0_list_*,auth0_get_* |
同时提供CLI标志时,CLI标志优先。
这种方法有几个重要的好处:
- 增强的安全性:通过将可用工具限制在所需的范围内,您可以减少潜在的攻击面,并防止对Auth0租户进行意外修改。
- 更好的性能为AI助手提供更少的工具实际上可以提高性能。当模型可以访问许多工具时,它们会使用更多的上下文窗口来推理要使用哪些工具。有了一套专注的工具,你会得到更快、更相关的回应。
- 基于资源的访问控制:您可以根据特定需求使用不同的工具集配置MCP服务器的不同实例——开发环境可能需要完全访问权限,而生产环境可能仅限于读取操作。
- 简化审计:在工具有限的情况下,通过人工智能助手更容易跟踪执行了哪些操作。
对于大多数用例,从所需的最小工具集开始,只在需要时添加更多工具。这遵循了最小特权原则,这是一种基本的安全最佳实践。
🛡️ 凭证保护
服务器自动 编辑敏感字段 (例如。, client_secret, token 在相关MCP工具响应中,将其替换为 [REDACTED]。这可以防止秘密泄露到AI助手日志或对话历史中。
为了在本地安全地存储凭据 auth0_save_credentials_to_file 工具将Auth0证书作为环境变量写入用户指定的文件(例如。, .env.local),并自动将其添加到 .gitignore如果文件已经存在,则附加凭据(保留现有内容);否则,将创建一个新文件。此工具可以手动调用,也可以在创建应用程序后,AI助手会自动提示您保存凭据。
🧪 安全扫描
我们建议使用内置的社区工具定期扫描此服务器以及您部署的任何其他MCP兼容服务器,以发现协议级风险和配置错误。
这些扫描程序有助于识别关键漏洞类别中的问题,包括:服务器实现错误、工具定义和生命周期风险、交互和数据流弱点,以及配置或环境差距。
有用的工具包括:
基于Web的扫描程序,用于检查活动MCP端点是否存在暴露的工具、模式实施差距和其他问题。
CLI工具,用于模拟攻击路径并从客户端角度评估服务器行为。
这些工具不能替代全面审计,但它们提供了有意义的护栏和预警。我们建议将它们纳入您的常规安全审查流程。
如果您发现漏洞,请按照我们的 负责任的披露过程.
🕸️ 建筑
Auth0 MCP服务器实现了模型上下文协议,允许Claude:
- 请求可用Auth0工具的列表
- 使用参数调用特定工具
- 从Auth0 Management API接收结构化响应
服务器通过Auth0管理API处理身份验证、请求验证和安全通信。
\[!注意\] 服务器作为连接到Claude Desktop的本地进程运行,在不暴露您的Auth0凭据的情况下实现安全通信。
🔐 认证
Auth0 MCP服务器使用Auth0 Management API,需要身份验证才能访问Auth0租户。
初始设置
要验证MCP服务器,请执行以下操作:
npx @auth0/auth0-mcp-server init这将启动设备授权流程,允许您登录Auth0帐户并选择要使用的租户。
\[!注意\] 不支持使用设备授权流进行身份验证 私有云 租户。 私有云用户应通过以下方式进行身份验证 客户端资格。尽可能缩短令牌寿命,以降低安全风险。 查看更多 ``bash npx @auth0/auth0-mcp-server init --auth0-domain --auth0-client-id --auth0-client-secret ``\[!重要\] Keep limited scope for client credentials M2M application: 支持的范围: -read:clients-create:clients-update:clients-read:resource_servers-create:resource_servers-update:resource_servers-read:actions-create:actions-update:actions-read:logs-read:forms-create:forms-update:formsTheinitcommand needs to be run whenever: - 您是第一次设置MCP服务器 - 您已退出上一个会话 - 您想切换到其他租户 - 您的令牌已过期 这run命令将在启动服务器之前自动检查令牌有效性,如果需要身份验证,将提供有用的错误消息。
\[!注意\] 根据订阅计划,使用MCP服务器将消耗管理API费率限制。请参阅 利率限制政策 了解更多信息。
\[!提示\] 使用 --no-interaction flag跳过用户交互(按回车键)在设置过程中打开浏览器。如果MCP服务器在某些环境(如AI代理)中启动,这可能会很有用。会话管理
要查看有关当前身份验证会话的信息,请执行以下操作:
npx @auth0/auth0-mcp-server session退出登录
对于安全最佳实践,当您完成会话时,请始终使用logout命令:
npx @auth0/auth0-mcp-server logout这可确保您的身份验证令牌从系统密钥链中正确删除。
身份验证流程
服务器使用OAuth 2.0设备授权流通过Auth0进行安全身份验证。您的凭据安全地存储在系统的密钥链中,永远不会以纯文本形式公开。
🩺 故障排除
当遇到Auth0 MCP服务器的问题时,有几个故障排除选项可用于帮助诊断和解决问题。
通过探索所有可用的命令和选项开始故障排除:
npx @auth0/auth0-mcp-server help🚥 操作模式
🐞 调试模式
- 更详细的日志记录
- 通过设置环境变量启用:
export DEBUG=auth0-mcp
\[!提示\] 调试模式在解决连接或身份验证问题时特别有用。
🔑 范围选择
服务器在初始化期间提供交互式作用域选择界面:
- 交互式选择:使用箭头键导航,并使用空格键切换选择
- 无默认作用域:默认情况下,不会选择任何范围以获得最大安全性
- 全球模式支持:快速选择多个具有模式的相关范围:
# Select all read scopes
npx @auth0/auth0-mcp-server init --scopes 'read:*'
# Select multiple scope patterns (comma-separated)
npx @auth0/auth0-mcp-server init --scopes 'read:*,create:clients,update:actions'\[!注意\] 所选范围决定MCP服务器可以在Auth0租户上执行哪些操作。
⚙️ 配置
其他MCP客户端:
要将Auth0 MCP服务器与任何其他MCP客户端一起使用,您可以将此配置添加到客户端并重新启动以使更改生效:
{
"mcpServers": {
"auth0": {
"command": "npx",
"args": ["-y", "@auth0/auth0-mcp-server", "run"],
"capabilities": ["tools"],
"env": {
"DEBUG": "auth0-mcp"
}
}
}
}\[!注意\]\ 如果需要或在npx init命令期间发生任何意外错误,您可以手动更新。
🚨 常见问题
- 身份验证失败
- 确保您在Auth0租户中具有正确的权限 - 尝试使用重新初始化 npx @auth0/auth0-mcp-server init
- Claude Desktop无法连接到服务器
- 安装后重新启动Claude Desktop - 检查服务器是否正在运行 ps aux | grep auth0-mcp
- API错误或权限问题
- 启用调试模式 export DEBUG=auth0-mcp - 检查您的Auth0令牌状态: npx @auth0/auth0-mcp-server session - 使用特定作用域重新初始化: npx @auth0/auth0-mcp-server init --scopes 'read:*,update:*,create:*' - 如果特定操作失败,则可能缺少所需的作用域
- 无效的Auth0配置错误
- 这通常发生在您的授权令牌丢失或过期时 - 跑 npx @auth0/auth0-mcp-server session 检查您的令牌状态 - 如果过期或丢失,请运行 npx @auth0/auth0-mcp-server init 鉴定
\[!提示\] 大多数连接问题都可以通过重新启动服务器和Claude Desktop来解决。
📋 调试日志
启用调试模式以查看详细日志:
export DEBUG=auth0-mcp从Claude Desktop获取详细的MCP客户端日志:
# Follow logs in real-time
tail -n 20 -F ~/Library/Logs/Claude/mcp*.log要进行高级故障排除,请使用MCP检查器:
npx @modelcontextprotocol/inspector -e DEBUG='auth0-mcp' @auth0/auth0-mcp-server run有关详细的MCP服务器日志,请在调试模式下运行服务器:
DEBUG=auth0-mcp npx @auth0/auth0-mcp-server run👨💻 发展
从源代码构建
# Clone the repository
git clone https://github.com/auth0/auth0-mcp-server.git
cd auth0-mcp-server
# Install dependencies
npm install
# Build the project
npm run build
# Initiate device auth flow
npx . init
# Configure your MCP Client (e.g. Claude Desktop) with MCP server path
npm run setup开发脚本
# Run directly with TypeScript (no build needed)
npm run dev
# Run with debug logs enabled
npm run dev:debug
# Run with MCP inspector for debugging
npm run dev:inspect
# Run the compiled JavaScript version
npm run start\[!注意\] 此服务器需要 .
🔒 安全
Auth0 MCP服务器优先考虑安全性:
- 凭据存储在系统的安全密钥链中
- 没有敏感信息以纯文本形式存储
- 身份验证使用OAuth 2.0设备授权流
- 默认情况下不请求权限(范围)
- 交互式范围选择允许您准确选择要授予的权限
- 支持glob模式以快速选择相关范围(例如。,
read:*) - 通过以下方式轻松删除令牌
logout不再需要时发出命令
\[!重要\] 对于安全最佳实践,请始终使用 npx @auth0/auth0-mcp-server logout 当你结束一个会话或在租户之间切换时。这可确保您的身份验证令牌从系统密钥链中正确删除。\[!小心\] 始终检查身份验证过程中请求的权限,以确保它们符合您的安全要求。
匿名分析披露
在使用此MCP服务器期间收集匿名数据点。这些数据包括MCP版本、操作系统、时间戳和其他不会识别您个人身份的技术细节。
Auth0使用这些数据来更好地了解此工具的使用情况,以优先考虑对我们的用户最重要的功能、增强和修复。
到 退出 在此集合中,设置 AUTH0_MCP_ANALYTICS 环境变量 false.
💬 反馈和贡献
我们感谢对这个项目的反馈和贡献!在开始之前,请参阅:
报告问题
要提供反馈或报告错误,请 在我们的问题跟踪器上提出问题.
漏洞报告
请不要在公共GitHub问题跟踪器上报告安全漏洞。这 责任披露计划 详细说明了披露安全问题的程序。
📄 许可证
该项目根据麻省理工学院许可证获得许可。看 许可证 文件以获取更多信息。
什么是Auth0?
Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout Why Auth0?
