Configuration File Location
The Secure MCP Gateway uses a JSON configuration file stored at:Configuration Structure
The configuration file has five main sections:- admin_apikey - Administrative API key for REST API
- common_mcp_gateway_config - Global gateway settings
- plugins - Plugin configurations (auth, guardrails, telemetry)
- mcp_configs - MCP server configurations
- projects - Project definitions
- users - User definitions
- apikeys - API key mappings
Full Configuration Schema
Location:src/secure_mcp_gateway/example_enkrypt_mcp_config.json
Section Details
1. Admin API Key
Purpose: Secures the REST API endpoints for administrative operations.- Automatically generated during
secure-mcp-gateway generate-config - 256 characters long for maximum security
- Used for all
/api/v1/*endpoints (except/health) - Required in
Authorization: Bearer <admin_apikey>header
2. Common Gateway Config
Location:common_mcp_gateway_config
Logging Settings
DEBUG, INFO, WARNING, ERROR
Source: src/secure_mcp_gateway/gateway.py:161
Remote Config Settings
enkrypt_use_remote_mcp_config: Load config from Enkrypt cloud (future feature)enkrypt_remote_mcp_gateway_name: Gateway identifier in Enkryptenkrypt_remote_mcp_gateway_version: Config version
Remote config is not yet available. Current version loads from local file.
Cache Settings
Location:src/secure_mcp_gateway/client.py:31
| Setting | Description | Default | Unit |
|---|---|---|---|
enkrypt_mcp_use_external_cache | Use Redis/KeyDB instead of in-memory | false | boolean |
enkrypt_cache_host | Redis/KeyDB hostname | localhost | string |
enkrypt_cache_port | Redis/KeyDB port | 6379 | integer |
enkrypt_cache_db | Redis database number | 0 | integer |
enkrypt_cache_password | Redis password | null | string |
enkrypt_tool_cache_expiration | Tool discovery cache duration | 4 | hours |
enkrypt_gateway_cache_expiration | Gateway config cache duration | 24 | hours |
- Local cache (default): In-memory dictionary, lost on restart
- External cache: Redis/KeyDB, shared across instances
Async Guardrails
true: Run guardrails asynchronously (don’t block request)false: Run guardrails synchronously (block until checked)
Timeout Settings
Location:src/secure_mcp_gateway/services/timeout/timeout_manager.py
| Operation | Default (s) | Description |
|---|---|---|
default_timeout | 30 | Generic operation timeout |
guardrail_timeout | 15 | Guardrail API check timeout |
auth_timeout | 10 | Authentication validation timeout |
tool_execution_timeout | 60 | MCP server tool call timeout |
discovery_timeout | 20 | Tool discovery timeout |
cache_timeout | 5 | Cache operation timeout |
connectivity_timeout | 2 | Network connectivity check |
warn_threshold(0.8): Log warning at 80% of timeouttimeout_threshold(1.0): Timeout at 100% of configured timefail_threshold(1.2): Hard failure at 120% of timeout
3. Plugins Configuration
Auth Plugin
Location:src/secure_mcp_gateway/plugins/auth/
| Provider | Description | Config Required |
|---|---|---|
local_apikey | Validates API keys from local config file | None |
enkrypt | Remote authentication via Enkrypt API | api_key, base_url |
Guardrails Plugin
Location:src/secure_mcp_gateway/plugins/guardrails/
| Provider | Description | Features |
|---|---|---|
enkrypt | Production Enkrypt API | PII, toxicity, NSFW, injection, policies, relevancy, adherence, hallucination |
openai | OpenAI Moderation API | Toxicity, NSFW detection |
custom_keyword | Simple keyword blocking | Configurable keyword list |
Telemetry Plugin
Location:src/secure_mcp_gateway/plugins/telemetry/
| Provider | Description | Exports |
|---|---|---|
opentelemetry | Full OpenTelemetry with OTLP | Logs (Loki), Traces (Jaeger), Metrics (Prometheus) |
stdout | Simple stdout logging | Console logs only |
4. MCP Configs
Location:mcp_configs.<config_id>.mcp_config[]
Defines the MCP servers that the gateway will proxy to.
Server Entry Structure
Server Config
Required fields:OAuth Configuration
Location:src/secure_mcp_gateway/services/oauth/
Full OAuth 2.0/2.1 configuration for server authentication:
| Setting | Description | Required |
|---|---|---|
OAUTH_VERSION | OAuth version (2.0 or 2.1) | Yes |
OAUTH_GRANT_TYPE | Grant type (client_credentials, authorization_code) | Yes |
OAUTH_CLIENT_ID | OAuth client ID | Yes |
OAUTH_CLIENT_SECRET | OAuth client secret | Yes |
OAUTH_TOKEN_URL | Token endpoint URL | Yes |
OAUTH_SCOPE | Requested scopes (space-separated) | No |
OAUTH_AUDIENCE | Token audience | No |
OAUTH_USE_MTLS | Enable mutual TLS (RFC 8705) | No |
OAUTH_CLIENT_CERT_PATH | Client certificate for mTLS | If mTLS |
OAUTH_CLIENT_KEY_PATH | Client key for mTLS | If mTLS |
For detailed OAuth setup, see the OAuth Authentication Guide.
Tools Configuration
Option 1: Empty (Tool Discovery)list_tools() and cache them.
Option 2: Explicit Tool Definition
Guardrails Policies
Tool Guardrails: Applied before tool name validation:| Condition | Trigger | Stage |
|---|---|---|
policy_violation | Custom policy rules violated | Input/Output |
injection_attack | SQL/command/prompt injection detected | Input |
topic_detector | Off-topic content detected | Input/Output |
nsfw | NSFW content detected | Input/Output |
toxicity | Toxic language detected | Input/Output |
pii | PII detected | Input/Output |
keyword_detector | Blocked keyword found | Input/Output |
bias | Biased content detected | Input/Output |
sponge_attack | Resource exhaustion attempt | Input |
| Setting | Description | Stage |
|---|---|---|
pii_redaction | Redact PII before sending to server | Input |
relevancy | Check response relevancy to request | Output |
hallucination | Detect hallucinated information | Output |
adherence | Verify response follows instructions | Output |
5. Projects
Purpose: Group users with shared MCP configurations.| Field | Type | Description |
|---|---|---|
project_name | string | Human-readable project name |
mcp_config_id | UUID | Reference to mcp_configs entry |
users | array | List of user UUIDs in this project |
created_at | ISO 8601 | Project creation timestamp |
6. Users
Purpose: Define gateway users.| Field | Type | Description |
|---|---|---|
email | string | User email address |
created_at | ISO 8601 | User creation timestamp |
7. API Keys
Purpose: Map API keys to project/user combinations.| Field | Type | Description |
|---|---|---|
project_id | UUID | Reference to projects entry |
user_id | UUID | Reference to users entry |
created_at | ISO 8601 | API key creation timestamp |
secure_mcp_gateway.utils.generate_custom_id():
- 34 random alphanumeric characters
- URL-safe (uses
_and-) - Example:
2W8UupCkazk4SsOcSu_1hAbiOgPdv0g-nN9Ntf
Configuration Loading
Location:src/secure_mcp_gateway/utils.py:190
Priority order:
- Docker config path (if
is_docker()returns True)/app/.enkrypt/docker/enkrypt_mcp_config.json
- User config path
~/.enkrypt/enkrypt_mcp_config.json
- Example config path (from package)
site-packages/secure_mcp_gateway/example_enkrypt_mcp_config.json
- Default config (hardcoded in
consts.py)
Configuration Management
CLI Commands
See CLI Commands Reference for complete list. Common operations:REST API
Endpoint:/api/v1/configs
Authentication: Admin API key required
Best Practices
Use External Cache for Production
Use External Cache for Production
For multi-instance deployments, enable external cache (Redis/KeyDB) to share tool discoveries and configs:
Secure Environment Variables
Secure Environment Variables
Never hardcode secrets in config. Use environment variable references:
Enable Guardrails Selectively
Enable Guardrails Selectively
Only enable guardrails on sensitive servers to minimize latency:
Backup Regularly
Backup Regularly
Schedule automatic backups of your configuration:
Explicit Tool Definitions
Explicit Tool Definitions
For production, explicitly define allowed tools instead of relying on discovery:This prevents new tools from being auto-discovered and exposed.
Next Steps
Authentication
Learn about API keys, projects, and users
Guardrails
Configure input and output protection
CLI Reference
Complete CLI commands documentation
API Reference
REST API endpoint documentation