Run Vitest tests via MCP
## Vitest MCP Server: Next-Generation Testing Framework The **Vitest MCP Server** integrates the blazing-fast Vitest testing framework into Google Antigravity, providing modern, Vite-powered testing capabilities with instant feedback and native ESM support for contemporary development workflows. ### Why Vitest MCP? - **Instant Feedback**: Near-instantaneous test execution with intelligent caching and parallel processing - **Vite Integration**: Native Vite integration means shared configuration, plugins, and transformers with your app - **ESM Native**: First-class ES modules support without complex configuration or workarounds - **Watch Mode**: Smart watch mode that only re-runs affected tests for rapid development iteration - **Jest Compatible**: Compatible with Jest APIs making migration seamless for existing test suites ### 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 all Vitest tests in watch mode and show only failing tests with detailed output" }] ) ``` #### 2. Coverage Analysis ```python # Generate coverage response = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[{ "role": "user", "content": "Run Vitest with coverage and show files below 80% coverage threshold" }] ) ``` #### 3. Snapshot Testing ```python # Manage snapshots response = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[{ "role": "user", "content": "Update outdated snapshots for the Button component tests after style changes" }] ) ``` #### 4. Test Filtering ```python # Run specific tests response = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[{ "role": "user", "content": "Run only tests matching auth pattern and tests that failed in the last run" }] ) ``` ### Configuration ```json { "mcpServers": { "vitest": { "command": "npx", "args": ["-y", "@anthropic/mcp-server-vitest"], "env": { "VITEST_CONFIG_PATH": "vitest.config.ts", "VITEST_COVERAGE_ENABLED": "true" } } } } ``` ### Use Cases **TDD Workflow**: Rapid test-driven development with instant feedback on code changes. **Component Testing**: Test Vue, React, and Svelte components with native framework support. **API Testing**: Fast integration testing for API endpoints with parallel execution. **Migration from Jest**: Gradually migrate Jest tests to Vitest while maintaining compatibility. The Vitest MCP Server brings modern testing capabilities to your AI-assisted workflow, enabling faster iteration and higher confidence in code quality.
{
"mcpServers": {
"vitest": {
"mcpServers": {
"vitest": {
"args": [
"-y",
"vitest-mcp-server"
],
"command": "npx"
}
}
}
}
}