loading…
Search for a command to run...
loading…
A Spring Boot REST API testing server that supports functional testing with assertions, database queries, and performance testing with configurable concurrency
A Spring Boot REST API testing server that supports functional testing with assertions, database queries, and performance testing with configurable concurrency and stress testing.
一个 MCP (Model Context Protocol) 服务器,为 Claude Code 提供 Spring Boot REST API 的功能测试和性能测试能力。
cd springboot-test-mcp
pip install -e .
或直接安装:
pip install httpx "mcp[cli]>=1.6.0" oracledb python-dotenv jmespath
复制 .env.example 为 .env,填入你的配置:
TARGET_BASE_URL=http://localhost:8080
ORACLE_HOST=localhost
ORACLE_PORT=1521
ORACLE_SERVICE=ORCL
ORACLE_USER=your_user
ORACLE_PASSWORD=your_password
在项目根目录创建 .claude/settings.json:
{
"mcpServers": {
"springboot-test": {
"command": "python",
"args": ["/absolute/path/to/springboot-test-mcp/main.py"]
}
}
}
或在 Claude Code 中运行:
claude mcp add springboot-test -- python /absolute/path/to/springboot-test-mcp/main.py
在 Claude Code 中:
# 检查配置
> check_config
# 发现 API
> discover_api_endpoints
# 功能测试
> call_api(method="GET", path="/api/users")
> run_functional_tests(test_cases=[{
"name": "创建用户",
"method": "POST",
"path": "/api/users",
"body": {"name": "Alice", "email": "[email protected]"},
"assertions": [
{"target": "status_code", "operator": "eq", "expected": 201},
{"target": "json_path", "json_path": "name", "operator": "eq", "expected": "Alice"}
]
}])
# 性能测试
> run_perf_test(name="用户列表压测", method="GET", path="/api/users",
concurrency=50, duration_seconds=30)
# 阶梯压测
> run_stress_test(name="用户API压测", method="GET", path="/api/users",
max_concurrency=200, step_size=50, step_duration_seconds=30)
# 数据库验证
> query_database(sql="SELECT * FROM users WHERE name='Alice'")
springboot-test-mcp/
├── main.py # 入口
├── server.py # MCP Tool 定义(所有工具)
├── config.py # 配置管理
├── core/
│ ├── __init__.py # HTTP 客户端(httpx)
│ ├── assertion_engine.py # 断言引擎
│ ├── test_runner.py # 功能测试执行器
│ └── perf_engine.py # 性能测试引擎(asyncio 并发)
├── db/
│ ├── __init__.py # Oracle 连接器(oracledb thin mode)
│ └── oracle_connector.py # 别名
├── discovery/
│ └── __init__.py # API 发现(Actuator + 源码扫描)
├── models/
│ └── __init__.py # 数据模型
├── .env.example # 环境变量模板
└── claude_desktop_config.json # Claude 配置参考
| target | 说明 | 示例 |
|---|---|---|
| status_code | HTTP 状态码 | {"target": "status_code", "operator": "eq", "expected": 200} |
| json_path | JSON 字段(JMESPath) | {"target": "json_path", "json_path": "data.name", "operator": "eq", "expected": "Alice"} |
| response_time | 响应时间(ms) | {"target": "response_time", "operator": "lt", "expected": 500} |
| body | 完整响应体 | {"target": "body", "operator": "contains", "expected": "success"} |
| header | 响应头 | {"target": "header", "operator": "contains", "expected": "application/json"} |
| operator | 说明 |
|---|---|
| eq / neq | 等于 / 不等于 |
| gt / lt / gte / lte | 大于 / 小于 / 大于等于 / 小于等于 |
| contains / not_contains | 包含 / 不包含 |
| matches | 正则匹配 |
| exists / not_exists | 存在 / 不存在 |
mcp[cli] (Python FastMCP)Run in your terminal:
claude mcp add springboot-test-mcp -- npx Security
Low riskAutomated heuristic from public metadata — not a security guarantee.