getAddresses
Fetch and validate address blocks for integration with stackzero-labs/ui components, supporting the MCP protocol for standalone or Claude Desktop and Cursor compatibility.
Instructions
Provides implementation details for address-01-block, address-02-block blocks.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:323-353 (registration)Dynamic registration of the 'getAddresses' tool (and other block category tools) using server.tool(`get${category}` ...) where category='Addresses' from blocksCategories.
server.tool( `get${category}`, `Provides implementation details for ${blockNamesString} blocks.`, {}, async () => { try { const categoryResults = await fetchBlocksByCategory( categoryBlocks, blocks ); return { content: [ { type: "text", text: JSON.stringify(categoryResults, null, 2), }, ], }; } catch (error) { let errorMessage = `Error processing ${category} blocks`; if (error instanceof Error) { errorMessage += `: ${error.message}`; } return { content: [{ type: "text", text: errorMessage }], isError: true, }; } } ); - src/server.ts:327-352 (handler)Inline async handler function executed by the getAddresses tool: calls fetchBlocksByCategory for the Addresses blocks, returns JSON stringified results as text content, or error message.
async () => { try { const categoryResults = await fetchBlocksByCategory( categoryBlocks, blocks ); return { content: [ { type: "text", text: JSON.stringify(categoryResults, null, 2), }, ], }; } catch (error) { let errorMessage = `Error processing ${category} blocks`; if (error instanceof Error) { errorMessage += `: ${error.message}`; } return { content: [{ type: "text", text: errorMessage }], isError: true, }; } } - src/server.ts:208-255 (helper)fetchBlocksByCategory helper: iterates over category blocks (e.g., Addresses), fetches details via fetchBlockDetails, formats install/disclaimer, validates with IndividualBlockSchema, collects results.
async function fetchBlocksByCategory( categoryBlocks: string[], allBlocks: any[] ) { const blockResults = []; for (const blockName of categoryBlocks) { const block = allBlocks.find((b) => b.name === blockName); if (!block) continue; try { const blockDetails = await fetchBlockDetails(blockName); const blockContent = blockDetails.files[0]?.content; // Generate installation instructions const installInstructions = `You can install the blocks using \ shadcn/ui CLI. For example, with npx: npx shadcn@latest add \ "https://ui.stackzero.co/r/${blockName}.json" (Rules: make sure the URL is wrapped in \ double quotes. Once installed, \ you can import the block like this: import { ${formatComponentName( block.name )} } from \ "@/components/ui/${blockName}";`; const disclaimerText = `The code below is for context only. It helps you understand the block's props, types, and behavior. After installing, the block will be available for import via: import { ${formatComponentName( block.name )} } \ from "@/components/ui/${blockName}";`; const validatedBlock = IndividualBlockSchema.parse({ name: block.name, type: block.type, description: block.description, install: installInstructions, content: blockContent && disclaimerText + blockContent, examples: [], // Blocks typically don't have examples, but can be added if needed }); blockResults.push(validatedBlock); } catch (error) { console.error(`Error processing block ${blockName}:`, error); } } return blockResults; } - src/lib/categories.ts:25-25 (helper)blocksCategories.Addresses array defining the specific blocks returned by the getAddresses tool.
Addresses: ["address-01-block", "address-02-block"], - src/utils/schemas.ts:29-33 (schema)IndividualBlockSchema: Zod schema for parsing individual formatted block objects used in getAddresses responses.
export const IndividualBlockSchema = BlockSchema.extend({ install: z.string(), content: z.string(), examples: z.array(ExampleSchema), });