Skip to main content
Glama
m-yoshiro

Storybook MCP Server

by m-yoshiro

find-components-by-name

Search UI components by name or keyword in Storybook to locate specific elements and retrieve usage examples for development.

Instructions

Search components by name/keyword

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesComponent name or keyword to search for
pathNoPath to the index.json or stories.json file (optional if default path is provided)

Implementation Reference

  • Main handler function that fetches components from Storybook static dir, filters by name keyword (case-insensitive), and returns JSON stringified matching components as text content.
    export const findComponentsByName = async (
      args: z.infer<typeof FindComponentByNameParamsSchema> & { storybookStaticDir: string }
    ) => {
      try {
        const components = await getComponents(args.storybookStaticDir);
        const searchTerm = args.name.toLowerCase();
        const matchingComponents = components.filter((component: Component) =>
          component.name.toLowerCase().includes(searchTerm)
        );
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(matchingComponents, null, 2),
            },
          ],
        };
      } catch (error) {
        console.error('Error finding component by name:', error);
        throw new McpError(ErrorCode.InternalError, 'Failed to find component by name');
      }
    };
  • src/index.ts:84-85 (registration)
    Switch case in CallToolRequestHandler that invokes the findComponentsByName handler with arguments.
    case 'find-components-by-name':
      return findComponentsByName({ name: args.name || '', storybookStaticDir });
  • src/index.ts:58-62 (registration)
    Tool registration in ListToolsResponse, defining name, description, and inputSchema.
    {
      name: 'find-components-by-name',
      description: 'Search components by name/keyword',
      inputSchema: zodToJsonSchema(findComponentsByNameParamsSchema.describe('Parameters for finding component by name')) as ToolInput,
    },
  • Zod schema for input parameters used in tool registration (name required, path optional).
    const findComponentsByNameParamsSchema = z.object({
      name: z.string().describe('Component name or keyword to search for'),
      path: z.string().optional().describe('Path to the index.json or stories.json file (optional if default path is provided)'),
    });
  • Local Zod schema for typing handler arguments (name only).
    const FindComponentByNameParamsSchema = z.object({
      name: z.string().describe('Component name or keyword to search for'),
    });
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the search action without disclosing behavioral traits such as search scope (e.g., partial/full matches), result format, pagination, or error handling. It adds little beyond the basic operation.

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 a single, efficient sentence with zero waste, clearly front-loading the tool's purpose. It is appropriately sized for a simple search tool, making it easy to parse quickly.

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

Completeness2/5

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

Given no annotations and no output schema, the description is incomplete for a search tool. It lacks details on behavioral aspects like result format, search behavior, or error cases, leaving gaps in understanding how to effectively use the tool.

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 both parameters ('name' and 'path'). The description adds no additional meaning beyond implying 'name' is used for searching, which aligns with the schema. Baseline 3 is appropriate as the schema handles parameter documentation.

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

Purpose4/5

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

The description 'Search components by name/keyword' clearly states the action (search) and target resource (components) with a specific criterion (name/keyword). It distinguishes from the sibling 'list-components' by implying filtering rather than enumeration, though not explicitly contrasting them.

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

Usage Guidelines2/5

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

No explicit guidance on when to use this tool versus alternatives like 'list-components' is provided. The description implies usage for searching by name, but lacks context on prerequisites, exclusions, or comparative scenarios, offering minimal direction.

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/m-yoshiro/storybook-mcp'

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