mcpspec 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +413 -0
  2. package/package.json +4 -4
package/README.md ADDED
@@ -0,0 +1,413 @@
1
+ # MCPSpec
2
+
3
+ **The complete testing, debugging, and quality platform for MCP servers.**
4
+
5
+ MCPSpec is Postman for [Model Context Protocol](https://modelcontextprotocol.io) — test collections, interactive inspection, security auditing, performance benchmarking, auto-generated docs, and a quality scoring system. Works from the CLI, in CI/CD, or through a full web UI.
6
+
7
+ ```
8
+ mcpspec test ./collection.yaml # Run tests
9
+ mcpspec inspect "npx my-server" # Interactive REPL
10
+ mcpspec audit "npx my-server" # Security scan
11
+ mcpspec bench "npx my-server" # Performance benchmark
12
+ mcpspec score "npx my-server" # Quality rating (0-100)
13
+ mcpspec docs "npx my-server" # Auto-generate documentation
14
+ mcpspec ui # Launch web dashboard
15
+ ```
16
+
17
+ ---
18
+
19
+ ## Why MCPSpec?
20
+
21
+ MCP servers expose tools (file access, database queries, API calls) to AI assistants. Before shipping a server, you need to answer:
22
+
23
+ - **Does it work?** — Do tools return correct results? Do they handle bad input?
24
+ - **Is it safe?** — Can inputs cause path traversal, injection, or information leaks?
25
+ - **Is it fast?** — What's the P95 latency? Can it handle load?
26
+ - **Is it documented?** — Do tools have descriptions and proper schemas?
27
+
28
+ MCPSpec answers all of these with a single tool.
29
+
30
+ ---
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ npm install -g mcpspec
36
+ ```
37
+
38
+ Requires Node.js 22+.
39
+
40
+ ---
41
+
42
+ ## Quick Start
43
+
44
+ ### 1. Initialize a project
45
+
46
+ ```bash
47
+ mcpspec init --template standard
48
+ ```
49
+
50
+ ### 2. Write a test collection
51
+
52
+ ```yaml
53
+ name: Filesystem Server Tests
54
+ server: npx @modelcontextprotocol/server-filesystem /tmp
55
+
56
+ tests:
57
+ - name: Read a file
58
+ call: read_file
59
+ with:
60
+ path: /tmp/test.txt
61
+ expect:
62
+ - exists: $.content
63
+
64
+ - name: Handle missing file
65
+ call: read_file
66
+ with:
67
+ path: /tmp/nonexistent.txt
68
+ expectError: true
69
+ ```
70
+
71
+ ### 3. Run it
72
+
73
+ ```bash
74
+ mcpspec test ./collection.yaml
75
+ ```
76
+
77
+ ```
78
+ MCPSpec running Filesystem Server Tests (2 tests)
79
+
80
+ ✓ Read a file (124ms)
81
+ ✓ Handle missing file (89ms)
82
+
83
+ Tests: 2 passed (2 total)
84
+ Time: 0.45s
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Commands
90
+
91
+ ### `mcpspec test` — Run Test Collections
92
+
93
+ ```bash
94
+ mcpspec test # Uses ./mcpspec.yaml
95
+ mcpspec test ./tests.yaml # Specific file
96
+ mcpspec test --env staging # Use staging variables
97
+ mcpspec test --tag @smoke # Filter by tag
98
+ mcpspec test --parallel 4 # Parallel execution
99
+ mcpspec test --reporter junit --output results.xml # JUnit for CI
100
+ mcpspec test --baseline main # Compare against saved baseline
101
+ mcpspec test --watch # Re-run on file changes
102
+ mcpspec test --ci # CI mode (no colors, strict exit codes)
103
+ ```
104
+
105
+ **Reporters:** `console`, `json`, `junit`, `html`, `tap`
106
+
107
+ ### `mcpspec inspect` — Interactive REPL
108
+
109
+ ```bash
110
+ mcpspec inspect "npx @modelcontextprotocol/server-filesystem /tmp"
111
+ ```
112
+
113
+ | Command | Description |
114
+ |---------|-------------|
115
+ | `.tools` | List all tools |
116
+ | `.resources` | List all resources |
117
+ | `.call <tool> <json>` | Call a tool |
118
+ | `.schema <tool>` | Show input schema |
119
+ | `.info` | Server info |
120
+ | `.exit` | Disconnect |
121
+
122
+ ### `mcpspec audit` — Security Scanner
123
+
124
+ Scans for 6 categories of vulnerabilities:
125
+
126
+ ```bash
127
+ mcpspec audit "npx my-server" # Passive (safe, read-only)
128
+ mcpspec audit "npx my-server" --mode active # Active (test payloads)
129
+ mcpspec audit "npx my-server" --mode aggressive # Aggressive probing
130
+ mcpspec audit "npx my-server" --fail-on medium # Fail CI on medium+ findings
131
+ ```
132
+
133
+ | Rule | What It Detects |
134
+ |------|-----------------|
135
+ | Path Traversal | `../../etc/passwd` style attacks |
136
+ | Input Validation | Missing/malformed input handling |
137
+ | Resource Exhaustion | Crash-inducing large payloads |
138
+ | Auth Bypass | Access control circumvention |
139
+ | Injection | SQL/command injection in tool inputs |
140
+ | Information Disclosure | Leaked paths, stack traces, secrets |
141
+
142
+ Active and aggressive modes send potentially harmful payloads and require confirmation (or `--acknowledge-risk` for CI).
143
+
144
+ ### `mcpspec bench` — Performance Benchmark
145
+
146
+ ```bash
147
+ mcpspec bench "npx my-server" # Default: 100 iterations
148
+ mcpspec bench "npx my-server" --iterations 500 # More iterations
149
+ mcpspec bench "npx my-server" --tool read_file # Specific tool
150
+ mcpspec bench "npx my-server" --args '{"path":"/tmp/f"}' # With arguments
151
+ ```
152
+
153
+ Reports min, max, mean, median, P95, P99, standard deviation, and throughput (calls/sec).
154
+
155
+ ### `mcpspec score` — MCP Quality Score
156
+
157
+ Calculates a 0–100 quality rating:
158
+
159
+ ```bash
160
+ mcpspec score "npx my-server"
161
+ mcpspec score "npx my-server" --badge badge.svg # Generate SVG badge
162
+ ```
163
+
164
+ ```
165
+ MCP Score
166
+ ────────────────────────────────────────
167
+ Documentation ████████████████████ 100/100
168
+ Schema Quality ████████████████████ 100/100
169
+ Error Handling ██████████████░░░░░░ 70/100
170
+ Performance ████████████████░░░░ 80/100
171
+ Security ████████████████████ 100/100
172
+
173
+ Overall: 91/100
174
+ ```
175
+
176
+ | Category (weight) | What It Measures |
177
+ |--------------------|-----------------|
178
+ | Documentation (25%) | % of tools/resources with descriptions |
179
+ | Schema Quality (25%) | Proper `type`, `properties`, `required` in input schemas |
180
+ | Error Handling (20%) | Returns `isError: true` for bad input vs. crashing |
181
+ | Performance (15%) | Median response latency |
182
+ | Security (15%) | Findings from a passive security scan |
183
+
184
+ The `--badge` flag generates a shields.io-style SVG for your README.
185
+
186
+ ### `mcpspec docs` — Documentation Generator
187
+
188
+ ```bash
189
+ mcpspec docs "npx my-server" # Markdown to stdout
190
+ mcpspec docs "npx my-server" --format html # HTML output
191
+ mcpspec docs "npx my-server" --output ./docs # Write to directory
192
+ ```
193
+
194
+ Connects to the server, introspects all tools and resources, and generates documentation with tool descriptions, input schemas, and resource tables.
195
+
196
+ ### `mcpspec compare` / `mcpspec baseline` — Regression Detection
197
+
198
+ ```bash
199
+ mcpspec baseline save main # Save current run as "main"
200
+ mcpspec baseline list # List saved baselines
201
+ mcpspec compare --baseline main # Compare latest run against baseline
202
+ mcpspec compare <run-id-1> <run-id-2> # Compare two specific runs
203
+ ```
204
+
205
+ ### `mcpspec init` — Project Scaffolding
206
+
207
+ ```bash
208
+ mcpspec init # Current directory
209
+ mcpspec init ./my-project # Specific directory
210
+ mcpspec init --template minimal # Minimal starter
211
+ mcpspec init --template standard # Standard (recommended)
212
+ mcpspec init --template full # Full with environments
213
+ ```
214
+
215
+ ### `mcpspec ui` — Web Dashboard
216
+
217
+ ```bash
218
+ mcpspec ui # Opens localhost:6274
219
+ mcpspec ui --port 8080 # Custom port
220
+ ```
221
+
222
+ Full web interface with:
223
+ - Server management and connection testing
224
+ - Collection editor with YAML validation
225
+ - Test run history with drill-down
226
+ - Interactive tool inspector
227
+ - Security audit with live progress
228
+ - Performance benchmarking with real-time stats
229
+ - Documentation generator with copy/download
230
+ - MCP Score calculator with category breakdown
231
+ - Dark mode
232
+
233
+ ---
234
+
235
+ ## Collection Format
236
+
237
+ ### Simple Format
238
+
239
+ ```yaml
240
+ name: My Tests
241
+ server: npx my-mcp-server
242
+
243
+ tests:
244
+ - name: Basic call
245
+ call: tool_name
246
+ with:
247
+ param: value
248
+ expect:
249
+ - exists: $.result
250
+ ```
251
+
252
+ ### Advanced Format
253
+
254
+ ```yaml
255
+ schemaVersion: "1.0"
256
+ name: Comprehensive Tests
257
+ description: Full test suite
258
+
259
+ server:
260
+ transport: stdio
261
+ command: npx
262
+ args: ["my-mcp-server"]
263
+ env:
264
+ NODE_ENV: test
265
+
266
+ environments:
267
+ dev:
268
+ variables:
269
+ BASE_PATH: /tmp/dev
270
+ prod:
271
+ variables:
272
+ BASE_PATH: /data
273
+
274
+ defaultEnvironment: dev
275
+
276
+ tests:
277
+ - id: test-1
278
+ name: Get data
279
+ tags: [smoke, api]
280
+ timeout: 5000
281
+ retries: 2
282
+ call: get_data
283
+ with:
284
+ path: "{{BASE_PATH}}/file.txt"
285
+ assertions:
286
+ - type: schema
287
+ - type: exists
288
+ path: $.content
289
+ - type: matches
290
+ path: $.content
291
+ pattern: "^Hello"
292
+ - type: latency
293
+ maxMs: 1000
294
+ - type: expression
295
+ expr: "response.content.length > 0"
296
+ extract:
297
+ - name: fileContent
298
+ path: $.content
299
+ ```
300
+
301
+ ### Assertion Types
302
+
303
+ | Type | Description | Example |
304
+ |------|-------------|---------|
305
+ | `schema` | Response is valid | `type: schema` |
306
+ | `equals` | Exact match | `path: $.id, value: 123` |
307
+ | `contains` | Array/string contains | `path: $.tags, value: "active"` |
308
+ | `exists` | Path exists | `path: $.name` |
309
+ | `matches` | Regex match | `path: $.email, pattern: ".*@.*"` |
310
+ | `type` | Type check | `path: $.count, expected: number` |
311
+ | `length` | Length check | `path: $.items, operator: gt, value: 0` |
312
+ | `latency` | Response time | `maxMs: 1000` |
313
+ | `mimeType` | Content type | `expected: "image/png"` |
314
+ | `expression` | Safe expression | `expr: "response.total > 0"` |
315
+
316
+ Expressions use [expr-eval](https://github.com/silentmatt/expr-eval) — comparisons, logical operators, property access, and math. No arbitrary code execution.
317
+
318
+ ---
319
+
320
+ ## CI/CD Integration
321
+
322
+ ### GitHub Actions
323
+
324
+ ```yaml
325
+ name: MCP Server Tests
326
+ on: [push, pull_request]
327
+
328
+ jobs:
329
+ test:
330
+ runs-on: ubuntu-latest
331
+ steps:
332
+ - uses: actions/checkout@v4
333
+ - uses: actions/setup-node@v4
334
+ with:
335
+ node-version: '22'
336
+
337
+ - run: npm install -g mcpspec
338
+
339
+ - name: Run tests
340
+ run: mcpspec test --ci --reporter junit --output results.xml
341
+
342
+ - name: Security audit
343
+ run: mcpspec audit "npx my-server" --mode passive --fail-on high
344
+
345
+ - uses: mikepenz/action-junit-report@v4
346
+ if: always()
347
+ with:
348
+ report_paths: results.xml
349
+ ```
350
+
351
+ ### Exit Codes
352
+
353
+ | Code | Meaning |
354
+ |------|---------|
355
+ | 0 | Success |
356
+ | 1 | Test failure |
357
+ | 2 | Runtime error |
358
+ | 3 | Configuration error |
359
+ | 4 | Connection error |
360
+ | 5 | Timeout |
361
+ | 6 | Security findings above threshold |
362
+ | 7 | Validation error |
363
+ | 130 | Interrupted (Ctrl+C) |
364
+
365
+ ---
366
+
367
+ ## Architecture
368
+
369
+ MCPSpec is a TypeScript monorepo:
370
+
371
+ | Package | Description |
372
+ |---------|-------------|
373
+ | `@mcpspec/shared` | Types, Zod schemas, constants |
374
+ | `@mcpspec/core` | MCP client, test runner, assertions, security scanner, profiler, doc generator, scorer |
375
+ | `@mcpspec/cli` | 10 CLI commands built with Commander.js |
376
+ | `@mcpspec/server` | Hono HTTP server with REST API + WebSocket for real-time updates |
377
+ | `@mcpspec/ui` | React SPA with TanStack Router, TanStack Query, Tailwind CSS, shadcn/ui |
378
+
379
+ Key design decisions:
380
+ - **Local-first** — works offline, no account needed, server binds to localhost only
381
+ - **Safe by default** — FAILSAFE YAML parsing, secret masking, process cleanup on SIGINT/SIGTERM
382
+ - **sql.js** for storage — WebAssembly SQLite, no native compilation required
383
+ - **Transports** — stdio, SSE, and streamable-http (SSE/HTTP lazy-loaded for code splitting)
384
+
385
+ ---
386
+
387
+ ## Development
388
+
389
+ ```bash
390
+ git clone https://github.com/mcpspec/mcpspec.git
391
+ cd mcpspec
392
+ pnpm install
393
+ pnpm build
394
+ pnpm test # 259 tests across core + server
395
+ ```
396
+
397
+ Run the CLI locally:
398
+
399
+ ```bash
400
+ node packages/cli/dist/index.js test ./examples/collections/simple.yaml
401
+ ```
402
+
403
+ Launch the UI in dev mode:
404
+
405
+ ```bash
406
+ node packages/cli/dist/index.js ui
407
+ ```
408
+
409
+ ---
410
+
411
+ ## License
412
+
413
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcpspec",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "The definitive MCP server testing platform",
5
5
  "keywords": [
6
6
  "mcp",
@@ -29,9 +29,9 @@
29
29
  "@inquirer/prompts": "^7.0.0",
30
30
  "commander": "^12.1.0",
31
31
  "open": "^10.1.0",
32
- "@mcpspec/core": "1.0.0",
33
- "@mcpspec/shared": "1.0.0",
34
- "@mcpspec/server": "1.0.0"
32
+ "@mcpspec/core": "1.0.1",
33
+ "@mcpspec/shared": "1.0.1",
34
+ "@mcpspec/server": "1.0.1"
35
35
  },
36
36
  "devDependencies": {
37
37
  "tsup": "^8.0.0",