Security audit framework for MCP (Model Context Protocol) servers
Project description
MCP Shield v2
Security audit framework for MCP (Model Context Protocol) servers.
MCP Shield scans MCP servers before installation to detect supply chain attacks, prompt injection, tool poisoning, and other threats specific to the AI agent ecosystem.
Features
15 Security Detectors across 3 Surfaces
Source Code Analysis (6 detectors)
shell_injection—shell=Truewith dynamic input,os.systemeval_exec— Dynamic code evaluation with untrusted inputssrf— HTTP requests with dynamic URLs from env/config (12+ HTTP libraries)secrets— Hardcoded tokens, API keys, passwords, TLS disabledpath_traversal— File operations with unsanitized user pathspermissions— Excessive permissions, postinstall scripts, code obfuscation
MCP Metadata Analysis (6 detectors)
prompt_injection— Hidden instructions in tool descriptions (18+ patterns)unicode_invisible— Zero-width characters, BOM, control chars in tool nameshomoglyph_spoofing— Cyrillic/Greek lookalikes substituted for Latin charactersschema_injection— Malicious defaults, enum payloads in input schemasmarkdown_injection—javascript:links, image exfiltration, HTML injectiondescription_heuristic— Oversized descriptions, imperative overload, empty descriptions
Runtime Delta Analysis (3 detectors)
tool_shadowing— Tools that appear live but not in source code (dynamic injection)param_divergence— Schema/description changes between source and runtime (rug pull)capability_drift— Annotation changes, polymorphic server behavior
Installation
No external dependencies required — stdlib only (Python 3.10+).
git clone https://github.com/GaboITB/mcp-shield.git
cd mcp-shield
Usage
Scan a MCP server before installation
# From GitHub
py -3 -m mcp_shield scan https://github.com/user/mcp-server
# From npm
py -3 -m mcp_shield scan @user/mcp-server --name my-mcp
# JSON output for CI/CD
py -3 -m mcp_shield scan https://github.com/user/repo --format json
Fetch live tools and compare
py -3 -m mcp_shield live my-mcp
Approve a scanned MCP
py -3 -m mcp_shield approve my-mcp
View approved MCPs
py -3 -m mcp_shield report
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Clean — no critical or high findings |
| 1 | Warnings — high severity findings detected |
| 2 | Critical — critical findings or dangerous patterns |
Design Philosophy
- Three detection surfaces — Source code, MCP metadata, and runtime delta each have their own Protocol and detector implementations
- Zero dependencies — stdlib only (
ast,re,argparse,dataclasses,json) - Plugin architecture — Add a detector by creating one file implementing a Protocol
- CLI-first — Not an MCP server (avoids circular trust). Hooks for runtime protection
- Approval workflow — Backup settings.json before any modification, diff + confirm
Threat Coverage
| Threat | Detected | Surface |
|---|---|---|
| Command injection (shell=True) | Yes | Code |
| Prompt injection in tool descriptions | Yes | Meta |
| Tool name spoofing (homoglyphs) | Yes | Meta |
| Invisible Unicode in names | Yes | Meta |
| Rug pull (description change post-approval) | Yes | Delta |
| Dynamic tool injection | Yes | Delta |
| Supply chain (postinstall scripts) | Yes | Code |
| SSRF via env variables | Yes | Code |
| Hardcoded secrets/tokens | Yes | Code |
| Schema default payloads | Yes | Meta |
| TLS disabled | Yes | Code |
| Code obfuscation | Yes | Code |
Architecture
Three Protocols, unified by the Finding dataclass:
SourceDetector.scan_file(path, content) -> list[Finding]MetadataDetector.scan_tool(name, desc, schema, annotations) -> list[Finding]RuntimeDetector.scan_delta(baseline, current) -> list[Finding]
Adding a new detector = one file, zero changes elsewhere.
License
MIT
Built by GaboLabs — Designed through multi-expert AI debate (5 experts, 4 rounds).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_shield_audit-2.0.0.tar.gz.
File metadata
- Download URL: mcp_shield_audit-2.0.0.tar.gz
- Upload date:
- Size: 91.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4ff614eac50cdb6674093cc40978c4711c0cca89cbe4ddfb082179c9d764276
|
|
| MD5 |
b7d84fcabf47de46ff2b502718d865b5
|
|
| BLAKE2b-256 |
33413c864c4bd98f26a15319666a9b45e06de420140bec60c5eb66308efcb7f5
|
File details
Details for the file mcp_shield_audit-2.0.0-py3-none-any.whl.
File metadata
- Download URL: mcp_shield_audit-2.0.0-py3-none-any.whl
- Upload date:
- Size: 106.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a9c0dd0b18d854a95ae56a53d157f462a08a314b01ff61d338676a7891658f8
|
|
| MD5 |
a4d7634cc419eeb4cfa436fad728d126
|
|
| BLAKE2b-256 |
ed6faba93e997ad50a6050d5b8b6194c8b2ed83bc787df74738121ad851bd952
|