Enkrypt AI Secure MCP Gateway
About
A secure MCP gateway that acts as a proxy, providing authentication, tool discovery, caching, and guardrail enforcement.
Details
- Author
- enkryptai
- Categories
- Developer Tools, Security, API, Infrastructure
Jump to
Setup
Install Enkrypt AI Secure MCP Gateway in your MCP client (Claude Desktop, Cursor, Windsurf, and others).
Repository: https://github.com/enkryptai/secure-mcp-gateway
Follow the installation instructions in the repository README, then restart your MCP client.
A secure MCP gateway that acts as a proxy, providing authentication, tool discovery, caching, and guardrail enforcement.
π Featured Blog Post:Learn how the Secure MCP Gateway prevents top attacks and vulnerabilities in our latest blog:
How Enkrypt's Secure MCP Gateway and MCP Scanner Prevent Top Attacks
Discover real-world attack scenarios, security best practices, and how our gateway protects your AI applications.
This Secure MCP Gateway is built with authentication, automatic tool discovery, caching, and guardrail enforcement.
It sits between your MCP client and MCP servers. So, by it's nature it itself also acts as an MCP server as well as an MCP client :)
When your MCP client connects to the Gateway, it acts as an MCP server. When the Gateway connects to the actual MCP server, it acts as an MCP client.
- CLI-Commands-Reference.mdfor the list of commands and their usage
- API-Reference.mdfor the list of API endpoints and their usage
- MCP Gateway Setup Notebookfor a complete walkthrough of all the essential commands
- 1. Features π
- 2. High level steps of how the MCP Gateway works πͺ
- 3. Prerequisites π§©
- 4. Gateway Setup π¨βπ»
- 5. (Optional) OpenTelemetry Setup π
- 6. Verify Installation and check the files generated β
- 7. Edit the Gateway config as needed βοΈ
- 8. CLI Quick Start Guide π₯οΈ
- 9. (Optional) Add GitHub MCP Server to the Gateway π€
- 9.1 (Optional) Connect to MCP Servers with OAuth π
- 10. (Optional) Protect GitHub MCP Server and Test Echo Server π
- 11. Recommendations for using Guardrails π‘
- 12. Other tools available π§
- 13. (Optional) Sandbox Isolation π‘οΈ
- 14. Deployment Patterns πͺ
- 15. Uninstall the Gateway ποΈ
- 16. Troubleshooting π΅
- 17. Known Issues being worked on ποΈ
- 18. Known Limitations β οΈ
- 19. Contribute π€
- 20. Testing π§ͺ
- 21. License
Below are the list of features Enkrypt AI Secure MCP Gateway provides:
-
Authentication: We use Unique Key to authenticate with the Gateway. We also use Enkrypt API Key if you want to protect your MCPs with Enkrypt Guardrails. Additionally, a secureadmin_apikey(256-character random string) is automatically generated at therootof the config for administrative REST API operations. (Whenplugins.auth.providerisenkrypt,admin_apikeyisoptionalβ the Enkrypt cloudapi_keydoubles as the admin credential for most REST endpoints. The cache-flush endpoint specifically uses a stricter org-id-gated policy under cloud auth β seeHot-Reload Auth Policy.)
Ease of use: You can configure all your MCP servers either locally inenkrypt_mcp_config.jsonor β better yet for teams and production β inEnkrypt cloud(runsecure-mcp-gateway generate-config --provider enkrypt). The cloud owns the server list, guardrail policies, andcommon_overrides, and the gateway pulls them at request time with a 5-minute TTL.
Dynamic Tool Discovery: The Gateway discovers tools from the MCP servers dynamically and makes them available to the MCP client
Restrict Tool Invocation: If you don't want all tools to be accessible of a an MCP server, you can restrict them by explicitly mentioning the tools in the Gateway config so that only the allowed tools are accessible to the MCP client
Caching: We cache the user gateway config and tools discovered from various MCP servers locally or in an external cache server like KeyDB if configured to improve performance
Guardrails: You can configure guardrails for each MCP server in Enkrypt both on input side (before sending the request to the MCP server) and output side (after receiving the response from the MCP server)
Logging: We log every request and response from the Gateway locally in your MCP logs and also forward them to Enkrypt(Coming soon)for monitoring. This enables you to see all the calls made in your account, servers used, tools invoked, requests blocked, etc.
Sandbox Isolation: MCP servers can be launched inside isolated sandbox environments (Docker, Podman, or microVMs) so that a compromised or malicious server cannot access the host filesystem, network, or other resources. Each sandbox is ephemeral β created per session and destroyed when done.
Input Protection:Topic detection, NSFW filtering, toxicity detection, injection attack prevention, keyword detection, policy violation detection, bias detection, and PII redaction (More coming soon like system prompt protection, copyright protection, etc.)
Output Protection:All input protections plus adherence checking and relevancy validation (More coming soon like hallucination detection, etc.) We also auto unredact the response if it was redacted on input.
-
MCP Config is an array of MCP servers likemcp_server_1,mcp_server_2,mcp_server_3etc.
User is a user of the gateway with unique email and ID
A project is a collection of users that share an MCP Config
- Project has a name and unique ID
- The MCP Config can be updated or can be pointed to a different config by the Admin
- Users can be added to multiple projects
An API Key is created for a user and project combination
- A user can have different API Keys for different projects
- This API Key is used to authenticate the user and identify the right project and MCP Config
See6.5 Example config file generatedand7. Edit the Gateway config as neededfor schema reference
2. High level steps of how the MCP Gateway works
-Your MCP client connects to the Secure MCP Gateway server with API Key (handled bysrc/secure_mcp_gateway/gateway.py).
Gateway server fetches the gateway config from either the localenkrypt_mcp_config.jsonfile (plugins.auth.provider = "local_apikey") or theremote Enkrypt cloudathttps://api.enkryptai.com/mcp-gateway/get-gateway-config(plugins.auth.provider = "enkrypt"). SeeΒ§14.5 Gateway Config Schemafor both shapes.
- It caches the config locally or in an external cache server like KeyDB if configured to improve performance.
If input guardrails are enabled, request is validated before the tool call (handled bysrc/secure_mcp_gateway/guardrail.py).
- Request is blocked if it violates any of the configured guardrails and the specific detector is configured to block.
Requests are forwarded to the Gateway Client (handled bysrc/secure_mcp_gateway/client.py).
The Gateway client forwards the request to the appropriate MCP server (handled bysrc/secure_mcp_gateway/client.py).
The MCP server processes the request and returns the response to the Gateway client.
If it was a discover tools call, the Gateway client caches the tools locally or in an external cache server like KeyDB if configured. It then forwards the response to the Gateway server.
The Gateway server receives the response from the Gateway client and if output guardrails are enabled, it validates the response against the configured guardrails (handled bysrc/secure_mcp_gateway/guardrail.py).
- Response is blocked if it violates any of the configured guardrails and the specific detector is configured to block.
The Gateway server forwards the response back to the MCP client if everything is fine.
Python 3.11or higher installed on your system and is accessible from the command line using eitherpythonorpython3command
pip 25.0.1or higher is installed on your system and is accessible from the command line using eitherpiporpython -m pipcommand
uv 0.7.9or higher is installed on your system and is accessible from the command line using eitheruvorpython -m uvcommand
-
Check if Python, pip and uv are installed
If any of the below commands fail, please refer the respective documentation to install them properly
# ------------------ # Python # ------------------ python --version # Example output Python 3.13.3 # If not, install python from their website and run the version check again # ------------------ # pip # ------------------ pip --version # Example output pip 25.0.1 from C:\Users\PC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\pip (python 3.13) # If not, try the following and run the version check again python -m ensurepip # ------------------ # uv # ------------------ uv --version # Or run with "python -m" if uv is not found directly # If this works, use "python -m" before all uv commands from now on python -m uv --version # Example output uv 0.7.9 (13a86a23b 2025-05-30) # If not, try the following and run the version check again python -m pip install uv
-
InstallClaude Desktopas the MCP Client fromtheir websiteif you haven't already and login to it
- If you are using Linux and cannot run anyunofficial versionof Claude Desktop, you can useany supported MCP Clientto test the Gateway. If it does not support mcp climcp installcommand, then go through the scripts code and run the commands supported manually.
Any other dependencies required for the MCP servers we want to proxy requests to
-
Follow the instructions of the respective MCP server to install its dependencies
(Optional) A cache server like KeyDB installed and running (If you want to cache externally and not locally)
If you want to protect your MCPs with Enkrypt Guardrails, you need to do the following:
-
Create a new account if you don't have one. It's free! π No credit card required π³π«
AnENKRYPT_API_KEYwhich you can get fromEnkrypt Dashboard Settings
To protect your MCPs with Guardrails, you can use the default sample GuardrailSample Airline Guardrailto get started or you can create your own custom Guardrail
To configure custom Guardrails, you need to either login to Enkrypt AI App or use the APIs/SDK
-
Create Guardrails in Enkrypt AI App Dashboard β
You can also use Enkrypt MCP Server π€― to create Guardrails and use them in the Gateway
python -m venv .secure-mcp-gateway-venv # Activate the virtual environment # On Windows .secure-mcp-gateway-venv\Scripts\activate # On Linux/macOS source .secure-mcp-gateway-venv/bin/activate # Run the below to exit the virtual environment later if needed deactivate
Install the package. For more info seehttps://pypi.org/project/secure-mcp-gateway/
-
This generates the config file at~/.enkrypt/enkrypt_mcp_config.jsonon macOS and%USERPROFILE%\.enkrypt\enkrypt_mcp_config.jsonon Windows
β οΈ Re-running on an existing config?generate-configrefuses to clobber an existing file by default β it exits withINFO: Config file already exists at <path>. ... use --overwrite flag.Add--overwriteto regenerate (a timestamped.bkp.<YYYYMMDD_HHMMSS>backup is written next to the original first). The flag also works with--provider enkryptbelow.
secure-mcp-gateway generate-config --overwrite
The default command emits the fulllocal-apikeyschema β a sample echo server, a default project, a user, and an auto-generated gateway API key β everything you need to boot offline. If you instead want the gateway to source its servers/projects/users fromEnkrypt cloud, generate the minimal cloud-backed config:
secure-mcp-gateway generate-config --provider enkrypt
This writes a much shorter file containing only:
- enkrypt_config.api_keyandbase_url(you fill in the apikey)
- plugins.auth.provider = "enkrypt"with agateway_nameplaceholder
- plugins.guardrails.provider = "enkrypt"
- plugins.telemetry.provider = "opentelemetry"(OTLP gRPC tolocalhost:4317, matching the local-apikey default and the bundled Prometheus/Grafana/Jaeger/Loki stack β setconfig.enabled: falseif you don't have a collector running)
- Two commonly-tweaked entries undercommon_mcp_gateway_config(enkrypt_log_level,enkrypt_gateway_cache_expiration_minutes)
No localmcp_configs/projects/users/apikeysblocks β the cloud owns those. After generation, edit the file and set:
- enkrypt_config.api_keyβ your Enkrypt cloud apikey
- plugins.auth.config.gateway_nameβ thesaved_nameof the gateway you created in the Enkrypt console
gateway_nameis the one value that can also arrive per request, as theX-Enkrypt-MCP-Gatewayheader from the MCP client, so that a single gateway process can serve several cloud gateways. When it is set in the config the config wins. Full config-key and header reference:Β§7.1 Enkrypt cloud auth provider and gateway headers.
The shipped reference file issrc/secure_mcp_gateway/example_enkrypt_cloud_config.jsonβ same shape the CLI generates. Use it as a template for hand-written configs.
Initializing Enkrypt Secure MCP Gateway Initializing Enkrypt Secure MCP Gateway Common Utilities Module Initializing Enkrypt Secure MCP Gateway Module -------------------------------- SYSTEM INFO: Using Python interpreter: C:\Users\PC\Documents\GitHub\EnkryptAI\secure-mcp-gateway\.secure-mcp-gateway-venv\Scripts\python.exe Python version: 3.13.3 (tags/v3.13.3:6280bb5, Apr 8 2025, 14:47:33) [MSC v.1943 64 bit (AMD64)] Current working directory: C:\Users\PC\Documents\GitHub\EnkryptAI\secure-mcp-gateway PYTHONPATH: Not set -------------------------------- Installing dependencies... All dependencies installed successfully. Initializing Enkrypt Secure MCP Gateway Client Module Initializing Enkrypt Secure MCP Gateway Guardrail Module Error: Gateway key is required. Please update your mcp client config and try again. Getting Enkrypt Common Configuration config_path: C:\Users\PC\.enkrypt\enkrypt_mcp_config.json example_config_path: C:\Users\PC\Documents\GitHub\EnkryptAI\secure-mcp-gateway\.secure-mcp-gateway-venv\Lib\site-packages\secure_mcp_gateway\example_enkrypt_mcp_config.json No enkrypt_mcp_config.json file found. Defaulting to example_enkrypt_mcp_config.json -------------------------------- ENKRYPT_GATEWAY_KEY: *NULL enkrypt_log_level: info is_debug_log_level: False enkrypt_base_url: https://api.enkryptai.com enkrypt_api_key: _KEY enkrypt_tool_cache_expiration: 4 enkrypt_gateway_cache_expiration: 24 enkrypt_mcp_use_external_cache: False enkrypt_async_input_guardrails_enabled: False -------------------------------- External Cache is not enabled. Using local cache only. Initializing Enkrypt Secure MCP Gateway CLI Module Generated default config at C:\Users\PC\.enkrypt\enkrypt_mcp_config.json
INFO: Initializing Enkrypt Secure MCP Gateway CLI Module v2.2.0 INFO: HOME_DIR: C:\Users\PC INFO: GATEWAY_PY_PATH: C:\Users\PC\Documents\GitHub\EnkryptAI\secure-mcp-gateway\.secure-mcp-gateway-venv\Lib\site-packages\secure_mcp_gateway\gateway.py INFO: ECHO_SERVER_PATH: C:\Users\PC\Documents\GitHub\EnkryptAI\secure-mcp-gateway\.secure-mcp-gateway-venv\Lib\site-packages\secure_mcp_gateway\bad_mcps\echo_oauth_mcp.py INFO: PICKED_CONFIG_PATH: C:\Users\PC\.enkrypt\enkrypt_mcp_config.json INFO: Generating minimal Enkrypt-cloud configuration (plugins.auth.provider=enkrypt)... SUCCESS: Generated config at C:\Users\PC\.enkrypt\enkrypt_mcp_config.json INFO: Before starting the gateway, edit the file and set: enkrypt_config.api_key (replace 'YOUR_ENKRYPT_API_KEY' with your Enkrypt cloud apikey) plugins.auth.config.gateway_name (replace 'your-gateway-saved-name' with the saved_name of the gateway you created in Enkrypt cloud)
Notice the cloud variant skips the long boot/dependency banner β it's a fast, focused command. The twoINFO: Before startingβ¦lines are the operator-must-edit checklist; the gateway will fail with a 401 from Enkrypt cloud on first boot if you skip them.
4.1.3 Example of the generated config file
Note:The examples below show thefull*schema emitted bysecure-mcp-gateway generate-config(default--provider local_apikey). Every field is included so you can compare your generated file 1:1. Theoauth_configblock ships disabled ("enabled": false) β its keys are placeholders you only need to fill in if a server uses OAuth. Thetimeout_settingsblock holds the per-operation timeouts the gateway uses internally; defaults are sane and rarely need editing.
- This is an example of the default configuration file generated by the CLI on macOS:
{ "admin_apikey": "AUTO_GENERATED_256_CHAR_KEY", "enkrypt_config": { "api_key": "YOUR_ENKRYPT_API_KEY", "base_url": "https://api.enkryptai.com" }, "common_mcp_gateway_config": { "enkrypt_log_level": "INFO", "enkrypt_mcp_use_external_cache": false, "enkrypt_cache_host": "localhost", "enkrypt_cache_port": 6379, "enkrypt_cache_db": 0, "enkrypt_cache_password": null, "enkrypt_tool_cache_expiration": 4, "enkrypt_gateway_cache_expiration": 24, "enkrypt_gateway_cache_expiration_minutes": 5, "enkrypt_config_watcher_poll_seconds": 2.0, "enkrypt_async_input_guardrails_enabled": false, "enkrypt_async_output_guardrails_enabled": false, "timeout_settings": { "default_timeout": 90, "guardrail_timeout": 390, "auth_timeout": 30, "tool_execution_timeout": 360, "discovery_timeout": 540, "cache_timeout": 15, "connectivity_timeout": 6, "escalation_policies": { "warn_threshold": 0.8, "timeout_threshold": 1.0, "fail_threshold": 1.2 } } }, "plugins": { "auth": { "provider": "local_apikey", "config": {} }, "guardrails": { "provider": "enkrypt", "config": {} }, "telemetry": { "provider": "opentelemetry", "config": { "enabled": true, "url": "http://localhost:4317", "insecure": true } } }, "mcp_configs": { "fcbd4508-1432-4f13-abb9-c495c946f638": { "mcp_config_name": "default_config", "common_overrides": { "server_tools_guardrails_config": { "enabled": false, "guardrail_name": "Sample Airline Guardrail", "block": [ "policy_violation", "injection_attack", "topic_detector", "nsfw", "toxicity", "pii", "keyword_detector", "bias", "sponge_attack" ] } }, "mcp_config": [ { "server_name": "echo_server", "description": "Simple Echo Server", "config": { "command": "python", "args": [ "/Users/user/enkryptai/secure-mcp-gateway/venv/lib/python3.13/site-packages/secure_mcp_gateway/bad_mcps/echo_mcp.py" ] }, "oauth_config": { "enabled": false, "is_remote": false, "OAUTH_VERSION": "2.1", "OAUTH_GRANT_TYPE": "client_credentials", "OAUTH_CLIENT_ID": "your-client-id", "OAUTH_CLIENT_SECRET": "your-client-secret", "OAUTH_TOKEN_URL": "https://auth.example.com/oauth/token", "OAUTH_AUDIENCE": "https://api.example.com", "OAUTH_ORGANIZATION": "your-org-id", "OAUTH_SCOPE": "read write", "OAUTH_RESOURCE": "https://resource.example.com", "OAUTH_TOKEN_EXPIRY_BUFFER": 300, "OAUTH_USE_BASIC_AUTH": true, "OAUTH_ENFORCE_HTTPS": true, "OAUTH_TOKEN_IN_HEADER_ONLY": true, "OAUTH_VALIDATE_SCOPES": true, "OAUTH_USE_MTLS": false, "OAUTH_CLIENT_CERT_PATH": null, "OAUTH_CLIENT_KEY_PATH": null, "OAUTH_CA_BUNDLE_PATH": null, "OAUTH_REVOCATION_URL": null, "OAUTH_ADDITIONAL_PARAMS": {}, "OAUTH_CUSTOM_HEADERS": {} }, "tools": {}, "denied_tools": [], "input_guardrails_config": { "enabled": false, "guardrail_name": "Sample Airline Guardrail", "additional_config": { "pii_redaction": false }, "block": [ "policy_violation", "injection_attack", "topic_detector", "nsfw", "toxicity", "pii", "keyword_detector", "bias", "sponge_attack" ] }, "output_guardrails_config": { "enabled": false, "guardrail_name": "Sample Airline Guardrail", "additional_config": { "relevancy": false, "hallucination": false, "adherence": false }, "block": [ "policy_violation", "injection_attack", "topic_detector", "nsfw", "toxicity", "pii", "keyword_detector", "bias", "sponge_attack" ] } } ] } }, "projects": { "3c09f06c-1f0d-4153-9ac5-366397937641": { "project_name": "default_project", "mcp_config_id": "fcbd4508-1432-4f13-abb9-c495c946f638", "users": [ "6469a670-1d64-4da5-b2b3-790de21ac726" ], "created_at": "2025-07-16T17:02:00.406877" } }, "users": { "6469a670-1d64-4da5-b2b3-790de21ac726": { "email": "default@example.com", "created_at": "2025-07-16T17:02:00.406902" } }, "apikeys": { "2W8UupCkazk4SsOcSu_1hAbiOgPdv0g-nN9NtfZyg-rvYGat": { "project_id": "3c09f06c-1f0d-4153-9ac5-366397937641", "user_id": "6469a670-1d64-4da5-b2b3-790de21ac726", "created_at": "2025-07-16T17:02:00.406905" } } }
- This is an example of the default configuration file generated by the CLI on Windows:
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





