
本页由 AI 翻译,技术细节请以原文为准。 查看原文
trailofbits/mcp-context-protector 是从 https://github.com/trailofbits/mcp-context-protector. 导入的 MCP 服务器候选
概览
trailofbits/mcp-context-protector 是从 https://github.com/trailofbits/mcp-context-protector. 导入的 MCP 服务器候选
概述(AI 翻译)
概述
MCP-Context-Protector 是一款为 MCP 服务器设计的安全包装器,用于解决运行不受信任的 MCP 服务器所带来的风险,包括跳线、意外服务器配置更改及其他提示注入攻击。通过包装器实现这些安全控制(而非通过在工具安装前运行的扫描仪或在 MCP 主机应用中添加安全功能)简化了执行流程,并确保与所有 MCP 应用的通用兼容性。
特色
- 服务器配置的首次信任钉钉
- 自动阻止未经批准的配置更改
- 护栏扫描与工具响应隔离
- ANSI 控制字符净化
- 协助编辑
mcp.json文件
快速开始
安装:
为了更方便地启动 mcp-context-protector,我们建议更新 mcp-context-protector.sh,以包含通往 uv 的完整路径。一些 MCP 客户端,包括 Claude Desktop,在启动 MCP 服务器时会用最简的路径集替换 PATH 环境变量,这可能使 claude_desktop_config.json 文件变得笨重且难以维护。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
mcp-context-protector
Overview
mcp-context-protector is a security wrapper for MCP servers that addresses risks associated with running untrusted MCP servers, including line jumping, unexpected server configuration changes, and other prompt injection attacks. Implementing these security controls through a wrapper (rather than through a scanner that runs before a tool is installed or by adding security features to an MCP host app) streamlines enforcement and ensures universal compatibility with all MCP apps.
Features
- Trust-on-first-use pinning of server configurations
- Automatic blocking of unapproved configuration changes
- Guardrail scanning and quarantining of tool responses
- ANSI control character sanitization
- Assisted editing of
mcp.jsonfiles
Quickstart
Installation:
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Download mcp-context-protector
git clone https://github.com/trailofbits/mcp-context-protector
# Install dependencies
cd mcp-context-protector
uv sync
To make it easier to launch mcp-context-protector, we recommend updating mcp-context-protector.sh to contain the full path to uv. Some MCP clients, including Claude Desktop, replace the PATH environment variable with a minimal set of paths when launching MCP servers, which can make your claude_desktop_config.json file unwieldy and hard to maintain. Including a full path to uv in the launcher helps mitigate this problem.
Now configure your client to run your MCP servers through mcp-context-protector, and tool configuration pinning will automatically be enabled. Here’s a sample Claude Desktop config:
{
"mcpServers": {
"wrapped_acme_server": {
"command": "/path/to/mcp-context-protector/mcp-context-protector.sh",
"args": ["--command", "/path/to/node /path/to/acme/server.js"]
}
}
}
Alternatively, use --command-args to have mcp-context-protector concatenate all arguments that follow into one command string:
{
"mcpServers": {
"wrapped_acme_server": {
"command": "/path/to/mcp-context-protector/mcp-context-protector.sh",
"args": ["--command-args", "/path/to/node", "/path/to/acme/server.js", "--acme-enhanced"]
}
}
}
TL;DR: use --command-args if your MCP client mangles your stdio server command, but be careful with escaping of shell metacharacters.
Longer explanation: Some clients (including, as of this writing, Cursor) will construct their MCP server commands by concatenating the arguments together into a space-delimited string. That is, mcp-context-protector.sh --command "cmd arg1 arg2 --arg3" will become mcp-context-protector.sh --command cmd arg1 arg2 --arg3, and mcp-context-protector will think arg1 through --arg3 are meant as arguments to the wrapper, not to the child command. The --command-args option addresses this issue.
Security risks and controls
| Risk | Relevant control |
|---|
安装
docker run --rm -i)