Spring集成测试MCP服务器
用于Spring Boot集成测试的令牌高效MCP服务器。返回结构化的JSON摘要,而不是转储整个文件。
快速入门(Docker)
1.塑造形象
# Using Docker
docker build -t spring-integration-test-mcp .
# Or using Podman
podman build -t spring-integration-test-mcp .2.将配置添加到Spring Boot项目中
创建 .mcp.json 在您想要测试的任何Spring Boot项目中:
{
"mcpServers": {
"spring-integration-test": {
"command": "docker",
"args": ["run", "-i", "--rm", "-v", ".:/workspace", "spring-integration-test-mcp"]
}
}
}替换docker和podman如果使用Podman。 对于Codex CLI,请使用全局config.toml以下示例代替.mcp.json.
3.启动克劳德代码
cd /path/to/your/spring-boot-project
claudeClaude Code将提示您批准MCP服务器。批准后,运行 /mcp 以验证它是否已连接。
4.启动Codex CLI(全局配置)
将其添加到Codex配置文件中(通常 ~/.codex/config.toml 在Windows上: C:\Users\brandon.baker\.codex\config.toml):
[mcp_servers.spring-integration-test]
command = "docker"
args = ["run", "-i", "--rm", "-v", "C:\\path\\to\\spring-boot-project:/workspace", "spring-integration-test-mcp"]保存后重新启动Codex config.toml。当Codex使用工具时,服务器会按需启动。
可用工具
环境
check_environment-验证Maven、Java、Docker/Podman的可用性
设置阶段
check_spring_boot_version-检测Spring Boot 2与3,javax与jakartafind_missing_properties-查找测试配置中缺少的@Value属性find_beans_needing_exclusion-查找需要@Profile的bean(“!test”)
调查阶段
investigate_jwt_claims-提取JWT索赔结构investigate_response_wrapper-检查{data:…}响应包装器investigate_entity_relationships-映射实体依赖关系investigate_service-分析服务依赖关系和异常analyze_controller-提取端点、HTTP方法、身份验证要求analyze_repository-提取查询方法,软删除信息check_json_naming_strategy-检测camelCase与snake_case
验证阶段
validate_maven_compile-运行编译并返回结构化通过/失败run_test_checkpoint-运行测试并返回解析结果
示例用法
Use check_environment with projectPath "/workspace"
Use analyze_controller with projectPath "/workspace" and controllerName "UserController"
Use run_test_checkpoint with projectPath "/workspace" and testClass "UserControllerTest"替代方案:不使用Docker运行
如果你不想使用Docker:
# Build
cd spring-integration-test-mcp
npm install
npm run build
# Create .mcp.json in your Spring Boot project
{
"mcpServers": {
"spring-integration-test": {
"command": "node",
"args": ["/absolute/path/to/spring-integration-test-mcp/dist/index.js"]
}
}
}Distrobox(Bazzite/不可变Fedora)注释
如果您在Distrobox容器内运行Codex,则在容器内运行Podman 可能会因存储数据库不匹配(主机与容器路径)而失败。在这种情况下,使用 以下两种方法之一。
选项A(推荐):直接使用Node运行MCP服务器
在容器内构建:
npm run build然后将Codex指向已编译的入口点:
[mcp_servers.spring-integration-test]
command = "node"
args = ["/home/brandon/Dev/spring-integration-test-mcp/dist/index.js"]选项B:从Distrobox内部使用主机Podman
在主机上构建映像:
podman build -t spring-integration-test-mcp /home/brandon/Dev/spring-integration-test-mcp然后通过以下方式致电主持人波德曼 distrobox-host-exec:
[mcp_servers.spring-integration-test]
command = "distrobox-host-exec"
args = ["podman","run","-i","--rm","-v","/home/brandon/Dev/your-spring-project:/workspace","spring-integration-test-mcp"]故障排除
MCP服务器未出现
- 创建后重新启动Claude代码
.mcp.json - 跑
/mcp检查服务器状态
找不到Docker映像
docker images | grep spring-integration-test-mcp如果未列出,请重建映像。
装载卷上的权限错误
使用您的用户ID进行重建:
docker build --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) -t spring-integration-test-mcp .平台支持
- Linux、macOS、Windows
- Docker或Podman
- 自动检测
mvn对比mvn.cmd
