Get the FREE Ultimate OpenClaw Setup Guide →

vitest

Advanced Model Context Protocol (MCP) server for Vitest testing with intelligent resources, coverage analysis, and AI-assisted development workflows

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio madrus-vitest-mcp-server npx -y @madrus/vitest-mcp-server@latest \
  --env VITEST_PROJECT_DIR="/Users/<your-username>/path/to/your/project/root"

How to use

This Vitest MCP Server enables AI assistants to run Vitest tests and generate coverage analyses within a project-specific context. It exposes tools for pinging the server, executing tests, and producing coverage reports, with the critical behavior of performing commands in the project's root directory so Vitest can locate vitest.config and related files. Use the run-vitest tool to execute your unit tests, view detailed results, and cache outcomes for efficient access by your AI assistant. Prefer run-vitest-coverage when you need a thorough coverage breakdown by file, including uncovered lines, branches, and function coverage, along with a status summary for quick assessment.

To use with your AI editor or assistant, configure the MCP server as described in the configuration section, ensuring the VITEST_PROJECT_DIR points to your project root. The server will invoke vitest commands in that directory, collect results, and expose them as resources like vitest://test-results, vitest://coverage-report, and vitest://test-summary for downstream tooling.

How to install

Prerequisites:\n- Node.js and npm installed on your machine\n- A Vitest-enabled project configured with vitest.config.* and package.json\n- Access to an MCP-compatible editor or runtime (e.g., Cursor, Claude Desktop)\n\nStep 1: Install the MCP server package globally (or use npx as configured in mcp_config)\n- Ensure npm is available, then you can rely on the npx invocation as part of your MCP configuration. Step 2: Create or update your MCP configuration file with the vitest-runner entry (see mcp_config). Step 3: Point the VITEST_PROJECT_DIR to your project root in the environment variables. Step 4: Restart your editor/assistant integration to pick up the new MCP server.\n\nOptional: Verify installation by testing the inspector or pinging the server through your editor’s MCP inspection tool.

Additional notes

Environment variable guidance:\n- VITEST_PROJECT_DIR must be an absolute path to your project root (where package.json and vitest.config.* reside).\n- The MCP server runs commands from within the specified project directory, so ensure the path is accessible from your development machine.\n- If vitest.config.* is missing or Vitest is not installed in the project, the tools may fail to run; ensure your project is set up correctly and that npm install has been run.\n- Use the MCP Inspector to test individual tools like ping, run-vitest, and run-vitest-coverage in a web interface before integrating with your AI assistant.

Related MCP Servers

Sponsor this space

Reach thousands of developers