Skip to main content
Glama
ymadd
by ymadd

search_components

Find shadcn/ui components by keyword to access relevant documentation and examples through a structured search query.

Instructions

Search for shadcn/ui components by keyword

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query to find relevant components

Implementation Reference

  • Primary handler that validates the query, loads the components cache if necessary, calls the search helper, and formats the response.
    private async handleSearchComponents(args: any) { const query = this.validateSearchQuery(args); try { // Ensure components list is loaded await this.ensureComponentsListLoaded(); // Filter components matching the search query const results = this.searchComponentsByQuery(query); return this.createSuccessResponse(results); } catch (error) { this.handleAxiosError(error, "Search failed"); } }
  • Input schema definition for the search_components tool requiring a string 'query' parameter.
    inputSchema: { type: "object", properties: { query: { type: "string", description: "Search query to find relevant components", }, }, required: ["query"], },
  • src/index.ts:167-168 (registration)
    Switch case registration that routes search_components tool calls to the handler method.
    case "search_components": return await this.handleSearchComponents(request.params.arguments);
  • Helper function implementing the core search logic by filtering the cached components list based on query matching name or lowercase description.
    private searchComponentsByQuery(query: string): ComponentInfo[] { if (!this.componentsListCache) { return []; } return this.componentsListCache.filter(component => { return ( component.name.includes(query) || component.description.toLowerCase().includes(query) ); }); }
  • Helper function that validates the presence and type of the query argument and returns it lowercased.
    private validateSearchQuery(args: any): string { if (!args?.query || typeof args.query !== "string") { throw new McpError( ErrorCode.InvalidParams, "Search query is required and must be a string" ); } return args.query.toLowerCase(); }

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/ymadd/shadcn-ui-mcp-server'

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