Skip to main content

Security proxy and verification layer for the Model Context Protocol (MCP)

Project description

๐Ÿ›ก๏ธ McpVanguard

A security proxy for AI agents that use MCP

MCP (Model Context Protocol) lets AI agents like Claude or GPT call tools on your computer โ€” reading files, running commands, browsing the web. McpVanguard sits in between, inspecting every tool call before it reaches your system and blocking anything that looks malicious.

No changes to your agent. No changes to your server. Just wrap it.

Tests PyPI version License: Apache 2.0 Python 3.11+

Part of the Provnai Open Research Initiative โ€” Building the Immune System for AI.


โšก Quickstart

pip install mcp-vanguard

Local stdio wrap (no network):

vanguard start --server "npx @modelcontextprotocol/server-filesystem ."

Cloud Security Gateway (SSE, deploy on Railway):

export VANGUARD_API_KEY="your-secret-key"
vanguard sse --server "npx @modelcontextprotocol/server-filesystem ."

Deploy on Railway

๐Ÿ“– Full Railway Deployment Guide


๐Ÿง  How it works

Every time an AI agent calls a tool (e.g. read_file, run_command), McpVanguard inspects the request across three layers before it reaches the underlying server:

Layer What it checks Latency
L1 โ€” Safe Zones & Rules Kernel-level isolation (openat2 / Windows canonicalization) and 50+ deterministic signatures ~16ms
L2 โ€” Semantic LLM-based intent scoring for ambiguous requests Async
L3 โ€” Behavioral Shannon Entropy ($H(X)$) scouter and sliding-window anomaly detection Stateful

On latency: 16ms is the overhead at peak concurrent load. In practice it's well under the 1โ€“2 second LLM response time โ€” imperceptible to the agent.

If a request is blocked, the agent receives a standard JSON-RPC error response. The underlying server never sees it.


๐Ÿ›ก๏ธ What gets blocked

  • Sandbox Escapes: TOCTOU symlink attacks, Windows 8.3 shortnames (PROGRA~1), DOS device namespaces
  • Data Exfiltration: High-entropy payloads (H > 7.5 cryptographic keys) and velocity-based secret scraping
  • Filesystem attacks: Path traversal (../../etc/passwd), null bytes, restricted paths (~/.ssh), Unicode homograph evasion
  • Command injection: Pipe-to-shell, reverse shells, command chaining via ; && \n, expansion bypasses
  • Network abuse: SSRF, cloud metadata endpoints (AWS/GCP/Azure), hex/octal encoded IPs
  • Prompt injection: Jailbreak patterns, instruction-ignore sequences, hidden unicode characters
  • Privilege escalation: SUID binary creation, LD_PRELOAD injection, crontab manipulation

๐Ÿ“Š VEX Protocol โ€” Immutable Audit Log

When McpVanguard blocks an attack, it creates an OPA/Cerbos-compatible Secure Tool Manifest detailing the Principal, Action, Resource, and environmental snapshot.

This manifest is then sent as a cryptographically-signed report to the VEX Protocol. VEX anchors that report to the Bitcoin blockchain via the CHORA Gate.

This means an auditor can independently verify exactly what was blocked, the entropy score, and why โ€” without relying on your local logs.

export VANGUARD_VEX_URL="https://api.vexprotocol.com"
export VANGUARD_VEX_KEY="your-agent-jwt"
vanguard sse --server "..." --behavioral

๐Ÿ—๏ธ Architecture

                      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  AI Agent            โ”‚            McpVanguard Proxy                    โ”‚
 (Claude, GPT)        โ”‚                                                 โ”‚
      โ”‚               โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
      โ”‚  JSON-RPC      โ”‚  โ”‚ L1 โ€” Rules Engine                        โ”‚  โ”‚
      โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚  โ”‚  50+ YAML signatures (path, cmd, net...)  โ”‚  โ”‚
      โ”‚  (stdio/SSE)   โ”‚  โ”‚  BLOCK on match โ†’ error back to agent    โ”‚  โ”‚
      โ”‚               โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
      โ”‚               โ”‚                   โ”‚ pass                         โ”‚
      โ”‚               โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
      โ”‚               โ”‚  โ”‚ L2 โ€” Semantic Scorer (optional)           โ”‚  โ”‚
      โ”‚               โ”‚  โ”‚  Ollama / OpenAI intent scoring 0.0โ†’1.0   โ”‚  โ”‚
      โ”‚               โ”‚  โ”‚  Async โ€” never blocks the proxy loop      โ”‚  โ”‚
      โ”‚               โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
      โ”‚               โ”‚                   โ”‚ pass                         โ”‚
      โ”‚               โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
      โ”‚               โ”‚  โ”‚ L3 โ€” Behavioral Analysis (optional)       โ”‚  โ”‚
      โ”‚               โ”‚  โ”‚  Sliding window: scraping, enumeration    โ”‚  โ”‚
      โ”‚               โ”‚  โ”‚  In-memory or Redis (multi-instance)      โ”‚  โ”‚
      โ”‚               โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
      โ”‚               โ”‚                   โ”‚                              โ”‚
      โ”‚โ—€โ”€โ”€ BLOCK โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค (any layer)                 โ”‚
      โ”‚  (JSON-RPC    โ”‚                   โ”‚ ALLOW                        โ”‚
      โ”‚   error)      โ”‚                   โ–ผ                              โ”‚
      โ”‚               โ”‚           MCP Server Process                     โ”‚
      โ”‚               โ”‚        (filesystem, shell, APIs...)              โ”‚
      โ”‚               โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
      โ”‚                                  โ”‚
      โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ response โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
      โ”‚
      โ”‚   (on BLOCK)
      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถ VEX API โ”€โ”€โ–ถ CHORA Gate โ”€โ”€โ–ถ Bitcoin Anchor
                       (async, fire-and-forget audit receipt)

๐Ÿ—บ๏ธ Project Status

Phase Goal Status
Phase 1 Foundation (Proxy, CLI, Defensive Rules) โœ… Done
Phase 2 Intelligence (L2 Semantic, L3 Behavioral) โœ… Done
Phase 3 Flight Recorder (VEX & CHORA Integration) โœ… Done
Phase 4 Distribution (stable PyPI release) โœ… Done
Phase 5 Production Hardening (v1.1.3 stability) โœ… Done
Phase 6 Security Audit Remediation (v1.1.4 hardening) โœ… Done
Phase 7 Titan-Grade L1 Perimeter (v1.5.0 Forensic Hardening) โœ… Done
Phase 8 Agent Identity & VEX v0.2 Spec ๐Ÿ”„ In Progress

๐Ÿ“š Resources


๐Ÿ“„ License

Apache License 2.0 โ€” see LICENSE.

Built by the Provnai Open Research Initiative. "Verifying the thoughts and actions of autonomous agents."

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_vanguard-1.5.0.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

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

mcp_vanguard-1.5.0-py3-none-any.whl (51.7 kB view details)

Uploaded Python 3

File details

Details for the file mcp_vanguard-1.5.0.tar.gz.

File metadata

  • Download URL: mcp_vanguard-1.5.0.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mcp_vanguard-1.5.0.tar.gz
Algorithm Hash digest
SHA256 9f3d3029fe7bd712a080d06ffcd5134b78441df467a7067edcf056a31ac0b0d4
MD5 892917f1c9fa3cd6345478286db21ad5
BLAKE2b-256 e869ef460680c4ab8247c1e04e2c9228f6af70bbe2045f670f8f24aed418067a

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_vanguard-1.5.0.tar.gz:

Publisher: publish.yml on provnai/McpVanguard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_vanguard-1.5.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_vanguard-1.5.0-py3-none-any.whl
  • Upload date:
  • Size: 51.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mcp_vanguard-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 665721e57004cbc285b1259bf7217229b91a282baab4f78fcbb46cdcc5844d7d
MD5 895f555e6906318703c71ab7cbf7477f
BLAKE2b-256 114e2604a0e4a3ad6f10b69b0dd089d033a028aca5b063b6b435e9d05ee7125d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_vanguard-1.5.0-py3-none-any.whl:

Publisher: publish.yml on provnai/McpVanguard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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