Skip to main content
Glama
freema

MCP Design System Extractor

search_components

Search design system components by name, title, or category to find UI elements like modals, buttons, and forms. Use pagination for large result sets and partial matching for precise discovery.

Instructions

Search design system components by name, title, or category. Find UI components like modals, dialogs, popups, overlays, buttons, forms, cards, etc. Name is the component name only (e.g., "Modal", "Dialog"), title is the full story path (e.g., "Components/Overlays/Modal"), category is the grouping (e.g., "Components/Overlays"). Use "*" as query to list all components. Supports pagination for large result sets.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe search query to match (e.g., "button", "form", "nav"). Use "*" to list all components. Case-insensitive partial matching.
searchInNoWhere to search: "name" (component name only), "title" (full path), "category" (grouping), or "all" (search everywhere, default)
pageNoPage number (1-based). Default is 1.
pageSizeNoNumber of components per page (1-100). Default is 50.

Implementation Reference

  • Main handler function executing the tool logic: input validation, Storybook stories fetching, filtering by query/searchIn (name/title/category/all), pagination, and formatted response.
    export async function handleSearchComponents(input: any) {
      try {
        const validatedInput = validateSearchComponentsInput(input);
        const client = new StorybookClient();
        const searchIn = validatedInput.searchIn || 'all';
        const query = validatedInput.query.toLowerCase();
    
        // Handle wildcard queries - if query is just "*" or empty, match everything
        const isWildcard = query === '*' || query === '' || query === '.*';
    
        const storiesIndex = await client.fetchStoriesIndex();
        const stories = storiesIndex.stories || storiesIndex.entries || {};
    
        const filterFn = (story: any, componentName: string, _category?: string) => {
          const storyTitle = story.title || '';
          const categoryParts = storyTitle.split('/').slice(0, -1);
          const storyCategory = categoryParts.length > 0 ? categoryParts.join('/') : undefined;
    
          if (isWildcard) {
            return true;
          }
    
          switch (searchIn) {
            case 'name':
              return componentName.toLowerCase().includes(query);
            case 'title':
              return storyTitle.toLowerCase().includes(query);
            case 'category':
              return storyCategory ? storyCategory.toLowerCase().includes(query) : false;
            case 'all':
            default:
              return (
                componentName.toLowerCase().includes(query) ||
                storyTitle.toLowerCase().includes(query) ||
                Boolean(storyCategory?.toLowerCase().includes(query))
              );
          }
        };
    
        const componentMap = mapStoriesToComponents(stories, { filterFn });
        const allResults = getComponentsArray(componentMap);
    
        // Apply pagination
        const paginationResult = applyPagination(allResults, {
          page: validatedInput.page,
          pageSize: validatedInput.pageSize,
        });
    
        const message = formatPaginationMessage(
          paginationResult,
          'Found',
          `matching "${validatedInput.query}", searched in: ${searchIn}`
        );
    
        return formatSuccessResponse(paginationResult.items, message);
      } catch (error) {
        return handleErrorWithContext(error, 'search components', {
          resource: 'component search results',
        });
      }
    }
  • Tool object definition for 'search_components' including name, description, and inputSchema specifying parameters: query (required), searchIn, page, pageSize.
    export const searchComponentsTool: Tool = {
      name: 'search_components',
      description:
        'Search design system components by name, title, or category. Find UI components like modals, dialogs, popups, overlays, buttons, forms, cards, etc. Name is the component name only (e.g., "Modal", "Dialog"), title is the full story path (e.g., "Components/Overlays/Modal"), category is the grouping (e.g., "Components/Overlays"). Use "*" as query to list all components. Supports pagination for large result sets.',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description:
              'The search query to match (e.g., "button", "form", "nav"). Use "*" to list all components. Case-insensitive partial matching.',
          },
          searchIn: {
            type: 'string',
            enum: ['name', 'title', 'category', 'all'],
            description:
              'Where to search: "name" (component name only), "title" (full path), "category" (grouping), or "all" (search everywhere, default)',
          },
          page: {
            type: 'number',
            description: 'Page number (1-based). Default is 1.',
          },
          pageSize: {
            type: 'number',
            description: 'Number of components per page (1-100). Default is 50.',
          },
        },
        required: ['query'],
      },
    };
  • src/index.ts:15-35 (registration)
    Registration in MCP server: 'search_components' handler mapped in toolHandlers Map and Tool object included in allTools array for listing.
    const toolHandlers = new Map<string, (input: any) => Promise<any>>([
      ['list_components', tools.handleListComponents],
      ['get_component_html', tools.handleGetComponentHTML],
      ['get_component_variants', tools.handleGetComponentVariants],
      ['search_components', tools.handleSearchComponents],
      ['get_component_dependencies', tools.handleGetComponentDependencies],
      ['get_theme_info', tools.handleGetThemeInfo],
      ['get_component_by_purpose', tools.handleGetComponentByPurpose],
      ['get_external_css', tools.handleGetExternalCSS],
    ]);
    
    const allTools = [
      tools.listComponentsTool,
      tools.getComponentHTMLTool,
      tools.getComponentVariantsTool,
      tools.searchComponentsTool,
      tools.getComponentDependenciesTool,
      tools.getThemeInfoTool,
      tools.getComponentByPurposeTool,
      tools.getExternalCSSTool,
    ];
  • Zod validation schema for SearchComponentsInput used in the tool handler validation.
    const SearchComponentsInputSchema = z.object({
      query: z.string(),
      searchIn: z.enum(['name', 'title', 'category', 'all']).optional(),
      page: z.number().int().positive().optional(),
      pageSize: z.number().int().min(1).max(100).optional(),
    });
  • Validation helper function that parses input using Zod schema and constructs typed SearchComponentsInput object.
    export function validateSearchComponentsInput(input: any): SearchComponentsInput {
      const parsed = SearchComponentsInputSchema.parse(input);
      const result: SearchComponentsInput = {
        query: parsed.query,
      };
      if (parsed.searchIn !== undefined) {
        result.searchIn = parsed.searchIn;
      }
      if (parsed.page !== undefined) {
        result.page = parsed.page;
      }
      if (parsed.pageSize !== undefined) {
        result.pageSize = parsed.pageSize;
      }
      return result;
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: case-insensitive partial matching, support for pagination, and the ability to search across different fields. It provides concrete examples of searchable component types (modals, buttons, etc.) and explains what happens with the '*' query. The only gap is lack of information about rate limits or authentication requirements.

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?

The description is efficiently structured with three sentences that each add value: the core purpose, examples of searchable components, and important behavioral notes about wildcard searching and pagination. There's no wasted text, and key information is front-loaded appropriately.

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

Completeness4/5

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

For a search tool with 4 parameters, 100% schema coverage, and no output schema, the description provides good contextual completeness. It explains the search behavior, gives concrete examples, and mentions pagination support. The main gap is the lack of information about return format or result structure, which would be helpful since there's no output schema.

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 description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds some value by explaining what 'name', 'title', and 'category' represent with examples, and clarifies that '*' lists all components. However, most parameter semantics are already covered in the schema descriptions, so this meets the baseline for high schema coverage.

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?

The description clearly states the tool's purpose: 'Search design system components by name, title, or category.' It specifies the verb ('search'), resource ('design system components'), and scope (searchable fields). It distinguishes from siblings like 'list_components' by emphasizing search functionality rather than simple listing.

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?

The description provides clear context for when to use this tool: for searching components by specific attributes. It mentions using '*' to list all components, which addresses a common use case. However, it doesn't explicitly state when NOT to use it or name specific alternatives among the sibling tools, though the distinction from 'list_components' is implied.

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/freema/mcp-design-system-extractor'

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