loading…
Search for a command to run...
loading…
CLI tool and MCP server that tests MCP servers for spec compliance
CLI tool and MCP server that tests MCP servers for spec compliance
npm version License: MIT GitHub stars CI
Test any MCP server for spec compliance. 88-test suite covering transport, lifecycle, tools, resources, prompts, error handling, schema validation, and security against the MCP specification. Works against HTTP endpoints (https://my-server.com/mcp) and stdio servers (npx @modelcontextprotocol/server-filesystem /tmp) alike. CLI, MCP server, and programmatic API.
Built and maintained by Yaw Labs.
MCP servers are multiplying fast — but most ship without compliance testing. Broken transport handling, missing error codes, malformed schemas, and silent capability violations are common. Hand-rolling test scripts is tedious and incomplete.
This tool solves that:
--strict mode exits with code 1 on required test failures. Drop it into any pipeline.Remote HTTP server:
npx @yawlabs/mcp-compliance test https://my-server.com/mcp
Local stdio server (the vast majority of MCP servers on npm):
# Pass the command directly, Inspector-style
npx @yawlabs/mcp-compliance test npx @modelcontextprotocol/server-filesystem /tmp
# Or a local build
npx @yawlabs/mcp-compliance test node ./dist/server.js
# With env vars
npx @yawlabs/mcp-compliance test -E GITHUB_TOKEN=$GITHUB_TOKEN -- npx @modelcontextprotocol/server-github
Install globally:
npm install -g @yawlabs/mcp-compliance
mcp-compliance test https://my-server.com/mcp
That's it. You'll get a colored terminal report with a letter grade (A-F), per-test pass/fail, and a compliance score.
# Terminal output with colors and grade
mcp-compliance test https://my-server.com/mcp
# JSON / SARIF for scripting + GitHub Code Scanning
mcp-compliance test https://my-server.com/mcp --format json
mcp-compliance test https://my-server.com/mcp --format sarif > compliance.sarif
# Strict mode for CI — exits 1 on required-test failure
mcp-compliance test https://my-server.com/mcp --strict
# Auth (shorthand or full header)
mcp-compliance test https://my-server.com/mcp --auth "Bearer tok123"
mcp-compliance test https://my-server.com/mcp -H "X-Api-Key: abc"
# Focus the run
mcp-compliance test https://my-server.com/mcp --only transport,lifecycle
mcp-compliance test https://my-server.com/mcp --skip prompts,resources
mcp-compliance test https://my-server.com/mcp --verbose
Pass the command and its args as positional arguments (MCP Inspector-style). Use -- to disambiguate when the target needs flags that collide with ours.
# npm-distributed stdio servers
mcp-compliance test npx -y @modelcontextprotocol/server-filesystem /tmp
mcp-compliance test uvx mcp-server-git
# Local build
mcp-compliance test node ./dist/server.js
# With env vars (repeatable -E, or --env-file)
mcp-compliance test -E API_KEY=secret -E REGION=us-east-1 -- npx my-server
mcp-compliance test --env-file .env -- node ./server.js
# Set working directory
mcp-compliance test --cwd ./services/mcp -- node ./dist/server.js
# Target uses a flag that collides with ours — use `--` to separate
mcp-compliance test --verbose -- node ./server.js --verbose
On Windows, npx and other .cmd shims are handled automatically by spawning through the shell.
| Option | Applies to | Description |
|---|---|---|
--format <format> |
both | Output format: terminal, json, sarif, github, or markdown (default: terminal) |
--config <path> |
both | Load defaults from a config file (default: mcp-compliance.config.json in cwd) |
--output <file> |
both | Write a local SVG badge to the given path after the run |
--list |
both | Print test IDs that would run given current filters, then exit (no connection) |
--transport <kind> |
both | Filter by http or stdio (only used with --list when no target is provided) |
--strict |
both | Exit with code 1 on any required test failure (for CI) |
--min-grade <grade> |
both | Exit with code 1 if grade is below this threshold (A–F) |
-H, --header <h> |
HTTP | Add header to all requests, format "Key: Value" (repeatable) |
--auth <token> |
HTTP | Shorthand for -H "Authorization: <token>" |
-E, --env <var> |
stdio | Set env var for stdio command, format "KEY=VALUE" (repeatable) |
--env-file <path> |
stdio | Load env vars from a file (one KEY=VALUE per line) |
--cwd <dir> |
stdio | Working directory for the stdio command |
--timeout <ms> |
both | Request timeout in milliseconds (default: 15000) |
--preflight-timeout <ms> |
HTTP | Preflight connectivity check timeout (HTTP only) |
--retries <n> |
both | Number of retries for failed tests (default: 0) |
--only <items> |
both | Only run tests matching these categories or test IDs (comma-separated) |
--skip <items> |
both | Skip tests matching these categories or test IDs (comma-separated) |
--concurrency <n> |
both | Max parallel-safe tests in flight (default: 1; raising reduces wall time but can perturb timing-sensitive servers) |
--verbose |
both | Print each test result as it runs (also forwards stdio stderr) |
GitHub Action (drop into any .github/workflows/*.yml):
- uses: YawLabs/mcp-compliance@v0
with:
target: 'node ./dist/server.js' # or a URL like https://my-server.com/mcp
format: github # ::error / ::warning annotations on the PR
strict: 'true' # exit non-zero if any required test fails
min-grade: 'A' # also exit if grade slips
Manual CLI invocation:
# GitHub Actions: emits ::error / ::warning annotations inline on the PR
mcp-compliance test https://my-server.com/mcp --format github --strict
# Slack/Linear/PR comment: drop the body straight into a comment
mcp-compliance test https://my-server.com/mcp --format markdown > report.md
# HTML report (self-contained, share anywhere — issue comments, S3, GitHub Pages)
mcp-compliance test https://my-server.com/mcp --format html > report.html
# Block release if grade slips below B
mcp-compliance test https://my-server.com/mcp --min-grade B
# Preview which tests will run before connecting (handy for --only/--skip authoring)
mcp-compliance test --list --transport stdio --skip security
# Diff two runs — exit 1 if anything that was passing is now failing
mcp-compliance test https://my-server.com/mcp --format json > current.json
mcp-compliance diff baseline.json current.json
# Watch mode for stdio dev loop — re-runs on file changes in cwd
mcp-compliance test --watch -- node ./dist/server.js
# Latency benchmark
mcp-compliance benchmark -- node ./dist/server.js -r 200 -c 4
Docker:
docker run --rm ghcr.io/yawlabs/mcp-compliance test https://my-server.com/mcp
mcp-compliance init
Interactive prompts walk you through transport (http/stdio), command/url, env vars, timeout, and strict mode — then write a mcp-compliance.config.json you can commit.
Check in a mcp-compliance.config.json so CI and your dev loop can run mcp-compliance test with no arguments. Supported locations (searched in order): mcp-compliance.config.json, .mcp-compliancerc.json, .mcp-compliancerc, and the "mcp-compliance" field of package.json. Pass --config <path> to load an explicit file.
HTTP:
{
"target": {
"type": "http",
"url": "https://my-server.com/mcp",
"headers": { "Authorization": "Bearer tok123" }
},
"timeout": 20000,
"strict": true
}
stdio:
{
"target": {
"type": "stdio",
"command": "node",
"args": ["./dist/server.js"],
"env": { "LOG_LEVEL": "error" }
},
"skip": ["security"],
"strict": true
}
Precedence: CLI flags > config file > defaults. Any field can be overridden on the command line.
mcp-compliance badge https://my-server.com/mcp
Runs the compliance suite, publishes the report to mcp.hosting, and prints the markdown embed for your README. The badge image reflects the real grade (A–F) and links to the full report.
| Option | Description |
|---|---|
-H, --header <header> |
Add header to all requests, format "Key: Value" (repeatable) |
--auth <token> |
Shorthand for -H "Authorization: <token>" |
--timeout <ms> |
Request timeout in milliseconds (default: 15000) |
--no-publish |
Skip publishing; print a local badge markdown only |
--output <file> |
Also write a local SVG badge to the given path |
Reports are kept for 90 days from last submission; resubmitting the same URL overwrites the previous report. Auth headers are stripped client-side before upload. Private/loopback URLs (localhost, 127.0.0.1, 192.168.*, etc.) trigger an interactive confirmation before publishing, and are rejected by the server in any case.
A delete token is returned at publish time and stored at ~/.mcp-compliance/tokens.json (mode 0600). Use it to take a report down:
mcp-compliance unpublish https://my-server.com/mcp
Stdio servers can't be published (no public URL to key on), but you can commit a local SVG reflecting the real grade:
mcp-compliance test node ./dist/server.js --output badge.svg
mcp-compliance badge npx -y @modelcontextprotocol/server-filesystem /tmp --output badge.svg
Then embed it in your README:

The test command never publishes — use it for CI, debugging, and local iteration. badge is the only command that publishes to mcp.hosting.
HTTP-only (13):
stdio-only (3):
_meta fields on incoming requests| Grade | Score |
|---|---|
| A | 90-100 |
| B | 75-89 |
| C | 60-74 |
| D | 40-59 |
| F | 0-39 |
Required tests are worth 70% of the score, optional tests 30%. See the full scoring algorithm in the methodology doc.
# GitHub Actions example
- name: MCP Compliance Check
run: npx @yawlabs/mcp-compliance test ${{ env.MCP_SERVER_URL }} --strict
# With JSON output for parsing
- name: MCP Compliance Check
run: |
npx @yawlabs/mcp-compliance test ${{ env.MCP_SERVER_URL }} --format json > compliance.json
cat compliance.json | jq '.grade'
# With retries for flaky network conditions
- name: MCP Compliance Check
run: npx @yawlabs/mcp-compliance test ${{ env.MCP_SERVER_URL }} --strict --retries 2 --timeout 30000
# SARIF output for GitHub Code Scanning
- name: MCP Compliance Check
run: npx @yawlabs/mcp-compliance test ${{ env.MCP_SERVER_URL }} --format sarif > compliance.sarif
- name: Upload SARIF
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: compliance.sarif
This package also exposes an MCP server with 3 tools that can be used from Claude Code, Cursor, or any MCP client.
Claude Code (one-liner):
claude mcp add mcp-compliance -- npx -y @yawlabs/mcp-compliance mcp
Or create .mcp.json in your project root:
macOS / Linux / WSL:
{
"mcpServers": {
"mcp-compliance": {
"command": "npx",
"args": ["-y", "@yawlabs/mcp-compliance", "mcp"]
}
}
}
Windows:
{
"mcpServers": {
"mcp-compliance": {
"command": "cmd",
"args": ["/c", "npx", "-y", "@yawlabs/mcp-compliance", "mcp"]
}
}
}
Tip: This file is safe to commit — it contains no secrets.
Restart your MCP client and approve the server when prompted.
All tools have MCP tool annotations (readOnlyHint, destructiveHint, idempotentHint, openWorldHint) so MCP clients can skip confirmation dialogs for safe operations.
import { runComplianceSuite } from '@yawlabs/mcp-compliance';
const report = await runComplianceSuite('https://my-server.com/mcp');
console.log(`Grade: ${report.grade} (${report.score}%)`);
// With options
const report2 = await runComplianceSuite('https://my-server.com/mcp', {
headers: { 'Authorization': 'Bearer tok123' },
timeout: 30000,
retries: 1,
only: ['transport', 'lifecycle'],
});
// Live progress for streaming UIs (e.g. server-sent-events to a browser)
await runComplianceSuite('https://my-server.com/mcp', {
onTestComplete: (result) => {
// result has the full TestResult: id, name, category, required,
// passed, details, durationMs, specRef. Push it to your client.
sendToClient(result);
},
});
The JSON output of the test suite is a stable, versioned contract. Every report includes a schemaVersion field at the top level. The full JSON Schema lives at schemas/report.v1.json and is shipped with the npm package.
{
"schemaVersion": "1", // bumped on breaking changes to the report shape
"specVersion": "2025-11-25", // MCP spec version tested against
"toolVersion": "0.10.0", // mcp-compliance version that produced the report
"url": "...",
"timestamp": "...",
"grade": "A",
"score": 92.5,
"tests": [ ... ],
// ...
}
Consumer guidance:
schemaVersion. Reject reports with an unknown version rather than guessing at the shape.ajv).The testing methodology is published openly so the grading is auditable:
mcp-compliance badge and any custom integrationsThe methodology is not an authoritative conformance standard — it's one tool's choices, published so they can be inspected, adopted, or forked. The official MCP specification defines what servers must do; this document describes how @yawlabs/mcp-compliance verifies it.
git clone https://github.com/YawLabs/mcp-compliance.git
cd mcp-compliance
npm install
npm run build
npm test
Development commands:
| Command | Description |
|---|---|
npm run build |
Compile with tsup |
npm run dev |
Watch mode |
npm test |
Run tests (vitest) |
npm run lint |
Check with Biome |
npm run lint:fix |
Auto-fix with Biome |
npm run typecheck |
TypeScript type checking |
npm run test:ci |
Build + test (CI-safe) |
MIT — see LICENSE.
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"compliance": {
"command": "npx",
"args": [
"-y",
"@yawlabs/mcp-compliance"
]
}
}
}