Skip to main content
Glama
yun8711

Element-UI MCP Server

by yun8711

Get Component Events

get_component_events

Retrieve event details for Element-UI components including event names, descriptions, and parameters to enable accurate Vue 2 code generation.

Instructions

获取 Element-UI 组件的所有事件(Events)信息,包括事件名称、描述、参数等。

Input Schema

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
totalYes事件总数
eventsYes
tagNameYes组件标签名

Implementation Reference

  • Async handler function that fetches component events from componentObject, filters by eventName if provided, and returns structured JSON output.
    async ({ tagName, eventName }) => {
      const component = componentObject[tagName]
    
      if (!component) {
        throw new Error(`Component "${tagName}" not found. Available components: ${Object.keys(componentObject).join(', ')}`)
      }
    
      let resultEvents = component.events || []
    
      // 如果指定了事件名,过滤特定事件
      if (eventName) {
        resultEvents = resultEvents.filter(event => event.name === eventName)
        if (resultEvents.length === 0) {
          throw new Error(`Event "${eventName}" not found in component "${tagName}". Available events: ${component.events?.map(e => e.name).join(', ') || 'none'}`)
        }
      }
    
      const result = {
        tagName,
        events: resultEvents,
        total: (component.events || []).length,
      }
    
      return {
        structuredContent: result,
        content: [
          {
            type: 'text' as const,
            text: JSON.stringify(result, null, 2),
          },
        ],
      }
    }
  • Zod schemas defining input (tagName, optional eventName) and output (tagName, events array, total count) for the tool.
    inputSchema: z.object({
      tagName: z.string().describe('组件标签名, 例如:el-button'),
      eventName: z.string().optional().describe('获取特定事件的名称,不指定则返回所有事件'),
    }),
    outputSchema: z.object({
      tagName: z.string().describe('组件标签名'),
      events: z.array(
        z.object({
          name: z.string().describe('事件名'),
          description: z.string().optional().describe('事件描述'),
          parameters: z.array(
            z.object({
              raw: z.string().describe('参数类型'),
            })
          ).optional().describe('事件参数'),
          ts: z.string().optional().describe('TypeScript 签名'),
        })
      ),
      total: z.number().describe('事件总数'),
    }),
  • Function that registers the 'get_component_events' tool on the MCP server, including schema and handler.
    export function registerGetComponentEvents(server: McpServer) {
      server.registerTool(
        'get_component_events',
        {
          title: 'Get Component Events',
          description: '获取 Element-UI 组件的所有事件(Events)信息,包括事件名称、描述、参数等。',
          inputSchema: z.object({
            tagName: z.string().describe('组件标签名, 例如:el-button'),
            eventName: z.string().optional().describe('获取特定事件的名称,不指定则返回所有事件'),
          }),
          outputSchema: z.object({
            tagName: z.string().describe('组件标签名'),
            events: z.array(
              z.object({
                name: z.string().describe('事件名'),
                description: z.string().optional().describe('事件描述'),
                parameters: z.array(
                  z.object({
                    raw: z.string().describe('参数类型'),
                  })
                ).optional().describe('事件参数'),
                ts: z.string().optional().describe('TypeScript 签名'),
              })
            ),
            total: z.number().describe('事件总数'),
          }),
        },
        async ({ tagName, eventName }) => {
          const component = componentObject[tagName]
    
          if (!component) {
            throw new Error(`Component "${tagName}" not found. Available components: ${Object.keys(componentObject).join(', ')}`)
          }
    
          let resultEvents = component.events || []
    
          // 如果指定了事件名,过滤特定事件
          if (eventName) {
            resultEvents = resultEvents.filter(event => event.name === eventName)
            if (resultEvents.length === 0) {
              throw new Error(`Event "${eventName}" not found in component "${tagName}". Available events: ${component.events?.map(e => e.name).join(', ') || 'none'}`)
            }
          }
    
          const result = {
            tagName,
            events: resultEvents,
            total: (component.events || []).length,
          }
    
          return {
            structuredContent: result,
            content: [
              {
                type: 'text' as const,
                text: JSON.stringify(result, null, 2),
              },
            ],
          }
        }
      )
    }
  • src/index.ts:34-34 (registration)
    Top-level call to register the get_component_events tool during server creation.
    registerGetComponentEvents(server);
  • src/index.ts:10-10 (registration)
    Import of the registerGetComponentEvents function.
    import { registerGetComponentEvents } from './tools/get-component-events.js';
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states what information is returned but doesn't disclose behavioral traits like whether this is a read-only operation (implied by 'get'), potential rate limits, authentication needs, or error conditions. The description is minimal on behavioral context.

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 a single, efficient sentence in Chinese that directly states the tool's purpose and scope. It's front-loaded with the core action and includes no unnecessary information, making it highly concise and well-structured.

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 presence of an output schema (which handles return values), the description is reasonably complete. It clearly states what the tool does and what information it returns, though it lacks behavioral details that would be helpful without annotations.

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?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema (e.g., no examples, format details, or edge cases). Baseline 3 is appropriate when schema does the heavy lifting.

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

Purpose5/5

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

The description clearly states the specific action ('获取' meaning 'get'), resource ('Element-UI 组件的所有事件'), and scope ('包括事件名称、描述、参数等'). It distinguishes from sibling tools like get_component_methods and get_component_props by focusing exclusively on events.

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

Usage Guidelines3/5

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

The description implies usage when needing event information for Element-UI components, but doesn't explicitly state when to use this vs. alternatives like get_component (which might provide broader info) or when not to use it. No explicit exclusions or prerequisites are mentioned.

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