get-component-examples
Retrieve code examples for a specific component using the Visa Design System MCP Server to streamline development and ensure design consistency.
Instructions
Get code examples for a specific component
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Component name |
Implementation Reference
- src/mcp-server.ts:483-510 (handler)Main MCP tool handler for 'get-component-examples': validates input, delegates to ComponentService, formats JSON response with examples./** * Handle get-component-examples tool call */ private async handleGetComponentExamples(args: Record<string, any>): Promise<CallToolResult> { const { name } = args; if (!name || typeof name !== 'string') { throw new McpError( ErrorCode.InvalidParams, 'Component name is required and must be a string' ); } const examples = await this.componentService.getComponentExamples(name); return { content: [ { type: 'text', text: JSON.stringify({ component: name, examples, count: examples.length }, null, 2) } ] }; }
- src/mcp-server.ts:202-215 (registration)Tool registration in getToolDefinitions(): defines name, description, and input schema requiring 'name' parameter.{ name: 'get-component-examples', description: 'Get code examples for a specific component', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Component name' } }, required: ['name'] } },
- src/mcp-server.ts:202-215 (schema)Input schema definition for the tool: object with required 'name' string property.{ name: 'get-component-examples', description: 'Get code examples for a specific component', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Component name' } }, required: ['name'] } },
- Helper method in ComponentService that retrieves the examples array from the component data.async getComponentExamples(name: string): Promise<ComponentExample[]> { const component = await this.getComponent(name); return component.examples; }
- Service-level handler implementing the core logic to fetch component examples from data cache.async getComponentExamples(name: string): Promise<ComponentExample[]> { const component = await this.getComponent(name); return component.examples; }