mcpField
V
vite-plugin-vue-mcp

vite-plugin-vue-mcp

本地服务
github.com/webfansplz开发工具57883 周前更新

关于 vite-plugin-vue-mcp

vite-plugin-vue-mcp 是一个 Vite 插件,可为 Vue 应用启动 MCP 服务,让模型获取组件树、状态、路由以及 Pinia 的信息。它面向使用 Vue 进行开发的前端开发者。

主要功能

  1. 01获取 Vue 组件树
  2. 02读取与编辑组件状态
  3. 03高亮指定组件
  4. 04查询路由信息
  5. 05读取 Pinia 仓库树与状态

适用场景

  1. 01让 AI 助手理解 Vue 应用的组件结构
  2. 02调试时检查或修改组件状态
  3. 03排查 Pinia 状态与路由相关问题

MCP 相关

该插件在 Vite 开发服务器中提供 MCP 服务,以 SSE 端点向 MCP 客户端暴露组件、状态、路由和 Pinia 相关的工具。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

暂未收录安装方式

我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。

代码仓库

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

vite-plugin-vue-mcp

npm version npm downloads bundle License

Vite 插件,可为 Vue 应用启用 MCP 服务,提供有关组件树、状态、路由以及 Pinia 树和状态的信息。

安装 📦

pnpm install vite-plugin-vue-mcp -D

使用 🔨

// vite.config.ts
import { VueMcp } from 'vite-plugin-vue-mcp'

export default defineConfig({
  plugins: [VueMcp()],
})

随后,MCP 服务将在 http://localhost:[port]/__mcp/sse 上提供。

如果你使用 Cursor,请在项目根目录中创建 .cursor/mcp.json 文件,此插件会自动更新该文件。有关 MCP 的详细信息,请查看 Cursor 官方文档。

选项
export interface VueMcpOptions {
  /**
   * The host to listen on, default is `localhost`
   */
  host?: string

  /**
   * Print the MCP server URL in the console
   *
   * @default true
   */
  printUrl?: boolean

  /**
   * The MCP server info. Ingored when `mcpServer` is provided
   */
  mcpServerInfo?: McpServerInfo

  /**
   * Custom MCP server, when this is provided, the built-in MCP tools will be ignored
   */
  mcpServer?: (viteServer: ViteDevServer) => Awaitable<McpServer>

  /**
   * Setup the MCP server, this is called when the MCP server is created
   * You may also return a new MCP server to replace the default one
   */
  mcpServerSetup?: (server: McpServer, viteServer: ViteDevServer) => Awaitable<void | McpServer>

  /**
   * The path to the MCP server, default is `/__mcp`
   */
  mcpPath?: string

  /**
   * Update the address of the MCP server in the cursor config file `.cursor/mcp.json`,
   * if `.cursor` folder exists.
   *
   * @default true
   */
  updateCursorMcpJson?: boolean | {
    enabled: boolean
    /**
     * The name of the MCP server, default is `vue-mcp`
     */
    serverName?: string
  }

  /**
   * append an import to the module id ending with `appendTo` instead of adding a script into body
   * useful for projects that do not use html file as an entry
   *
   * WARNING: only set this if you know exactly what it does.
   * @default ''
   */
  appendTo?: string | RegExp
}

功能/工具 ✨

获取组件树

get-component-tree:获取 Vue 组件树。

组件树

获取组件状态

get-component-state:获取组件的状态(输入:componentName)。

组件状态

编辑组件状态

edit-component-state:编辑组件的状态(输入:componentName、path、value、valueType)。

编辑组件状态

高亮组件

highlight-component:高亮显示组件(输入:componentName)。

高亮组件

获取路由

get-router-info:获取应用的 Vue Router 信息。

路由树

获取 Pinia 树

get-pinia-tree:获取应用的 Pinia 树。

Pinia 树

获取 Pinia 状态

get-pinia-state:获取应用的 Pinia 状态(输入:storeName)。

Pinia 状态

架构 ⚡️

架构

注意 💡

使用这些功能前,请确保应用已在浏览器中运行。

致谢 💖

本项目的灵感来自 vite-plugin-mcp。感谢 @antfu 的出色工作。

许可证 📖

MIT 许可证 © Arlo

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。