Skip to main content
Glama
yun8711

Element-UI MCP Server

by yun8711

Get Component Methods

get_component_methods

Retrieve method details for Element-UI components, including names, parameters, and return values, to support accurate Vue 2 code generation.

Instructions

获取 Element-UI 组件的所有方法(Methods)信息,包括方法名称、参数、返回值等。

Input Schema

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
totalYes方法总数
methodsYes
tagNameYes组件标签名

Implementation Reference

  • The handler function implementing the core logic of the 'get_component_methods' tool. It fetches the component data, filters methods if specified, and returns structured JSON output.
      async ({ tagName, methodName }) => {
        const component = componentObject[tagName]
    
        if (!component) {
          throw new Error(`Component "${tagName}" not found. Available components: ${Object.keys(componentObject).join(', ')}`)
        }
    
        let resultMethods = component.methods || []
    
        // 如果指定了方法名,过滤特定方法
        if (methodName) {
          resultMethods = resultMethods.filter(method => method.name === methodName)
          if (resultMethods.length === 0) {
            throw new Error(`Method "${methodName}" not found in component "${tagName}". Available methods: ${component.methods?.map(m => m.name).join(', ') || 'none'}`)
          }
        }
    
        const result = {
          tagName,
          methods: resultMethods,
          total: (component.methods || []).length,
        }
    
        return {
          structuredContent: result,
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(result, null, 2),
            },
          ],
        }
      }
    )
  • Input and output schema definitions for the 'get_component_methods' tool using Zod for validation.
    {
      title: 'Get Component Methods',
      description: '获取 Element-UI 组件的所有方法(Methods)信息,包括方法名称、参数、返回值等。',
      inputSchema: z.object({
        tagName: z.string().describe('组件标签名, 例如:el-button'),
        methodName: z.string().optional().describe('获取特定方法的名称,不指定则返回所有方法'),
      }),
      outputSchema: z.object({
        tagName: z.string().describe('组件标签名'),
        methods: z.array(
          z.object({
            name: z.string().describe('方法名'),
            description: z.string().optional().describe('方法描述'),
            parameters: z.array(
              z.object({
                raw: z.string().describe('参数类型'),
              })
            ).optional().describe('方法参数'),
            returnType: z.object({
              raw: z.string().describe('返回值类型'),
            }).optional().describe('返回值类型'),
            ts: z.string().optional().describe('TypeScript 签名'),
          })
        ),
        total: z.number().describe('方法总数'),
      }),
    },
  • The module-level registration function that registers the 'get_component_methods' tool with the MCP server, including schema and handler.
    export function registerGetComponentMethods(server: McpServer) {
      server.registerTool(
        'get_component_methods',
        {
          title: 'Get Component Methods',
          description: '获取 Element-UI 组件的所有方法(Methods)信息,包括方法名称、参数、返回值等。',
          inputSchema: z.object({
            tagName: z.string().describe('组件标签名, 例如:el-button'),
            methodName: z.string().optional().describe('获取特定方法的名称,不指定则返回所有方法'),
          }),
          outputSchema: z.object({
            tagName: z.string().describe('组件标签名'),
            methods: z.array(
              z.object({
                name: z.string().describe('方法名'),
                description: z.string().optional().describe('方法描述'),
                parameters: z.array(
                  z.object({
                    raw: z.string().describe('参数类型'),
                  })
                ).optional().describe('方法参数'),
                returnType: z.object({
                  raw: z.string().describe('返回值类型'),
                }).optional().describe('返回值类型'),
                ts: z.string().optional().describe('TypeScript 签名'),
              })
            ),
            total: z.number().describe('方法总数'),
          }),
        },
        async ({ tagName, methodName }) => {
          const component = componentObject[tagName]
    
          if (!component) {
            throw new Error(`Component "${tagName}" not found. Available components: ${Object.keys(componentObject).join(', ')}`)
          }
    
          let resultMethods = component.methods || []
    
          // 如果指定了方法名,过滤特定方法
          if (methodName) {
            resultMethods = resultMethods.filter(method => method.name === methodName)
            if (resultMethods.length === 0) {
              throw new Error(`Method "${methodName}" not found in component "${tagName}". Available methods: ${component.methods?.map(m => m.name).join(', ') || 'none'}`)
            }
          }
    
          const result = {
            tagName,
            methods: resultMethods,
            total: (component.methods || []).length,
          }
    
          return {
            structuredContent: result,
            content: [
              {
                type: 'text' as const,
                text: JSON.stringify(result, null, 2),
              },
            ],
          }
        }
      )
    }
  • src/index.ts:36-36 (registration)
    Top-level call to register the 'get_component_methods' tool during server initialization.
    registerGetComponentMethods(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 returns method information including name, parameters, and return values, but doesn't cover other important aspects like whether it's a read-only operation (implied but not stated), error handling, rate limits, authentication needs, or response format details. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

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 that directly states the tool's purpose and what information it returns. It's front-loaded with the core function and avoids unnecessary details. However, it could be slightly more structured by explicitly separating input and output aspects.

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

Completeness4/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 (which handles return values), the description is reasonably complete. It clearly defines the tool's scope (Element-UI component methods) and output content. However, it lacks behavioral context (e.g., error cases, permissions) and usage guidelines relative to siblings, which are minor gaps.

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 ('tagName' and 'methodName') with clear descriptions. The description adds no additional parameter semantics beyond what's in the schema—it mentions '方法名称、参数、返回值等' (method name, parameters, return values, etc.), but this refers to output, not input parameters. 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 组件的所有方法(Methods)信息' (Get all method information for Element-UI components). It specifies the resource (Element-UI components) and verb (get methods), but doesn't explicitly distinguish it from sibling tools like 'get_component' or 'get_component_props' beyond mentioning it's for methods specifically.

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' (which might return general component info) or 'get_component_events' (for events instead of methods), nor does it specify prerequisites or exclusions. Usage is implied by the purpose but not explicitly defined.

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