Skip to main content
Glama

Vitest Migrator MCP (vitest-migrator-mcp)

A Model Context Protocol (MCP) Server that provides automated AST codemods, multi-project test runner scaffolding, and self-learning diagnostic tools for migrating JavaScript/TypeScript packages from legacy test runners (Karma, Webpack, Mocha) to Vitest (Node and Playwright Chromium browser testing).


Prerequisites

  • Node.js: >= 18.0.0 (Node 20 or Node 22 recommended)

  • Package Manager: npm, yarn, or pnpm

  • Supported OS: Linux, macOS, Windows (WSL / Native)


Related MCP server: MCP Server - Test Migration (WDIO to Playwright)

Installation & Setup

1. Clone and Build Locally

# Clone the repository
git clone https://github.com/Manvi1203/vitest-migrator-mcp.git
cd vitest-migrator-mcp

# Install dependencies
npm install

# Build TypeScript to dist/
npm run build

This generates the executable entry point at dist/index.js.


Connecting to MCP Clients

The server communicates via standard I/O (stdio). You can register it in any MCP-compatible AI assistant or editor.

A. Claude Desktop

Add the server to your claude_desktop_config.json:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

  • Linux: ~/.config/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "vitest-migrator": {
      "command": "node",
      "args": ["/ABSOLUTE/PATH/TO/vitest-migrator-mcp/dist/index.js"]
    }
  }
}

B. Cursor / VS Code (Cline / Roo Code / MCP Extension)

Add to your MCP configuration file (mcp.json or Extension settings):

{
  "mcpServers": {
    "vitest-migrator": {
      "command": "node",
      "args": ["/ABSOLUTE/PATH/TO/vitest-migrator-mcp/dist/index.js"]
    }
  }
}

C. Gemini CLI / Jetski / Antigravity

Add to your workspace or global mcp_config.json:

{
  "mcpServers": {
    "vitest-migrator": {
      "command": "node",
      "args": ["/ABSOLUTE/PATH/TO/vitest-migrator-mcp/dist/index.js"]
    }
  }
}

Exposed MCP Tools Reference

The server exposes 7 specialized tools designed for test suite analysis, transformation, and verification:

Tool

Parameters

Description

vitest_classify_package

packagePath: string

Inspects package.json, test directories, and karma configs to classify the package tier (tier1: standard unit, tier2: emulator/integration, tier3: complex multi-target/platform aliased).

vitest_scaffold_config

packagePath: string, tier?: string

Scaffolds unified vitest.config.mjs (Node + Chromium projects), src/types/vitest-globals.d.ts, and test/setup.ts, and updates package.json test scripts with Playwright guards.

vitest_apply_ast_codemods

packagePath: string

Executes deterministic AST transformations (ts-morph) to fix type-only re-exports (export type), chained Mocha .timeout(ms), this.test.fullTitle(), and CommonJS require() imports.

vitest_run_verification

packagePath: string, target: "vitest-browser" | "vitest-node" | "mocha-node"

Executes the test suite in headless mode and parses test execution outputs into structured JSON pass/fail diagnostics.

vitest_lookup_knowledge_bank

errorMessage: string

Matches runtime errors against indexed error signatures and returns root cause explanations and recommended code transforms.

vitest_record_learning

errorPattern: string, rule: string, rootCause: string, fixStrategy: "AST_TRANSFORM" | "AI_PROMPT"

Dynamically adds newly discovered error patterns and resolution strategies to data/knowledge-bank.json.

vitest_list_knowledge_rules

(none)

Returns all active rules and diagnostic patterns stored in the knowledge base.


Step-by-Step Package Migration Workflow

When migrating a package with an AI agent or automated script, follow this structured pipeline:

flowchart TD
    A[1. vitest_classify_package] --> B[2. vitest_scaffold_config]
    B --> C[3. vitest_apply_ast_codemods]
    C --> D[4. vitest_run_verification]
    D -->|Pass| E[5. Complete]
    D -->|Fail| F[6. vitest_lookup_knowledge_bank]
    F --> G[7. Apply Fix & vitest_record_learning]
    G --> D

1. Classify the Package

Inspect complexity, target runtime, and emulator dependencies:

{
  "name": "vitest_classify_package",
  "arguments": {
    "packagePath": "/path/to/my-monorepo/packages/auth"
  }
}

2. Scaffold Configs & Dependencies

Generate multi-project configurations and package scripts:

{
  "name": "vitest_scaffold_config",
  "arguments": {
    "packagePath": "/path/to/my-monorepo/packages/auth",
    "tier": "tier3"
  }
}

3. Run Deterministic AST Codemods

Automatically rewrite syntax that differs between Karma/Webpack and Vitest ESM:

{
  "name": "vitest_apply_ast_codemods",
  "arguments": {
    "packagePath": "/path/to/my-monorepo/packages/auth"
  }
}

4. Execute Verification Loop

Run browser and Node unit tests headlessly:

{
  "name": "vitest_run_verification",
  "arguments": {
    "packagePath": "/path/to/my-monorepo/packages/auth",
    "target": "vitest-browser"
  }
}

5. Diagnose & Record Fixes

If a test failure occurs, query the Knowledge Bank or save the solution:

{
  "name": "vitest_lookup_knowledge_bank",
  "arguments": {
    "errorMessage": "TypeError: Cannot redefine property: getAuth"
  }
}

Architecture & File Layout

vitest-migrator-mcp/
├── data/
│   └── knowledge-bank.json      # Persistent error signatures and fix rules
├── src/
│   ├── index.ts                 # MCP Server entrypoint (stdio protocol handler)
│   ├── templates/               # Boilerplate templates injected during scaffolding
│   │   ├── setup.ts.tpl         # Browser test setup (Chai, Sinon, Mocha aliases)
│   │   ├── setup.node.ts.tpl    # Node test setup
│   │   ├── vitest.config.mjs.tpl# Multi-project runner config
│   │   └── vitest-globals.d.ts.tpl # Ambient typing definitions
│   └── tools/
│       ├── classifier.ts        # Package analysis logic
│       ├── scaffolder.ts        # Config & package.json injector
│       ├── codemods.ts          # ts-morph AST transformations
│       ├── runner.ts            # Test execution and stdout parser
│       └── knowledgeBank.ts     # Diagnostic knowledge lookup and rule persistence
├── package.json
└── tsconfig.json

Development & Maintenance

Build from Source

npm run build

Watch Mode

npm run watch

Test Stdio Directly

You can run the server directly in terminal to verify startup:

node dist/index.js

License

Apache-2.0

F
license - not found
A
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    C
    quality
    D
    maintenance
    Enables comprehensive analysis of JavaScript/TypeScript project testing setups by detecting frameworks like Jest, Vitest, and Cypress, analyzing test coverage metrics, and generating actionable recommendations for improving test quality. Provides detailed insights into test structure, dependencies, and coverage thresholds with visual feedback.
    3
    1
  • A
    license
    B
    quality
    D
    maintenance
    Enables AI agents to safely upgrade JavaScript and TypeScript projects through dependency analysis, upgrade path detection, breaking change identification, codemod application, and PR summary generation.
    14
    28
    MIT

View all related MCP servers

Related MCP Connectors

  • Flaky test detection, root cause analysis, and fix suggestions for development teams.

  • AI Agent with Architectural Memory. Impact analysis (free), tests and code from the graph (pro).

  • AI QA tester — real browsers scan sites for bugs, SEO, perf, and accessibility issues via chat.

View all MCP Connectors

Latest Blog Posts

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/Manvi1203/vitest-migrator-mcp'

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