Skip to main content

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_injectionshell=True with dynamic input, os.system
  • eval_exec — Dynamic code evaluation with untrusted input
  • ssrf — HTTP requests with dynamic URLs from env/config (12+ HTTP libraries)
  • secrets — Hardcoded tokens, API keys, passwords, TLS disabled
  • path_traversal — File operations with unsanitized user paths
  • permissions — 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 names
  • homoglyph_spoofing — Cyrillic/Greek lookalikes substituted for Latin characters
  • schema_injection — Malicious defaults, enum payloads in input schemas
  • markdown_injectionjavascript: links, image exfiltration, HTML injection
  • description_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

  1. Three detection surfaces — Source code, MCP metadata, and runtime delta each have their own Protocol and detector implementations
  2. Zero dependencies — stdlib only (ast, re, argparse, dataclasses, json)
  3. Plugin architecture — Add a detector by creating one file implementing a Protocol
  4. CLI-first — Not an MCP server (avoids circular trust). Hooks for runtime protection
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_shield_audit-2.0.0.tar.gz (91.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_shield_audit-2.0.0-py3-none-any.whl (106.5 kB view details)

Uploaded Python 3

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

Hashes for mcp_shield_audit-2.0.0.tar.gz
Algorithm Hash digest
SHA256 c4ff614eac50cdb6674093cc40978c4711c0cca89cbe4ddfb082179c9d764276
MD5 b7d84fcabf47de46ff2b502718d865b5
BLAKE2b-256 33413c864c4bd98f26a15319666a9b45e06de420140bec60c5eb66308efcb7f5

See more details on using hashes here.

File details

Details for the file mcp_shield_audit-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_shield_audit-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a9c0dd0b18d854a95ae56a53d157f462a08a314b01ff61d338676a7891658f8
MD5 a4d7634cc419eeb4cfa436fad728d126
BLAKE2b-256 ed6faba93e997ad50a6050d5b8b6194c8b2ed83bc787df74738121ad851bd952

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page