Skip to main content
Glama

search-api-schemas

Search for schemas across multiple OpenAPI specifications integrated into the MCP server, enabling precise schema discovery for API development and LLM-powered IDE integrations.

Instructions

Search for schemas across specifications

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
specIdNo

Implementation Reference

  • Registration of the MCP tool 'search-api-schemas' including description, input parameters schema, and inline handler function.
    server.tool( "search-api-schemas", "Search for schemas across specifications", { query: z.string(), specId: z.string().optional(), }, async (args, extra) => { try { this.logger.debug('Searching API schemas', { query: args.query, specId: args.specId }); const schemas = await this.specExplorer.searchSchemas(args.query, args.specId); return { content: [ { type: "text", text: stringify({ schemas }, { indent: 2 }) }, ], }; } catch (error) { this.logger.error('Failed to search API schemas', { error, query: args.query }); throw error; } } );
  • Handler function for the 'search-api-schemas' tool: logs, calls specExplorer.searchSchemas, stringifies result as YAML in text content, handles errors.
    async (args, extra) => { try { this.logger.debug('Searching API schemas', { query: args.query, specId: args.specId }); const schemas = await this.specExplorer.searchSchemas(args.query, args.specId); return { content: [ { type: "text", text: stringify({ schemas }, { indent: 2 }) }, ], }; } catch (error) { this.logger.error('Failed to search API schemas', { error, query: args.query }); throw error; } } );
  • Input schema for the tool: query (required string), specId (optional string) using Zod validation.
    query: z.string(), specId: z.string().optional(), },
  • Core implementation of schema search: filters specs by optional specId, collects schema entries, uses Fuse.js fuzzy search on name/description, returns matching schemas.
    async searchSchemas( query: string, specId?: string ): Promise<SpecSchemaEntry[]> { const targetSpecs: SpecCatalogEntry[] = []; if (specId) { const spec = this.catalog.find((spec) => spec.uri.specId === specId); if (spec) { targetSpecs.push(spec); } } else { targetSpecs.push(...this.catalog); } const schemaEntries: SpecSchemaEntry[] = []; for (const spec of targetSpecs) { schemaEntries.push( ...spec.schemas.map((schema) => ({ ...schema, specId: spec.uri.specId, })) ); } const fuse = new Fuse(schemaEntries, { includeScore: true, threshold: 0.2, keys: ["name", "description"], }); const results = fuse.search(query); return results.map((result) => result.item); }

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/ReAPI-com/mcp-openapi'

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