Tox 测试 MCP 服务器
一个 MCP 服务器,它执行 tox 命令,使用 pytest 在项目中运行 Python 测试。该服务器通过模型上下文协议 (MCP) 提供了一种便捷的方法来运行和管理 Python 测试。
特征
工具
Related MCP server: Lodestar MCP Server
发展
安装依赖项:
构建服务器:
对于使用自动重建的开发:
安装
要与 VSCode 一起使用,请将服务器配置添加到您的 MCP 设置文件中: ~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
{
"mcpServers": {
"tox-testing": {
"command": "node",
"args": ["/path/to/tox-testing/build/index.js"],
"env": {
"TOX_APP_DIR": "/path/to/your/python/project",
"TOX_TIMEOUT": "600"
}
}
}
}
配置选项
超时对于以下情况尤其重要:
防止测试进程挂起
管理长期运行的集成测试
确保 CI/CD 管道不会卡住
用法
服务器提供了一个可以在不同模式下使用的单一工具run_tox_tests :
工具参数
// Run all tests
{
"mode": "all"
}
// Run tests from a specific group
{
"mode": "all",
"group": "api"
}
// Run tests from a specific file
{
"mode": "file",
"testFile": "tests/test_api.py"
}
// Run a specific test case
{
"mode": "case",
"testFile": "tests/test_api.py",
"testCase": "test_endpoint_response"
}
// Run tests from a specific directory
{
"mode": "directory",
"directory": "tests/api/"
}
与 Cline 一起使用
将此 MCP 与 Cline 配合使用时,您可以配置 Cline 的自定义指令,以高效地处理测试执行。以下是推荐的工作流程:
If asked to run tests on the project, use the tox-testing MCP. Follow these steps:
1. Run all tests across the project unless you are given instructions to run a specific test file or test case.
2. Review and rerun each failed test case individually as you troubleshoot and fix the issue from its output.
3. Repeat step 2 until the testcase passes.
4. Once all failed test cases from step 1 are passing rerun all tests again and repeat all steps until all tests pass.
此工作流程可确保:
首先运行所有测试,实现全面的测试覆盖
通过隔离失败的测试用例进行重点调试
通过重新测试个别案例来验证修复
通过再次运行所有测试进行最终验证
与 Cline 的互动示例:
You: Run the tests for this project
Cline: I'll use the tox-testing MCP to run all tests:
{
"mode": "all"
}
You: Fix the failing test in test_api.py
Cline: I'll first run the specific test file:
{
"mode": "file",
"testFile": "tests/test_api.py"
}
Then address each failing test case individually:
{
"mode": "case",
"testFile": "tests/test_api.py",
"testCase": "test_endpoint_response"
}
贡献
请参阅CONTRIBUTING.md了解我们的行为准则和提交拉取请求的流程的详细信息。