Universal Authentication Gateway for MCP (Model Context Protocol) Servers
Project description
AuthMCP Gateway
Secure authentication proxy for Model Context Protocol (MCP) servers
AuthMCP Gateway provides centralized authentication, authorization, and monitoring for MCP servers. It acts as a secure proxy between clients and your MCP backends, adding JWT-based authentication, rate limiting, real-time monitoring, and comprehensive security logging.
๐ Table of Contents
- โจ Features
- ๐ Documentation
- ๐ธ Screenshots
- ๐ Quick Start
- โ๏ธ Configuration
- ๐ก Usage
- ๐๏ธ Architecture
- ๐ API Endpoints
- ๐ Security
- ๐ ๏ธ Development
- ๐ Monitoring
- ๐ง Troubleshooting
โจ Features
๐ Authentication & Authorization
- OAuth 2.0 + JWT - Industry-standard authentication flow
- User Management - Multi-user support with role-based access
- Backend Token Management - Secure storage and auto-refresh of MCP server credentials
- Rate Limiting - Per-user request throttling with configurable limits
๐ Real-Time Monitoring
- Live MCP Activity Monitor - Real-time request feed with auto-refresh
- Performance Metrics - Response times, success rates, requests/minute
- Security Event Logging - Unauthorized access attempts, rate limiting, suspicious activity
- Health Checking - Automatic health checks for all connected MCP servers
๐๏ธ Admin Dashboard
- User Management - Create, edit, and manage users
- MCP Server Configuration - Add and configure backend MCP servers
- Token Management - Monitor token health and manual refresh
- Security Events - View and filter security events
- API Testing - Built-in MCP testing interface
๐ก๏ธ Security
- JWT token-based authentication with refresh tokens
- Secure credential storage with encrypted database support
- CORS protection and request validation
- Security event logging and monitoring
- File-based logging - No database bloat, 30-day rotation
- Built-in security testing guide
๐ Documentation
๐ Complete Documentation - Full documentation index
Quick Links:
- Deployment Guide - Production setup with HTTPS, Docker, cloud platforms
- Logging Architecture - File-based logging, log formats, analysis
- API Reference - REST API documentation with examples
- Security Testing - Security verification and testing
- Publishing Guide - Publishing to PyPI
๐ธ Screenshots
๐ฅ๏ธ Dashboard - Real-time Overview
Live statistics, server health monitoring, top tools usage, and recent activity feed
๐ง MCP Servers - Connection Management
Manage backend MCP server connections with status monitoring and health checks
๐ MCP Activity Monitor - Real-time Request Tracking
Monitor live MCP requests with detailed metrics, top tools ranking, and request feed
๐ก๏ธ Security Events - Threat Detection
Track security events, rate limiting, suspicious payloads, and unauthorized access attempts
๐ MCP Security Audit - Vulnerability Scanner
Test any MCP server for security vulnerabilities with comprehensive automated checks
๐ Quick Start
Option 1: PyPI Package (Recommended)
Install from PyPI and run:
pip install authmcp-gateway
authmcp-gateway
Then access http://localhost:8000/ to complete setup wizard.
Option 2: Docker Compose
-
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:
- Open http://localhost:9105/
- Complete setup wizard to create admin user
- Add your MCP servers
โ๏ธ Configuration
Environment Variables
# Gateway Settings
GATEWAY_PORT=9105 # Gateway port (default: 8000)
JWT_SECRET=your-secret-key # JWT signing key (auto-generated if not set)
REQUIRE_AUTH=true # Enable authentication (default: true)
# Admin Settings
ADMIN_USERNAME=admin # Initial admin username
ADMIN_PASSWORD=secure-password # Initial admin password
Adding MCP Servers
Via Admin Panel:
- Navigate to MCP Servers โ Add Server
- Enter server details:
- Name (e.g., "GitHub MCP")
- URL (e.g., "http://github-mcp:8000/mcp")
- Backend token (if required)
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"
}'
๐ก Usage
For End Users
-
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:
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"}'
For Administrators
Admin Panel Features:
- Dashboard - Overview of users, servers, and activity
- MCP Activity - Real-time monitoring of all MCP requests
- Security Events - View unauthorized access attempts and suspicious activity
- User Management - Create and manage user accounts
- Token Management - Monitor and refresh backend tokens
๐๏ธ Architecture
โโโโโโโโโโโโโโโ
โ Client โ
โ (Claude, โ
โ etc.) โ
โโโโโโโโฌโโโโโโโ
โ JWT Auth
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ AuthMCP Gateway โ
โ โ
โ โข Authentication โ
โ โข Rate Limiting โ
โ โข Security Logging โ
โ โข Request Routing โ
โ โข Health Monitoring โ
โโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโ
โผ โผ โผ โผ
โโโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโ
โGitHub โ โ RAG โ โ Home โ โCustom โ
โMCP โ โ MCP โ โAssistantโ โ MCP โ
โโโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโ
๐ API Endpoints
Public Endpoints
POST /auth/login- User loginPOST /auth/register- User registration (if enabled)POST /auth/refresh- Refresh access tokenGET /.well-known/oauth-authorization-server- OAuth discovery
Protected Endpoints
POST /mcp- Aggregated MCP endpoint (all servers)POST /mcp/{server_name}- Specific MCP server endpointGET /auth/me- Current user infoPOST /auth/logout- Logout
Admin Endpoints
GET /admin- Admin dashboardGET /admin/mcp-activity- Real-time MCP monitoringGET /admin/security-logs- Security eventsGET /admin/users- User managementGET /admin/mcp-servers- MCP server configuration- Plus full REST API for management
๐ Security
Testing Security
See docs/SECURITY_TESTING.md for:
- Manual security tests
- Automated testing script
- Production deployment checklist
- Security best practices
Security Features
- โ JWT-based authentication with refresh tokens
- โ Rate limiting per user
- โ Security event logging
- โ MCP request tracking with suspicious activity detection
- โ Health monitoring for backend servers
- โ CORS protection
- โ Secure credential storage
๐ ๏ธ Development
Local Development
# 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
Running Tests
pytest tests/
Project Structure
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
๐ Monitoring
Real-Time Dashboard
Access /admin/mcp-activity for:
- Live request feed (updates every 3 seconds)
- Requests per minute
- Average response times
- Success rates
- Top tools usage
- Per-server statistics
Logs
View logs in real-time:
docker logs -f authmcp-gateway
๐ง Troubleshooting
Cannot access admin panel:
- Ensure you've completed the setup wizard at
/setup - Check that cookies are enabled
- Verify JWT_SECRET is set correctly
MCP server shows as offline:
- Check server URL is correct and reachable
- Verify backend token if required
- View error details in MCP Servers page
401 Unauthorized errors:
- Token may have expired - use refresh token
- Verify Authorization header format:
Bearer YOUR_TOKEN - Check user has permission for the MCP server
For more help, see docs/SECURITY_TESTING.md.
License
MIT License - see LICENSE file for details.
Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
Roadmap
- Prometheus metrics export
- WebSocket support for real-time updates
- Per-tool rate limiting
- Enhanced security testing automation
- Multi-tenancy support
- API key authentication option
Built with โค๏ธ for the MCP ecosystem
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file authmcp_gateway-1.0.4.tar.gz.
File metadata
- Download URL: authmcp_gateway-1.0.4.tar.gz
- Upload date:
- Size: 129.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d3a4c4347ea73e387a0ff0477dd4f61309ebd0fa141caf9f7ddf30fbcbaac81
|
|
| MD5 |
65501a7012413e2226edd08f1d44d793
|
|
| BLAKE2b-256 |
93848ede55f18b2a3477d35121a361c8301ee478addb6d0855f8aa25ad0aa562
|
File details
Details for the file authmcp_gateway-1.0.4-py3-none-any.whl.
File metadata
- Download URL: authmcp_gateway-1.0.4-py3-none-any.whl
- Upload date:
- Size: 149.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77c69cdf902c281a0408284824620a5ab9c1e1906b91f633ae46bb95d0f416fa
|
|
| MD5 |
6dcdece5dc26e208474ba8a63a2d51ca
|
|
| BLAKE2b-256 |
e4e5f380debb8dd77dc8cc26d1dc140b75be67fbfe9fd08b9ecd49d4c5a3cdfb
|