Testing framework for MCP servers
## Pytest MCP Server: Python Testing Framework The **Pytest MCP Server** integrates the powerful Pytest testing framework into Google Antigravity, enabling comprehensive Python test execution, fixture management, and result analysis through AI-assisted workflows. ### Why Pytest MCP? - **Simple Syntax**: Write tests with minimal boilerplate using intuitive assert statements - **Powerful Fixtures**: Reusable test fixtures with flexible scoping and dependency injection - **Plugin Ecosystem**: Extensive plugins for coverage, parallel execution, and framework integration - **Parametrization**: Run tests with multiple input sets using simple decorators - **Detailed Output**: Clear failure messages with comprehensive traceback information ### Key Features #### 1. Test Execution ```python from anthropic import Anthropic client = Anthropic() response = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[{ "role": "user", "content": "Run pytest on tests/ directory with verbose output and stop on first failure" }] ) ``` #### 2. Coverage Analysis ```python # Check coverage response = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[{ "role": "user", "content": "Run pytest with coverage and show files below 80% threshold" }] ) ``` #### 3. Fixture Management ```python # Work with fixtures response = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[{ "role": "user", "content": "Create pytest fixtures for database setup with proper cleanup and scope" }] ) ``` #### 4. Test Selection ```python # Select tests response = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[{ "role": "user", "content": "Run only tests marked as slow and tests that failed in the last run" }] ) ``` ### Configuration ```json { "mcpServers": { "pytest": { "command": "npx", "args": ["-y", "@anthropic/mcp-server-pytest"], "env": { "PYTEST_CONFIG": "pytest.ini", "PYTEST_COVERAGE_MIN": "80" } } } } ``` ### Use Cases **Unit Testing**: Write and run comprehensive unit tests for Python applications. **Integration Testing**: Test component interactions with fixture-based setup and teardown. **CI/CD Integration**: Automate test execution in deployment pipelines with coverage gates. **TDD Workflow**: Support test-driven development with fast feedback loops. The Pytest MCP Server brings Python testing excellence to your AI-assisted workflow, enabling thorough testing with minimal friction.
{
"mcpServers": {
"pytest": {
"mcpServers": {
"pytest-mcp": {
"args": [
"install",
"pytest-mcp"
],
"command": "pip"
}
}
}
}
}