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'}` ); } }

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