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) enables AI agents to interact with host-level tools. McpVanguard interposes between the agent and the system, provide real-time inspection and enforcement prefixing every tool call.

Transparent integration. Zero-configuration requirements for existing servers.

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


๐Ÿ›ก๏ธ Getting Started (New Users)

Bootstrap your security workspace with a single command:

# 1. Initialize safe zones and .env template
vanguard init

# 2. (Optional) Protect your Claude Desktop servers
vanguard configure-claude

# 3. Launch the visual security dashboard
vanguard ui --port 4040

๐Ÿง  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 via OpenAI, DeepSeek, Groq or Ollama Async
L3 โ€” Behavioral Shannon Entropy ($H(X)$) scouter and sliding-window anomaly detection Stateful

Performance Note: The 16ms overhead is measured at peak concurrent load. In standard operation, the latency is well under 2msโ€”negligible relative to typical LLM inference times.

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

Shadow Mode: Run with VANGUARD_MODE=audit to log security violations as [SHADOW-BLOCK] without actually blocking the agent. Perfect for assessing risk in existing production workflows.


๐Ÿ›ก๏ธ 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
  • SSRF & Metadata Protection: Blocks access to cloud metadata endpoints (AWS/GCP/Azure) and hex/octal encoded IPs.
  • Jailbreak Detection: Actively identifies prompt injection patterns and instruction-ignore sequences.
  • Continuous Monitoring: Visualize all of the above in real-time with the built-in Security Dashboard.

๐Ÿ“Š Security Dashboard

Launch the visual monitor to see your agent's activity and security status in real-time.

vanguard ui --port 4040

The dashboard provides a low-latency, HTMX-powered feed of:

  • Real-time Blocks: Instantly see which rule or layer triggered a rejection.
  • Entropy Scores: Pulse-check the $H(X)$ levels of your agent's data streams.
  • Audit History: Contextual log fragments for rapid incident response.

VEX Protocol โ€” Deterministic 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"
export VANGUARD_AUDIT_FORMAT="json" # Optional: Route JSON logs directly into SIEM (ELK, Splunk)
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)           โ”‚  โ”‚
      โ”‚               โ”‚  โ”‚  OpenAI / MiniMax / Ollama 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)

L2 Semantic Backend Options

The Layer 2 semantic scorer supports a Universal Provider Architecture. Set the corresponding API keys to activate a backend โ€” the first available key wins (priority: Custom > OpenAI > MiniMax > Ollama):

Backend Env Vars Notes
Universal Custom (DeepSeek, Groq, Mistral, vLLM) VANGUARD_SEMANTIC_CUSTOM_KEY, VANGUARD_SEMANTIC_CUSTOM_MODEL, VANGUARD_SEMANTIC_CUSTOM_URL Fast, cheap inference. Examples:
Groq: https://api.groq.com/openai/v1
DeepSeek: https://api.deepseek.com/v1
OpenAI VANGUARD_OPENAI_API_KEY, VANGUARD_OPENAI_MODEL Default model: gpt-4o-mini
MiniMax VANGUARD_MINIMAX_API_KEY, VANGUARD_MINIMAX_MODEL, VANGUARD_MINIMAX_BASE_URL Default model: MiniMax-M2.5
Ollama (local) VANGUARD_OLLAMA_URL, VANGUARD_OLLAMA_MODEL Default model: phi4-mini. No API key required
# Example: Use Groq for ultra-fast L2 scoring
export VANGUARD_SEMANTIC_ENABLED=true
export VANGUARD_SEMANTIC_CUSTOM_KEY="your-groq-key"
export VANGUARD_SEMANTIC_CUSTOM_MODEL="llama3-8b-8192"
export VANGUARD_SEMANTIC_CUSTOM_URL="https://api.groq.com/openai/v1"
vanguard start --server "npx @modelcontextprotocol/server-filesystem ."

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 Production Hardening & Cloud Scaling (v1.6.0 Release) [DONE]
Phase 9 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.6.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.6.0-py3-none-any.whl (58.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mcp_vanguard-1.6.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.6.0.tar.gz
Algorithm Hash digest
SHA256 35cc9338ed0c1cba0cf3ae628e6a3f91bb978a173297af74d3b1a2497e079a9c
MD5 8f9214980deb8bfbc1cc307bd87ff6d1
BLAKE2b-256 94931e32592a28bab619973560666e58a3bf48db505a3144be2ed28f23fb5368

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_vanguard-1.6.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.6.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_vanguard-1.6.0-py3-none-any.whl
  • Upload date:
  • Size: 58.4 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.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3da0d87677b757a04399d3cd1f0eeb65d03a8fe55a2fd5ed2969e712e33b84df
MD5 2f48831d5008be7c8f258595d0dd38c5
BLAKE2b-256 632ac1c42fd1d5953a7d2d3815be7376b290588fdf77cf25c930a3814b17438b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_vanguard-1.6.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