π
Uno Oauth MCP
Quickly integrate OAuth authentication from mcpmarket.cn into your MCP Server.
0 installs
Trust: 43 β Fair
Security
Installation
npx uno-oauth-mcpAsk AI about Uno Oauth MCP
Powered by Claude Β· Grounded in docs
I know everything about Uno Oauth MCP. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Loading tools...
Reviews
Documentation
Uno OAuth MCP
Quickly integrate mcpmarket.cn OAuth authentication into your MCP Server.
β¨ Features
- π Out-of-the-box - Integrate OAuth authentication with just a few lines of code
- π― Dual Mode Support - FastMCP (simple) and Low-level Server (flexible)
- β‘ High Performance - Built-in Token caching (LRU + TTL)
- π Standard Compliant - Automatically generates RFC 9728/8414 well-known endpoints
π¦ Installation
pip install uno-oauth-mcp
Or using uv:
uv add uno-oauth-mcp
π Quick Start
Method 1: Based on FastMCP (Recommended for Beginners)
FastMCP is the official high-level wrapper with a simpler API:
from uno_oauth_mcp import UnoOAuthMCP
# Create an MCP Server with OAuth
mcp = UnoOAuthMCP(name="My Server", port=8080)
@mcp.tool()
def hello(name: str) -> str:
"""Say hello to the user"""
return f"Hello, {name}!"
@mcp.tool()
def add(a: int, b: int) -> int:
"""Calculate the sum of two numbers"""
return a + b
# Run
mcp.run(transport="streamable-http")
Method 2: Based on Low-level Server (More Flexible)
The low-level Server provides complete MCP protocol control:
import mcp.types as types
from uno_oauth_mcp import UnoOAuthServer
# Create a Server with OAuth
server = UnoOAuthServer(name="My Server", port=8080)
@server.list_tools()
async def list_tools():
return [
types.Tool(
name="hello",
description="Say hello to the user",
inputSchema={
"type": "object",
"properties": {"name": {"type": "string"}},
"required": ["name"]
}
)
]
@server.call_tool()
async def call_tool(name: str, arguments: dict):
if name == "hello":
return [types.TextContent(type="text", text=f"Hello, {arguments['name']}!")]
return []
# Run
server.run()
π Comparison of Two Methods
| Feature | UnoOAuthMCP (FastMCP) | UnoOAuthServer (Low-level Server) |
|---|---|---|
| Target Audience | Beginners, rapid development | Developers needing full control |
| API Style | Decorators + type inference | Explicit MCP type definitions |
| Tool Definition | @mcp.tool() auto-inference | Manual types.Tool construction |
| Flexibility | βββ | βββββ |
| Code Amount | Less | More |
π§ Configuration Options
# FastMCP method
mcp = UnoOAuthMCP(
name="My Server", # Server name
port=8080, # Listening port
host="0.0.0.0", # Listening address
mcpmarket_url="https://mcpmarket.cn", # Authentication server
required_scopes=["read", "write"], # OAuth scopes
cache_ttl=300, # Token cache time (seconds)
# Production environment needs to specify external access URL
# resource_server_url="https://my-mcp.example.com",
)
# Low-level Server method
server = UnoOAuthServer(
name="My Server",
port=8080,
mcp_path="/mcp", # MCP endpoint path
# ... other parameters same as above
)
π Auto-registered Endpoints
The SDK automatically registers the following endpoints:
| Endpoint | Description |
|---|---|
/.well-known/oauth-protected-resource | OAuth Protected Resource Metadata (RFC 9728) |
/.well-known/oauth-authorization-server | OAuth Authorization Server Metadata (RFC 8414) |
/mcp | MCP protocol endpoint (requires authentication) |
/health | Health check |
/ | Server information |
π Authentication Flow
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β MCP Client β β Your Server β β mcpmarket.cn β
β(Cursor/Claude)β β β β β
ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ
β β β
β 1. Access MCP endpoint β
β βββββββββββββββββ> β β
β β β
β 2. 401 + well-known β
β <βββββββββββββββββ β β
β β β
β 3. OAuth authorization β
β ββββββββββββββββββββββββββββββββββββββ> β
β β β
β 4. Get Token β
β <ββββββββββββββββββββββββββββββββββββββ β
β β β
β 5. Access with Token β
β βββββββββββββββββ> β β
β β 6. Verify Token β
β β βββββββββββββββββ> β
β β 7. Verification success β
β β <βββββββββββββββββ β
β 8. MCP response β
β <βββββββββββββββββ β β
π More Examples
Server with Resources
from uno_oauth_mcp import UnoOAuthMCP
mcp = UnoOAuthMCP(name="Resource Server")
@mcp.tool()
def get_data(key: str) -> str:
return f"Data for {key}"
@mcp.resource("config://app")
def get_config() -> str:
return '{"version": "1.0.0"}'
@mcp.resource("data://{item_id}")
def get_item(item_id: str) -> str:
return f'{{"id": "{item_id}"}}'
mcp.run(transport="streamable-http")
Using Native Server + create_oauth_starlette_app
from mcp.server.lowlevel import Server
from uno_oauth_mcp import create_oauth_starlette_app
import uvicorn
server = Server("my-server")
@server.list_tools()
async def list_tools():
return [...]
# Create Starlette app with OAuth
app = create_oauth_starlette_app(server, port=8080)
# Can add custom routes
# from starlette.routing import Route
# app.routes.append(Route("/custom", ...))
uvicorn.run(app, host="0.0.0.0", port=8080)
π Related Resources
- MCPMarket - MCP Server Marketplace
- MCP Python SDK
- RFC 9728 - OAuth Protected Resource Metadata
- RFC 8414 - OAuth Authorization Server Metadata
π License
MIT License
Made with β€οΈ by MCPMarket
