t

tox测试

@that1guy15/tox-testing
0 Stars 13 次浏览 that1guy15 更新于 2026-08-23

一个MCP服务器,用于执行tox命令,在使用pytest的项目中运行Python测试,允许用户运行所有测试或特定的测试组、文件、用例或目录。

该服务暂未提供标准配置,请参考 README 手动接入

可用工具 (1 个)

该服务在 MCP 协议中暴露的工具,AI 可按需调用

run_tox_tests 5 个参数 需填 1 项

Run tox tests with different modes and options

必填参数:mode

服务介绍

Tox 测试 MCP 服务器

一个使用 pytest 在项目中执行 tox 命令来运行 Python 测试的 MCP 服务器。该服务器通过 Model Context Protocol (MCP) 提供了一种方便的方式来运行和管理 Python 测试。

功能

工具

  • run_tox_tests - 以各种模式和选项执行 tox 测试
    • 支持不同的执行模式:
      • all: 运行所有测试或特定组中的测试
      • file: 运行特定文件中的测试
      • case: 运行特定的测试用例
      • directory: 运行指定目录中的所有测试
    • 支持的测试组:
      • clients: 客户端相关的测试
      • api: API 端点测试
      • auth: 认证测试
      • uploads: 上传功能测试
      • routes: 路由处理程序测试

开发

安装依赖项:

npm install

构建服务器:

npm run build

开发时自动重建:

npm run watch

安装

要与 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"
      }
    }
  }
}

配置选项

  • env.TOX_TIMEOUT: (可选) 等待测试执行完成的最大时间(秒)。如果测试运行时间超过此超时时间,它将被终止。默认值为 600 秒(10 分钟)
  • env.TOX_APP_DIR: (必需) 包含 tox.ini 文件的目录。这是将执行 tox 命令的位置。路径应指向包含 tox.ini 的 Python 项目的根目录。

超时对于以下情况尤为重要:

  • 防止挂起的测试进程
  • 管理长时间运行的集成测试
  • 确保 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 了解有关我们的行为准则以及提交拉取请求过程的详细信息。

相关 MCP 服务