MCP Tool Guard
Zero-dependency MCP tool-poisoning, RFC 8785 JCS Ed25519 AgentCard & x402 payment security verifier
Documentation
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.
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-toolstdioMCP server all run on 100% Python stdlib. For classical asymmetricEdDSA/ES256/PS256JWS verification alongsideSLH-DSA-SHA2-128f, pass--with cryptographytouvx.
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 (
.mcpb1-Click Install): Downloadmcp-tool-guard.mcpb(${__dirname}external-cwd-safe launcher,256x256icon,<200mszero-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 Tool | Scope | openWorldHint | What It Verifies |
|---|---|---|---|
scan_mcp_tools | MCP tools/list | false | 5-layer prompt injection, invisible Unicode Tags, homoglyphs, typosquats & dangerous $ref/exec schemas |
check_mcp_pin_drift | Stateless Pin / Lockfile | false | Stateless SHA-256 baseline pin creation & rug-pull drift across (name, description, inputSchema, annotations) |
audit_a2a_agent_card | A2A v1.0.1 Card | true | Inline JSON, local file, or SSRF-pinned HTTPS origin + jwks.json Ed25519/SLH-DSA/JCS, S4-REJECT-005 & 7-vector A2ABreak |
scan_a2a_lockfile_cves | 10 Lockfile Formats | false | 11 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_attenuation | A2A -> MCP Hops | false | Monotonic scope & capability attenuation verifier blocking confused-deputy privilege escalation |
verify_a2a_x402_mandate | AP2 / x402 v2 | false | HTTP 402 payment mandate validator enforcing integer minor-unit caps, payee binding, expiry & replay-nonce safety |
export_security_sarif | GitHub Code Scanning | false | Converts scan/audit findings into OASIS SARIF 2.1.0 JSON + $GITHUB_STEP_SUMMARY Markdown |
audit_pqc_readiness | Post-Quantum (FIPS 205) | false | Gidney-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):audit-live-a2a-agent(agent_url) — Live HTTPSagent-card.json+jwks.jsonJCS/Ed25519 &S4-REJECT-005audit + SARIF export.audit-mcp-server-tools(tools_json) — 5-layer MCP poisoning/schema scan + stateless SHA-256 baseline pin minting.verify-x402-delegation-chain(parent_scopes,child_tools,max_amount_minor) — Monotonic A2A->MCP attenuation + integerx402spend cap check.
- MCP Resources (
resources/list&resources/read):a2a-guard://advisories/2026-a2a-mcp-cves— Machine-readable JSON catalog of all 11 OSV-verified A2A/MCP SDK advisories.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
| Capability | mcp-tool-guard v0.8.0 | mcp-scan | pip-audit / osv-scanner |
|---|---|---|---|
0 Runtime Deps (dependencies = []) | Yes (pure Python stdlib) | No (heavy CLI/HTTP tree) | No |
NIST FIPS 205 SLH-DSA-SHA2-128f PQC | Yes (bit-exact ACVP pure stdlib + Hybrid JWS) | No | No |
Offline Air-Gapped Mode | Yes (100% deterministic local rules) | Partial (cloud API default) | Requires vulnerability DB sync |
MCP Pinning & 5-Layer Scan | Yes (stateless SHA-256 + annotation diff) | Yes | No |
Live A2A v1.0.1 JWS/JWKS | Yes (DNS-pinned SSRF-safe HTTPS + JWKS) | No | No |
Cross-SDK JCS & S4-REJECT-005 | Yes (A2A#2122, a2a-js#627, a2a-tck#261) | No | No |
11 Commit-Mapped A2A SDK CVEs | Yes (PyPI, npm, Go go.mod/go.sum, Cargo, Maven) | No | Partial (misses commit-only OSV ranges) |
A2A->MCP Attenuation & x402 Guard | Yes (monotonic grants + integer minor-unit caps) | No | No |
Built-In MCP Server & .mcpb | Yes (8 tools, 3 prompts, 2 resources, <200ms boot) | No | No |
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 ID | Ecosystem & Package | Vulnerable Range | Patched | Class & A2ABreak Vector |
|---|---|---|---|---|
CVE-2026-90790 | PyPI a2a-sdk | <= 1.1.3 | 1.1.4 | Push Notification webhook SSRF (#7) |
CVE-2025-6167 | PyPI python-a2a | < 0.5.6 | 0.5.6 | Workflow identifier path traversal |
CVE-2026-118128 | npm @a2a-js/sdk (+ aliases) | <= 1.1.0 | 1.2.0 | Task FSM concurrent status race / TOCTOU (#6) |
CVE-2026-116478 | Go github.com/a2aproject/a2a-go(/v2) | <= 2.4.0 | 2.5.0 | Internal network error disclosure in push handler (#7) |
CVE-2026-113706 | Cargo a2a-rs / a2a-lf / a2a | <= 0.4.3 | >= 0.4.4 | historyLength conversation history leak (#3) |
CVE-2026-90819 | Maven io.a2a.sdk:* | < 1.3.0 | 1.3.0.Final | Push Authorization header CRLF splitting (#7) |
CVE-2026-111761 | Maven io.a2a.sdk:* (server-common) | < 1.3.0 | 1.3.0.Final | Unvalidated push webhook SSRF (#7) |
CVE-2026-111762 | Maven io.a2a.sdk:* (transport-rest) | < 1.3.0 | 1.3.0.Final | Cleartext bearer token logged on Protobuf parse error (#7) |
CVE-2026-111763 | Maven io.a2a.sdk:* (parent/client) | < 1.3.0 | 1.3.0.Final | Cross-domain API key leak via HTTP 30x redirect (#1, #2) |
CVE-2026-111764 | Maven io.a2a.sdk:* (server-common) | < 1.3.0 | 1.3.0.Final | Fail-open InMemoryTaskStore cross-tenant IDOR (#3) |
CVE-2026-111765 | Maven io.a2a.sdk:* (http-client-android) | < 1.3.2 | 1.3.2.Final | Synchronous 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:
| Workload | Iterations | p50 (µs) | p95 (µs) | p99 (µs) | Mean (µs) |
|---|---|---|---|---|---|
| Single tool: canonical SHA-256 pin hash only | 2,500 | 63.3 | 80.8 | 101.6 | 66.3 |
| Single tool: cold pin + full 5-layer scan | 1,000 | 1,033.9 | 1,717.3 | 1,810.2 | 1,182.9 |
10-tool tools/list: cold pin + 5-layer scan | 500 | 10,827.9 | 15,581.4 | 16,011.5 | 11,471.8 |
20-tool tools/list: steady-state guard verify | 500 | 1,427.5 | 1,768.3 | 1,845.0 | 1,416.6 |
50-tool tools/list: steady-state guard verify | 250 | 3,841.1 | 4,421.4 | 4,560.3 | 3,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/.