Skip to main content
Glama
yun8711

Element-UI MCP Server

by yun8711

Search Element-UI Components

search_components

Search Element-UI component library by keyword to find components matching names or descriptions, helping developers locate UI elements for Vue 2 projects.

Instructions

根据关键词搜索 Element-UI 组件库中的组件。支持在组件名和描述中进行模糊匹配。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordYes搜索关键词
limitNo返回结果的最大数量,默认返回所有匹配结果

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
totalYes匹配到的组件总数
componentsYes

Implementation Reference

  • The core handler function for the 'search_components' tool. It filters components from the imported componentObject based on keyword matching in tagName or description, sorts by tagName, applies optional limit, maps to output format, and returns structuredContent and text content with results.
    async ({ keyword, limit }) => {
      const components = Object.values(componentObject)
    
      // 搜索匹配的组件
      const matchedComponents = components.filter(component => {
        const nameMatch = component.tagName.toLowerCase().includes(keyword.toLowerCase())
        const descMatch = component.description && component.description.toLowerCase().includes(keyword.toLowerCase())
        return nameMatch || descMatch
      })
    
      // 按标签名排序
      matchedComponents.sort((a, b) => a.tagName.localeCompare(b.tagName))
    
      // 限制返回数量
      const resultComponents = limit ? matchedComponents.slice(0, limit) : matchedComponents
    
      const list = resultComponents.map(component => ({
        tagName: component.tagName,
        description: component.description,
        docUrl: component.docUrl,
      }))
    
      return {
        structuredContent: {
          components: list,
          total: matchedComponents.length,
        },
        content: [
          {
            type: 'text' as const,
            text: `找到 ${matchedComponents.length} 个匹配的组件${limit && matchedComponents.length > limit ? `(显示前 ${limit} 个)` : ''}:\n\n${JSON.stringify({ components: list, total: matchedComponents.length }, null, 2)}`,
          },
        ],
      }
    }
  • Input and output schema definitions for the search_components tool, using Zod for validation. Input: keyword (string), optional limit (number). Output: array of components (tagName, description, docUrl) with total count.
    {
      title: 'Search Element-UI Components',
      description:
        '根据关键词搜索 Element-UI 组件库中的组件。支持在组件名和描述中进行模糊匹配。',
      inputSchema: z.object({
        keyword: z.string().describe('搜索关键词'),
        limit: z.number().optional().describe('返回结果的最大数量,默认返回所有匹配结果'),
      }),
      outputSchema: z.object({
        components: z.array(
          z.object({
            tagName: z.string().describe('组件标签名, 例如:el-button'),
            description: z.string().describe('组件描述'),
            docUrl: z.string().url().describe('组件文档URL'),
          })
        ),
        total: z.number().describe('匹配到的组件总数'),
      }),
    },
  • The registerSearchComponents function exports the registration of the 'search_components' tool to the MCP server, including schema and handler.
    export function registerSearchComponents(server: McpServer) {
      server.registerTool(
        'search_components',
        {
          title: 'Search Element-UI Components',
          description:
            '根据关键词搜索 Element-UI 组件库中的组件。支持在组件名和描述中进行模糊匹配。',
          inputSchema: z.object({
            keyword: z.string().describe('搜索关键词'),
            limit: z.number().optional().describe('返回结果的最大数量,默认返回所有匹配结果'),
          }),
          outputSchema: z.object({
            components: z.array(
              z.object({
                tagName: z.string().describe('组件标签名, 例如:el-button'),
                description: z.string().describe('组件描述'),
                docUrl: z.string().url().describe('组件文档URL'),
              })
            ),
            total: z.number().describe('匹配到的组件总数'),
          }),
        },
        async ({ keyword, limit }) => {
          const components = Object.values(componentObject)
    
          // 搜索匹配的组件
          const matchedComponents = components.filter(component => {
            const nameMatch = component.tagName.toLowerCase().includes(keyword.toLowerCase())
            const descMatch = component.description && component.description.toLowerCase().includes(keyword.toLowerCase())
            return nameMatch || descMatch
          })
    
          // 按标签名排序
          matchedComponents.sort((a, b) => a.tagName.localeCompare(b.tagName))
    
          // 限制返回数量
          const resultComponents = limit ? matchedComponents.slice(0, limit) : matchedComponents
    
          const list = resultComponents.map(component => ({
            tagName: component.tagName,
            description: component.description,
            docUrl: component.docUrl,
          }))
    
          return {
            structuredContent: {
              components: list,
              total: matchedComponents.length,
            },
            content: [
              {
                type: 'text' as const,
                text: `找到 ${matchedComponents.length} 个匹配的组件${limit && matchedComponents.length > limit ? `(显示前 ${limit} 个)` : ''}:\n\n${JSON.stringify({ components: list, total: matchedComponents.length }, null, 2)}`,
              },
            ],
          }
        }
      )
    }
  • src/index.ts:31-31 (registration)
    Calls registerSearchComponents during server setup to register the tool.
    registerSearchComponents(server);
  • src/index.ts:7-7 (registration)
    Imports the registerSearchComponents function from the tool module.
    import { registerSearchComponents } from './tools/search-components.js';
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions fuzzy matching in component names and descriptions, which adds some context, but doesn't cover other important aspects like whether this is a read-only operation, what the output format is, if there are rate limits, or any error conditions. For a search tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded: it's a single, efficient sentence that directly states the purpose and key feature (fuzzy matching). Every word earns its place, with no redundancy or unnecessary details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that there is an output schema (which covers return values), the description doesn't need to explain outputs. However, with no annotations and a search tool that likely has behavioral nuances (e.g., search scope, result ordering), the description is minimal. It's adequate for a basic search but lacks depth for more complex usage scenarios.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema already documents both parameters ('keyword' and 'limit') with descriptions. The description adds no additional meaning beyond what the schema provides, such as explaining the fuzzy matching algorithm or default behavior for 'limit'. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: '根据关键词搜索 Element-UI 组件库中的组件' (search Element-UI component library components by keyword). It specifies the verb '搜索' (search) and resource 'Element-UI 组件库中的组件' (Element-UI component library components), but doesn't explicitly differentiate from sibling tools like 'list_components' or 'get_component', which is why it doesn't reach a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It mentions '支持在组件名和描述中进行模糊匹配' (supports fuzzy matching in component names and descriptions), which hints at context, but doesn't specify when to choose this over 'list_components' or 'get_component', nor does it mention any exclusions or prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/yun8711/element-ui-mcp'

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