Skip to main content
Glama
shadcnspace

Shadcn Space MCP

Search Blocks by Keyword

searchBlocks

Search for Shadcn Space blocks using keywords or tags to identify components that fit specific content types or user needs.

Instructions

Search Shadcn Space blocks using keywords or tags. Agents can use this to find relevant blocks when building a page based on user requirements or content type.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesKeyword or tag to search for relevant blocks.

Implementation Reference

  • src/server.ts:155-184 (registration)
    Registration of the 'searchBlocks' tool via server.registerTool(). Defines name, title, description, and inputSchema (query string).
    // Register tools for Searching a Block by keyword
    server.registerTool(
      "searchBlocks",
      {
        title: "Search Blocks by Keyword",
        description:
          "Search Shadcn Space blocks using keywords or tags. Agents can use this to find relevant blocks when building a page based on user requirements or content type.",
        inputSchema: z.object({
          query: z
            .string()
            .describe("Keyword or tag to search for relevant blocks."),
        }),
      },
      async ({ query }) => {
        const blocks = await fetchUIBlocks();
        const filtered = blocks.filter(
          (b: { name: string | string[]; tags: any[] }) =>
            b.name.includes(query) || b.tags?.some((t) => t.includes(query)),
        );
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(filtered, null, 2),
            },
          ],
        };
      },
    );
  • The handler function for searchBlocks. It fetches all UI blocks via fetchUIBlocks(), filters them by matching the query against block names or tags, and returns the filtered results as JSON.
    async ({ query }) => {
      const blocks = await fetchUIBlocks();
      const filtered = blocks.filter(
        (b: { name: string | string[]; tags: any[] }) =>
          b.name.includes(query) || b.tags?.some((t) => t.includes(query)),
      );
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(filtered, null, 2),
          },
        ],
      };
    },
  • Input schema for searchBlocks defining a single required 'query' string parameter.
    inputSchema: z.object({
      query: z
        .string()
        .describe("Keyword or tag to search for relevant blocks."),
    }),
  • The fetchUIBlocks() helper function called by the searchBlocks handler. Fetches the registry JSON and filters for items of type 'registry:block'.
    export async function fetchUIBlocks() {
      try {
        const response = await fetch(
          "https://shadcnspace.com/r/registry.json",
        );
    
        if (!response.ok) {
          throw new Error(
            `Failed to Fetch Registry.json : ${response.statusText} (Status: ${response.status})`,
          );
        }
        const data = await response.json();
    
        return data.items
          .filter((item: any) => item.type === "registry:block")
          .map((item: any) => {
            try {
              return ComponentSchema.parse({
                name: item.name,
                type: item.type,
                description: item.description,
                title: item.title,
              });
            } catch (parseError) {
              return null;
            }
          });
      } catch (error) {
        return [];
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations present, so description must fully disclose behavior. It does not state if the operation is read-only, any auth needs, rate limits, or return format. Only purpose is conveyed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two concise sentences, front-loaded with action and target. Every sentence adds value, no fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple 1-param search tool with no output schema, description covers when to use but omits return value details (e.g., format, pagination). Adequate but not thorough.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with a single 'query' parameter described as 'Keyword or tag to search for relevant blocks.' Description repeats this but adds no significant new meaning beyond schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states the tool searches Shadcn Space blocks using keywords or tags, with a specific use case. It distinguishes itself from siblings like listBlocks (all blocks) or search-related tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit guidance on when to use: 'when building a page based on user requirements or content type.' No when-not or alternatives, but context is clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/shadcnspace/shadcnspace-mcp'

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