Skip to main content
Glama
NutUI-React MCP Service

NutUI-React MCP Service

by tony2026m

NutUI-React MCP Service

npm version license Node.js version

📖 介绍

nutui-react-mcp 是一个基于 Model Context Protocol (MCP) 的 NutUI-React 组件库智能助手服务。通过提供组件文档查询、API 文档、代码示例等功能,显著减少 AI 在生成 NutUI 组件代码时的幻觉问题,帮助开发者更准确、高效地使用 NutUI-React 组件库开发移动端应用。

核心特性

  • 🎯 精确的组件查询 - 支持 H5 和小程序(Taro)两种场景的组件列表查询

  • 📚 完整的文档支持 - 提供组件属性、API、使用方法等详细文档

  • 💡 代码示例获取 - 获取组件的外部示例代码,快速理解使用方法

  • 🚀 智能缓存机制 - 使用 node-cache 缓存查询结果,提升响应速度

  • 🔧 自动化文档提取 - 支持从 NutUI-React 仓库自动提取和更新组件文档

Related MCP server: MCP Vue UI Kit Server

📦 安装

全局安装

npm install -g @tony2026m/nutui-react-mcp

作为依赖安装

npm install @tony2026m/nutui-react-mcp

或使用 pnpm:

pnpm add @tony2026m/nutui-react-mcp

🚀 使用说明

启动 MCP 服务

# 使用全局安装
nutui-react-mcp

# 使用 npx
npx @tony2026m/nutui-react-mcp

# 本地开发
pnpm start

提取组件文档

# 从默认位置提取(../.temp/nutui-react)
nutui-react-mcp extract

# 从指定路径提取
nutui-react-mcp extract /path/to/nutui-react

在 Cursor/Claude Desktop 中配置

在 MCP 配置文件中添加(通常在 ~/Library/Application Support/Claude/claude_desktop_config.json 或 Cursor 配置中):

{
  "mcpServers": {
    "NutUI Components": {
      "command": "npx",
      "args": ["@tony2026m/nutui-react-mcp"]
    }
  }
}

可用工具

  1. list-components - 列出所有可用组件

    • 参数: isH5 (boolean) - 是否查询 H5 组件

  2. get-component-doc - 获取组件详细文档

    • 参数: isH5 (boolean) - 是否查询 H5 组件, componentName (string) - 组件名称

  3. get-component-example - 获取组件示例代码

    • 参数: src (string) - 示例代码路径

  4. get-nutui-info - 获取 NutUI 版本和简介信息

示例提示词

# 查询 H5 组件列表
我需要开发一个 H5 表单页面,有哪些可用的组件?

# 查询组件文档
告诉我 Form 组件在小程序中如何使用?

# 获取示例代码
获取 Form 组件基础用法的示例代码(路径:/form/demos/taro/demo1.tsx)

🔧 开发

环境要求

  • Node.js >= 20.0.0

  • pnpm (推荐)

  • Python 3.x (用于文档提取)

开发命令

# 安装依赖
pnpm install

# 开发模式(带 watch)
pnpm dev

# 构建
pnpm build

# 测试服务
pnpm test

# 使用 MCP Inspector 调试
pnpm inspector

🤝 参与贡献

欢迎贡献代码、报告问题或提出建议!

  1. Fork 本仓库

  2. 创建特性分支 (git checkout -b feature/AmazingFeature)

  3. 提交更改 (git commit -m 'Add some AmazingFeature')

  4. 推送到分支 (git push origin feature/AmazingFeature)

  5. 提交 Pull Request

📄 许可证

本项目采用 MIT 许可证。

🔗 相关链接

👤 作者

tony2026m


Available Tools

4 tools
get-component-docA

通过组件名称,获取 NutUI(NutUI-React) 特定组件的详细文档 适用场景:

  1. 用户询问如何使用特定组件

  2. 用户需要查看该组件的 api、props 属性,示例代码等

参数说明:isH5(是否H5页面,true:H5页面,false:非H5页面(小程序等)),componentName(组件名称)

Inputs: isH5 (required), componentName (required).

get-component-exampleB

获取外部示例代码,通过 src,获取 NutUI(NutUI-React) 特定组件的外部示例代码 适用场景:

  1. 用户询问组件特定的外部代码示例时

  2. 用户想要实现某个特定功能时直接告知可使用的代码例子

  3. 生成业务页面前,获取类似可用的外部代码示例

参数说明:src(外部代码示例的 src 属性)

Inputs: src (required).

get-nutui-infoA

获取 NutUI(NutUI-React) 简介、概况信息、version 适用场景:

  1. 用户询问什么是 NutUI(NutUI-React)

  2. 用户需要知道 NutUI(NutUI-React) 的版本信息时

Inputs: no named parameters.

list-componentsA

当用户请求做成一个新的移动端页面(UI),或实现新的移动端业务页面时,使用 NutUI(NutUI-React) 组件时使用此工具。 此工具仅返回可用的组件列表。 调用此工具后,你必须根据你的业务需求、来选择符合你业务需求的组件,编辑或添加前端页面代码实现 组件列表元素数据结构: `ts export interface ComponentData { // 组件名称 name: string; // 组件文档所在文件夹名称 dirName: string; // 组件描述 description: string; // 何时使用组件 whenToUse: string; }

参数说明:isH5(是否H5页面,true:H5页面,false:非H5页面(小程序等)) `

Inputs: isH5 (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 4 tools

    Disambiguation4/5

    The four tools target distinct stages: overview/version, component discovery, component documentation, and external example retrieval. The only mild overlap is between get-component-doc (which mentions example code) and get-component-example, but the descriptions distinguish them by source (internal docs vs external src).

    Naming Consistency4/5

    All names use kebab-case with a clear verb_noun structure (get-nutui-info, list-components, get-component-doc, get-component-example). Slight inconsistency: get-nutui-info omits the word 'component' present in the other get- tools, but it is still readable and predictable.

    Tool Count4/5

    Four tools is well-scoped for a component-library documentation server: info, list, doc, and examples. It is on the lean side but each tool clearly earns its place, so nothing feels padded or missing at the count level.

    Completeness4/5

    The surface covers the core documentation workflow: discover components, fetch detailed docs, and get example code, plus package metadata. A keyword-search tool over components and explicit isH5 filtering documentation are minor gaps an agent can work around via list-components.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers