loading…
Search for a command to run...
loading…
Auth proxy for MCP servers: OAuth2 + DCR, JWT, RBAC, rate limiting, multi-server aggregation, and monitoring dashboard.
Auth proxy for MCP servers: OAuth2 + DCR, JWT, RBAC, rate limiting, multi-server aggregation, and monitoring dashboard.
Secure authentication proxy for Model Context Protocol (MCP) servers
PyPI version License: MIT Python 3.11+ Docker MCP 2025-03-26
AuthMCP Gateway is a full MCP protocol proxy with centralized authentication, authorization, and monitoring. It transparently proxies all MCP capabilities — tools, resources, prompts, and completions — from multiple backend servers through a single authenticated endpoint.
OAuth + DCR ready: the gateway supports OAuth 2.0 Authorization Code flow with Dynamic Client Registration (DCR), so MCP clients like Codex can self-register and authenticate without manual client provisioning.
tools/list, tools/call with intelligent routing (prefix, mapping, auto-discovery)resources/list, resources/read, resources/templates/listprompts/list, prompts/getcompletion/complete with ref-based routinginitialize and advertises only what they support
Live statistics, server health monitoring, top tools usage, and recent activity feed

Manage backend MCP server connections with status monitoring and health checks

Monitor live MCP requests with detailed metrics, top tools ranking, and request feed

Track security events, rate limiting, suspicious payloads, and unauthorized access attempts

Test any MCP server for security vulnerabilities with comprehensive automated checks
1. Install:
pip install authmcp-gateway
2. First Run:
authmcp-gateway start
# ✓ Auto-creates .env with JWT_SECRET_KEY
# ✓ Auto-creates data/ directory
# ✓ Initializes database
3. Access Setup Wizard: Open http://localhost:8000/ in your browser to create admin user.
4. Optional - Customize Configuration:
# Edit auto-generated .env or download full example
curl -o .env https://raw.githubusercontent.com/loglux/authmcp-gateway/main/.env.example.pypi
# Common settings to customize in .env:
# PORT=9000 # Change server port
# PASSWORD_REQUIRE_SPECIAL=false # Relax password requirements
# LOG_LEVEL=DEBUG # More detailed logs
# Restart to apply changes
authmcp-gateway start
Available Commands:
authmcp-gateway start # Start server (default: 0.0.0.0:8000)
authmcp-gateway start --port 9000 # Start on custom port
authmcp-gateway start --host 127.0.0.1 # Bind to localhost only
authmcp-gateway start --env-file custom.env # Use custom config file
authmcp-gateway init-db # Initialize database
authmcp-gateway create-admin # Create admin user via CLI
authmcp-gateway version # Show version
authmcp-gateway --help # Show all options
Clone and configure:
git clone https://github.com/loglux/authmcp-gateway.git
cd authmcp-gateway
cp .env.example .env
# Edit .env with your settings
Start the gateway:
docker-compose up -d
Access admin panel:
# Gateway Settings
GATEWAY_PORT=9105 # Host port mapping for Docker (container listens on 8000)
JWT_SECRET_KEY=your-secret-key # JWT signing key (auto-generated if not set)
AUTH_REQUIRED=true # Enable authentication (default: true)
# Admin Settings
ADMIN_USERNAME=admin # Initial admin username
ADMIN_PASSWORD=secure-password # Initial admin password
Via Admin Panel:
Via API:
curl -X POST http://localhost:9105/admin/api/mcp-servers \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "GitHub MCP",
"url": "http://github-mcp:8000/mcp",
"backend_token": "optional-token"
}'
Login to get access token:
curl -X POST http://localhost:9105/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"your-username","password":"your-password"}'
Use token to access MCP endpoints:
# List tools from all backends
curl -X POST http://localhost:9105/mcp \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
# List resources
curl -X POST http://localhost:9105/mcp \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":2,"method":"resources/list"}'
# List prompts
curl -X POST http://localhost:9105/mcp \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":3,"method":"prompts/list"}'
# Ping
curl -X POST http://localhost:9105/mcp \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":4,"method":"ping"}'
Admin Panel Features:
┌──────────────────────────────────────────┐
│ MCP Clients (Claude, Codex, etc.) │
│ OAuth 2.0 / JWT Authentication │
└────────────────────┬─────────────────────┘
│
┌────────────────────▼─────────────────────┐
│ AuthMCP Gateway │
│ MCP 2025-03-26 Proxy │
│ │
│ • Full MCP Protocol Proxy │
│ • Tools / Resources / Prompts │
│ • OAuth 2.0 + DCR │
│ • JWT Auth (HS256/RS256+JWKS) │
│ • Rate Limiting │
│ • Security Logging │
│ • Multi-Server Aggregation │
│ • Health Monitoring │
│ • Admin Dashboard │
└────────────────────┬─────────────────────┘
│
┌──────────┬──────────┬──────────┐
▼ ▼ ▼ ▼
┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐
│ RAG │ │WhatsApp│ │ Docs │ │Custom │
│ MCP │ │ MCP │ │ MCP │ │ MCP │
└────────┘ └────────┘ └────────┘ └────────┘
POST /auth/login - User loginPOST /auth/register - User registration (if enabled)POST /auth/refresh - Refresh access tokenPOST /oauth/register - OAuth dynamic client registration (if enabled)GET /.well-known/oauth-authorization-server - OAuth discoveryPOST /mcp - Aggregated MCP endpoint (all servers)POST /mcp/{server_name} - Specific MCP server endpointGET /mcp - Streamable MCP endpoint (SSE/stream clients)GET /auth/me - Current user infoPOST /auth/logout - Logout| Method | Description |
|---|---|
initialize |
Dynamic capabilities discovery from backends |
ping |
Health check |
tools/list |
Aggregated tools from all backends |
tools/call |
Routed to correct backend (prefix/mapping/auto-discovery) |
resources/list |
Aggregated resources from all backends |
resources/read |
Routed by URI to owning backend |
resources/templates/list |
Aggregated resource templates |
prompts/list |
Aggregated prompts from all backends |
prompts/get |
Routed by name to owning backend |
completion/complete |
Routed by ref type (prompt/resource) |
logging/setLevel |
Accepted (no-op at gateway level) |
notifications/* |
Gracefully ignored |
Direct tool name (e.g. rag_query) |
Codex-style: routed as tools/call (openai/codex#2264) |
| Unknown namespaced methods | Returns JSON-RPC -32601 Method not found |
For tools/call, the gateway prefers standard MCP tool annotations when deciding whether a tool is read-only
or safe to retry:
annotations.readOnlyHintannotations.idempotentHintannotations.destructiveHintBehavior:
arguments.idempotency_key and reuses the same key on retry.tools/call.This keeps the gateway aligned with standard MCP annotations while allowing backend MCP servers to implement stronger idempotency semantics where needed.
Codex uses OAuth Authorization Code + PKCE and Dynamic Client Registration (DCR). When running in a terminal without an auto-launching browser, you must manually open the authorization URL and then call the localhost callback URL yourself to finish the login.
Steps:
codex mcp add rag --url https://your-domain.com/mcp/your-backend
http://127.0.0.1:<port>/callback?... URL.
Copy that full URL and call it from another terminal:curl "http://127.0.0.1:<port>/callback?code=...&state=..."
You should see: Authentication complete. You may close this window.
Once completed, Codex shows the MCP server as logged in.
On headless servers (no desktop environment), Codex cannot access the OS keyring to store OAuth tokens. This causes "Auth required" errors even after a successful login. To fix this, switch to file-based token storage:
# ~/.codex/config.toml
mcp_oauth_credentials_store = "file"
Reference: Codex Config Reference
Without this parameter Codex fails to refresh tokens because it looks for a keyring security service and fails. That forces you to re-login each time again and again following the manual procedure above. After updating the config, restart Codex.
Some MCP clients probe OpenID discovery using non-standard paths after a successful token exchange. In
addition to the standard /.well-known/openid-configuration, the gateway also serves the same discovery
document at /oauth/token/.well-known/openid-configuration as a compatibility alias.
If you are already locked out and see this warning:
⚠ The rag MCP server is not logged in. Run `codex mcp login rag`.
⚠ MCP startup incomplete (failed: rag)
You can refresh tokens with the helper script without going through the manual authentication procedure again:
python3 scripts/codex_refresh_mcp.py rag https://your-domain.com/oauth/token
If Codex runs on multiple machines, each machine stores its own local tokens. In that case, a login from one machine can invalidate tokens on another when Enforce Single Session is enabled (one active token per user). Disable Enforce Single Session in the admin settings to avoid forced logouts in multi-machine setups.
Release process: see docs/RELEASE.md.
# Clone repository
git clone https://github.com/loglux/authmcp-gateway.git
cd authmcp-gateway
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # or `venv\Scripts\activate` on Windows
# Install dependencies
pip install -e .
# Run gateway
authmcp-gateway
pytest tests/
authmcp-gateway/
├── src/authmcp_gateway/
│ ├── admin/ # Admin panel routes and logic
│ ├── auth/ # Authentication & authorization
│ ├── mcp/ # MCP proxy and handlers
│ ├── security/ # Security logging and monitoring
│ ├── middleware.py # Request middleware
│ └── app.py # Main application
│ ├── templates/ # Jinja2 templates (admin UI)
├── docs/ # Documentation
├── tests/ # Test suite
└── docker-compose.yml # Docker deployment
Access /admin/mcp-activity for:
View logs in real-time:
docker logs -f authmcp-gateway
Cannot access admin panel:
/setupMCP server shows as offline:
401 Unauthorized errors:
Bearer YOUR_TOKENFor more help, see the troubleshooting and usage sections above.
MIT License - see LICENSE file for details.
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"loglux-authmcp-gateway": {
"command": "npx",
"args": []
}
}
}PRs, issues, code search, CI status
Database, auth and storage
Reference / test server with prompts, resources, and tools.
Secure file operations with configurable access controls.