get_component_metadata
Retrieve detailed metadata for any shadcn/ui v4 component, including structure, usage, and installation details, to enhance development workflows.
Instructions
Get metadata for a specific shadcn/ui v4 component
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| componentName | Yes | Name of the shadcn/ui component (e.g., "accordion", "button") |
Implementation Reference
- Primary handler function that implements the core logic of the 'get_component_metadata' tool: fetches metadata via dynamic axios instance and returns JSON-formatted content.export async function handleGetComponentMetadata({ componentName }: { componentName: string }) { try { const axios = await getAxiosImplementation(); const metadata = await axios.getComponentMetadata(componentName); if (!metadata) { throw new Error(`Component metadata not found: ${componentName}`); } return { content: [{ type: "text", text: JSON.stringify(metadata, null, 2) }] }; } catch (error) { logError(`Failed to get metadata for component "${componentName}"`, error); throw new Error(`Failed to get metadata for component "${componentName}": ${error instanceof Error ? error.message : String(error)}`); } }
- Input schema definition for the tool parameters.export const schema = { componentName: { type: 'string', description: 'Name of the shadcn/ui component (e.g., "accordion", "button")' } };
- src/tools/index.ts:17-25 (registration)Registers the handler function under the tool name 'get_component_metadata' in the toolHandlers export, which is imported by server/handler.ts for tool execution.export const toolHandlers = { get_component: handleGetComponent, get_component_demo: handleGetComponentDemo, list_components: handleListComponents, get_component_metadata: handleGetComponentMetadata, get_directory_structure: handleGetDirectoryStructure, get_block: handleGetBlock, list_blocks: handleListBlocks };
- src/tools/index.ts:64-72 (registration)Defines the complete tool metadata including name, description, and input schema for MCP tool listing and validation.'get_component_metadata': { name: 'get_component_metadata', description: 'Get metadata for a specific shadcn/ui v4 component', inputSchema: { type: 'object', properties: getComponentMetadataSchema, required: ['componentName'] } },
- src/server/handler.ts:281-306 (registration)The MCP server request handler for call_tool requests that dispatches to the appropriate tool handler based on name, enabling execution of get_component_metadata.server.setRequestHandler(CallToolRequestSchema, async (request) => { return await handleRequest( 'call_tool', request.params, async (validatedParams: any) => { const { name, arguments: params } = validatedParams; if (!name || typeof name !== 'string') { throw new Error("Tool name is required"); } const handler = toolHandlers[name as keyof typeof toolHandlers]; if (!handler) { throw new Error(`Tool not found: ${name}`); } // Execute handler with circuit breaker protection const result = await circuitBreakers.external.execute(() => Promise.resolve(handler(params || {})) ); return result; } ); });