MCP负载测试工具
又快又脏。NET的负载测试工具,用于使用HTTP流传输的模型上下文协议(MCP)服务器。
快速开始
1.建设项目
cd McpLoad
dotnet build2.运行负载测试
针对Azure Functions MCP服务器进行测试:
dotnet run -- --url http://localhost:7071/runtime/webhooks/mcp这将运行一个60秒的负载测试,有10个并发客户端调用 hello 工具。
3.查看结果
该工具将每5秒显示一次实时进度更新和最终摘要,包括:
- 发送的请求总数
- 成功/失败率
- 吞吐量(每秒请求数)
- 响应时间统计(平均值、最小值、最大值、P50、P90、P95、P99)
- 错误消息(如有)
常见测试场景
高并发测试
dotnet run -- --url http://localhost:7071/runtime/webhooks/mcp --clients 100固定请求计数测试
dotnet run -- --url http://localhost:7071/runtime/webhooks/mcp --requests 1000测试不同的操作
# List tools
dotnet run -- --url http://localhost:7071/runtime/webhooks/mcp --operation list-tools
# Mixed workload
dotnet run -- --url http://localhost:7071/runtime/webhooks/mcp --operation mixed带参数的调用工具
dotnet run -- --url http://localhost:7071/runtime/webhooks/mcp --tool-name save_snippet --tool-args '{"snippetname":"test","snippet":"console.log(\"hello\");"}'使用功能键和高负载测试Azure功能
# Set the function key as an environment variable
export MCP_FUNCTION_KEY="your-function-key-here"
# Use the environment variable in the command
dotnet run -- --url https://func-api-abcdefg.azurewebsites.net/runtime/webhooks/mcp --header "x-functions-key:${MCP_FUNCTION_KEY}" --clients 10更多信息
看 规格.md 完整的规格说明。
看 McpLoad/README.md 详细的使用文档。
项目结构
mcpload/
├── .gitignore
├── README.md # This file
├── SPEC.md # Full specification
├── mcpload.sln # Solution file
└── McpLoad/ # Main project directory
├── LoadTestConfig.cs # Configuration model
├── LoadTester.cs # Main orchestrator
├── McpClientWorker.cs # Individual client worker
├── MetricsCollector.cs # Metrics tracking
├── Program.cs # Entry point with CLI
├── McpLoad.csproj # Project file
└── README.md # Detailed documentation依赖项
- .NET 9.0
- ModelContextProtocol 0.4.0-preview.3(C#SDK)
- 系统。命令行2.0.0
目标服务器
设计用于: Azure功能MCP服务器
许可证
样品/测试工具-使用风险自负。
