WV

webfansplz/vite-plugin-vue-mcp

浏览器自动化

本页由 AI 翻译,技术细节请以原文为准。 查看原文

578 stars 33 forks 质量 62 趋势 21MIT

Vite 插件,支持一个 MCP 服务器,帮助模型更好地理解你的 Vue 应用。

概览

![NPM版本][npm-版本-href]![npm下载][npm-downloads-href]![捆绑包][捆绑包-href]![许可证][许可证-href] Vite 插件,使你的 Vue 应用的 MCP 服务器能够提供关于组件树、状态、路由以及 Pinia 树和状态的信息。 然后MCP服务器将在[[T0]处开放。 如果你用的是Cursor,在项目根创建一个.cursor/mcp.json文件,这个插件会自动帮你更新。想了解更多MCP的细节,请查看官方Cursor文档。 get-component-tree:获取 Vue 组件树。 get-component-state:获取组件的状态(输入:componentName)。 edit-component-state:编辑组件的状态(输入:componentName, path, value, valueType)。 highlight-component:高亮一个组件(输入:componentName)。

概述(AI 翻译)

Vite 插件,使你的 Vue 应用的 MCP 服务器能够提供关于组件树、状态、路由以及 Pinia 树和状态的信息。

安装 📦

用途 🔨

然后MCP服务器将在http://localhost:[port]/__mcp/sse开放。

如果你使用光标,请在项目根创建 .cursor/mcp.json 文件,这个插件会自动帮你更新。想了解更多关于 MCP 的细节,请查看官方光标文档。

选项

功能/工具 ✨

获取组件树

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

获取组件状态

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

编辑组件状态

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

高光组件

highlight-component:高亮一个组件(输入:componentName)。

获取路线

get-router-info:获取应用的Vue路由器信息。

去拿松树

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

去皮尼亚州

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

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

vite-plugin-vue-mcp

[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![bundle][bundle-src]][bundle-href] [![License][license-src]][license-href]

Vite plugin that enables a MCP server for your Vue app to provide information about the component tree, state, routes, and pinia tree and state.

Installation 📦

pnpm install vite-plugin-vue-mcp -D

Usage 🔨

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

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

Then the MCP server will be available at http://localhost:[port]/__mcp/sse.

If you are using Cursor, create a .cursor/mcp.json file in your project root, this plugin will automatically update it for you. For more details about the MCP, check the official Cursor documentation.

Options

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

  /**
   * 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

  /**
   * 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
}

Features/Tools ✨

Get Component Tree

get-component-tree: Get the Vue component tree.

Get Component State

get-component-state: Get the state of a component (input: componentName).

Edit Component State

edit-component-state: Edit the state of a component (input: componentName, path, value, valueType).

Highlight Component

highlight-component: Highlight a component (input: componentName).

在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →