Overview
The Secure MCP Gateway REST API uses Bearer token authentication with an admin API key to secure all endpoints. This ensures that only authorized administrators can manage configurations, projects, and users.Authentication Flow
Admin API Key
What is the Admin API Key?
The admin API key is a special authentication token that grants full administrative access to the REST API. It is distinct from user API keys, which are used for gateway access. Key Differences:Locating Your Admin API Key
The admin API key is stored in your configuration file: Configuration Path:- macOS/Linux:
~/.enkrypt/enkrypt_mcp_config.json - Windows:
%USERPROFILE%\.enkrypt\enkrypt_mcp_config.json - Docker:
/app/.enkrypt/docker/enkrypt_mcp_config.json
Regenerating the Admin API Key
If your admin API key is compromised or you need to regenerate it:-
Manual Method: Edit the configuration file and replace the
admin_apikeyvalue with a new random string (34+ characters recommended) - Backup Method: Use the system backup/restore feature:
Authorization Header
Format
All authenticated requests must include theAuthorization header:
Example
Authentication Errors
Missing Authorization Header
Request:401 Unauthorized
Invalid Authorization Format
Request:401 Unauthorized
Invalid Admin API Key
Request:401 Unauthorized
Admin API Key Not Configured
If the configuration file is missing theadmin_apikey field:
Response: 500 Internal Server Error
Implementation Details
Authentication Function
The API uses a dependency injection pattern for authentication:Validation Flow
- Extract Header: API server extracts
Authorizationheader from request - Parse Token: Removes “Bearer ” prefix to get the API key
- Load Config: Reads the configuration file to get
admin_apikey - Compare: Performs string comparison between provided and stored keys
- Grant/Deny: Returns 200 OK or 401 Unauthorized
Security Best Practices
Protect Your Admin API Key
Do:- Store the admin API key in environment variables or secrets management systems
- Use HTTPS in production to encrypt the Authorization header in transit
- Rotate the admin API key periodically
- Restrict API server access to trusted networks
- Use firewall rules to limit access to port 8001
- Commit the admin API key to version control
- Share the admin API key in plain text
- Expose the API server to the public internet without additional security
- Use the admin API key in client applications
Environment Variables
Store the admin API key securely:HTTPS Configuration
For production deployments, use a reverse proxy with TLS: NGINX Example:Network Security
Restrict API access using firewall rules:Testing Authentication
Valid Request
200 OK
Invalid Request
401 Unauthorized
Health Check Endpoint
The health check endpoint does not require authentication:200 OK
- Load balancer health checks
- Monitoring and alerting systems
- Startup readiness checks in container orchestration
Next Steps
Configuration Endpoints
Manage MCP configurations
User Management
Create and manage users
API Key Management
Generate user API keys
System Operations
Backup and restore operations