
MCP Safety Warden
io.github.gautamvarmadatla由 GitHub 账号 gautamvarmadatla 发布v1.6.0更新于 Nov 8, 2026
MCP proxy adding security scanning, behavioral profiling, risk gating, and safe tool call execution.
概览
本地 MCP 代理,为其他 MCP 服务器加上安全扫描、行为画像、风险门控与受控的工具调用执行。
- 可以做什么
- 注册、检查并列出被代理的 MCP 服务器,刷新工具画像并检测 schema 或工具列表漂移
- 按效果类别、破坏性与风险标签为工具画像,并统计延迟、失败率与重试策略
- 调用前评估风险,经门控执行调用并给出更安全的替代方案,可设置永久的允许/阻止策略
- 对服务器及其 GitHub 源码做安全审计,包括注入、密钥与组合风险检查
- 构建并查询跨服务器、工具、发现项与客户端代理的风险图,可导出为 JSON 或 Mermaid
- 扫描磁盘上的 MCP 客户端配置并批量接入发现的服务器
- 适用场景
- 适合在助手连接第三方或不可信 MCP 服务器时充当把关者,筛查工具元数据、参数与输出;也适合在允许某服务器运行前先审计其源码与行为。
- 运行要求
- 需要 Python 3.10 或更高版本,通过 pip 本地安装,并至少有一个可代理的 MCP 服务器(stdio、SSE 或 streamable_http)。建议提供 LLM API 密钥(Anthropic、OpenAI 或 Gemini),或显式指定本地 Ollama 模型;没有密钥时仅以规则模式运行。可选密钥:SNYK_TOKEN、MCP_SCANNER_API_KEY、MCP_SCANNER_LLM_API_KEY、GITHUB_TOKEN、MCP_DB_ENCRYPTION_KEY。配置均通过环境变量完成。
安装
在 SourceWeft 中
- 打开 控制台中的 MCP Safety Warden,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
MCP safety warden is a proxy server that wraps any MCP server and adds behavioral profiling, security scanning, risk gating, and safe execution to its tools.
[PyPI] [Python] [PyPI Downloads] [License] [CI] [CodeQL] [MCP Registry] [Docker Pulls] [OpenSSF Scorecard] [OpenSSF Best Practices] [GitHub Stars]
Contents
- Overview
- Prerequisites
- Installation
- Configuration
- MCP Integration
- CLI Reference
- Auxiliary Integrations
- Development
- Testing
- Further reading
[!IMPORTANT] MCP security is an active research area. Recent surveys catalog a lot of protocol-specific threat categories spanning tool poisoning, prompt injection, rug-pull attacks, supply chain compromise, credential exfiltration, and composition attacks across the full server lifecycle. See Securing the MCP (OpenReview), Landscape & Threats (arXiv), When MCP Servers Attack (arXiv), and MCP-38 Taxonomy (arXiv).
Overview
Use as a proxy to add safety gating to any MCP server, or point it at a server you don't own and run a full security audit without making a single tool call.
[Two operating modes]
Fig 1. Two operating modes: proxy and audit
Behavioral profiling: Effect class, retry safety, destructiveness. LLM-assisted (Anthropic, OpenAI, Gemini, Ollama) with rule-based fallback. Observed stats (latency p50/p95, failure rate, output size) updated after every proxied call.
Security scanning: mcpsafety+ five-stage pipeline (Recon, Planner, Hacker, Auditor, Supervisor). Cisco AI Defense (AST/YARA). Snyk (metadata analysis). Kali and Burp Suite integrations enrich the pipeline with real network data and HTTP-layer probes. Source code scanning from GitHub with entropy, AST, taint flow, and rug-pull detection.
[3e457b83-6980-49fc-b812-350ab94f5633]
Fig 2. mcpsafety+ five-stage pipeline, triggered when you run a full security audit on any MCP server
Safe execution: Argument scanning (20+ attack categories, LLM second-pass). Two-layer output injection scanning. Risk gating with alternatives and per-tool policies. Drift detection on every call and standalone check.
[fb949e62-5a3e-4a5c-be14-3523ef92295e]
Fig 3. Safe execution pipeline: the five checks every proxied tool call passes through
CLI: 24 subcommands, interactive risk menu, --json flag on every command, --yes for CI.
What it detects
- Prompt injection: tool outputs trying to hijack the agent: role hijacking, jailbreaks, fake system prompts, instruction overrides. Detects 11 obfuscation techniques including Unicode lookalikes, zero-width characters, and base64-encoded payloads.
- Malicious tool metadata: descriptions containing injection strings, hardcoded secrets, suspicious download URLs, tool impersonation (shadowing), direct financial execution, system service modification, and untrusted external dependencies. Backed by 19 Snyk checks.
- Argument injection: 20+ attack categories checked on every tool call before the call is forwarded: SSRF to cloud metadata endpoints (AWS, GCP, Azure, Alibaba), path traversal, credential file access (.aws, .ssh, .kube, .env), command injection, SQL/NoSQL/LDAP/XPath injection, XXE, template injection (SSTI), CRLF, null byte, deserialization payloads (Java, Python pickle, PHP, .NET), Windows UNC/ADS attacks, and base64-obfuscated variants of all of the above.
- Source code risks: fetches the server's GitHub source and runs 6 analysis layers: entropy scanning for hardcoded secrets, AST taint flow tracking (parameter to dangerous sink), description-vs-implementation mismatch, Bandit and Semgrep SAST, and LLM cross-function reasoning. Supports Python and TypeScript/JavaScript.
- Rug-pull and drift: stores a SHA-256 hash of the server's source on first scan and alerts if it changes. Catches description swaps, schema changes, and tool removal live on every call via a per-call drift guard.
- Behavior anomalies: classifies every tool by effect class, destructiveness, and 7 risk tags: credential exposure, arbitrary execution, data exfiltration, filesystem access, lateral movement, privilege escalation, and prompt injection surface.
- Composition attacks: analyzes tool sets for chaining risks: IDOR chains, read-write pairs, auth flow exploitation, write-then-execute sequences, and data accumulation + exfiltration paths across multiple tools.
- Network and host risks: when Kali Linux MCP is registered: open ports, running services, OS fingerprint via nmap. When Burp Suite MCP is registered: HTTP-layer active probing and blind SSRF via out-of-band callbacks.
- Credential exposure in outputs: redacts secrets from tool responses before storage. Injection-flagged responses are quarantined and never returned to the calling agent - stored under a run ID for forensic review.
- CVE research and Arxiv findings: the mcpsafety+ Auditor stage cross-references discovered capabilities against known vulnerabilities and recent security research.
Prerequisites
- Python 3.10 or later
- At least one wrapped MCP server to proxy (stdio, SSE, or streamable_http)
- Recommended: an LLM API key (Anthropic, OpenAI, or Gemini)
Without a key the wrapper operates in rule-based-only mode: lower confidence tool classification, regex-only injection scanning, no alternatives in the risk gate, no mcpsafety+ pipeline. For a fully local setup, run Ollama, set OLLAMA_MODEL, and pass --provider ollama explicitly (Ollama is not auto-detected).
[!NOTE] stdio servers that require local setup (
stdioservers that need local configuration before starting - missing config files, credentials, data directories, or OS-specific dependencies) cannot be inspected by the wrapper - tool discovery will fail and 0 tools will be stored. You can still run a full source-code security scan without spawning the server by passing--github-urltoscan/onboard, or thegithub_urlparameter tosecurity_scan_server. The mcpsafety+ pipeline will fetch and analyze the source directly from GitHub.sseandstreamable_httpservers are not affected.
Installation
With all optional extras:
Or specific extras:
From source:
The SQLite database is created automatically on first run in the platform user data directory (~/.local/share/mcpsafetywarden/ on Linux, ~/Library/Application Support/mcpsafetywarden/ on macOS, %APPDATA%\mcpsafetywarden\ on Windows). Override with MCP_DB_PATH.
Credential protection (automatic, no action required)
Secret values passed to register_server or onboard_server (Bearer tokens, API keys in headers or env) are automatically detected and replaced with opaque cref_ identifiers before anything touches the model context. The real credential is stored encrypted in the database and resolved silently at connection time. The model, conversation history, and logs only ever see cref_<id>.
Optional: at-rest encryption for stored credentials
Set the printed key as MCP_DB_ENCRYPTION_KEY before starting the server. This encrypts both server credentials and cref_ values at rest.
Configuration
All configuration is via environment variables.
Security note: Never commit API keys or the encryption key. The wrapper strips its own secrets from child process environments before spawning stdio servers.
MCP Integration
Connecting with Claude Desktop
Add the wrapper to claude_desktop_config.json:
Register each server with the wrapper before use:
For a mandatory gateway setup where all tool calls must go through the wrapper, see docs/DEPLOYMENT.md.
Available MCP tools
See docs/TOOLS.md for the full tool reference.
CLI Reference
24 subcommands covering all 25 MCP tools. Every command supports --json for machine-readable output and --yes / -y to skip confirmation prompts.
See docs/CLI.md for the full reference with flags and examples.
Auxiliary Security Tool Integrations
Kali Linux MCP, Burp Suite MCP, and Snyk each integrate automatically once registered. Kali enriches the Recon stage and ping_server with real nmap/traceroute data. Burp adds raw HTTP probing, out-of-band callbacks, and proxy evidence. Snyk analyses tool metadata for injection strings, tool shadowing, hardcoded secrets, and 16 other checks.
See docs/INTEGRATIONS.md for setup instructions.
Development
Install in editable mode:
Run the server and observe logs:
Every module uses logging.getLogger(__name__). The server does not call logging.basicConfig itself - configure logging in your entry point before importing.
Testing
Set an LLM API key to include LLM-assisted tests; without one they are skipped automatically. See docs/TESTING.md for step-by-step verification of classification, injection scanning, risk gating, and policy enforcement.
Further reading
Contributing
See CONTRIBUTING.md for code standards and pull request guidelines.
License
Apache License 2.0. See LICENSE for details.
来源:README.md,提交 4d182fd
工具
0版本历史
21- v1.5.9Nov 4, 2026
- v1.5.8Oct 29, 2026
- v1.5.3Oct 26, 2026
- v1.5.2Oct 25, 2026
- v1.5.1Oct 24, 2026
- v1.5.0Oct 19, 2026
- v1.4.36Oct 17, 2026
- v1.4.34Oct 15, 2026
- v1.4.33Oct 15, 2026
- v1.4.32Oct 15, 2026
- v1.4.31Oct 13, 2026
- v1.4.29Oct 13, 2026
- v1.4.27Oct 12, 2026
- v1.4.26Oct 12, 2026
- v1.4.25Oct 11, 2026
- v1.4.24Oct 11, 2026
- v1.4.23Oct 4, 2026
- v1.4.22Oct 4, 2026
- v1.4.21Oct 3, 2026
- v1.4.20Sep 30, 2026
- v1.4.18Sep 16, 2026
评分
已满足适用检查项的 40%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
请在仓库或注册中心条目中声明许可证。