Skip to main content
Glama
stackzero-labs

stackzero-labs/mcp

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
NameRequiredDescriptionDefault

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,
          };
        }
      }
    );
  • 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,
        };
      }
    }
  • 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;
    }
  • blocksCategories.Addresses array defining the specific blocks returned by the getAddresses tool.
    Addresses: ["address-01-block", "address-02-block"],
  • 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),
    });
Install Server

Other Tools

Related 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/stackzero-labs/mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server