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
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| specId | No |
Implementation Reference
- src/McpService.ts:118-139 (registration)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; } } );
- src/McpService.ts:125-139 (handler)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; } } );
- src/McpService.ts:122-124 (schema)Input schema for the tool: query (required string), specId (optional string) using Zod validation.query: z.string(), specId: z.string().optional(), },
- src/core/SpecService.ts:383-415 (helper)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); }