Skip to main content
Glama
component.ts1.71 kB
import { formatComponentQueryResult } from '@/utils/index.js'; import { queryComponentByName } from '@/core/index.js'; /** * Component query tool result interface */ export interface ComponentQueryResult { success: boolean; data?: { componentName: string; componentInfo: any; }; error?: string; metadata: { processingTime: number; timestamp: string; }; } /** * Component query tool implementation * Query detailed information of a component by name, including docs, API, examples, etc. * Returns all content except purpose and usage. */ 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}`, }, ], }; } }

Implementation Reference

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