Skip to main content
Glama

query_component

Retrieve component details such as documentation, API references, and example code by specifying the component name. Use this tool to access comprehensive information for frontend development.

Instructions

Query detailed information of a component including documentation, API, and example code. Provide the component name to get all related information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
componentNameYesComponent name to query, e.g., 'das-action-more'

Implementation Reference

  • The main execution handler for the 'query_component' tool. Validates the input, calls the core query function, formats the result, and returns it in the expected MCP content array format.
    export async function queryComponentTool(
      args: any
    ): Promise<{ content: any[] }> {
      const startTime = Date.now();
    
      try {
        // Validate input parameters
        if (
          !args ||
          typeof args.componentName !== 'string' ||
          !args.componentName.trim()
        ) {
          throw new Error('Missing required parameter: componentName is required');
        }
    
        const componentName = args.componentName as string;
        // Query component info
        const componentInfo = await queryComponentByName(componentName);
    
        // Minimal output for IDE
        return {
          content: [
            {
              type: 'text',
              text: formatComponentQueryResult(componentInfo),
            },
            {
              type: 'text',
              text: JSON.stringify({ componentName, componentInfo }),
            },
          ],
        };
      } catch (error) {
        console.error('Query component tool error:', error);
    
        const message =
          error instanceof Error ? error.message : 'Unknown error occurred';
        return {
          content: [
            {
              type: 'text',
              text: `❌ Component query failed: ${message}`,
            },
          ],
        };
      }
    }
  • Registration dispatch in the CallToolRequest handler that maps 'query_component' tool calls to the queryComponentTool function.
    case 'query_component':
      return await queryComponentTool(args);
  • Tool registration in ListToolsRequest handler, defining the name, description, and input schema for 'query_component'.
    {
      name: 'query_component',
      description:
        'Query detailed information of a component including documentation, API, and example code. Provide the component name to get all related information.',
      inputSchema: {
        type: 'object',
        properties: {
          componentName: {
            type: 'string',
            description: "Component name to query, e.g., 'das-action-more'",
          },
        },
        required: ['componentName'],
      },
    },
  • Type definition for the component query result used in the tool handler.
    export interface ComponentQueryResult {
      success: boolean;
      data?: {
        componentName: string;
        componentInfo: any;
      };
      error?: string;
      metadata: {
        processingTime: number;
        timestamp: string;
      };
    }
  • Core helper function that loads component data from codegens.json, retrieves and filters the specified component information (excluding purpose and usage).
    export async function queryComponentByName(
      componentName: string
    ): Promise<any> {
      try {
        console.log('[QueryCore] Starting to load configuration file...');
    
        // Use unified path utilities
        const codegensData = loadCodegensFile();
        console.log('[QueryCore] Successfully loaded configuration file');
    
        // Find private components using unified utility
        const privateComponents = findPrivateComponents(codegensData);
    
        if (!privateComponents) {
          throw new Error('No private components found in codegens.json');
        }
    
        console.log(
          '[QueryCore] Found private component library, number of components:',
          Object.keys(privateComponents).length
        );
    
        const componentInfo = privateComponents[componentName];
    
        if (!componentInfo) {
          const availableComponents = Object.keys(privateComponents).join(', ');
          throw new Error(
            `Component '${componentName}' not found. Available components: ${availableComponents}`
          );
        }
    
        console.log('[QueryCore] Successfully found component:', componentName);
    
        // Filter out purpose and usage, return all other content
        const filteredComponentInfo = { ...componentInfo };
        delete filteredComponentInfo.purpose;
        delete filteredComponentInfo.usage;
    
        return filteredComponentInfo;
      } catch (error) {
        throw new Error(
          `Failed to query component '${componentName}': ${error instanceof Error ? error.message : 'Unknown error'}`
        );
      }
    }
Behavior2/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 states the tool queries information, implying a read-only operation, but doesn't address critical aspects like authentication requirements, rate limits, error handling, or response format. For a tool with zero annotation coverage, this is a significant gap in transparency.

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

Conciseness4/5

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

The description is concise and front-loaded, consisting of two clear sentences. The first sentence states the purpose, and the second provides basic usage. There's no wasted text, though it could be slightly more informative without losing efficiency.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain what the return value looks like (e.g., structure of documentation, API details, or example code), nor does it cover behavioral aspects like permissions or errors. For a query tool with no structured support, this leaves the agent under-informed.

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 schema description coverage is 100%, with the parameter 'componentName' well-documented in the schema. The description adds minimal value beyond the schema, only reiterating that a component name should be provided. It doesn't explain nuances like naming conventions or examples beyond what's in the schema, so the baseline score of 3 is appropriate.

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 tool's purpose: 'Query detailed information of a component including documentation, API, and example code.' It specifies the verb ('query') and resource ('component') with details about what information is retrieved. However, it doesn't explicitly differentiate from sibling tools like 'design_component' or 'integrate_design', which might have overlapping functionality.

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?

The description provides minimal guidance: 'Provide the component name to get all related information.' It doesn't specify when to use this tool versus alternatives like 'design_component' or 'integrate_design', nor does it mention prerequisites, exclusions, or specific contexts. This lack of comparative guidance leaves the agent uncertain about tool selection.

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

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/lyw405/mcp-garendesign'

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