Skip to main content

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
Config Structure:

Regenerating the Admin API Key

If your admin API key is compromised or you need to regenerate it:
  1. Manual Method: Edit the configuration file and replace the admin_apikey value with a new random string (34+ characters recommended)
  2. Backup Method: Use the system backup/restore feature:
After regenerating the admin API key, all API clients must update their authentication credentials.

Authorization Header

Format

All authenticated requests must include the Authorization header:

Example

Authentication Errors

Missing Authorization Header

Request:
Response: 401 Unauthorized

Invalid Authorization Format

Request:
Response: 401 Unauthorized

Invalid Admin API Key

Request:
Response: 401 Unauthorized

Admin API Key Not Configured

If the configuration file is missing the admin_apikey field: Response: 500 Internal Server Error

Implementation Details

Authentication Function

The API uses a dependency injection pattern for authentication:

Validation Flow

  1. Extract Header: API server extracts Authorization header from request
  2. Parse Token: Removes “Bearer ” prefix to get the API key
  3. Load Config: Reads the configuration file to get admin_apikey
  4. Compare: Performs string comparison between provided and stored keys
  5. Grant/Deny: Returns 200 OK or 401 Unauthorized

Security Best Practices

Protect Your Admin API Key

The admin API key grants full control over the gateway. Protect it like a root password.
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
Don’t:
  • 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

Expected Response: 200 OK

Invalid Request

Expected Response: 401 Unauthorized

Health Check Endpoint

The health check endpoint does not require authentication:
Response: 200 OK
This endpoint is useful for:
  • 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