MCPcopy Create free account
hub / github.com/ReAPI-com/mcp-openapi / searchSchemas

Method searchSchemas

src/core/SpecService.ts:383–415  ·  view source on GitHub ↗
(
    query: string,
    specId?: string
  )

Source from the content-addressed store, hash-verified

381 }
382
383 async searchSchemas(
384 query: string,
385 specId?: string
386 ): Promise<SpecSchemaEntry[]> {
387 const targetSpecs: SpecCatalogEntry[] = [];
388 if (specId) {
389 const spec = this.catalog.find((spec) => spec.uri.specId === specId);
390 if (spec) {
391 targetSpecs.push(spec);
392 }
393 } else {
394 targetSpecs.push(...this.catalog);
395 }
396
397 const schemaEntries: SpecSchemaEntry[] = [];
398 for (const spec of targetSpecs) {
399 schemaEntries.push(
400 ...spec.schemas.map((schema) => ({
401 ...schema,
402 specId: spec.uri.specId,
403 }))
404 );
405 }
406
407 const fuse = new Fuse(schemaEntries, {
408 includeScore: true,
409 threshold: 0.2,
410 keys: ["name", "description"],
411 });
412
413 const results = fuse.search(query);
414 return results.map((result) => result.item);
415 }
416
417 async findSchemaByName(
418 specId: string,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected