mcp应激
MCP(模型上下文协议)服务器的压力测试工具。
安装
# npm
npx mcp-stress
npm install -g mcp-stress
# JSR / Deno
deno install -g -A --name mcp-stress jsr:@dgellow/mcp-stress/cli命令
跑
对MCP服务器执行压力测试。
# Stdio transport (spawns the server)
mcp-stress run -d 30 -c 10 --tool echo -- node my-server.js
# HTTP transport
mcp-stress run -d 30 -c 10 --url http://localhost:3000/mcp
# Find max throughput (auto-scales concurrency)
mcp-stress run -p find-ceiling -d 120 -c 50 -- node my-server.js
# CI mode: JSON output + assertions
mcp-stress run --json --assert "p99 < 500ms" --assert "error_rate < 1%" -- node my-server.js
# Live browser dashboard
mcp-stress run --live -d 60 -c 10 -o results.ndjson -- node my-server.js
# Send exactly N requests (useful for debugging)
mcp-stress run -n 5 -v -- node my-server.js选项:
| 标志 | 描述 |
|---|---|
-p, --profile | 工作负载配置文件(默认值: tool-flood) |
-d, --duration | 测试持续时间(秒)(默认值:10) |
-n, --requests | N个请求后停止(覆盖持续时间) |
-c, --concurrency | 峰值并发工作者(默认值:1) |
-t, --timeout | 请求超时(毫秒)(默认值:30000) |
--tool | 按名称定位特定工具 |
--shape | 负载形状: constant, linear-ramp, exponential, step, spike, sawtooth |
-o, --output | NDJSON输出文件路径 |
--live | 打开实时浏览器仪表板 |
--json | 将JSON摘要输出到stdout |
--assert | 阈值断言,可重复(例如。 "p99 < 500ms") |
--seed | PRNG种子可重复性 |
--sse | 使用传统的HTTP+SSE传输(默认:可流式传输HTTP) |
-v, --verbose | 记录每个请求/响应 |
图表
从上次运行生成交互式HTML报告。
mcp-stress chart results.ndjson --open比较
比较两次测试运行并检测回归。
mcp-stress compare baseline.ndjson current.ndjson --open
mcp-stress compare baseline.ndjson current.ndjson --json --assert "p99_delta < 10%"诊断
探测服务器连接和协议合规性。
mcp-stress diagnose -- node my-server.js
mcp-stress diagnose --url http://localhost:3000/mcp发现
枚举服务器功能(工具、资源、提示)。
mcp-stress discover -- node my-server.js轮廓/形状
列出可用的工作负载配置文件和负载形状。
mcp-stress profiles
mcp-stress shapes运输
- 标准 (默认):将服务器作为子进程生成。使用
-- command [args].
- 流式HTTP:连接到正在运行的服务器。使用
--url. - 上海证券交易所 (遗留):使用
--url随着--sse.
输出
所有测试数据都以NDJSON(换行符分隔的JSON)形式编写,带有三个事件 类型:
meta--运行参数和配置request--单个请求结果(方法、延迟、正常/错误)summary--综合统计
发展
./scripts/lint # Format check + type check
./scripts/test # Run tests
./scripts/build # Compile binary + npm packages
./scripts/start # Run the CLI