loading…
Search for a command to run...
loading…
An MCP-compliant server that enables the execution of pytest test suites and the storage of results into a QA platform database. It allows AI models to trigger
An MCP-compliant server that enables the execution of pytest test suites and the storage of results into a QA platform database. It allows AI models to trigger test runs, track execution progress, and retrieve historical test data through specialized tool interfaces.
一个基于 Model Context Protocol (MCP) 的测试执行服务器,支持执行 pytest 测试并将结果存储到 QA 平台数据库。
mcp-pytest-server/
├── src/ # 源代码目录
│ ├── __init__.py
│ ├── main.py # FastAPI 主应用
│ ├── mcp/ # MCP 协议实现
│ ├── pytest_executor/ # pytest 执行器
│ ├── database/ # 数据库操作
│ └── tools/ # 工具定义
├── tests/ # 测试代码
├── config/ # 配置文件
├── docs/ # 文档
└── requirements.txt # 依赖包
pip install -r requirements.txt
编辑 config/database.yaml 配置数据库连接。
python -m src.main
在 Goose 配置中添加 MCP 服务器:
mcp_servers:
pytest_server:
command: "python"
args: ["-m", "src.main"]
env:
DATABASE_URL: "sqlite:///./test_results.db"
POST /initialize - 初始化连接POST /tools/list - 列出可用工具POST /tools/call - 调用工具POST /resources/list - 列出资源POST /resources/read - 读取资源run_pytest_tests - 执行 pytest 测试
test_path (测试路径), options (pytest 选项)store_test_results - 存储测试结果到数据库
test_results (测试结果数据)get_test_history - 获取历史测试记录
limit (限制数量), project (项目名称)CREATE TABLE test_runs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
project_name TEXT NOT NULL,
test_path TEXT NOT NULL,
total_tests INTEGER,
passed INTEGER,
failed INTEGER,
skipped INTEGER,
duration REAL,
status TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE test_cases (
id INTEGER PRIMARY KEY AUTOINCREMENT,
run_id INTEGER,
test_name TEXT NOT NULL,
status TEXT,
duration REAL,
error_message TEXT,
stack_trace TEXT,
FOREIGN KEY (run_id) REFERENCES test_runs (id)
);
src/tools/ 目录下创建新的工具模块src/tools/__init__.py 中注册工具src/database/models.py 中添加新模型MIT License
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"mcp-pytest-server": {
"command": "npx",
"args": []
}
}
}Query your database in natural language
Read-only database access with schema inspection.
Interact with Redis key-value stores.
Database interaction and business intelligence capabilities.