pytest-mcp-server
MCP server for debugging pytest failures, allowing users to register test failures, apply systematic debugging principles, and analyze failure patterns.
README
Pytest MCP Server
A Model Context Protocol (MCP) server for debugging pytest failures using systematic debugging principles.
✅ Status: Production Ready
This MCP server is fully functional and ready for use. All 8 tools work correctly with proper error handling and response formatting that complies with the official MCP specification.
🧪 Testing Status
✅ Server Functionality: Perfect
- All tools work correctly with valid inputs
- Proper error handling for invalid inputs
- Compliant with MCP error reporting standards
- Successfully tested with direct JSON-RPC calls
- Compatible with MCP Inspector and real MCP clients
⚠️ Framework Testing Limitation: Known Issue
- MCP Testing Framework shows 1 validation error due to a bug in mcp-framework 0.2.13
- Root Cause: mcp-framework returns validation errors with
"type": "error"instead of MCP-compliant"type": "text" - Impact: Testing framework validation fails, but server works perfectly in real usage
- Status: Documented issue, affects testing only, not production functionality
This is a known pattern documented in the official Standardized Error Reporting Formats for Model Context Protocol Servers document regarding SDK implementation challenges.
🛠 Tools Available
- register_pytest_failure - Register a new test failure
- list_failures - List all registered failures
- get_failure_info - Get detailed information about a specific failure
- debug_with_principle - Apply debugging principles systematically
- analyze_failures - Analyze patterns in test failures
- generate_debug_prompt - Generate LLM prompts for debugging
- pytest_docs_guide - Get pytest documentation guidance
- example_tool - Example tool for testing
🚀 Quick Start
Installation
npm install -g pytest-mcp-server
Usage with Claude Desktop
Add to your Claude Desktop MCP configuration:
{
"mcpServers": {
"pytest-mcp-server": {
"command": "pytest-mcp-server",
"args": ["start"],
"env": {
"DATA_DIR": "./pytest-data"
}
}
}
}
Usage as HTTP Server
# Start HTTP server on port 3001
pytest-mcp-server start-http
# Or specify custom port
PORT=8080 pytest-mcp-server start-http
Direct Usage
# Start MCP server (stdio mode)
pytest-mcp-server start
# Test with MCP Inspector
npx @modelcontextprotocol/inspector pytest-mcp-server start
📋 Example Usage
1. Register a Test Failure
{
"name": "register_pytest_failure",
"arguments": {
"test_name": "test_user_authentication",
"file_path": "/tests/test_auth.py",
"line_number": 45,
"error_message": "AssertionError: Expected status 200, got 401",
"traceback": "Full traceback here..."
}
}
2. Apply Debugging Principles
{
"name": "debug_with_principle",
"arguments": {
"failure_id": "1234567890",
"principle_number": 1,
"analysis": "This test is checking user authentication flow. The system expects a valid JWT token but seems to be receiving an invalid or expired token."
}
}
3. Get Failure Analytics
{
"name": "analyze_failures",
"arguments": {
"analysis_type": "patterns"
}
}
🔧 Development
Prerequisites
- Node.js 18.19.0 or higher
- npm or yarn
Setup
# Clone the repository
git clone <repository-url>
cd pytest-mcp-server
# Install dependencies
npm install
# Build the project
npm run build
# Start development server
npm run watch
Testing
# Test with simple script
./test-simple.sh
# Test with MCP Testing Framework (shows known validation issue)
mcp-test --test-config mcp-test-config.json --test-mcp-servers
# Test with Dagger (containerized testing)
./test-dagger-simple.sh
📁 Data Storage
The server stores data in JSON files:
failures.json- Test failure recordsdebug_sessions.json- Debugging session data
Default location: ./data/ (configurable via DATA_DIR environment variable)
🐛 Known Issues
MCP Framework Validation Error
- Issue: mcp-framework 0.2.13 returns validation errors with non-compliant
"type": "error" - Expected: MCP specification requires
"type": "text"for all error content - Impact: MCP Testing Framework validation fails (false negative)
- Workaround: Use direct testing or MCP Inspector for validation
- Status: Reported to framework maintainers
See framework-issue-report.md for detailed technical analysis.
🤝 Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
📄 License
MIT License - see LICENSE file for details.
🔗 Related
Note: This server is production-ready and fully functional. The testing framework validation issue is a known limitation of the current mcp-framework implementation and does not affect real-world usage.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。