Sponsored by Deepsite.site

Pytest Mcp Server

Created By
tosin20137 months ago
A Model Context Protocol (MCP) server for debugging pytest failures using systematic debugging principles. 🛠 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
Content

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

  1. register_pytest_failure - Register a new test failure
  2. list_failures - List all registered failures
  3. get_failure_info - Get detailed information about a specific failure
  4. debug_with_principle - Apply debugging principles systematically
  5. analyze_failures - Analyze patterns in test failures
  6. generate_debug_prompt - Generate LLM prompts for debugging
  7. pytest_docs_guide - Get pytest documentation guidance
  8. 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 records
  • debug_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

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

📄 License

MIT License - see LICENSE file for details.


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.

Server Config

{
  "mcpServers": {
    "pytest-mcp-server": {
      "command": "pytest-mcp-server",
      "args": [
        "start"
      ],
      "env": {
        "DATA_DIR": "./pytest-data"
      }
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
WindsurfThe new purpose-built IDE to harness magic
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Serper MCP ServerA Serper MCP Server
ChatWiseThe second fastest AI chatbot™
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Playwright McpPlaywright MCP server
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Amap Maps高德地图官方 MCP Server
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
DeepChatYour AI Partner on Desktop
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
CursorThe AI Code Editor
Tavily Mcp
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.