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
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"query": "<query>"
},
"name": "search-api-schemas"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| specId | No |
Implementation Reference
- src/McpService.ts:125-138 (handler)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; } } - src/McpService.ts:122-124 (schema)Input parameters schema using Zod: query (string, required), specId (string, optional).
query: z.string(), specId: z.string().optional(), }, - src/McpService.ts:118-139 (registration)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; } } ); - src/core/SpecService.ts:383-415 (helper)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); }