MCP Tool Guard

Zero-dependency MCP tool-poisoning, RFC 8785 JCS Ed25519 AgentCard & x402 payment security verifier

Documentation

mcp-tool-guard & a2a-card-guard v0.8.0

Featured in awesome-a2a Official Anthropic MCP Registry Glama MCP GitHub Actions CI NIST FIPS 205 SLH-DSA-SHA2-128f SARIF v2.1.0 0 Runtime Deps MIT License

Zero-dependency Python 3.10+ library, triple CLI (mcp-tool-guard, a2a-card-guard, mcp-tool-guard-server), NIST FIPS 205 Post-Quantum SLH-DSA-SHA2-128f Dual-Hybrid JWS engine, SARIF GitHub Action, 1-click .mcpb Desktop Bundle, and Official MCP Server guarding MCP & A2A Protocol Specification v1.0.1.

mcp-tool-guard v0.8.0 live terminal demo

0.3-Second Prebuilt Wheel & 1-Click .mcpb Install (No Git Clone Needed)

Run directly from the signed v0.8.0 prebuilt wheel (dependencies = [], zero transitive supply-chain surface) or install the 1-click mcp-tool-guard.mcpb desktop bundle in Claude Desktop:

# Instant one-shot live A2A v1.0.1 AgentCard + Dual-Hybrid Ed25519 / NIST FIPS 205 SLH-DSA audit via uvx
uvx --from https://github.com/khoap1220-hue/mcp-tool-guard/releases/latest/download/mcp_tool_guard-0.8.0-py3-none-any.whl \
  a2a-card-guard audit https://khoaphan.dev --auto-jwks --strict-v1

# Post-Quantum Readiness Audit (Gidney-2025 RSA, Shor ECC, EU NIS2 / CNSA 2.0, FIPS 205 SLH-DSA-SHA2-128f)
uvx --from https://github.com/khoap1220-hue/mcp-tool-guard/releases/latest/download/mcp_tool_guard-0.8.0-py3-none-any.whl \
  mcp-tool-guard pqc-audit https://khoaphan.dev --auto-jwks

# Or install into any Python 3.10+ virtualenv / CI image in <0.5s
pip install https://github.com/khoap1220-hue/mcp-tool-guard/releases/latest/download/mcp_tool_guard-0.8.0-py3-none-any.whl

Note: Bit-exact NIST FIPS 205 SLH-DSA-SHA2-128f (keygen, sign, verify — verified against official NIST ACVP vectors), HS256, RFC 8785 JCS canonicalization, cross-SDK JCS divergence checks, SSRF-pinned HTTPS fetching, 5-layer prompt-injection scanning, 11-CVE multi-language SCA, monotonic A2A->MCP attenuation, AP2/x402 mandate checks, SARIF v2.1.0, and the 8-tool stdio MCP server all run on 100% Python stdlib. For classical asymmetric EdDSA / ES256 / PS256 JWS verification alongside SLH-DSA-SHA2-128f, pass --with cryptography to uvx.


1-Click .mcpb Bundle & IDE MCP Server Config (Claude Desktop, Claude Code, Cursor, Windsurf, VS Code)

Registered on the Official Anthropic MCP Registry as io.github.khoap1220-hue/mcp-tool-guard (v0.8.0):

  • Claude Desktop (.mcpb 1-Click Install): Download mcp-tool-guard.mcpb (${__dirname} external-cwd-safe launcher, 256x256 icon, <200ms zero-dep boot) and open in Claude Desktop.
  • IDE JSON Config (.mcp.json, ~/.cursor/mcp.json, claude_desktop_config.json):
{
  "mcpServers": {
    "mcp-tool-guard": {
      "command": "uvx",
      "args": [
        "--from",
        "https://github.com/khoap1220-hue/mcp-tool-guard/releases/latest/download/mcp_tool_guard-0.8.0-py3-none-any.whl",
        "mcp-tool-guard-server"
      ]
    }
  }
}

8 Built-In Read-Only Security Tools (mcp-tool-guard serve)

MCP ToolScopeopenWorldHintWhat It Verifies
scan_mcp_toolsMCP tools/listfalse5-layer prompt injection, invisible Unicode Tags, homoglyphs, typosquats & dangerous $ref/exec schemas
check_mcp_pin_driftStateless Pin / LockfilefalseStateless SHA-256 baseline pin creation & rug-pull drift across (name, description, inputSchema, annotations)
audit_a2a_agent_cardA2A v1.0.1 CardtrueInline JSON, local file, or SSRF-pinned HTTPS origin + jwks.json Ed25519/SLH-DSA/JCS, S4-REJECT-005 & 7-vector A2ABreak
scan_a2a_lockfile_cves10 Lockfile Formatsfalse11 A2A & MCP SDK CVEs (package-lock.json, pnpm-lock.yaml, uv.lock, poetry.lock, requirements.txt, go.sum, Cargo.lock, pom.xml)
verify_a2a_mcp_attenuationA2A -> MCP HopsfalseMonotonic scope & capability attenuation verifier blocking confused-deputy privilege escalation
verify_a2a_x402_mandateAP2 / x402 v2falseHTTP 402 payment mandate validator enforcing integer minor-unit caps, payee binding, expiry & replay-nonce safety
export_security_sarifGitHub Code ScanningfalseConverts scan/audit findings into OASIS SARIF 2.1.0 JSON + $GITHUB_STEP_SUMMARY Markdown
audit_pqc_readinessPost-Quantum (FIPS 205)falseGidney-2025 RSA (<1M noisy qubits), Shor ECC, Grover bounds, EU NIS2 / CNSA 2.0 & pure-stdlib SLH-DSA-SHA2-128f Dual-Hybrid JWS

3 Guided Slash Prompts & 2 Embedded Security Resources

  • MCP Prompts (prompts/list & prompts/get):
    1. audit-live-a2a-agent (agent_url) — Live HTTPS agent-card.json + jwks.json JCS/Ed25519 & S4-REJECT-005 audit + SARIF export.
    2. audit-mcp-server-tools (tools_json) — 5-layer MCP poisoning/schema scan + stateless SHA-256 baseline pin minting.
    3. verify-x402-delegation-chain (parent_scopes, child_tools, max_amount_minor) — Monotonic A2A->MCP attenuation + integer x402 spend cap check.
  • MCP Resources (resources/list & resources/read):
    1. a2a-guard://advisories/2026-a2a-mcp-cves — Machine-readable JSON catalog of all 11 OSV-verified A2A/MCP SDK advisories.
    2. a2a-guard://spec/s4-reject-005-protojson-jcs — Developer reference on cross-SDK ProtoJSON vs RFC 8785 JCS signing + interactive validator (khoaphan.dev/a2a-iq/).

Objective Feature Comparison Matrix

Capabilitymcp-tool-guard v0.8.0mcp-scanpip-audit / osv-scanner
0 Runtime Deps (dependencies = [])Yes (pure Python stdlib)No (heavy CLI/HTTP tree)No
NIST FIPS 205 SLH-DSA-SHA2-128f PQCYes (bit-exact ACVP pure stdlib + Hybrid JWS)NoNo
Offline Air-Gapped ModeYes (100% deterministic local rules)Partial (cloud API default)Requires vulnerability DB sync
MCP Pinning & 5-Layer ScanYes (stateless SHA-256 + annotation diff)YesNo
Live A2A v1.0.1 JWS/JWKSYes (DNS-pinned SSRF-safe HTTPS + JWKS)NoNo
Cross-SDK JCS & S4-REJECT-005Yes (A2A#2122, a2a-js#627, a2a-tck#261)NoNo
11 Commit-Mapped A2A SDK CVEsYes (PyPI, npm, Go go.mod/go.sum, Cargo, Maven)NoPartial (misses commit-only OSV ranges)
A2A->MCP Attenuation & x402 GuardYes (monotonic grants + integer minor-unit caps)NoNo
Built-In MCP Server & .mcpbYes (8 tools, 3 prompts, 2 resources, <200ms boot)NoNo

Drop-In 5-Line GitHub Action (action.yml + SARIF Code Scanning)

- uses: khoap1220-hue/mcp-tool-guard@v0.8.0
  with:
    agent-card: .well-known/agent-card.json
    jwks: .well-known/jwks.json
    mcp-config: tools.json
    sarif-output: mcp-tool-guard.sarif

Upload mcp-tool-guard.sarif directly to the GitHub Security tab via github/codeql-action/upload-sarif@v3; every run also writes a Markdown scorecard table to $GITHUB_STEP_SUMMARY.


Ground-Truth A2A SDK CVE Coverage (a2a-sca / A2A-08)

Standard OSV package queries (pip-audit, npm audit, osv-scanner, Dependabot) miss 2026 a2aproject/* advisories mapped only to git commit SHAs. a2a-sca detects all 11 verified advisories deterministically across uv.lock, poetry.lock, requirements*.txt, pyproject.toml, package-lock.json, pnpm-lock.yaml, go.mod, Cargo.lock, and pom.xml:

Advisory IDEcosystem & PackageVulnerable RangePatchedClass & A2ABreak Vector
CVE-2026-90790PyPI a2a-sdk<= 1.1.31.1.4Push Notification webhook SSRF (#7)
CVE-2025-6167PyPI python-a2a< 0.5.60.5.6Workflow identifier path traversal
CVE-2026-118128npm @a2a-js/sdk (+ aliases)<= 1.1.01.2.0Task FSM concurrent status race / TOCTOU (#6)
CVE-2026-116478Go github.com/a2aproject/a2a-go(/v2)<= 2.4.02.5.0Internal network error disclosure in push handler (#7)
CVE-2026-113706Cargo a2a-rs / a2a-lf / a2a<= 0.4.3>= 0.4.4historyLength conversation history leak (#3)
CVE-2026-90819Maven io.a2a.sdk:*< 1.3.01.3.0.FinalPush Authorization header CRLF splitting (#7)
CVE-2026-111761Maven io.a2a.sdk:* (server-common)< 1.3.01.3.0.FinalUnvalidated push webhook SSRF (#7)
CVE-2026-111762Maven io.a2a.sdk:* (transport-rest)< 1.3.01.3.0.FinalCleartext bearer token logged on Protobuf parse error (#7)
CVE-2026-111763Maven io.a2a.sdk:* (parent/client)< 1.3.01.3.0.FinalCross-domain API key leak via HTTP 30x redirect (#1, #2)
CVE-2026-111764Maven io.a2a.sdk:* (server-common)< 1.3.01.3.0.FinalFail-open InMemoryTaskStore cross-tenant IDOR (#3)
CVE-2026-111765Maven io.a2a.sdk:* (http-client-android)< 1.3.21.3.2.FinalSynchronous POST cross-authority credential redirect (#1, #2)

Real MCP Attack Example (readOnlyHint -> destructiveHint Rug-Pull)

A server serves examples/tools_v1.json at approval time, then silently mutates only annotations in examples/tools_v2_rugpull.json:

       "annotations": {
         "title": "Analytics Reader",
-        "readOnlyHint": true,
-        "destructiveHint": false,
+        "readOnlyHint": false,
+        "destructiveHint": true,
         "idempotentHint": true,
         "openWorldHint": false
       }

Pinning and verifying with the CLI immediately flags HIGH severity annotation-loosening drift (exit code 2) and records old/new hashes and exact field diffs in a SHA-256 hash-chained audit trail:

mcp-tool-guard pin examples/tools_v1.json --server analytics-mcp -o pins.lock.json
mcp-tool-guard verify examples/tools_v2_rugpull.json --server analytics-mcp -l pins.lock.json --sarif-out drift.sarif

Python Library & CLI Reference

from mcp_tool_guard import (
    MCPStdioServer,
    MCPToolGuard,
    audit_live_agent_card,
    check_cross_sdk_jcs_divergence,
    load_tools_list_file,
    scan_a2a_lockfiles,
)

# 1. MCP tools/list pin & rug-pull verification
guard = MCPToolGuard(trusted_servers=["analytics-mcp"])
guard.evaluate_tools(load_tools_list_file("examples/tools_v1.json", default_server="analytics-mcp"))
decisions = guard.evaluate_tools(load_tools_list_file("examples/tools_v2_rugpull.json", default_server="analytics-mcp"))
assert decisions[0].decision == "human_review" and decisions[0].drift_severity == "HIGH"

# 2. Multi-language A2A SDK lockfile & split-brain scan
sca_report = scan_a2a_lockfiles(".")
assert sca_report.passed is True
# MCP subcommands & stdio server
mcp-tool-guard serve
mcp-tool-guard-server --version
mcp-tool-guard pin examples/tools_v1.json --server analytics-mcp -o pins.lock.json
mcp-tool-guard verify examples/tools_v2_rugpull.json --server analytics-mcp -l pins.lock.json --format sarif
mcp-tool-guard scan examples/tools_v1.json --server analytics-mcp --github-summary
mcp-tool-guard check-stateless examples/stateless_desync_request.json
mcp-tool-guard audit-toolbox examples/mcp_toolbox_sample.yaml --format sarif
mcp-tool-guard check-a2a chain.json --secret-env MCP_GUARD_SECRET --server analytics-mcp --tool query_records

# A2A v1.0 subcommands (available on both `a2a-card-guard` and `mcp-tool-guard a2a-*`)
a2a-card-guard audit https://khoaphan.dev --auto-jwks --strict-v1
a2a-card-guard pin examples/agent_card_v1.json -o a2a.lock.json --hmac-secret-env A2A_DEMO_HMAC
a2a-card-guard verify examples/agent_card_v2_rugpull.json -l a2a.lock.json --hmac-secret-env A2A_DEMO_HMAC
a2a-card-guard sca . --agent-card examples/agent_card_v1.json --format json
a2a-card-guard delegation-audit examples/a2a_delegation_escalation.json --format sarif
a2a-card-guard generate --url https://guard.example.com --pay-to 0x1111111111111111111111111111111111111111 --price-usdc 0.05

# Post-Quantum (NIST FIPS 205 SLH-DSA-SHA2-128f) Dual-Hybrid JWS & NIS2/CNSA 2.0 Audit
mcp-tool-guard pqc-keygen --kid a2a-slh-dsa-v1 --sk-out slh.key --jwks-out jwks.json
mcp-tool-guard pqc-sign-card examples/agent_card_v1.json --sk-file slh.key --kid a2a-slh-dsa-v1 -o signed_card.json
mcp-tool-guard pqc-verify-card signed_card.json --jwks jwks.json
mcp-tool-guard pqc-audit signed_card.json --jwks jwks.json

Architecture

src/mcp_tool_guard/
├── models.py          # Frozen dataclasses (MCPToolDefinition, DriftReport, AuditEntry)
├── canonical.py       # Sorted-key JSON canonicalizer, ASCII prose normalization, deep field differ
├── policy.py          # Monotonic annotation guardrails & HIGH-severity annotation loosening detector
├── scanner.py         # 5-layer prompt-injection & Unicode homoglyph/Tag smuggling scanner
├── typosquat.py       # Damerau-Levenshtein edit-distance-1 & confusable server spoof detector
├── audit.py           # Append-only SHA-256 hash-chained AuditLog with JSONL serialization
├── guard.py           # Stateful MCPToolGuard, lockfile I/O, separation-of-duties drift promotion
├── loader.py          # Parser for standard MCP tools/list, JSON-RPC 2.0, array, and multi-server JSON
├── stateless.py       # Stateless MCP 2026-07-28 header-body verifier & multi-replica consensus detector
├── toolbox_audit.py   # Zero-dep Google mcp-toolbox tools.yaml, shell/SQL, MCP Apps & Tasks auditor
├── a2a_attenuation.py # Cryptographically linked monotonic A2A <-> MCP capability attenuation chain
├── a2a_guard.py       # A2A v1.0 JCS/JWS verifier, live SSRF-pinned URL probe, JCS divergence & A2ABreak
├── a2a_sca.py         # Zero-dep 9-manifest A2A SDK CVE & v0.3/v1.0 framework split-brain scanner (A2A-08)
├── a2a_x402.py        # A2A v1.0.1 /.well-known/agent-card.json generator & exact-Decimal x402 v2 helpers
├── pqc_guard.py       # Pure-stdlib NIST FIPS 205 SLH-DSA-SHA2-128f & Gidney-2025/NIS2 PQC readiness auditor
├── sarif.py           # OASIS SARIF v2.1.0 & GitHub Actions $GITHUB_STEP_SUMMARY Markdown formatter
├── mcp_server.py      # Zero-dep JSON-RPC 2.0 stdio MCP server (8 read-only tools, 3 prompts, 2 resources)
└── cli.py             # Triple zero-dep CLIs (`mcp-tool-guard`, `a2a-card-guard`, `mcp-tool-guard-server`)

Benchmarks

Measured with python -B benchmarks/bench_guard.py --iterations 500 --warmup 50 on Python 3.12 (AMD64), zero external dependencies:

WorkloadIterationsp50 (µs)p95 (µs)p99 (µs)Mean (µs)
Single tool: canonical SHA-256 pin hash only2,50063.380.8101.666.3
Single tool: cold pin + full 5-layer scan1,0001,033.91,717.31,810.21,182.9
10-tool tools/list: cold pin + 5-layer scan50010,827.915,581.416,011.511,471.8
20-tool tools/list: steady-state guard verify5001,427.51,768.31,845.01,416.6
50-tool tools/list: steady-state guard verify2503,841.14,421.44,560.33,781.3

License

MIT — see LICENSE.


Maintained by Khoa Phan as part of an open-core A2A engineering practice (100% written asynchronous execution via GitHub Specs/PRs and Email, zero live meetings). For teams needing production remediation, custom A2A v0.3 -> v1.0 migration adapters, or formal security sign-off, details on the 72h Fixed-Scope A2A v1.0 & MCP Security Hardening Audit are available at khoaphan.dev/mcp/.