Skip to main content
Glama

search-api-schemas

Search for API schemas across OpenAPI specifications to help developers find and understand API structures within their development tools.

Instructions

Search for schemas across specifications

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
specIdNo

Implementation Reference

  • Executes the tool logic: logs the search, calls specExplorer.searchSchemas, stringifies results to YAML, and returns as text content.
    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 parameters schema using Zod: query (string, required), specId (string, optional).
    query: z.string(), specId: z.string().optional(), },
  • Registers the 'search-api-schemas' tool on the MCP server with name, description, input schema, and handler.
    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; } } );
  • Implements the schema search functionality using Fuse.js for fuzzy matching on schema names and descriptions across specified or all specs.
    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