Skip to content
Projetos

Sobre

Deterministic conformance, security, tool-poisoning, and token-bloat benchmark runner for Model Context Protocol (MCP) servers

Segurança e privacidade

Como estes números são medidos

Crescimento medido de estrelas

em 24 h
+3
em 7 dias
Coletando histórico
em 15 dias
Coletando histórico
em 1 mês
Coletando histórico

Variações líquidas em períodos sobrepostos, não totais diários. Medições ausentes ficam em branco. Estrelas indicam interesse, não qualidade.

README.md

Original

mcp-bench

License: MIT Node.js TypeScript Platform MCP

Deterministic conformance, security, tool-poisoning, and token-bloat benchmark runner for any Model Context Protocol (MCP) server.

Works with any stdio MCP server—regardless of whether it is written in TypeScript, Python (FastMCP), Go, Rust, or C#—with zero LLM API keys required and only 1 runtime dependency (@modelcontextprotocol/sdk).


Why mcp-bench?

Every connected MCP server injects its tool definitions into every single LLM turn and runs with your user's permissions. Yet most MCP servers ship without automated checks for:

  • Tool poisoning & prompt injection (MCP-SEC-001) — hidden <IMPORTANT> tags, ignore previous instructions directives, exfiltration hints, or zero-width Unicode steganography embedded in tool metadata.
  • Silent context token tax (MCP-TOK-001, MCP-TOK-002) — verbose tool descriptions and bloated schemas that burn thousands of tokens per turn before the user even types a message.
  • Schema & runtime bugs (MCP-SCH-*, MCP-CONF-*) — missing parameter descriptions, dangling required keys, unhandled unknown tools, stack-trace/path leaks, or hanging handshakes.

mcp-bench runs offline in under a second, outputs a deterministic 0–100 scorecard (A–F), and drops straight into CI pipelines.


Sample Output

mcp-bench Report — firestore-guard-mcp v1.0.0
Score: 100/100 (Grade A) | Startup: 118ms | tools/list: 4ms | Tools: 3 (~389 tokens/turn)
Findings: 0 (critical: 0, high: 0, medium: 0, low: 0, info: 0)

Tool Token Breakdown:
  - audit_firestore_rules: ~111 tokens (2 params, 0 required)
  - audit_firestore_indexes: ~124 tokens (2 params, 0 required)
  - audit_firestore_project: ~154 tokens (3 params, 0 required)

No issues found.

Quick Start Guide

1. Install & Build

Requires Node.js >= 20 (Windows, macOS, or Linux).

git clone https://github.com/Adjureee/mcp-bench.git
cd mcp-bench
npm install
npm run build

2. Benchmark Any MCP Server (Language-Agnostic)

Pass your MCP server launch command after --:

# TypeScript / Node.js MCP server
node ./dist/cli/index.js -- node /path/to/server/dist/index.js

# Python / FastMCP server
node ./dist/cli/index.js --fuzz -- python /path/to/server.py

# Go / Rust compiled binary
node ./dist/cli/index.js --fuzz -- /path/to/mcp-server-binary

# Published npm MCP server via npx
node ./dist/cli/index.js --json -- npx -y @modelcontextprotocol/server-everything

3. Enforce Quality Gates in CI (GitHub Actions)

Use --fail-on <severity> to fail pull requests when critical/high issues appear:

- name: Benchmark MCP server
  run: |
    npx mcp-bench --fuzz --fail-on high --max-total-tokens 2000 -- node ./dist/index.js

CLI Reference

Flag Default Description
--fuzz false Probe tools with missing required arguments to verify graceful validation and detect stack-trace leaks (Node, Python, Go, Rust)
--json false Output full structured JSON report
--fail-on <level> — Exit with code 1 if any finding is >= critical, high, medium, low, or info
--max-startup-ms <n> 2000 Maximum allowed initialization/handshake latency (ms)
--max-tool-tokens <n> 300 Maximum estimated tokens per individual tool definition
--max-total-tokens <n> 2500 Maximum estimated tokens across all tools on the server
--timeout-ms <n> 15000 Timeout per handshake / RPC call to prevent hanging CI jobs
-v, --version — Print version
-h, --help — Show help

Programmatic API (Vitest / Jest Integration)

Test your MCP server directly in unit tests (works with both StdioClientTransport and InMemoryTransport):

import { benchmarkStdioServer, formatBenchReport } from 'mcp-bench';

const report = await benchmarkStdioServer('node', ['./dist/index.js'], {
  fuzz: true,
  maxTotalTokens: 1500,
  timeoutMs: 10000,
});

console.log(formatBenchReport(report));
if (report.summary.counts.critical > 0 || report.summary.counts.high > 0) {
  process.exit(1);
}

Rules Reference

Rule ID Category Severity What It Checks
MCP-SEC-001 Security Critical Tool poisoning / prompt injection (<IMPORTANT>, ignore previous instructions, stealth directives, exfiltration hints, zero-width Unicode)
MCP-SEC-002 Security Medium Unconstrained sensitive parameters (cmd, command, shell, exec, sql, script, eval, code) without enum or pattern
MCP-SEC-003 Security Low Stack trace or local user path leakage in error responses (--fuzz, supports Node/Python/Go/Rust)
MCP-SCH-001 Schema High Empty or duplicate tool names in tools/list
MCP-SCH-002 Schema Medium Missing or overly brief (<15 chars) tool description
MCP-SCH-003 Schema High Invalid inputSchema.type, malformed property schema, or required key missing from properties
MCP-SCH-004 Schema Low Tool parameters missing description fields
MCP-TOK-001 Tokens Medium Individual tool definition exceeds token budget
MCP-TOK-002 Tokens Medium Total server tools/list payload exceeds token budget
MCP-CONF-001 Conformance High Server does not return an error on unknown tool invocation
MCP-CONF-002 Conformance Medium Tool accepts {} when required parameters are declared (--fuzz)
MCP-CONF-003 Conformance Info Server exposes zero tools or does not support tools/list
MCP-PERF-001 Performance Medium Slow server initialization/handshake (> --max-startup-ms)

Scoring

Every benchmark starts at 100 and deducts per finding:

  • Critical: -30 | High: -15 | Medium: -8 | Low: -3 | Info: 0
  • Grades: A (90–100), B (80–89), C (70–79), D (50–69), F (0–49)

Development

npm run typecheck   # Strict TypeScript check (tsc --noEmit)
npm test            # Vitest unit & InMemoryTransport integration tests
npm run build       # Bundle ESM library, .d.ts types, and CLI via tsup

License

Released under the MIT License.

Explore projetos relacionados

Carregando…