Skip to main content
Glama
stackzero-labs

stackzero-labs/mcp

getUIBlocks

Retrieve a comprehensive list of all UI blocks from stackzero-labs, enabling integration and usage in applications via the MCP protocol.

Instructions

Provides a comprehensive list of all stackzero-labs/ui blocks.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • src/server.ts:56-82 (registration)
    Registers the MCP tool 'getUIBlocks' with an inline handler that fetches UI blocks using fetchUIBlocks and returns them as JSON text.
    server.tool(
      "getUIBlocks",
      "Provides a comprehensive list of all stackzero-labs/ui blocks.",
      {},
      async () => {
        try {
          const uiBlocks = await fetchUIBlocks();
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(uiBlocks, null, 2),
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: "Failed to fetch stackzero-labs/ui blocks",
              },
            ],
          };
        }
      }
    );
  • Handler function for the getUIBlocks tool, which calls fetchUIBlocks and formats the response.
    async () => {
      try {
        const uiBlocks = await fetchUIBlocks();
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(uiBlocks, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: "Failed to fetch stackzero-labs/ui blocks",
            },
          ],
        };
      }
    }
  • Core helper function that fetches the list of UI blocks from the registry, filters by type 'registry:block', parses with BlockSchema, and returns the array.
    export async function fetchUIBlocks() {
      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:block")
          .map((item: any) => {
            try {
              return BlockSchema.parse({
                name: item.name,
                type: item.type,
                description: item.description,
              });
            } catch (parseError) {
              return null;
            }
          });
      } catch (error) {
        return [];
      }
    }
  • Zod schema used to validate and parse individual UI block objects from the registry data.
    export const BlockSchema = ComponentSchema.extend({
      name: z.string(),
      type: z.string(),
      description: z.string().optional(),
    });
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