Skip to main content
Glama
BrightX

rsbuild-plugin-vue-mcp

by BrightX

Rsbuild plugin VueDevtools MCP

Language / 语言: English | 中文

基于 Vue DevTools 的 Rsbuild/Rspack MCP 插件。

支持 Rsbuild 1.x/2.xRspack 1.x/2.x

通过 Model Context Protocol (MCP),AI 工具(例如 IDE 助手和代理)可以实时读取和操作你的 Vue 应用状态,真正实现“理解你应用的 AI”。

该插件通过 基于 WebSocket 的 birpc 将你的开发服务器与应用页面内运行的 Vue DevTools 连接起来,暴露一组 MCP 工具,让 AI 能够检查组件、路由和 Pinia stores,甚至直接编辑组件状态。

Features

  • 🔌 零配置 MCP 服务器 —— 自动挂载在你现有的开发服务器上(无需独立进程)。

  • 🌳 检查运行中应用的组件树

  • 🧩 读取和编辑 Vue 组件状态(响应式数据、props、computed、refs…)。

  • 🔦 在页面中高亮组件,以便直观定位。

  • 🧭 读取 Vue Router 信息(当前路由、匹配记录、params、query…)。

  • 🗄️ 检查 Pinia —— 浏览 store 树并读取单个 store 的状态。

  • ⚡️ 同时支持 RsbuildRspack 开发服务器。

Related MCP server: vue-mcp-next

使用方法

安装

# 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 传输)将可在 http://localhost:[port]/__mcp/mcp 访问。

要求:需要 @rsbuild/core >= 1.2.9(用于 Rsbuild)或 @rspack/core >= 1.3.0(用于 Rspack),这样插件才能挂载到底层 HTTP 服务器。

连接 MCP 客户端

启动开发服务器(通常是 npm run dev)。它会在控制台打印 MCP 服务地址,例如:

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

将该地址添加到你的 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 格式的文本(而非 Markdown)返回。

工具

描述

输入

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

以 JSON 形式获取当前 Vue Router 信息(路由、匹配记录、params、query…)。

get-pinia-tree

以 JSON 形式获取 Pinia store 树。

get-pinia-state

以 JSON 形式获取单个 Pinia store 的状态。

storeName: string

示例 AI 工作流

  • “显示当前页面的组件树。”

  • UserCard 组件当前的状态是什么?”

  • “将 Counter 中的 count 设置为 10。” → 调用 edit-component-state,UI 立即更新。

  • “高亮 Navbar 组件。” → 元素在浏览器中闪烁。

  • “我们当前在哪个路由?路由参数是什么?” → 调用 get-router-info

  • “显示 cart Pinia store 的状态。”

工作原理

该插件使用 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. 注入 —— 当开发服务器启动时,插件会将 overlay.js 注入到应用的 HTML 中(或当配置了 appendTo 时,将 import 附加到匹配的源码模块)。overlay.js 初始化 @vue/devtools-kit 并打开一个指向开发服务器 /__vue-devtools-mcp-wsWebSocket

  2. RPC 桥接 —— 开发服务器通过 WebSocket 连接创建一个 birpc 服务(createRPCServer)。overlay.js 创建一个 birpc 客户端(createBirpc)。来自服务器的请求被转发到应用;响应通过 hook 回调(onTreeUpdatedonStateUpdated、…)返回。

  3. MCP 层 —— MCP 工具处理器(src/mcp/server.ts)调用 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 >= 22

  • @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 传输下,将其指向 http://localhost:<你的端口>/__mcp/mcp

参考 / 致谢

License

MIT

A
license - permissive license
Not graded
quality - not tested
B
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

  • 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,375
    573
    MIT
  • A
    license
    Not graded
    quality
    C
    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
    44
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    This MCP server enables real-time debugging and inspection of running React Native apps, providing access to console logs, errors, network requests, navigation state, storage, and performance profiling.
    1
    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.
    32
    4
    MIT

View all related MCP servers

Related MCP Connectors

  • MCP server for interacting with the Supabase platform

  • MCP server for managing Prisma Postgres.

  • MCP server exposing the Backtest360 engine API as tools for AI agents.

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/BrightX/rsbuild-plugin-vue-mcp'

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