Skip to main content
Glama

search_components

Find UI components by name or category to build user interfaces using Basecoat CSS components. Search for buttons, forms, navigation, and other elements with HTML and documentation.

Instructions

Search for components by name or category

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch term (e.g., "button", "form", "navigation")

Implementation Reference

  • The core handler function that implements the logic to search for Basecoat components matching the query in name or category.
    async searchComponents(query) {
      const components = await this.getComponentsList();
      const results = [];
    
      const queryLower = query.toLowerCase();
    
      for (const [category, categoryComponents] of Object.entries(components)) {
        for (const component of categoryComponents) {
          // Search in component name and category
          if (component.name.toLowerCase().includes(queryLower) ||
            category.toLowerCase().includes(queryLower)) {
            results.push({
              name: component.name,
              category: category,
              file: component.file,
              match: component.name.toLowerCase().includes(queryLower) ? 'name' : 'category'
            });
          }
        }
      }
    
      return results;
    }
  • server.js:221-234 (registration)
    Registration of the 'search_components' tool in the ListTools response, including name, description, and input schema.
    {
      name: 'search_components',
      description: 'Search for components by name or category',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Search term (e.g., "button", "form", "navigation")',
          },
        },
        required: ['query'],
      },
    },
  • The tool dispatcher case that calls the searchComponents handler, formats the results into a markdown response, and returns the MCP content.
    case 'search_components': {
      const results = await this.searchComponents(args.query);
      let output = `# Search Results for "${args.query}"\n\n`;
    
      if (results.length === 0) {
        output += 'No components found matching your search.\n';
      } else {
        output += `Found ${results.length} matching component(s):\n\n`;
        for (const result of results) {
          output += `- **${result.name}** (${result.category}) - matched by ${result.match}\n`;
        }
      }
    
      return {
        content: [
          {
            type: 'text',
            text: output,
          },
        ],
      };
    }
  • Helper function that scans the components directory to build a list of all available components by category, used by searchComponents.
    async getComponentsList() {
      const categories = ['forms', 'navigation', 'feedback', 'interactive', 'layout'];
      const components = {};
    
      for (const category of categories) {
        const categoryPath = path.join(__dirname, 'components', category);
        try {
          const files = await fs.readdir(categoryPath);
          const htmlFiles = files
            .filter(file => file.endsWith('.html'))
            .map(file => ({
              name: file.replace('.html', ''),
              category: category,
              file: file
            }));
    
          if (htmlFiles.length > 0) {
            components[category] = htmlFiles;
          }
        } catch (error) {
          console.error(`Error reading category ${category}:`, error.message);
        }
      }
    
      return components;
    }
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 basic function. It doesn't disclose behavioral traits such as whether this is a read-only operation, how results are returned (e.g., pagination, sorting), or any limitations (e.g., rate limits, authentication needs). This leaves significant gaps for an agent to understand tool behavior.

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. It's appropriately sized and front-loaded, clearly stating the tool's purpose without unnecessary details.

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 the tool's moderate complexity (search operation with one parameter) and lack of annotations and output schema, the description is incomplete. It doesn't cover behavioral aspects like result format, error handling, or usage context, which are essential for an agent to use it effectively.

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?

The input schema has 100% description coverage, with the 'query' parameter well-documented. The description adds minimal value by mentioning 'name or category' as search criteria, which aligns with but doesn't significantly expand beyond the schema's example terms. Baseline 3 is appropriate as the schema does the heavy lifting.

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 clearly states the action ('Search for') and resource ('components'), specifying search criteria ('by name or category'). It distinguishes from siblings like 'list_components' by implying filtering, but doesn't explicitly differentiate from 'get_component' which might retrieve a single component by ID.

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 guidance is provided on when to use this tool versus alternatives like 'list_components' (which might list all without filtering) or 'get_component' (which might retrieve a specific one). The description implies usage for searching, but lacks explicit context or exclusions.

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/GustavoGomezPG/basecoat-mcp'

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