Skip to main content
Glama
BrightX

rsbuild-plugin-vue-mcp

by BrightX

Rsbuild plugin VueDevTools MCP

언어 / 语言: English | 中文

Vue DevTools 기반의 Rsbuild/Rspack MCP 플러그인입니다.

Rsbuild 1.x/2.x 및 Rspack 1.x/2.x를 지원합니다.

Model Context Protocol (MCP)를 통해 AI 도구(예: IDE 어시스턴트 및 에이전트)는 Vue 애플리케이션의 상태를 실시간으로 읽고 조작할 수 있습니다. 즉, "애플리케이션을 이해하는 AI"를 실현합니다.

이 플러그인은 birpc over WebSocket을 통해 개발 서버와 앱 페이지 내부에서 실행 중인 Vue DevTools를 연결하고, AI가 컴포넌트·라우터·Pinia 스토어를 검사하고 컴포넌트 상태를 직접 편집할 수 있는 MCP 도구 세트를 노출합니다.

주요 기능

  • 🔌 제로 구성 MCP 서버 — 기존 개발 서버에 자동으로 마운트됩니다(별도 프로세스 불필요).

  • 🌳 실행 중인 앱의 컴포넌트 트리 검사 — 트리 구조로 표시.

  • 🧩 Vue 컴포넌트 상태 조회 및 편집 (reactive data, props, computed, refs…).

  • 🔦 페이지의 컴포넌트 강조 표시 — 시각적으로 위치 확인.

  • 🧭 Vue Router 정보 조회 (현재 라우트, matched records, params, query…).

  • 🗄️ Pinia 검사 — 스토어 트리 탐색 및 개별 스토어 상태 조회.

  • ⚡️ Rsbuild 및 Rspack 개발 서버에서 모두 동작.

Related MCP server: vue-mcp-next

사용법

Install

# For npm
npm add rsbuild-plugin-vue-mcp -D

# For yarn
yarn add rsbuild-plugin-vue-mcp -D

# For pnpm
pnpm add rsbuild-plugin-vue-mcp -D

Rsbuild

// rsbuild.config.js
import { defineConfig } from '@rsbuild/core';
import { pluginVue } from '@rsbuild/plugin-vue';
import { pluginVueMcp } from "rsbuild-plugin-vue-mcp";

export default defineConfig({
    plugins: [
        pluginVue(),
        pluginVueMcp(),
    ],
});

Rspack

// rspack.config.js
import { defineConfig } from '@rspack/cli';
import { rspack } from "@rspack/core";
import { VueLoaderPlugin } from 'rspack-vue-loader';
import { VueMcpPlugin } from 'rsbuild-plugin-vue-mcp/rspack';

export default defineConfig({
    plugins: [
        new rspack.HtmlRspackPlugin(),
        new VueLoaderPlugin(),
        new VueMcpPlugin(),
    ],
    module: {
        rules: [
            {
                test: /\.vue$/,
                loader: 'rspack-vue-loader',
                options: {
                    experimentalInlineMatchResource: true,
                },
            },
        ],
    },
});

MCP 서버(Streamable HTTP transport)는 http://localhost:[port]/__mcp/mcp에서 사용할 수 있습니다.

요구 사항: 플러그인이 내부 HTTP 서버에 연결되도록 @rsbuild/core >= 1.2.9(Rsbuild용) 또는 @rspack/core >= 1.3.0(Rspack용)이 필요합니다.

MCP 클라이언트 연결

개발 서버를 시작합니다(보통 npm run dev). 콘솔에 MCP 서비스 URL이 출력됩니다. 예:

➜  MCP:     Server is running at http://localhost:5173/__mcp/mcp

해당 URL을 클라이언트의 MCP 구성(Cursor, Claude Desktop, VS Code 등)에 추가하세요:

{
  "mcpServers": {
    "vue-mcp": {
      "type": "streamable-http",
      "url": "http://localhost:<YourPort>/__mcp/mcp",
      "disabled": false
    }
  }
}

[!IMPORTANT] MCP 도구를 실제로 호출하고 앱을 디버깅하려면 두 가지가 필요합니다:

  1. 개발 서버가 실행 중이어야 합니다(MCP 서버가 활성화됨).

  2. 브라우저에서 앱 페이지를 열어 두어야 합니다 (예: http://localhost:5173). 그러면 주입된 overlay.js가 WebSocket을 통해 개발 서버에 연결되고 Vue DevTools 런타임을 노출합니다.

도구는 WebSocket 연결을 통해 실시간 앱에 접근합니다. 앱 페이지가 열려 있지 않으면 도구 호출이 실패하거나 시간 초과됩니다.

페이지가 열리면 AI 어시스턴트가 실행 중인 개발 앱에서 아래 도구를 호출할 수 있습니다.

MCP 도구

이 플러그인은 MCP 서버에 다음 도구를 등록합니다. 각 도구는 birpc를 통해 앱 페이지와 통신하므로 데이터는 항상 실시간 애플리케이션을 반영합니다. 모든 도구는 결과를 JSON 형식 텍스트(마크다운 아님)로 반환합니다.

Tool

Description

Inputs

get-component-tree

Vue 컴포넌트 트리를 가져옵니다. 결과는 JSON 텍스트 페이로드로 반환됩니다.

—

get-component-state

컴포넌트 상태를 JSON으로 가져옵니다 (data, props, computed, refs…).

componentName: string

edit-component-state

컴포넌트 상태의 값을 (실시간 반응형으로) 편집합니다.

componentName: string, path: string[], value: string, valueType: 'string' | 'number' | 'boolean' | 'object' | 'array'

highlight-component

페이지에서 컴포넌트를 강조 표시합니다 (5초 후 자동 해제).

componentName: string

get-router-info

현재 Vue Router 정보를 JSON으로 가져옵니다 (route, matched records, params, query…).

—

get-pinia-tree

Pinia 스토어 트리를 JSON으로 가져옵니다.

—

get-pinia-state

단일 Pinia 스토어의 상태를 JSON으로 가져옵니다.

storeName: string

AI 워크플로우 예시

  • "현재 페이지의 컴포넌트 트리를 보여줘."

  • "UserCard 컴포넌트의 상태는 무엇인가요?"

  • "Counter에서 count를 10으로 설정해 줘." → edit-component-state 호출, UI가 즉시 업데이트됩니다.

  • "Navbar 컴포넌트를 강조 표시해 줘." → 브라우저에서 해당 요소가 강조됩니다.

  • "현재 라우트는 무엇이고, params는 무엇인가요?" → get-router-info 호출.

  • "cart Pinia 스토어의 상태를 보여줘."

작동 방식

이 플러그인은 개발 서버와 앱 페이지 사이에서 birpc를 RPC 계층으로, WebSocket을 전송으로 사용합니다.

graph TD
    subgraph A["MCP Host (AI Client)"]
        A1[MCP Client]
        A2[MCP Client]
    end

    subgraph B["MCP Server (Rsbuild/Rspack Dev Server)"]
        B1[MCP Tools<br/>get-component-tree / get-component-state / ...]
        B2[birpc group<br/>createRPCServer]
        B3[WebSocket Server<br/>/__vue-devtools-mcp-ws]
    end

    subgraph C["Vue App (Browser)"]
        C1[overlay.js injected]
        C2[birpc client]
        C3[Vue DevTools Kit<br/>devtools.api / ctx]
    end

    A <-- " streamable-http / SSE " --> B1
    B1 --> B2
    B2 <== " birpc over WebSocket " ==> B3
    B3 --> C1 --> C2 --> C3
  1. 주입 — 개발 서버가 시작되면 앱의 HTML에 overlay.js를 주입합니다(또는 appendTo가 설정된 경우 소스 모둘에 import를 추가). overlay.js가 @vue/devtools-kit을 초기화하고 /__vue-devtools-mcp-ws로 개발 서버에 WebSocket을 엽니다.

  2. RPC 브리지 — 개발 서버는 WebSocket 연결 위에 birpc 그룹 (createRPCServer)을 생성하고, overlay.js는 birpc 클라이언트(createBirpc)를 생성합니다. 서버의 요청은 앱으로 전달되고, hook 콜백(onInspectorTreeUpdated, onInspectorStateUpdated, …)으로 응답이 돌아옵니다.

  3. MCP 계층 — MCP 도구 핸들러(src/mcp/)가 birpc 클라이언트를 호출하여 앱에 접근하고, hookable hooks를 통해 응답을 기다려 도구 결과로 반환합니다.

이러한 두 단계 구조(MCP ↔ birpc ↔ DevTools)는 모든 도구 호출이 정적 스냅샷이 아닌 실행 중인 실제 앱을 검사하거나 변경한다는 뜻입니다.

구성

pluginVueMcp(options) (Rsbuild)와 new VueMcpPlugin(options) (Rspack)은 모두 동일한 옵션을 받습니다:

interface PluginVueMcpOptions {
    /** Host to listen on. Default: `localhost`. */
    host?: string

    /** Print the MCP server URL in the console. Default: `true`. */
    printUrl?: boolean

    /** Custom MCP server info (name/version). Ignored when `mcpServer` is provided. */
    mcpServerInfo?: { name?: string, version?: string, ... }

    /**
     * Customize or replace the MCP server instance. Called whenever a server is created.
     * You may register extra tools, or return a new McpServer to replace the default one.
     */
    mcpServerSetup?: (server: McpServer, api: RsbuildPluginAPI | Compiler) => void | Promise<void | McpServer>

    /** Path prefix for the MCP endpoint. Default: `/__mcp` (so the endpoint is `/__mcp/mcp`). */
    mcpPath?: string

    /**
     * Instead of injecting a <script> into HTML, append an import to modules whose id
     * matches this regex. Useful for projects without an HTML entry.
     * WARNING: only set this if you know exactly what it does.
     */
    appendTo?: string | RegExp
}

예시

기본 도구와 함께 추가 MCP 도구를 등록합니다:

pluginVueMcp({
    mcpServerSetup(server, api) {
        server.registerTool('ping', { description: 'Ping the dev server' }, async () => ({
            content: [{ type: 'text', text: 'pong' }],
        }))
    },
})

사용자 지정 MCP 엔드포인트 경로 사용:

pluginVueMcp({ mcpPath: '/my-mcp' })
// → http://localhost:<port>/my-mcp/mcp

요구 사항

  • Node.js >= 18

  • @rsbuild/core >= 1.2.9 || >= 2.0.0 (선택 peer, Rsbuild 플러그인용)

  • @rspack/core >= 1.3.0 || >= 2.0.0 (선택 peer, Rspack 플러그인용)

  • @vue/devtools-kit으로 계측된 Vue 3 애플리케이션 (주입된 overlay가 자동 처리).

디버깅

공식 MCP Inspector로 MCP 서버를 검사할 수 있습니다:

npx @modelcontextprotocol/inspector

그런 다음 Streamable HTTP transport를 사용하여 http://localhost:<YourPort>/__mcp/mcp로 연결하세요.

참고 / 크레딧

License

MIT

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    F
    maintenance
    Provides application insights for Vue apps by exposing component trees, state, routes, and Pinia data through a Model Context Protocol server.
    2,623 npm
    579
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables real-time debugging and state manipulation of Vue.js applications through MCP protocol, integrating with Vue DevTools to access component trees, states, router info, and Pinia stores.
    34 npm
    43
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    A Vite plugin that provides MCP server capabilities, enabling MCP clients to interact with browser environments through adapters for console, cookies, storage, performance, and component tree inspection.
    106 npm
    4
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    An MCP server for tailing Re.Pack/Rspack dev server logs. Enables AI assistants to query build logs, find errors, and monitor compilation status.
    5
    15 npm
    MIT