MCP Guard Kit

MCP 도구 응답에서 HTTP 200 무응답 오류를 감사하고, 퀀트 백테스트의 과적합 여부를 검증하며, x402 API를 테스트합니다(매일 무료 호출 5회).

문서

MCP Guard Kit

CI License: MIT Python 3.10+

Zero-dependency MCP tool fault-injection & anti-hallucination verifier for AI agents.

When an MCP tool fails silently (HTTP 200 with error body, truncated JSON, partial batch failure, schema drift, or malformed streams), LLMs and naive status_code == 200 checks routinely assume success.

Reproducible Benchmark (python -m mcp_guard benchmark --trials 60 --seed 42)

Across 60 deterministic trials (48 faulted calls spanning all 8 fault categories + 12 clean baselines, saved in docs/benchmark_results.json):

  • Naive HTTP-200 Verifier: missed 36 / 48 (75.0%) of faulted MCP responses (6 of 8 fault categories return HTTP 200 / ok=true).
  • mcp-guard Evidence Verifier: caught 48 / 48 (100.0%) with 0 false alarms on clean payloads.

mcp-guard-kit catches lying agents deterministically in CI — zero SaaS lock-in, zero external dependencies.

Live Comparison & Interactive Calculator: https://thongtuehuu-cyber.github.io/mcp-guard-kit/

Quick Start

pip install -e .

# Run the built-in 10-case MCP chaos audit (8 fault modes + 2 clean baselines)
python -m mcp_guard audit --html-out report.html --md-out report.md

# Simulate an LLM hallucinating success on 33% of tool failures (exits non-zero for CI)
python -m mcp_guard audit --simulate-lying-agent --json

8 Built-In MCP Fault Modes

Fault IDCategoryWhat It Catches
timeoutTransportAgent claims success after 504 ETIMEDOUT
malformed_jsonSerializationAgent guesses missing fields from broken JSON
empty_payloadContractAgent fabricates records on 200 OK + empty body
silent_error_200SemanticHTTP 200 hiding "Permission denied / written: 0"
http_429_rate_limitQuotaAgent ignores 429 Retry-After and fakes completion
schema_driftContractRequired keys renamed/dropped silently defaulting to 0
partial_failureConsistency207 batch 1 succeeded / 4 failed summarized as "all done"
truncated_responseTransportMid-stream cut payload extrapolated by the LLM

Python API

from mcp_guard import FaultInjector, ToolTrace, verify_trace

injector = FaultInjector(seed=42)
broken_resp = injector.inject("silent_error_200")

res = verify_trace(
    ToolTrace(
        case_id="write-01",
        tool_name="save_invoice",
        fault_id="silent_error_200",
        tool_response=broken_resp,
        agent_claim="Successfully saved invoice!",
    )
)
assert res.verdict == "FAIL_HALLUCINATION"

Pro Automation Suite v1.2 & Deal Monitor ($19–$79 USDC · 0% Fee)

Need live JSON-RPC protocol proxies, 30 production chaos scenarios, native pytest fixtures, policy gates, and security-gate reports out of the box? MCP Guard Kit Pro v1.2 adds:

  • 30 Production MCP Chaos Scenarios across Stripe, GitHub, Postgres, Slack, Playwright & MCP Core (96 / 96 = 100.0% caught, 0 false alarms in the 120-trial seed=42 benchmark)
  • Live proxy-stdio & Streamable-HTTP Chaos Proxies wrapping real upstream MCP servers (stderr-safe framing, --rules-file, JSONL capture)
  • Policy Gates, Scaffolding & Regression Replay: mcp-guard-pro init, --policy JSON gates, distill / replay sanitized trace generator
  • Native Pytest Plugin (pytest11): mcp_chaos, mcp_assert_honest, mcp_stdio_proxy, mcp_http_proxy
  • SARIF 2.1.0, JUnit XML & Executive HTML Reports + ready-to-use GitHub Actions PR gate + perpetual commercial license

Instant automated checkout on Solana Mainnet USDC (QR + 7-day signed ZIP delivery, no account required):

Overview & interactive fault simulator: live landing page.

x402 Agent Pay-Per-Call API (HTTP 402 · Solana USDC)

Autonomous AI agents that prefer pay-per-request micro-billing over bundled downloads can query https://pay.staai.click directly using x402 (X-PAYMENT / PAYMENT-SIGNATURE header with a finalized Solana Mainnet USDC transfer):

  • Discovery Manifest: GET https://pay.staai.click/.well-known/x402.json
  • POST /api/v1/x402/mcp-audit (0.05 USDC / call): Verify up to 100 MCP tool_response + agent_claim traces against silent HTTP-200 failures, GraphQL errors, isError, and schema drift.
  • POST /api/v1/x402/price-extract (0.05 USDC / call): SSRF-safe structured price extraction across JSON-LD (AggregateOffer), Shopify JSON, Steam, GOG, and JSON-Path.
  • POST /api/v1/x402/pr-critic (0.15 USDC / call): Deterministic PR diff & secret/trivial-test verifier before opening GitHub PRs.
  • POST /api/v1/x402/blind-judge (0.10 USDC / call): Swap-debiased A/B + B/A pairwise blind evaluator & Elo scorer.
  • POST /api/v1/x402/bounty-feed (0.05 USDC / call): Live filtered shortlist of active 0-PR GitHub bounties and EV-positive Make.fun arenas.

GitHub Marketplace Action (1-Line CI Gate)

- name: MCP Guard Anti-Hallucination Audit
  uses: thongtuehuu-cyber/mcp-guard-kit@v1.2
  with:
    mode: audit
    sarif-out: mcp-guard.sarif