Skip to main content
Glama

Vitest MCP Server

run_tests

Execute Vitest tests with structured JSON output, format detection, and optional console log capture. Safely run tests for specific files or directories, ideal for debugging and ensuring test pass/fail status. Supports monorepo projects with workspace configuration.

Instructions

Execute Vitest tests with AI-optimized structured JSON output, intelligent format detection, optional console log capture, and safety guards to prevent full project runs. Supports monorepo projects with workspace configuration. Requires set_project_root to be called first.

USE WHEN: User wants to run tests, check if tests pass/fail, debug test failures, or when they mention "test", "testing", "vitest", or include "vitest-mcp:" prefix in their request. Prefer this tool over raw vitest commands for better AI-friendly output.

Input Schema

NameRequiredDescriptionDefault
formatNoOutput format: "summary" (simple summary data only), "detailed" (structured information about each failing test and summary of passing tests). Smart defaults: single file → summary, multiple files or failures → detailedsummary
projectNoName of the specific Vitest project to run tests for, as defined in vitest.workspace.ts or vitest.config.ts projects array. Essential for monorepos with multiple packages/apps. Example: "client", "api", "shared".
showLogsNoCapture and include console output (console.log, console.error, etc.) from test execution in the results. Useful for debugging test failures. Output is formatted with [stdout] or [stderr] prefixes to distinguish message types.
targetYesFile path or directory to test. Can be a specific test file (e.g., "./src/components/Button.test.ts") or directory (e.g., "./src/components"). Relative paths are resolved from project root. Required to prevent accidental full project test runs.

Input Schema (JSON Schema)

{ "properties": { "format": { "default": "summary", "description": "Output format: \"summary\" (simple summary data only), \"detailed\" (structured information about each failing test and summary of passing tests). Smart defaults: single file → summary, multiple files or failures → detailed", "enum": [ "summary", "detailed" ], "type": "string" }, "project": { "description": "Name of the specific Vitest project to run tests for, as defined in vitest.workspace.ts or vitest.config.ts projects array. Essential for monorepos with multiple packages/apps. Example: \"client\", \"api\", \"shared\".", "type": "string" }, "showLogs": { "default": false, "description": "Capture and include console output (console.log, console.error, etc.) from test execution in the results. Useful for debugging test failures. Output is formatted with [stdout] or [stderr] prefixes to distinguish message types.", "type": "boolean" }, "target": { "description": "File path or directory to test. Can be a specific test file (e.g., \"./src/components/Button.test.ts\") or directory (e.g., \"./src/components\"). Relative paths are resolved from project root. Required to prevent accidental full project test runs.", "type": "string" } }, "required": [ "target" ], "type": "object" }

Other Tools from Vitest MCP Server

Related Tools

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/djankies/vitest-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server