Skip to main content
Glama
yun8711

Element-UI MCP Server

by yun8711

Get Component Props

get_component_props

Retrieve detailed property information for Element-UI components including names, types, descriptions, and default values to support Vue 2 development.

Instructions

获取 Element-UI 组件的所有属性(Props)信息,包括名称、类型、描述、默认值等。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tagNameYes组件标签名, 例如:el-button
propNameNo获取特定属性的名称,不指定则返回所有属性

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
propsYes
totalYes属性总数
tagNameYes组件标签名

Implementation Reference

  • The asynchronous handler function that implements the core logic of the 'get_component_props' tool. It fetches component data from componentObject, filters props if propName is specified, handles errors for missing components or props, and returns structured content with JSON stringified text.
    async ({ tagName, propName }) => {
      const component = componentObject[tagName]
    
      if (!component) {
        throw new Error(`Component "${tagName}" not found. Available components: ${Object.keys(componentObject).join(', ')}`)
      }
    
      let resultProps = component.props || []
    
      // 如果指定了属性名,过滤特定属性
      if (propName) {
        resultProps = resultProps.filter(prop => prop.name === propName)
        if (resultProps.length === 0) {
          throw new Error(`Property "${propName}" not found in component "${tagName}". Available props: ${component.props?.map(p => p.name).join(', ') || 'none'}`)
        }
      }
    
      const result = {
        tagName,
        props: resultProps,
        total: (component.props || []).length,
      }
    
      return {
        structuredContent: result,
        content: [
          {
            type: 'text' as const,
            text: JSON.stringify(result, null, 2),
          },
        ],
      }
    }
  • Zod schemas for input (tagName: string, propName: optional string) and output (tagName, props array with name/description/type/required/default, total count) validation.
    inputSchema: z.object({
      tagName: z.string().describe('组件标签名, 例如:el-button'),
      propName: z.string().optional().describe('获取特定属性的名称,不指定则返回所有属性'),
    }),
    outputSchema: z.object({
      tagName: z.string().describe('组件标签名'),
      props: z.array(
        z.object({
          name: z.string().describe('属性名'),
          description: z.string().optional().describe('属性描述'),
          type: z.object({
            raw: z.string().describe('属性类型'),
          }).describe('属性类型信息'),
          required: z.boolean().optional().describe('是否必需'),
          default: z.any().optional().describe('默认值'),
        })
      ),
      total: z.number().describe('属性总数'),
    }),
  • The registerGetComponentProps function that registers the 'get_component_props' tool on the MCP server, including tool name, title, description, input/output schemas, and handler.
    export function registerGetComponentProps(server: McpServer) {
      server.registerTool(
        'get_component_props',
        {
          title: 'Get Component Props',
          description: '获取 Element-UI 组件的所有属性(Props)信息,包括名称、类型、描述、默认值等。',
          inputSchema: z.object({
            tagName: z.string().describe('组件标签名, 例如:el-button'),
            propName: z.string().optional().describe('获取特定属性的名称,不指定则返回所有属性'),
          }),
          outputSchema: z.object({
            tagName: z.string().describe('组件标签名'),
            props: z.array(
              z.object({
                name: z.string().describe('属性名'),
                description: z.string().optional().describe('属性描述'),
                type: z.object({
                  raw: z.string().describe('属性类型'),
                }).describe('属性类型信息'),
                required: z.boolean().optional().describe('是否必需'),
                default: z.any().optional().describe('默认值'),
              })
            ),
            total: z.number().describe('属性总数'),
          }),
        },
        async ({ tagName, propName }) => {
          const component = componentObject[tagName]
    
          if (!component) {
            throw new Error(`Component "${tagName}" not found. Available components: ${Object.keys(componentObject).join(', ')}`)
          }
    
          let resultProps = component.props || []
    
          // 如果指定了属性名,过滤特定属性
          if (propName) {
            resultProps = resultProps.filter(prop => prop.name === propName)
            if (resultProps.length === 0) {
              throw new Error(`Property "${propName}" not found in component "${tagName}". Available props: ${component.props?.map(p => p.name).join(', ') || 'none'}`)
            }
          }
    
          const result = {
            tagName,
            props: resultProps,
            total: (component.props || []).length,
          }
    
          return {
            structuredContent: result,
            content: [
              {
                type: 'text' as const,
                text: JSON.stringify(result, null, 2),
              },
            ],
          }
        }
      )
    }
  • src/index.ts:33-33 (registration)
    Invocation of registerGetComponentProps in the main server creation function to include the tool in the MCP server.
    registerGetComponentProps(server);
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 states the tool retrieves property information but doesn't describe the return format (though an output schema exists, which helps), error handling (e.g., for invalid component names), or performance aspects (e.g., if it's a read-only operation, which is implied but not explicit). For a tool with no annotations, this leaves significant gaps in understanding its behavior beyond basic functionality.

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

Conciseness4/5

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

The description is a single, efficient sentence in Chinese that clearly states the tool's purpose and what information it returns. It's front-loaded with the main action and includes specific details (name, type, description, default value). There's no wasted verbiage, though it could be slightly more structured for readability.

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 the tool's moderate complexity (2 parameters, 1 required), 100% schema coverage, and the presence of an output schema, the description is minimally adequate. It explains what the tool does but lacks usage guidelines, behavioral details (e.g., error cases), and differentiation from siblings. The output schema mitigates the need to describe return values, but overall completeness is limited to basic functionality.

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%, with clear descriptions for both parameters: 'tagName' (component tag name, e.g., el-button) and 'propName' (specific property name, optional to return all). The description adds minimal value beyond the schema, mentioning 'Element-UI 组件' to contextualize the tagName but not elaborating on parameter usage or constraints. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.

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 组件的所有属性(Props)信息,包括名称、类型、描述、默认值等' (Get all property information for Element-UI components, including name, type, description, default value, etc.). It specifies the verb ('获取' - get) and resource ('Element-UI 组件的所有属性' - all properties of Element-UI components). However, it doesn't explicitly differentiate from sibling tools like 'get_component' (which might get general component info) or 'get_component_events' (which gets events).

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 doesn't mention sibling tools like 'get_component' (for general info), 'get_component_events' (for events), or 'list_components' (for listing components). There's no context about prerequisites, such as needing a valid component name, or exclusions. The agent must infer usage from the tool name and description alone.

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