性能测试MCP服务器
用Java开发的MCP(模型上下文协议)服务器,用于测试InTech发现客户端的性能。
功能
MCP工具可用
- run_performance_test -执行单个性能测试
- run_load_test -使用多个并发ES请求执行负载测试
- 分析测试结果 -分析和总结测试结果
- 监视器成本 -监控和跟踪API成本
- 基准情景 -执行预定义的基准场景
- 导出结果 -将结果导出为不同格式
先决条件
- Java 21或更高版本
- Maven 3.8+
- 正在运行的InTech发现客户端(默认为http://localhost:8072)
安装
- 克隆项目
- 使用Maven编译:
mvn clean compile使用
STDIO模式(适用于MCP客户端)
java -cp target/classes com.mcp.RayenMalouche.performance.testing.server.PerformanceTestingServer.PerformanceTestingServerApplication --stdioHTTP/SSE模式(用于测试和检查)
java -cp target/classes com.mcp.RayenMalouche.performance.testing.server.PerformanceTestingServer.PerformanceTestingServerApplicationHTTP流模式(用于MCP检查器)
java -cp target/classes com.mcp.RayenMalouche.performance.testing.server.PerformanceTestingServer.PerformanceTestingServerApplication --streamable-http端点
当服务器在HTTP模式下运行时:
- MCP端点 : http://localhost:45451/
- SSE端点 : http://localhost:45451/sse
- 健康检查 : http://localhost:45451/api/health
工具使用示例
1.性能测试独一无二
{
"query": "Créez un dataset complet sur toutes les solutions Sage de Discovery Intech",
"targetUrl": "http://localhost:8072",
"testId": "test_sage_001"
}2.测试充电
{
"queries": [
"Créez un dataset sur les solutions Sage",
"Générez un dataset sur les solutions QAD",
"Produisez un dataset sur Microsoft Dynamics 365"
],
"concurrentUsers": 5,
"requestsPerUser": 2,
"targetUrl": "http://localhost:8072"
}3.基准场景
{
"scenarios": ["sage", "qad", "microsoft", "sap"],
"targetUrl": "http://localhost:8072"
}可用场景:
sage:Sage解决方案qad:解决方案QADmicrosoft:微软Dynamics 365sap:SAP解决方案sectors:活动领域services:提供的服务company:公司信息all:所有场景
4.结果分析
{
"testIds": ["test_sage_001", "test_qad_002"],
"generateReport": true
}5.成本监测
{
"timeframe": "day",
"modelName": "llama-3.1-8b-instant"
}时间范围选项: hour, day, week
6.输出结果
{
"format": "json",
"filepath": "/tmp/test_results.json",
"includeDetails": true
}可用格式 : json, csv, html
收集的指标
对于每个测试,收集以下指标:
- 响应时间 (毫秒)
- 代币名称 使用(估计)
- 成本 估计(基于GROQ定价)
- 数据集大小 (元素数)
- MCP呼叫数 执行
- 网址 恢复
- 状态 成功/失败
- 错误消息 (si适用)
结果结构
测试结果
{
"testId": "test_001",
"timestamp": "2025-01-XX:XX:XX",
"query": "Question de test",
"responseTime": 15000,
"tokensUsed": 1500,
"cost": 0.12,
"success": true,
"datasetSize": 25,
"mcpCallsCount": 8,
"urlsFetched": ["https://www.discoveryintech.com/..."],
"errorMessage": null
}负载测试结果
{
"testId": "load_test_123",
"startTime": "2025-01-XX:XX:XX",
"endTime": "2025-01-XX:XX:XX",
"totalTests": 10,
"successfulTests": 9,
"failedTests": 1,
"averageResponseTime": 12500.5,
"totalTokens": 15000,
"totalCost": 1.25,
"concurrentUsers": 5,
"requestsPerUser": 2
}配置
默认情况下,服务器使用以下端口:
- HTTP/SSE : 45451
- 健康检查 :45451/api/健康
要更改配置,您可以:
- 更改源代码中的常量
- 环境变量的利用者
- 添加application.properties文件
日志记录
日志显示在stderr上,以便不干扰stdout上的MCP协议。
发展
项目结构
src/main/java/com/dicovery/performance/mcp/test/server/
├── PerformanceTestingServerApplication.java # Classe principale
└── README.md # Documentation汇编和执行
mvn clean compile
mvn spring-boot:run -Dspring-boot.run.arguments="--stdio"测试
mvn test故障排除
常见错误
- 连接被拒绝 :验证InTech发现客户端是否正在运行
- 超时 :增加长请求的超时
- JSON解析错误 :检查请求的格式
调试
通过添加以下内容激活详细日志:
-Dlogging.level.com.dicovery=DEBUG贡献
- 分叉项目
- 创建功能分支
- 提交您的更改
- 向分支推
- 创建拉取请求
