mcp-auth-oidc

MCP运维云端

提供方 johnidm

运维云端 stdio · 本地进程 OAuth 授权 社区 / 第三方 Claude DesktopClaude
查看接入方式

A production-ready Model Context Protocol (MCP) server with OAuth 2.1 authentication using FastMCP's built-in OIDC Proxy and Auth0 as the identity provider.

一句话选型结论

按资料字段整理

mcp-auth-oidc 属于运维云端类 MCP 服务器,stdio · 本地进程,OAuth 授权,可直接接入 Claude Desktop、Claude,有可直接执行的安装命令。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类运维云端 传输方式stdio · 本地进程 鉴权OAuth 授权 部署方式本地部署
GitHub 星标 1 仓库热度,无公开仓库时显示未标注
工具数 未标注 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

运维云端
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量未标注暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

Local Deployment OAuth Authentication Model Context Protocol Python Identity Verification FastMCP Auth0

支持客户端

适用场景

Local DeploymentOAuth AuthenticationModel Context Protocol

安装与配置

stdio · 本地进程 OAuth 授权
客户端在本机拉起子进程,数据不出本机
http://localhost:8000

把它填进客户端的 MCP 配置即可,不需要在本地安装运行时。

  1. 1
    准备运行环境

    stdio 服务在本地起进程,需要先装好 python,再按安装命令拉取依赖。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后随便调一个只读工具,确认能返回结果,再接入正式流程。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
云资源查询

查实例、存储、账单等云上资源状态。

部署与发布

把部署、重启、回滚这类操作接进对话。

监控与告警

拉取监控指标,异常时让模型帮你判断。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 已适配 Claude Desktop、Claude,换客户端不用重新研究配置。

先想清楚的地方

  • stdio 方式要求本地装好运行时(如 Node.js),换机器要重新装一遍。
  • 使用前要准备好OAuth 授权对应的凭据,并按最小权限配置。
  • 资料没标注工具数量,实际能力要装好后确认。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在运维云端场景里让模型直接调用外部能力的人。
  • 已经在用 Claude Desktop、Claude 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 不方便管理密钥或第三方授权的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
mcp-auth-oidc当前 未标注 stdio · 本地进程 本地部署 有 2025-12-18
lobehub 未标注 stdio · 本地进程 本地部署 有 2026-04-11
TrendRadar 未标注 stdio · 本地进程 本地部署 有 2026-04-13
Ui Tars Desktop 8a825770 未标注 stdio · 本地进程 本地部署 有 2026-05-17
ruflo 未标注 stdio · 本地进程 本地部署 有 2026-04-13
FastGPT 未标注 stdio · 本地进程 本地部署 有 2026-04-11

服务器档案

运维云端
字段来自项目仓库与公开索引,中文说明由本站标注
提供方johnidm上游标注的维护方 johnidm
分类运维云端本站按上游分类展示
连接方式stdio · 本地进程客户端在本机拉起子进程,数据不出本机
鉴权方式OAuth 授权远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时未标注 · python本地安装时用到的包标识与运行时
部署类型本地部署上游给出的部署形态
最近核验2025-12-18上游最后核验时间

详细介绍

13.8 KB
来自项目仓库与上游目录的原文,未做删改

🔐 MCP Server with OAuth Authentication via Auth0

> 🚀 A production-ready Model Context Protocol (MCP) server with OAuth 2.1 authentication using FastMCP's built-in OIDC Proxy and Auth0 as the identity provider.

✨ Features

  • 🔒 FastMCP OIDC Proxy: Built-in OAuth authentication via FastMCP's OIDCProxy
  • 🌐 Auth0 Integration: Pre-configured Auth0 provider for seamless authentication
  • 🔄 Dynamic Client Registration: Proxies DCR for Auth0 to work with Claude.ai
  • 🛠️ Demo Tools: Calculator and notes management tools for testing
  • 📡 HTTP/SSE Transport: Built-in server with automatic routing and auth

🏗️ Architecture

FastMCP's OIDC Proxy acts as a bridge between Claude.ai and Auth0:```
┌─────────────┐
│ Claude.ai │
│ Client │
└──────┬──────┘
│
│ 1. DCR Request
↓
┌──────────────────────────────────┐
│ FastMCP Server (OIDC Proxy) │
│ - Proxies DCR │
│ - Handles OAuth flow │
│ - Validates tokens │
│ - Protects MCP tools │
└──────────┬───────────────────────┘
│
│ 2. OAuth with Auth0
↓
┌──────────────────────────────────┐
│ Auth0 (IdP) │
│ - User authentication │
│ - Token issuance │
│ - OIDC discovery │
└──────────────────────────────────┘


## 📋 Prerequisites

- 🐍 Python 3.10 or higher
- 🔑 Auth0 account (free tier works)
- ⚙️ Auth0 application configured with redirect URI

## 📦 Installation

### 1️⃣ Clone the Repository```bash
git clone <your-repo-url>
cd mcp-auth-oidcO

2️⃣ Install Dependencies```bash

pip install -r requirements.txt


Or with a virtual environment:```bash
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt

3️⃣ Configure Auth0

🎯 Create an Auth0 Application

  1. Log in to your Auth0 Dashboard
  2. Navigate to Applications → Create Application
  3. Choose Regular Web Application
  4. Note your Domain, Client ID, and Client Secret

🔗 Configure Redirect URI

In your Auth0 application settings, add the callback URL:

For local development:```
http://localhost:8000/auth/callback


**For production:**```
https://your-domain.com/auth/callback

🎫 Create an API (for audience)

  1. Navigate to APIs → Create API
  2. Set an identifier (e.g., https://dev-zilqiezmsk6ylig2.us.auth0.com/api/v2/)
  3. Add the following scopes:
    - 📖 read:notes - Read notes
    - ✍️ write:notes - Create, update, delete notes
    - 🧮 use:calculator - Use calculator tools

4️⃣ Configure Environment Variables

Create a .env file in the project root:```env

Auth0 Configuration

AUTH0_DOMAIN=your-domain.us.auth0.com
AUTH0_CLIENT_ID=your_client_id
AUTH0_CLIENT_SECRET=your_client_secret
AUTH0_AUDIENCE=https://your-domain.us.auth0.com/api/v2/

Server Configuration

RESOURCE_ID=http://localhost:8000
SERVER_HOST=0.0.0.0
SERVER_PORT=8000


**✨ Demo credentials** (pre-configured):```env
AUTH0_DOMAIN=dev-zilqiezmsk6ylig2.us.auth0.com
AUTH0_CLIENT_ID=GsJfBMVGn5cDgWQwTiq91SIQBYxQccJA
AUTH0_CLIENT_SECRET=Qst5RVD9Vt79F5NgM_s6ymZSvMYemKrFMykWrDOtextPC2nBeK593yBvpJBafIDl
AUTH0_AUDIENCE=https://dev-zilqiezmsk6ylig2.us.auth0.com/api/v2/
RESOURCE_ID=http://localhost:8000
SERVER_HOST=0.0.0.0
SERVER_PORT=8000

🚀 Running the Server

Start the server:```bash
python run.py


You should see:```
============================================================
MCP Auth Demo Server (FastMCP + OIDC Proxy)
============================================================
Base URL: http://localhost:8000
Auth0 Domain: dev-zilqiezmsk6ylig2.us.auth0.com
Server: http://0.0.0.0:8000
Auth Callback: http://localhost:8000/auth/callback
============================================================

Starting server with FastMCP's built-in HTTP/SSE transport...

The server will start on http://localhost:8000 with the following endpoints:
- 📡 MCP/SSE: /mcp/sse or /sse (authenticated)
- 🔄 Auth Callback: /auth/callback (OAuth redirect)
- ✅ Consent: /auth/consent (user authorization)

🛠️ Available Tools

🧮 Calculator Tools

All calculator tools require the use:calculator scope:

  1. add_numbers(a, b) ➕ Add two numbers
  2. subtract_numbers(a, b) ➖ Subtract b from a
  3. multiply_numbers(a, b) ✖️ Multiply two numbers
  4. divide_numbers(a, b) ➗ Divide a by b

📝 Notes Tools

Notes tools require either read:notes or write:notes scope:

  1. create_note(title, content) ✍️ Create a new note (requires write:notes)
  2. read_note(note_id) 📖 Read a specific note (requires read:notes)
  3. list_notes() 📋 List all notes (requires read:notes)
  4. update_note(note_id, title, content) 📝 Update a note (requires write:notes)
  5. delete_note(note_id) 🗑️ Delete a note (requires write:notes)

🔌 Connecting to Claude.ai

🌐 Method 1: Claude.ai Web Interface

  1. Open Claude.ai
  2. Go to Settings → Integrations → Model Context Protocol
  3. Click "Add Remote MCP Server"
  4. Enter your server URL: http://localhost:8000
  5. Claude.ai will:
    - Perform Dynamic Client Registration (DCR) via the proxy
    - Redirect you to Auth0 for authentication
    - Request consent for the required scopes
    - Connect to your MCP server with a valid access token

🌍 Method 2: Using ngrok for Remote Access

If Claude.ai needs to access your local server over the internet:

  1. Install ngrok
  2. Start ngrok:bash ngrok http 8000
  3. Update your .env file with the ngrok URL:env RESOURCE_ID=https://your-ngrok-id.ngrok.io
  4. Update Auth0 redirect URI to: https://your-ngrok-id.ngrok.io/auth/callback
  5. Restart the server
  6. Use the ngrok URL in Claude.ai: https://your-ngrok-id.ngrok.io

💻 Method 3: Claude Desktop App

For the Claude Desktop application, add to your MCP configuration:

Location:
- macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
- Windows: %APPDATA%\Claude\claude_desktop_config.json

Configuration:```json
{
"mcpServers": {
"auth-demo": {
"url": "http://localhost:8000",
"transport": "sse"
}
}
}


## 🔍 Testing with MCP Inspector

The MCP Inspector is an interactive developer tool for testing and debugging your OAuth-enabled MCP server.

### ⚡ Quick Start

1. **Start your server**:```bash
   python run.py
   ```

2. **Launch MCP Inspector** (in a new terminal):```bash
   npx @modelcontextprotocol/inspector
   ```

   This will open the Inspector at `http://localhost:6274`

3. **Configure connection** in the Inspector UI:
   - **Transport**: Select "HTTP with SSE"
   - **Server URL**: `http://localhost:8000/mcp`
   - **OAuth Scopes**: `read:notes write:notes use:calculator`

4. **Update Auth0 redirect URI**:
   - Add `http://localhost:6274/oauth/callback` to your Auth0 application's Allowed Callback URLs

5. **Connect and test**:
   - Click "Connect" to initiate OAuth flow
   - Authenticate with Auth0
   - Test calculator and notes tools interactively

### 🎯 What You Can Do with Inspector

- ✅ Test OAuth authentication flow step-by-step
- ✅ Call MCP tools with custom parameters
- ✅ View detailed request/response data
- ✅ Debug authentication and authorization issues
- ✅ Verify scope-based access control
- ✅ Test error handling and edge cases

### 📚 Detailed Guide

For comprehensive testing instructions, including:
- Step-by-step OAuth flow testing
- Example tool calls with expected results
- Common issues and solutions
- Advanced testing scenarios

See the complete MCP Inspector Testing Guide.

## 🔄 How It Works

### 🔐 OAuth Flow with OIDC Proxy

1. **Client Registration** 📝 Claude.ai sends a DCR request to FastMCP
2. **Proxy DCR** 🔄 FastMCP proxies the registration (Auth0 doesn't support DCR natively)
3. **Authorization** 🔑 User is redirected to Auth0 for authentication
4. **Consent** ✅ User authorizes the scopes requested by Claude.ai
5. **Token Exchange** 🎫 FastMCP exchanges the authorization code for tokens
6. **Token Validation** ✔️ FastMCP validates tokens using Auth0's OIDC configuration
7. **Tool Access** 🛠️ Authenticated requests can access protected MCP tools

### 🌟 Key Benefits of OIDC Proxy

- 🚀 **No Manual Registration**: Clients register dynamically
- ✅ **Automatic Token Validation**: JWT verification via Auth0's JWKS
- 🔒 **Scope-Based Authorization**: Tools protected by OAuth scopes
- 👤 **Consent Flow**: Users see and approve what clients can access
- 🌐 **Works with Any OIDC Provider**: Not just Auth0

## 📁 Project Structure```
mcp-auth-oidcO/
├── src/
│   ├── __init__.py           # Package initialization
│   ├── auth_config.py        # Auth0Provider configuration
│   ├── server.py             # FastMCP server with demo tools
│   ├── app.py                # FastMCP app export
│   └── main.py               # Main entry point
├── .env                      # Environment variables (not in git)
├── .gitignore               # Git ignore rules
├── pyproject.toml           # Python project configuration
├── requirements.txt         # Python dependencies
├── run.py                   # Convenience script
├── README.md               # This file
├── QUICKSTART.md           # Quick start guide
└── TESTING.md              # Testing guide

👨‍💻 Development

📝 Code Structure

The server is built with three simple files:

  1. auth_config.py 🔧 Configures Auth0Provider
  2. server.py 🛠️ Defines MCP tools with @mcp.tool() decorator
  3. main.py 🚀 Starts the FastMCP HTTP server

That's it! FastMCP handles all the routing, authentication, and SSE automatically.

➕ Adding New Tools

To add new tools:

  1. Open src/server.py
  2. Add a new function with the @mcp.tool() decorator:```python
    @mcp.tool()
    def my_new_tool(param: str) -> str:
    """
    Description of what the tool does.

    Args:
    param: Description

    Returns:
    Description of return value

    Requires:
    Scope: my:scope
    """
    return f"Result: {param}"


3. Add the scope to `src/auth_config.py`:```python
SUPPORTED_SCOPES = [
    "read:notes",
    "write:notes",
    "use:calculator",
    "my:scope",  # Add your new scope
]
  1. Configure the scope in Auth0

🧪 Testing

See TESTING.md for comprehensive testing instructions.

⚡ Quick Test

Start the server and verify it's running:```bash

Start server

python run.py

In another terminal, check health (if you add a health endpoint)

curl http://localhost:8000/


## 🔧 Troubleshooting

### ❌ Server Won't Start

- ✅ Check Python version: `python --version` (need 3.10+)
- ✅ Verify all environment variables are set in `.env`
- ✅ Ensure dependencies are installed: `pip install -r requirements.txt`

### 🔐 Authentication Fails

- ✅ Verify Auth0 credentials in `.env` are correct
- ✅ Check that redirect URI in Auth0 matches `{BASE_URL}/auth/callback`
- ✅ Ensure scopes are configured in Auth0 API

### 🌐 Claude.ai Can't Connect

- ✅ Verify the server is running and accessible
- ✅ Check that the base URL is correct
- ✅ For local testing, ensure Claude.ai can reach localhost (try ngrok)
- ✅ Review server logs for authentication errors

## 🔒 Security Considerations

### 🚨 For Production Deployment

1. 🔐 **HTTPS Only**: Always use HTTPS in production
2. 🔑 **Environment Variables**: Never commit `.env` to version control
3. 🗝️ **Secure Secrets**: Use a secrets manager (AWS Secrets Manager, Azure Key Vault, etc.)
4. 💾 **Token Storage**: Configure encrypted storage backend (Redis with encryption)
5. 🎫 **JWT Signing Key**: Set explicit `jwt_signing_key` in production
6. ⏱️ **Rate Limiting**: Add rate limiting middleware
7. 📝 **Logging**: Implement comprehensive audit logs
8. 🌐 **CORS**: Configure specific origins (not `*`)

### ⚙️ Production Configuration```python
from fastmcp.server.auth.providers.auth0 import Auth0Provider
from key_value.aio.stores.redis import RedisStore
from key_value.aio.wrappers.encryption import FernetEncryptionWrapper
from cryptography.fernet import Fernet
import os

auth = Auth0Provider(
    config_url=f"https://{os.environ['AUTH0_DOMAIN']}/.well-known/openid-configuration",
    client_id=os.environ['AUTH0_CLIENT_ID'],
    client_secret=os.environ['AUTH0_CLIENT_SECRET'],
    audience=os.environ['AUTH0_AUDIENCE'],
    base_url=os.environ['BASE_URL'],
    required_scopes=SUPPORTED_SCOPES,
    jwt_signing_key=os.environ['JWT_SIGNING_KEY'],
    client_storage=FernetEncryptionWrapper(
        key_value=RedisStore(host="redis.example.com", port=6379),
        fernet=Fernet(os.environ['STORAGE_ENCRYPTION_KEY'])
    )
)

📚 References

  • 🚀 FastMCP Documentation
  • 🔐 FastMCP OIDC Proxy Guide
  • 📖 Model Context Protocol Specification
  • 🔒 OAuth 2.1 Draft
  • 🌐 Auth0 Documentation

📄 License

MIT License - feel free to use this as a template for your own MCP servers.

💬 Support

For issues and questions:
- 🚀 FastMCP: GitHub Issues | Discord
- 🌐 Auth0: Community Forum

🤝 Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.


⭐ Star this repo if you find it helpful! ⭐

Made with ❤️ using FastMCP and Auth0

常见问题

8 问
答案由本站依据条目字段整理,不引用上游原文
mcp-auth-oidc 怎么安装?

在客户端按下面的安装命令接入:http://localhost:8000。装完在客户端配置里引用同一个包或端点。

mcp-auth-oidc 怎么在 Claude Desktop、Claude 里配置?

它的传输方式是stdio · 本地进程,在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,配置才会生效。

mcp-auth-oidc 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

mcp-auth-oidc 需要 API Key 吗?

资料标注需要OAuth 授权认证,使用前准备好对应凭据,并按最小权限配置。

mcp-auth-oidc 支持哪些客户端?

资料标注支持 Claude Desktop、Claude;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

mcp-auth-oidc 能提供哪些能力?

资料显示能力标签包括 Local Deployment、OAuth Authentication、Model Context Protocol、Python、Identity Verification、FastMCP。具体工具清单以官方文档为准。

mcp-auth-oidc 需要什么运行环境?

运行时为 python;属于本地进程,需要在本机装好运行环境。

mcp-auth-oidc 是本地还是远程?

它是本地进程(stdio),由客户端在本机拉起。传输方式为stdio · 本地进程。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 2025-12-18。