Enkrypt AI安全MCP网关
> 📖 特色博客文章: 在我们的最新博客中了解安全MCP网关如何防止顶级攻击和漏洞:
>
> Enkrypt的安全MCP网关和MCP扫描器如何防止顶级攻击
>
> 了解真实世界的攻击场景、安全最佳实践,以及我们的网关如何保护您的AI应用程序。
概述
此安全MCP网关具有身份验证、自动工具发现、缓存和护栏实施功能。
它位于MCP客户端和MCP服务器之间。因此,从本质上讲,它本身也充当MCP服务器和MCP客户端:)
当您的MCP客户端连接到网关时,它充当MCP服务器。当网关连接到实际的MCP服务器时,它充当MCP客户端。
-
Pypi包
-
Docker镜像
-
另请参见:
-
CLI-Commands-Reference.md 查看命令列表及其用法
- API参考.md 获取API终结点及其用法的列表
- MCP网关设置笔记本 了解所有基本命令的完整演练
目录
- 1.特点🚀
- 2.MCP网关工作原理的高级步骤🪜
- 3.先决条件🧩
- 4.网关设置👨💻
- 5.(可选)开放遥测设置📊
- 6.验证安装并检查生成的文件✅
- 7.根据需要编辑网关配置✏️
- 8.CLI快速入门指南🖥️
- 9.(可选)将GitHub MCP服务器添加到网关🤖
- 9.1(可选)使用OAuth连接到MCP服务器🔐
- 10.(可选)保护GitHub MCP服务器并测试Echo服务器🔒
- 11.护栏使用建议💡
- 12.其他可用工具🔧
- 13.(可选)沙箱隔离🛡️
- 14.部署模式🪂
- 15.卸载网关🗑️
- 16.故障排除🕵
- 17.正在处理的已知问题🏗️
- 18.已知限制⚠️
- 19.贡献🤝
- 20.测试🧪
- 21.许可证
1.特点
以下是Enkrypt AI安全MCP网关提供的功能列表:
-
认证:我们使用唯一密钥向网关进行身份验证。如果您想使用Enkrypt Guardrails保护您的MCP,我们也使用Enkrypt API密钥。此外,安全
admin_apikey(256字符随机字符串)是为管理REST API操作自动生成的。 -
易用性:您可以在配置文件中本地配置所有MCP服务器,或者更好的是在Enkrypt中配置 (即将推出) 并在网关中使用它们的名称
-
动态工具发现:网关从MCP服务器动态发现工具,并将其提供给MCP客户端
-
限制工具调用:如果您不希望MCP服务器访问所有工具,可以通过在网关配置中明确提及这些工具来限制它们,以便MCP客户端只能访问允许的工具
-
缓存:我们在本地或外部缓存服务器(如KeyDB)中缓存从各种MCP服务器发现的用户网关配置和工具,如果配置为提高性能
-
护栏:您可以在输入侧(在向MCP服务器发送请求之前)和输出侧(在收到MCP服务器的响应之后)为Enkrypt中的每个MCP服务器配置护栏
-
日志记录:我们在本地MCP日志中记录网关的每个请求和响应,并将其转发给Enkrypt (即将推出) 用于监控。这使您能够查看帐户中进行的所有调用、使用的服务器、调用的工具、阻止的请求等。
-
沙箱隔离:MCP服务器可以在隔离的沙盒环境(Docker、Podman或microVM)中启动,这样受感染或恶意的服务器就无法访问主机文件系统、网络或其他资源。每个沙箱都是短暂的——每个会话创建一个沙箱,完成后销毁。
1.1护栏
输入保护: 主题检测、NSFW过滤、毒性检测、注入攻击预防、关键字检测、策略违规检测、偏见检测和PII编辑(即将推出系统提示保护、版权保护等)
输出保护: 所有输入保护,加上依从性检查和相关性验证(即将推出更多功能,如幻觉检测等)。如果响应在输入时被编辑,我们还会自动取消编辑。
1.2概念
-
MCP Config是一系列MCP服务器,如
mcp_server_1,mcp_server_2,mcp_server_3等等 -
每个配置都有一个唯一的ID
-
用户是具有唯一电子邮件和ID的网关用户
-
项目是共享MCP配置的用户集合
-
项目有一个名称和唯一的ID
- MCP配置可以更新,也可以由管理员指向其他配置
-
用户可以添加到多个项目中
-
为用户和项目组合创建API密钥
-
用户可以为不同的项目使用不同的API密钥
-
此API密钥用于验证用户并识别正确的项目和MCP配置
-
看 6.5生成的配置文件示例 和 7.根据需要编辑网关配置 用于模式参考
2.MCP网关工作原理的高级步骤
🪜 Steps
-
您的MCP客户端使用API密钥连接到Secure MCP网关服务器(由处理
src/secure_mcp_gateway/gateway.py). -
网关服务器从本地获取网关配置
enkrypt_mcp_config.json文件或远程Enkrypt身份验证服务器 (即将推出).
- 它在本地或外部缓存服务器(如KeyDB)中缓存配置(如果配置为提高性能)。
- 如果启用了输入护栏,则在工具调用之前验证请求(由
src/secure_mcp_gateway/guardrail.py).
- 如果请求违反了任何配置的护栏,并且特定的检测器被配置为阻止,则请求将被阻止。
-
请求被转发到网关客户端(由
src/secure_mcp_gateway/client.py). -
网关客户端将请求转发到相应的MCP服务器(由
src/secure_mcp_gateway/client.py). -
MCP服务器处理请求并将响应返回给网关客户端。
-
如果是发现工具调用,网关客户端会在本地或外部缓存服务器(如KeyDB)中缓存工具(如果已配置)。然后,它将响应转发到网关服务器。
-
网关服务器从网关客户端接收响应,如果启用了输出护栏,它将根据配置的护栏(由处理)验证响应
src/secure_mcp_gateway/guardrail.py).
- 如果响应违反了任何配置的护栏,并且特定的检测器被配置为阻止,则响应将被阻止。
- 如果一切正常,网关服务器会将响应转发回MCP客户端。
3.先决条件
🔗 Dependencies
-
Git 2.43或更高 -
Python 3.11或更高版本安装在您的系统上,可以使用以下任一方式从命令行访问python或python3命令 -
pip 25.0.1您的系统上安装了或更高版本,可以使用以下任一方式从命令行访问pip或python -m pip命令 -
uv 0.7.9您的系统上安装了或更高版本,可以使用以下任一方式从命令行访问uv或python -m uv命令
🔍 Check versions
-
检查是否安装了Python、pip和uv
-
如果以下任何命令失败,请参阅相应的文档以正确安装它们```bash
------------------
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
- 安装 **克劳德桌面版** 作为MCP客户端 他们的网站 如果您还没有,请登录
- *如果你使用的是Linux,无法运行任何 非官方版本 克劳德桌面,你可以使用 任何支持的MCP客户端 以测试网关。如果它不支持mcp-cli `mcp install` 命令,然后遍历脚本代码并手动运行支持的命令。*
- 我们希望代理请求的MCP服务器所需的任何其他依赖关系
- 按照相应MCP服务器的说明安装其依赖项
- 喜欢 `Node.js`, `npx`, `docker`等等。
- (可选)安装并运行KeyDB等缓存服务器(如果您想在外部而非本地缓存)
🔒 Optional Protection with Enkrypt Guardrails
如果您想使用Enkrypt护栏保护MCP,您需要执行以下操作:
- 如果您没有新帐户,请创建一个新帐户。它是免费的! 🆓 无需信用卡💳🚫
- 一 `ENKRYPT_API_KEY` 你可以从那里得到 Enkrypt仪表板设置
- 要使用护栏保护MCP,您可以使用默认的护栏示例 `Sample Airline Guardrail` 开始使用,或者您可以创建自己的自定义护栏
- 要配置自定义护栏,您需要登录Enkrypt AI应用程序或使用API/SDK
- 在Enkrypt AI应用程序仪表板中创建护栏✅
- 使用API创建护栏
- 使用SDK创建护栏
- 您还可以使用Enkrypt MCP服务器🤯 创建护栏并在网关中使用
## 4.网关设置
### 4.1带管道的本地安装
📦 Pip Installation Steps
#### 4.1.1下载并安装软件包
- 激活虚拟环境```bash
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
- 安装软件包。有关更多信息,请参阅 https://pypi.org/project/secure-mcp-gateway/```bash
pip install secure-mcp-gateway
#### 4.1.2运行Generate命令
- **这将在以下位置生成配置文件 `~/.enkrypt/enkrypt_mcp_config.json` 在macOS和 `%USERPROFILE%\.enkrypt\enkrypt_mcp_config.json` 在Windows上**```bash
secure-mcp-gateway generate-config
🖨️ Example output```bash
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_use_remote_mcp_config: False
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
#### 4.1.3生成的配置文件示例
🍎 Example file in macOS
- 这是macOS上CLI生成的默认配置文件的示例:```json
{
"common_mcp_gateway_config": {
"enkrypt_log_level": "INFO",
"enkrypt_base_url": "https://api.enkryptai.com",
"enkrypt_api_key": "YOUR_ENKRYPT_API_KEY",
"enkrypt_use_remote_mcp_config": false,
"enkrypt_remote_mcp_gateway_name": "enkrypt-secure-mcp-gateway-1",
"enkrypt_remote_mcp_gateway_version": "v1",
"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_async_input_guardrails_enabled": false,
"enkrypt_async_output_guardrails_enabled": false,
"enkrypt_telemetry": {
"enabled": true,
"insecure": true,
"endpoint": "http://localhost:4317"
}
},
"mcp_configs": {
"fcbd4508-1432-4f13-abb9-c495c946f638": {
"mcp_config_name": "default_config",
"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"
]
},
"tools": {},
"input_guardrails_config": {
"enabled": false,
"guardrail_name": "Sample Airline Guardrail",
"additional_config": {
"pii_redaction": false
},
"block": [
"policy_violation"
]
},
"output_guardrails_config": {
"enabled": false,
"guardrail_name": "Sample Airline Guardrail",
"additional_config": {
"relevancy": false,
"hallucination": false,
"adherence": false
},
"block": [
"policy_violation"
]
}
}
]
}
},
"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"
}
}
}
🪟 Example file in Windows
- 这是Windows上CLI生成的默认配置文件的示例:```json
{
"common_mcp_gateway_config": {
"enkrypt_log_level": "INFO",
"enkrypt_base_url": "https://api.enkryptai.com",
"enkrypt_api_key": "YOUR_ENKRYPT_API_KEY",
"enkrypt_use_remote_mcp_config": false,
"enkrypt_remote_mcp_gateway_name": "enkrypt-secure-mcp-gateway-1",
"enkrypt_remote_mcp_gateway_version": "v1",
"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_async_input_guardrails_enabled": false,
"enkrypt_async_output_guardrails_enabled": false,
"enkrypt_telemetry": {
"enabled": true,
"insecure": true,
"endpoint": "http://localhost:4317"
}
},
"mcp_configs": {
"fcbd4508-1432-4f13-abb9-c495c946f638": {
"mcp_config_name": "default_config",
"mcp_config": [
{
"server_name": "echo_server",
"description": "Simple Echo Server",
"config": {
"command": "python",
"args": [
"C:\Users\\Documents\GitHub\EnkryptAI\secure-mcp-gateway\.secure-mcp-gateway-venv\Lib\site-packages\secure_mcp_gateway\bad_mcps\echo_mcp.py"
]
},
"tools": {},
"input_guardrails_config": {
"enabled": false,
"guardrail_name": "Sample Airline Guardrail",
"additional_config": {
"pii_redaction": false
},
"block": [
"policy_violation"
]
},
"output_guardrails_config": {
"enabled": false,
"guardrail_name": "Sample Airline Guardrail",
"additional_config": {
"relevancy": false,
"hallucination": false,
"adherence": false
},
"block": [
"policy_violation"
]
}
}
]
}
},
"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"
}
}
}
#### 4.1.4安装克劳德桌面网关
- 运行以下命令为Claude安装网关:```bash
secure-mcp-gateway install --client claude-desktop
-
这将在Claude Desktop上注册Enkrypt安全MCP网关。
-
注意:请在安装后重新启动Claude Desktop
🖨️ Example output```bash
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
Loading enkrypt_mcp_config.json file...
ENKRYPT_GATEWAY_KEY: *NULL
enkrypt_log_level: info
is_debug_log_level: False
enkrypt_base_url: https://api.enkryptai.com
enkrypt_use_remote_mcp_config: False
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
CONFIG_PATH: C:\Users\PC.enkrypt\enkrypt_mcp_config.json
GATEWAY_PY_PATH: C:\Users\PC\Documents\GitHub\EnkryptAI\secure-mcp-gateway.secure-mcp-gateway-venv\Lib\site-packages\secure_mcp_gateway\gateway.py
client name from args: claude-desktop
Successfully installed gateway for claude-desktop
Path to gateway is incorrect. Modifying the path to gateway in claude_desktop_config.json file...
Path to gateway modified in claude_desktop_config.json file
Please restart Claude Desktop to use the gateway.
#### 4.1.5安装后的Claude桌面配置示例
🍎 Example file in macOS
- `~/Library/Application Support/Claude/claude_desktop_config.json````json
{
"mcpServers": {
"Enkrypt Secure MCP Gateway": {
"command": "mcp",
"args": [
"run",
"/Users/user/enkryptai/secure-mcp-gateway/venv/lib/python3.13/site-packages/secure_mcp_gateway/gateway.py"
],
"env": {
"ENKRYPT_GATEWAY_KEY": "2W8UupCkazk4SsOcSu_1hAbiOgPdv0g-nN9NtfZyg-rvYGat",
"ENKRYPT_PROJECT_ID": "3c09f06c-1f0d-4153-9ac5-366397937641",
"ENKRYPT_USER_ID": "6469a670-1d64-4da5-b2b3-790de21ac726"
}
}
}
}
🪟 Example file in Windows
- `%USERPROFILE%\AppData\Roaming\Claude\claude_desktop_config.json````json
{
"mcpServers": {
"Enkrypt Secure MCP Gateway": {
"command": "mcp",
"args": [
"run",
"C:\Users\\Documents\GitHub\EnkryptAI\secure-mcp-gateway\.secure-mcp-gateway-venv\Lib\site-packages\secure_mcp_gateway\gateway.py"
],
"env": {
"ENKRYPT_GATEWAY_KEY": "2W8UupCkazk4SsOcSu_1hAbiOgPdv0g-nN9NtfZyg-rvYGat",
"ENKRYPT_PROJECT_ID": "3c09f06c-1f0d-4153-9ac5-366397937641",
"ENKRYPT_USER_ID": "6469a670-1d64-4da5-b2b3-790de21ac726"
}
}
}
}
#### 4.1.6安装游标网关
- 运行Cursor的CLI安装命令```bash
secure-mcp-gateway install --client cursor
-
这将自动用正确的条目更新您的~/.cursor/mcp.json(在Windows上,它位于:%USERPROFILE%.cursor\mcp.json)。
-
虽然通常不需要重新启动,但如果您看到它长时间处于加载状态,请重新启动Cursor
🍎 Example file in macOS
- `~/.cursor/mcp.json````json
{
"mcpServers": {
"Enkrypt Secure MCP Gateway": {
"command": "mcp",
"args": [
"run",
"/Users/user/enkryptai/secure-mcp-gateway/venv/lib/python3.13/site-packages/secure_mcp_gateway/gateway.py"
],
"env": {
"ENKRYPT_GATEWAY_KEY": "2W8UupCkazk4SsOcSu_1hAbiOgPdv0g-nN9NtfZyg-rvYGat",
"ENKRYPT_PROJECT_ID": "3c09f06c-1f0d-4153-9ac5-366397937641",
"ENKRYPT_USER_ID": "6469a670-1d64-4da5-b2b3-790de21ac726"
}
}
}
}
🪟 Example file in Windows
- `%USERPROFILE%\.cursor\mcp.json````json
{
"mcpServers": {
"Enkrypt Secure MCP Gateway": {
"command": "uv",
"args": [
"run",
"--with",
"mcp[cli]",
"mcp",
"run",
"C:\\Users\\\\Documents\\GitHub\\EnkryptAI\\secure-mcp-gateway\\.secure-mcp-gateway-venv\\Lib\\site-packages\\secure_mcp_gateway\\gateway.py"
],
"env": {
"ENKRYPT_GATEWAY_KEY": "2W8UupCkazk4SsOcSu_1hAbiOgPdv0g-nN9NtfZyg-rvYGat",
"ENKRYPT_PROJECT_ID": "3c09f06c-1f0d-4153-9ac5-366397937641",
"ENKRYPT_USER_ID": "6469a670-1d64-4da5-b2b3-790de21ac726"
}
}
}
}
4.1.7安装克劳德代码网关
克劳德代码 是Anthropic基于CLI的编码代理。它使用 claude mcp add 配置MCP服务器的命令。与使用JSON配置文件的Claude Desktop和Cursor不同,Claude Code通过自己的CLI管理MCP服务器。
> 先决条件: 这 claude CLI必须安装在您的系统上。看 Claude代码文档 用于安装。
步骤1:安装网关```bash
secure-mcp-gateway install --client claude-code
这会自动:
- 从生成的配置中读取网关密钥、项目ID和用户ID
- 跑 `claude mcp add` 具有正确的凭据和网关路径
- 向注册服务器 `--scope user` (适用于所有Claude Code项目)
**步骤2:验证服务器是否已添加**```bash
claude mcp list
你应该看看 Enkrypt-Secure-MCP-Gateway 在列表中。
步骤3:使用Claude Code中的网关
启动Claude Code并尝试:```
list all servers, get all tools available
Manual alternative (if you prefer to run claude mcp add directly)
从生成的中获取您的凭据 `enkrypt_mcp_config.json` 以及网关路径:```bash
python -c "import secure_mcp_gateway.gateway; print(secure_mcp_gateway.gateway.__file__)"
然后手动添加网关:```bash
claude mcp add --transport stdio --env ENKRYPT_GATEWAY_KEY=YOUR_GATEWAY_KEY --env ENKRYPT_PROJECT_ID=YOUR_PROJECT_ID --env ENKRYPT_USER_ID=YOUR_USER_ID --scope user Enkrypt-Secure-MCP-Gateway -- mcp run /path/to/secure_mcp_gateway/gateway.py
> **注:** 服务器名称必须使用连字符或下划线——Claude Code不允许名称中有空格。
### 4.2使用git clone进行本地安装
🗂️ Git Clone Installation Steps
#### 4.2.1克隆仓库,设置虚拟环境并安装依赖项
- 克隆存储库:```bash
git clone https://github.com/enkryptai/secure-mcp-gateway
cd secure-mcp-gateway
⚡ Activate a virtual environment```bash
------------------
Create a virtual environment
------------------
uv venv
Example output
Using CPython 3.13.3 interpreter at: C:\Users\PC\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\python.exe
Creating virtual environment at: .venv
Activate with: .venv\Scripts\activate
------------------
Activate the virtual environment
------------------
For 🍎 Linux/macOS, run the following
source ./.venv/Scripts/activate
For 🪟 Windows, run the following
..venv\Scripts\activate
After activating, you should see (enkrypt-secure-mcp-gateway) before the file path in the terminal
Example:
(enkrypt-secure-mcp-gateway) %USERPROFILE%\Documents\GitHub\EnkryptAI\secure-mcp-gateway>
------------------
Install pip in the virtual environment
------------------
python -m ensurepip
------------------
Install uv in the virtual environment
------------------
python -m pip install uv
- 安装Python依赖项:```bash
uv pip install -r requirements.txt
- 验证mcp-cli是否已成功安装:```bash
mcp version
Example output
MCP version 1.9.2
#### 4.2.2运行安装脚本
- 此脚本在以下位置创建配置文件 `~/.enkrypt/enkrypt_mcp_config.json` 在macOS和 `%USERPROFILE%\.enkrypt\enkrypt_mcp_config.json` 基于Windows `src/secure_mcp_gateway/example_enkrypt_mcp_config.json` 文件
- 它取代了 `UNIQUE_GATEWAY_KEY` 以及其他 `UUIDs` 具有自动生成的值,并替换 `DUMMY_MCP_FILE_PATH` 带有测试MCP文件的实际路径 `bad_mcps/echo_mcp.py`
- 它还将MCP客户端安装在Claude Desktop中
- *注意:请在运行安装脚本后重新启动Claude Desktop,以查看网关在Claude Desktop中的运行情况*```bash
# On 🍎 Linux/macOS run the below
cd scripts
chmod +x *.sh
./setup.sh
# On 🪟 Windows run the below
cd scripts
setup.bat
# Now restart Claude Desktop to see the Gateway running
🖨️ Example output```bash
Setting up Enkrypt Secure MCP Gateway enkrypt_mcp_config.json config file
1 file(s) copied.
Generated unique gateway key: WTZOpoU1mXJz8b_ZJQ42DuSXlQCSCtWOn3FX0jG8sO_FKYNJetjYEgSluvhtBN8_
Generated unique uuid: 7920749a-228e-47fe-a6a9-cd2d64a2283b
DUMMY_MCP_FILE_PATH: C:\Users\PC\Documents\GitHub\EnkryptAI\secure-mcp-gateway\src\secure_mcp_gateway\bad_mcps\echo_mcp.py
Setup complete. Please check the enkrypt_mcp_config.json file in the ~.enkrypt directory and update with your MCP server configs as needed.
Installing Enkrypt Secure MCP Gateway with gateway key and dependencies
mcp is installed. Proceeding with installation...
ENKRYPT_GATEWAY_KEY: WTZOpoU1mXJz8b_ZJQ42DuSXlQCSCtWOn3FX0jG8sO_FKYNJetjYEgSluvhtBN8_
The system cannot find the path specified.
Package names only:
Dependencies string for the cli install command:
Running the cli install command: mcp install gateway.py --env-var ENKRYPT_GATEWAY_KEY=WTZOpoU1mXJz8b_ZJQ42DuSXlQCSCtWOn3FX0jG8sO_FKYNJetjYEgSluvhtBN8_
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\src\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
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
Loading enkrypt_mcp_config.json file...
ENKRYPT_GATEWAY_KEY: *BN8_
enkrypt_log_level: info
is_debug_log_level: False
enkrypt_base_url: https://api.enkryptai.com
enkrypt_use_remote_mcp_config: False
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 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\src\secure_mcp_gateway
PYTHONPATH: Not set
Installing dependencies...
All dependencies installed successfully.
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
Loading enkrypt_mcp_config.json file...
ENKRYPT_GATEWAY_KEY: *BN8_
enkrypt_log_level: info
is_debug_log_level: False
enkrypt_base_url: https://api.enkryptai.com
enkrypt_use_remote_mcp_config: False
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.
[06/15/25 13:14:10] INFO Added server 'Enkrypt Secure MCP Gateway' to Claude config claude.py:137
INFO Successfully installed Enkrypt Secure MCP Gateway in Claude app cli.py:486
Installation complete. Check the claude_desktop_config.json file as per the readme instructions and restart Claude Desktop.
#### 4.2.3设置其他MCP客户端
⬡ Cursor
- 您可以导航到光标的 **全球MCP** 文件在 `~/.cursor/mcp.json` 在Linux/macOS或 `%USERPROFILE%\.cursor\mcp.json` 在Windows上
- 如果你想在a **项目级别** 把它放在你的项目中。有关详细信息,请参阅 Cursor的文档
- 您还可以通过单击光标的UI导航到文件 `settings` 右上角的齿轮图标
- 点击 `MCP` 然后单击 `Add new global MCP server` 这会带你去 `mcp.json` 文件
- 示例 `mcp.json` 在编辑器中打开的文件
- 在全局或项目级别打开文件后,您可以复制粘贴我们在中使用的相同配置 `Claude Desktop`。作为参考,您可以参考 安装-6.2生成的MCP配置文件示例📄
- *请确保使用您自己的文件,该文件由 `setup` 脚本在 安装-4.2.2运行安装脚本📥。请不要复制粘贴此仓库中的示例配置文件。*
- 看 验证光标 验证MCP服务器是否在Cursor中运行的部分
⬡ Claude Code
- 克劳德代码 使用自己的CLI来管理MCP服务器,而不是JSON配置文件
- 从生成的中获取您的凭据 `enkrypt_mcp_config.json` (网关密钥、项目ID、用户ID)
- 查找gateway.py路径:```bash
python -c "import secure_mcp_gateway.gateway; print(secure_mcp_gateway.gateway.__file__)"
- 将网关添加到Claude Code:```bash
claude mcp add --transport stdio --env ENKRYPT_GATEWAY_KEY=YOUR_GATEWAY_KEY --env ENKRYPT_PROJECT_ID=YOUR_PROJECT_ID --env ENKRYPT_USER_ID=YOUR_USER_ID --scope user Enkrypt-Secure-MCP-Gateway -- mcp run /path/to/secure_mcp_gateway/gateway.py
- 验证: `claude mcp list`
- 有关详细设置,请参阅 4.1.7安装克劳德代码网关
### 4.3 Docker安装
🐳 Docker Installation Steps
#### 4.3.1构建Docker镜像```bash
docker build -t secure-mcp-gateway .
🖨️ Example output```bash
[+] Building 72.9s (20/20) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 724B 0.1s
=> [internal] load metadata for docker.io/library/python:3.11-alpine 1.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 456B 0.1s
=> [ 1/15] FROM docker.io/library/python:3.11-alpine@sha256:8068890a42d68ece5b62455ef327253249b5f094dcdee57f492635a40217f6a3 0.0s
=> => resolve docker.io/library/python:3.11-alpine@sha256:8068890a42d68ece5b62455ef327253249b5f094dcdee57f492635a40217f6a3 0.0s
=> [internal] load build context 1.5s
=> => transferring context: 82.25kB 1.4s
=> CACHED [ 2/15] WORKDIR /app 0.0s
=> CACHED [ 3/15] COPY requirements.txt . 0.0s
=> [ 4/15] COPY requirements-dev.txt . 0.0s
=> [ 5/15] RUN pip install --upgrade pip && pip install -r requirements.txt && pip install -r requirements-dev.txt 38.7s
=> [ 6/15] COPY src src 0.2s
=> [ 7/15] COPY setup.py setup.py 0.1s
=> [ 8/15] COPY MANIFEST.in MANIFEST.in 0.1s
=> [ 9/15] COPY pyproject.toml pyproject.toml 0.1s
=> [10/15] COPY CHANGELOG.md CHANGELOG.md 0.1s
=> [11/15] COPY LICENSE.txt LICENSE.txt 0.1s
=> [12/15] COPY README.md README.md 0.1s
=> [13/15] COPY README_PYPI.md README_PYPI.md 0.1s
=> [14/15] RUN python -m build 8.5s
=> [15/15] RUN pip install . 5.5s
=> exporting to image 16.6s
=> => exporting layers 11.8s
…(正文过长,页面只展示前面部分,完整内容见仓库)
```
