UNPKG

clinicaltrialsgov-mcp-server

Version:

Search ClinicalTrials.gov trials, retrieve study details and results, and match patients to eligible trials via MCP. STDIO or Streamable HTTP.

43 lines 2.01 kB
/** * @fileoverview Indexing and ranked-search utilities over the ClinicalTrials.gov * field model. Flattens the metadata tree into a flat list of valid field * identifiers (PascalCase `piece` names) and provides a scoring function used * for both keyword discovery and "did you mean" suggestions on validation. * @module services/clinical-trials/field-search */ import type { FieldNode } from './types.js'; /** A flattened entry for one field in the ClinicalTrials.gov data model. */ export interface FieldIndexEntry { /** Field description from the data model. */ description?: string; /** Whether the field is an enum. */ isEnum?: boolean; /** camelCase tree name. */ name: string; /** Full dot-notation path in the study record. */ path: string; /** PascalCase identifier used in `fields`, `AREA[]`, and `sort` parameters. */ piece: string; /** Source data type from the upstream model. */ sourceType?: string; /** Data type (STRING, INTEGER, DATE, ENUM, BOOLEAN, etc.). */ type?: string; } /** Walk the metadata tree and emit one entry per node that has a `piece` name. */ export declare function flattenMetadata(tree: FieldNode[]): FieldIndexEntry[]; /** * Rank entries by relevance to query and return the top `limit` along with the * pre-cap match total, so callers can disclose truncation accurately — the slice * alone can't distinguish "exactly `limit` matched" from "more than `limit`". */ export declare function searchFields(query: string, entries: FieldIndexEntry[], limit: number): { entries: FieldIndexEntry[]; total: number; }; /** * Suggest the closest valid `piece` names to an invalid input. Uses the same * keyword scoring first, falls back to Levenshtein distance for typos that * don't share token-level signal (e.g., `ConditionList` → `Condition`). */ export declare function nearestPieces(invalid: string, entries: FieldIndexEntry[], n?: number): string[]; //# sourceMappingURL=field-search.d.ts.map