Ready-to-run test collections, CI/CD configurations, and end-to-end workflows. Copy, paste, and go.
Minimal collection — the simplest way to test a server. Uses shorthand assertions.
name: Simple Filesystem Tests
server: npx -y @modelcontextprotocol/server-filesystem /tmp
tests:
- name: List allowed directories
call: list_allowed_directories
expect:
- exists: $.content
- name: Read a test file
call: read_file
with:
path: /tmp/mcpspec-test.txt
expect:
- exists: $.content
- name: Handle missing file
call: read_file
with:
path: /tmp/nonexistent-file-12345.txt
expectError: true
mcpspec test examples/collections/simple.yaml
Advanced collection with environments, tags, typed assertions, and latency checks.
schemaVersion: "1.0"
name: Environment-Aware Tests
description: Tests that use environment variables
server:
transport: stdio
command: npx
args: ["-y", "@modelcontextprotocol/server-filesystem", "{{baseDir}}"]
environments:
dev:
variables:
baseDir: /tmp
staging:
variables:
baseDir: /var/tmp
defaultEnvironment: dev
tests:
- id: test-list
name: List directories
tags: [smoke]
call: list_allowed_directories
assertions:
- type: schema
- type: latency
maxMs: 10000
- id: test-read
name: Read test file
tags: [integration]
call: read_file
with:
path: "{{baseDir}}/mcpspec-test.txt"
assertions:
- type: exists
path: $.content
mcpspec test examples/collections/with-environments.yaml --env dev
70 tests across 7 popular MCP servers. Each collection is ready to run with no setup.
@modelcontextprotocol/server-filesystem
Read/write files, list directories, search, edit, path traversal security checks.
schemaVersion: "1.0"
name: Filesystem Server Tests
description: Tests for the official MCP filesystem server
server:
transport: stdio
command: npx
args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
tests:
- id: list-allowed
name: List allowed directories
tags: [smoke, discovery]
call: list_allowed_directories
assertions:
- type: schema
- type: exists
path: $.content
- id: list-tmp
name: List /tmp directory contents
tags: [smoke, read]
call: list_directory
with:
path: /tmp
assertions:
- type: schema
- type: exists
path: $.content
- id: write-file
name: Write a test file
tags: [write]
call: write_file
with:
path: /tmp/mcpspec-test-file.txt
content: "Hello from MCPSpec!"
assertions:
- type: schema
- id: read-file
name: Read the test file back
tags: [read]
call: read_text_file
with:
path: /tmp/mcpspec-test-file.txt
assertions:
- type: schema
- type: exists
path: $.content
- type: contains
path: $.content[0].text
value: "Hello from MCPSpec!"
- id: read-missing-file
name: Handle missing file gracefully
tags: [smoke, error]
call: read_text_file
with:
path: /tmp/nonexistent-file-99999.txt
expectError: true
- id: read-outside-sandbox
name: Reject path outside allowed directories
tags: [security, error]
call: read_text_file
with:
path: /etc/passwd
expectError: true
- id: path-traversal
name: Reject path traversal attempts
tags: [security, error]
call: read_text_file
with:
path: /tmp/../../etc/passwd
expectError: true
mcpspec test examples/collections/servers/filesystem.yaml
@modelcontextprotocol/server-memory
Knowledge graph CRUD: create entities/relations, search, add observations, delete, verify cleanup.
schemaVersion: "1.0"
name: Memory Server Tests
description: Tests for the official MCP knowledge graph memory server
server:
transport: stdio
command: npx
args: ["-y", "@modelcontextprotocol/server-memory"]
tests:
- id: create-entities
name: Create entities in the knowledge graph
tags: [smoke, write]
call: create_entities
with:
entities:
- name: "Alice"
entityType: "person"
observations:
- "Software engineer"
- "Lives in San Francisco"
- name: "Bob"
entityType: "person"
observations:
- "Product manager"
assertions:
- type: schema
- type: exists
path: $.content
- id: create-relations
name: Create relations between entities
tags: [write]
call: create_relations
with:
relations:
- from: "Alice"
to: "Bob"
relationType: "collaborates_with"
assertions:
- type: schema
- id: read-graph
name: Read the entire knowledge graph
tags: [smoke, read]
call: read_graph
assertions:
- type: schema
- type: exists
path: $.content
- id: search-nodes
name: Search for nodes by query
tags: [read]
call: search_nodes
with:
query: "engineer"
assertions:
- type: schema
- type: exists
path: $.content
- id: delete-entities
name: Delete entities from the graph
tags: [write, cleanup]
call: delete_entities
with:
entityNames: ["Alice", "Bob"]
assertions:
- type: schema
mcpspec test examples/collections/servers/memory.yaml
@modelcontextprotocol/server-everything
Reference server exercising all protocol features: echo, sum, images, annotations, resource links.
schemaVersion: "1.0"
name: Everything Server Tests
description: Tests for the official MCP reference server
server:
transport: stdio
command: npx
args: ["-y", "@modelcontextprotocol/server-everything"]
tests:
- id: echo
name: Echo a message
tags: [smoke]
call: echo
with:
message: "Hello MCPSpec!"
assertions:
- type: schema
- type: exists
path: $.content
- type: contains
path: $.content[0].text
value: "Hello MCPSpec!"
- id: sum
name: Calculate sum of two numbers
tags: [smoke]
call: get-sum
with:
a: 42
b: 58
assertions:
- type: schema
- type: exists
path: $.content
- id: tiny-image
name: Get tiny image (binary content)
tags: [smoke]
call: get-tiny-image
assertions:
- type: schema
- type: exists
path: $.content
- id: echo-latency
name: Echo responds within 5 seconds
tags: [performance]
call: echo
with:
message: "latency test"
assertions:
- type: latency
maxMs: 5000
mcpspec test examples/collections/servers/everything.yaml
@modelcontextprotocol/server-time
Time and timezone queries, conversions, and error handling for invalid inputs.
mcpspec test examples/collections/servers/time.yaml
@modelcontextprotocol/server-fetch
HTTP fetch operations, URL validation, content extraction, and error handling.
mcpspec test examples/collections/servers/fetch.yaml
@modelcontextprotocol/server-github
GitHub API operations: search repos, list issues, get file contents, user info.
mcpspec test examples/collections/servers/github.yaml
chrome-devtools-mcp
Browser automation: navigate, screenshot, evaluate JS, network, console, accessibility.
mcpspec test examples/collections/servers/chrome-devtools.yaml
Complete workflow with test, audit, and quality gate steps.
name: MCP Server Tests
on: [push, pull_request]
jobs:
mcpspec:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- run: npm install -g mcpspec
- name: Run tests
run: mcpspec test --ci --reporter junit --output results.xml
- name: Security audit
run: mcpspec audit "npx my-server" --mode passive --fail-on high
- name: Quality gate
run: mcpspec score "npx my-server" --min-score 80
- uses: mikepenz/action-junit-report@v4
if: always()
with:
report_paths: results.xml
mcpspec ci-init --platform github --checks test,audit,score
GitLab CI job with JUnit artifact reporting.
mcpspec:
image: node:22
stage: test
script:
- npm install -g mcpspec
- mcpspec test --ci --reporter junit --output results.xml
- mcpspec audit "npx my-server" --mode passive --fail-on high
artifacts:
when: always
paths:
- results.xml
reports:
junit: results.xml
expire_in: 1 week
mcpspec ci-init --platform gitlab --checks test,audit
Portable shell script for any CI system or local use.
#!/bin/bash
set -euo pipefail
echo "=== MCPSpec CI ==="
# Run tests
mcpspec test --ci --reporter junit --output results.xml
echo "Tests passed"
# Security audit
mcpspec audit "npx my-server" --mode passive --fail-on high
echo "Audit passed"
# Quality gate
mcpspec score "npx my-server" --min-score 80
echo "Score check passed"
echo "=== All checks passed ==="
mcpspec ci-init --platform shell --checks test,audit,score
Record a session once. Replay it to catch regressions. Mock it for CI. No API keys required.
# 1. Record a session against your real server
mcpspec record start "npx my-server"
# In the REPL:
# .call get_user {"id": "1"}
# .call list_items {}
# .call create_item {"name": "test"}
# .save my-api
# 2. Replay against a new version — catch regressions
mcpspec record replay my-api "npx my-server-v2"
# 3. Start a mock server (drop-in replacement)
mcpspec mock my-api
# 4. Generate standalone .js file for CI
mcpspec mock my-api --generate ./mocks/server.js
# 5. Use mock in your test suite
mcpspec test --server "node ./mocks/server.js"
Full quality pipeline: run tests, audit for vulnerabilities, and enforce a minimum quality score.
# 1. Generate CI config with all checks
mcpspec ci-init --platform github \
--checks test,audit,score \
--fail-on medium \
--min-score 80
# 2. Or run manually:
# Run tests with JUnit output
mcpspec test --ci --reporter junit --output results.xml
# Security audit (passive = safe for production)
mcpspec audit "npx my-server" --fail-on medium
# Quality gate with badge generation
mcpspec score "npx my-server" --min-score 80 --badge ./badge.svg
# Performance baseline
mcpspec bench "npx my-server" --iterations 50