getUIComponents
Retrieve a full list of stackzero-labs/ui components via the MCP protocol, enabling seamless integration with applications like Claude Desktop and Cursor.
Instructions
Provides a comprehensive list of all stackzero-labs/ui components.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:25-53 (registration)Registers the getUIComponents tool with the MCP server. The handler fetches UI components using fetchUIComponents and returns them as JSON text.
server.tool( "getUIComponents", "Provides a comprehensive list of all stackzero-labs/ui components.", {}, async () => { try { const uiComponents = await fetchUIComponents(); return { content: [ { type: "text", text: JSON.stringify(uiComponents, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: "Failed to fetch stackzero-labs/ui components", }, ], isError: true, }; } } ); - src/utils/api.ts:15-41 (helper)Core helper function that fetches the registry, filters components, and validates them using ComponentSchema.
export async function fetchUIComponents() { try { const response = await fetch(mcpConfig.registryFileUrl); if (!response.ok) { throw new Error( `Failed to fetch registry.json: ${response.statusText} - Status: ${response.status}` ); } const data = await response.json(); return data.registry .filter((item: any) => item.type === "registry:component") .map((item: any) => { try { return ComponentSchema.parse({ name: item.name, type: item.type, description: item.description, }); } catch (parseError) { return null; } }); } catch (error) { return []; } } - src/utils/schemas.ts:4-8 (schema)Zod schema for validating UI component objects used in fetchUIComponents.
export const ComponentSchema = z.object({ name: z.string(), type: z.string(), description: z.string().optional(), });