UNPKG

clinicaltrialsgov-mcp-server

Version:

ClinicalTrials.gov Model Context Protocol (MCP) Server that provides a suite of tools for interacting with the official ClinicalTrials.gov v2 API. Enables AI agents and LLMs to programmatically search, retrieve, and analyze clinical trial data.

998 lines (997 loc) 38.6 kB
/** * @fileoverview Defines the core logic, schemas, and types for the `clinicaltrials_search_studies` tool. * @module src/mcp-server/tools/searchStudies/logic */ import { z } from "zod"; import { type RequestContext } from "../../../utils/index.js"; /** * Zod schema for the `clinicaltrials_search_studies` tool input. */ export declare const SearchStudiesInputSchema: z.ZodObject<{ query: z.ZodOptional<z.ZodObject<{ cond: z.ZodOptional<z.ZodString>; term: z.ZodOptional<z.ZodString>; locn: z.ZodOptional<z.ZodString>; titles: z.ZodOptional<z.ZodString>; intr: z.ZodOptional<z.ZodString>; outc: z.ZodOptional<z.ZodString>; spons: z.ZodOptional<z.ZodString>; id: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { id?: string | undefined; cond?: string | undefined; term?: string | undefined; locn?: string | undefined; titles?: string | undefined; intr?: string | undefined; outc?: string | undefined; spons?: string | undefined; }, { id?: string | undefined; cond?: string | undefined; term?: string | undefined; locn?: string | undefined; titles?: string | undefined; intr?: string | undefined; outc?: string | undefined; spons?: string | undefined; }>>; filter: z.ZodOptional<z.ZodObject<{ ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; overallStatus: z.ZodOptional<z.ZodArray<z.ZodEnum<["ACTIVE_NOT_RECRUITING", "COMPLETED", "ENROLLING_BY_INVITATION", "NOT_YET_RECRUITING", "RECRUITING", "SUSPENDED", "TERMINATED", "WITHDRAWN", "UNKNOWN"]>, "many">>; geo: z.ZodOptional<z.ZodObject<{ latitude: z.ZodNumber; longitude: z.ZodNumber; radius: z.ZodNumber; unit: z.ZodDefault<z.ZodEnum<["km", "mi"]>>; }, "strip", z.ZodTypeAny, { latitude: number; longitude: number; radius: number; unit: "km" | "mi"; }, { latitude: number; longitude: number; radius: number; unit?: "km" | "mi" | undefined; }>>; advanced: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { overallStatus?: ("ACTIVE_NOT_RECRUITING" | "COMPLETED" | "ENROLLING_BY_INVITATION" | "NOT_YET_RECRUITING" | "RECRUITING" | "SUSPENDED" | "TERMINATED" | "WITHDRAWN" | "UNKNOWN")[] | undefined; ids?: string[] | undefined; geo?: { latitude: number; longitude: number; radius: number; unit: "km" | "mi"; } | undefined; advanced?: string | undefined; }, { overallStatus?: ("ACTIVE_NOT_RECRUITING" | "COMPLETED" | "ENROLLING_BY_INVITATION" | "NOT_YET_RECRUITING" | "RECRUITING" | "SUSPENDED" | "TERMINATED" | "WITHDRAWN" | "UNKNOWN")[] | undefined; ids?: string[] | undefined; geo?: { latitude: number; longitude: number; radius: number; unit?: "km" | "mi" | undefined; } | undefined; advanced?: string | undefined; }>>; fields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; sort: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; pageSize: z.ZodOptional<z.ZodDefault<z.ZodNumber>>; pageToken: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { sort?: string[] | undefined; filter?: { overallStatus?: ("ACTIVE_NOT_RECRUITING" | "COMPLETED" | "ENROLLING_BY_INVITATION" | "NOT_YET_RECRUITING" | "RECRUITING" | "SUSPENDED" | "TERMINATED" | "WITHDRAWN" | "UNKNOWN")[] | undefined; ids?: string[] | undefined; geo?: { latitude: number; longitude: number; radius: number; unit: "km" | "mi"; } | undefined; advanced?: string | undefined; } | undefined; fields?: string[] | undefined; query?: { id?: string | undefined; cond?: string | undefined; term?: string | undefined; locn?: string | undefined; titles?: string | undefined; intr?: string | undefined; outc?: string | undefined; spons?: string | undefined; } | undefined; pageSize?: number | undefined; pageToken?: string | undefined; }, { sort?: string[] | undefined; filter?: { overallStatus?: ("ACTIVE_NOT_RECRUITING" | "COMPLETED" | "ENROLLING_BY_INVITATION" | "NOT_YET_RECRUITING" | "RECRUITING" | "SUSPENDED" | "TERMINATED" | "WITHDRAWN" | "UNKNOWN")[] | undefined; ids?: string[] | undefined; geo?: { latitude: number; longitude: number; radius: number; unit?: "km" | "mi" | undefined; } | undefined; advanced?: string | undefined; } | undefined; fields?: string[] | undefined; query?: { id?: string | undefined; cond?: string | undefined; term?: string | undefined; locn?: string | undefined; titles?: string | undefined; intr?: string | undefined; outc?: string | undefined; spons?: string | undefined; } | undefined; pageSize?: number | undefined; pageToken?: string | undefined; }>; /** * TypeScript type inferred from the input schema. */ export type SearchStudiesInput = z.infer<typeof SearchStudiesInputSchema>; /** * Zod schema for the output of the `clinicaltrials_search_studies` tool. */ export declare const SearchStudiesOutputSchema: z.ZodObject<{ studies: z.ZodArray<z.ZodObject<{ protocolSection: z.ZodOptional<z.ZodObject<{ identificationModule: z.ZodOptional<z.ZodObject<{ nctId: z.ZodString; orgStudyIdInfo: z.ZodOptional<z.ZodObject<{ id: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; }, { id: string; }>>; organization: z.ZodOptional<z.ZodObject<{ fullName: z.ZodString; class: z.ZodString; }, "strip", z.ZodTypeAny, { class: string; fullName: string; }, { class: string; fullName: string; }>>; briefTitle: z.ZodOptional<z.ZodString>; officialTitle: z.ZodOptional<z.ZodString>; acronym: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { nctId: string; orgStudyIdInfo?: { id: string; } | undefined; organization?: { class: string; fullName: string; } | undefined; briefTitle?: string | undefined; officialTitle?: string | undefined; acronym?: string | undefined; }, { nctId: string; orgStudyIdInfo?: { id: string; } | undefined; organization?: { class: string; fullName: string; } | undefined; briefTitle?: string | undefined; officialTitle?: string | undefined; acronym?: string | undefined; }>>; statusModule: z.ZodOptional<z.ZodObject<{ overallStatus: z.ZodOptional<z.ZodString>; lastKnownStatus: z.ZodOptional<z.ZodString>; startDateStruct: z.ZodOptional<z.ZodObject<{ date: z.ZodString; type: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { date: string; type?: string | undefined; }, { date: string; type?: string | undefined; }>>; primaryCompletionDateStruct: z.ZodOptional<z.ZodObject<{ date: z.ZodString; type: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { date: string; type?: string | undefined; }, { date: string; type?: string | undefined; }>>; completionDateStruct: z.ZodOptional<z.ZodObject<{ date: z.ZodString; type: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { date: string; type?: string | undefined; }, { date: string; type?: string | undefined; }>>; }, "strip", z.ZodTypeAny, { overallStatus?: string | undefined; lastKnownStatus?: string | undefined; startDateStruct?: { date: string; type?: string | undefined; } | undefined; primaryCompletionDateStruct?: { date: string; type?: string | undefined; } | undefined; completionDateStruct?: { date: string; type?: string | undefined; } | undefined; }, { overallStatus?: string | undefined; lastKnownStatus?: string | undefined; startDateStruct?: { date: string; type?: string | undefined; } | undefined; primaryCompletionDateStruct?: { date: string; type?: string | undefined; } | undefined; completionDateStruct?: { date: string; type?: string | undefined; } | undefined; }>>; sponsorCollaboratorsModule: z.ZodOptional<z.ZodObject<{ responsibleParty: z.ZodOptional<z.ZodObject<{ type: z.ZodString; }, "strip", z.ZodTypeAny, { type: string; }, { type: string; }>>; leadSponsor: z.ZodOptional<z.ZodObject<{ name: z.ZodString; class: z.ZodString; }, "strip", z.ZodTypeAny, { name: string; class: string; }, { name: string; class: string; }>>; collaborators: z.ZodOptional<z.ZodArray<z.ZodObject<{ name: z.ZodString; class: z.ZodString; }, "strip", z.ZodTypeAny, { name: string; class: string; }, { name: string; class: string; }>, "many">>; }, "strip", z.ZodTypeAny, { responsibleParty?: { type: string; } | undefined; leadSponsor?: { name: string; class: string; } | undefined; collaborators?: { name: string; class: string; }[] | undefined; }, { responsibleParty?: { type: string; } | undefined; leadSponsor?: { name: string; class: string; } | undefined; collaborators?: { name: string; class: string; }[] | undefined; }>>; descriptionModule: z.ZodOptional<z.ZodObject<{ briefSummary: z.ZodOptional<z.ZodString>; detailedDescription: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { briefSummary?: string | undefined; detailedDescription?: string | undefined; }, { briefSummary?: string | undefined; detailedDescription?: string | undefined; }>>; conditionsModule: z.ZodOptional<z.ZodObject<{ conditions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; keywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; }, "strip", z.ZodTypeAny, { conditions?: string[] | undefined; keywords?: string[] | undefined; }, { conditions?: string[] | undefined; keywords?: string[] | undefined; }>>; armsInterventionsModule: z.ZodOptional<z.ZodObject<{ arms: z.ZodOptional<z.ZodArray<z.ZodObject<{ name: z.ZodString; type: z.ZodString; description: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { type: string; name: string; description?: string | undefined; }, { type: string; name: string; description?: string | undefined; }>, "many">>; interventions: z.ZodOptional<z.ZodArray<z.ZodObject<{ type: z.ZodString; name: z.ZodString; description: z.ZodOptional<z.ZodString>; armNames: z.ZodArray<z.ZodString, "many">; }, "strip", z.ZodTypeAny, { type: string; name: string; armNames: string[]; description?: string | undefined; }, { type: string; name: string; armNames: string[]; description?: string | undefined; }>, "many">>; }, "strip", z.ZodTypeAny, { arms?: { type: string; name: string; description?: string | undefined; }[] | undefined; interventions?: { type: string; name: string; armNames: string[]; description?: string | undefined; }[] | undefined; }, { arms?: { type: string; name: string; description?: string | undefined; }[] | undefined; interventions?: { type: string; name: string; armNames: string[]; description?: string | undefined; }[] | undefined; }>>; designModule: z.ZodOptional<z.ZodObject<{ studyType: z.ZodOptional<z.ZodString>; phases: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; designInfo: z.ZodOptional<z.ZodObject<{ allocation: z.ZodOptional<z.ZodString>; interventionModel: z.ZodOptional<z.ZodString>; primaryPurpose: z.ZodOptional<z.ZodString>; maskingInfo: z.ZodOptional<z.ZodObject<{ masking: z.ZodString; }, "strip", z.ZodTypeAny, { masking: string; }, { masking: string; }>>; }, "strip", z.ZodTypeAny, { allocation?: string | undefined; interventionModel?: string | undefined; primaryPurpose?: string | undefined; maskingInfo?: { masking: string; } | undefined; }, { allocation?: string | undefined; interventionModel?: string | undefined; primaryPurpose?: string | undefined; maskingInfo?: { masking: string; } | undefined; }>>; }, "strip", z.ZodTypeAny, { studyType?: string | undefined; phases?: string[] | undefined; designInfo?: { allocation?: string | undefined; interventionModel?: string | undefined; primaryPurpose?: string | undefined; maskingInfo?: { masking: string; } | undefined; } | undefined; }, { studyType?: string | undefined; phases?: string[] | undefined; designInfo?: { allocation?: string | undefined; interventionModel?: string | undefined; primaryPurpose?: string | undefined; maskingInfo?: { masking: string; } | undefined; } | undefined; }>>; contactsLocationsModule: z.ZodOptional<z.ZodObject<{ locations: z.ZodOptional<z.ZodArray<z.ZodObject<{ city: z.ZodOptional<z.ZodString>; state: z.ZodOptional<z.ZodString>; country: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { city?: string | undefined; state?: string | undefined; country?: string | undefined; }, { city?: string | undefined; state?: string | undefined; country?: string | undefined; }>, "many">>; }, "strip", z.ZodTypeAny, { locations?: { city?: string | undefined; state?: string | undefined; country?: string | undefined; }[] | undefined; }, { locations?: { city?: string | undefined; state?: string | undefined; country?: string | undefined; }[] | undefined; }>>; }, "strip", z.ZodTypeAny, { identificationModule?: { nctId: string; orgStudyIdInfo?: { id: string; } | undefined; organization?: { class: string; fullName: string; } | undefined; briefTitle?: string | undefined; officialTitle?: string | undefined; acronym?: string | undefined; } | undefined; statusModule?: { overallStatus?: string | undefined; lastKnownStatus?: string | undefined; startDateStruct?: { date: string; type?: string | undefined; } | undefined; primaryCompletionDateStruct?: { date: string; type?: string | undefined; } | undefined; completionDateStruct?: { date: string; type?: string | undefined; } | undefined; } | undefined; sponsorCollaboratorsModule?: { responsibleParty?: { type: string; } | undefined; leadSponsor?: { name: string; class: string; } | undefined; collaborators?: { name: string; class: string; }[] | undefined; } | undefined; descriptionModule?: { briefSummary?: string | undefined; detailedDescription?: string | undefined; } | undefined; conditionsModule?: { conditions?: string[] | undefined; keywords?: string[] | undefined; } | undefined; armsInterventionsModule?: { arms?: { type: string; name: string; description?: string | undefined; }[] | undefined; interventions?: { type: string; name: string; armNames: string[]; description?: string | undefined; }[] | undefined; } | undefined; designModule?: { studyType?: string | undefined; phases?: string[] | undefined; designInfo?: { allocation?: string | undefined; interventionModel?: string | undefined; primaryPurpose?: string | undefined; maskingInfo?: { masking: string; } | undefined; } | undefined; } | undefined; contactsLocationsModule?: { locations?: { city?: string | undefined; state?: string | undefined; country?: string | undefined; }[] | undefined; } | undefined; }, { identificationModule?: { nctId: string; orgStudyIdInfo?: { id: string; } | undefined; organization?: { class: string; fullName: string; } | undefined; briefTitle?: string | undefined; officialTitle?: string | undefined; acronym?: string | undefined; } | undefined; statusModule?: { overallStatus?: string | undefined; lastKnownStatus?: string | undefined; startDateStruct?: { date: string; type?: string | undefined; } | undefined; primaryCompletionDateStruct?: { date: string; type?: string | undefined; } | undefined; completionDateStruct?: { date: string; type?: string | undefined; } | undefined; } | undefined; sponsorCollaboratorsModule?: { responsibleParty?: { type: string; } | undefined; leadSponsor?: { name: string; class: string; } | undefined; collaborators?: { name: string; class: string; }[] | undefined; } | undefined; descriptionModule?: { briefSummary?: string | undefined; detailedDescription?: string | undefined; } | undefined; conditionsModule?: { conditions?: string[] | undefined; keywords?: string[] | undefined; } | undefined; armsInterventionsModule?: { arms?: { type: string; name: string; description?: string | undefined; }[] | undefined; interventions?: { type: string; name: string; armNames: string[]; description?: string | undefined; }[] | undefined; } | undefined; designModule?: { studyType?: string | undefined; phases?: string[] | undefined; designInfo?: { allocation?: string | undefined; interventionModel?: string | undefined; primaryPurpose?: string | undefined; maskingInfo?: { masking: string; } | undefined; } | undefined; } | undefined; contactsLocationsModule?: { locations?: { city?: string | undefined; state?: string | undefined; country?: string | undefined; }[] | undefined; } | undefined; }>>; }, "strip", z.ZodTypeAny, { protocolSection?: { identificationModule?: { nctId: string; orgStudyIdInfo?: { id: string; } | undefined; organization?: { class: string; fullName: string; } | undefined; briefTitle?: string | undefined; officialTitle?: string | undefined; acronym?: string | undefined; } | undefined; statusModule?: { overallStatus?: string | undefined; lastKnownStatus?: string | undefined; startDateStruct?: { date: string; type?: string | undefined; } | undefined; primaryCompletionDateStruct?: { date: string; type?: string | undefined; } | undefined; completionDateStruct?: { date: string; type?: string | undefined; } | undefined; } | undefined; sponsorCollaboratorsModule?: { responsibleParty?: { type: string; } | undefined; leadSponsor?: { name: string; class: string; } | undefined; collaborators?: { name: string; class: string; }[] | undefined; } | undefined; descriptionModule?: { briefSummary?: string | undefined; detailedDescription?: string | undefined; } | undefined; conditionsModule?: { conditions?: string[] | undefined; keywords?: string[] | undefined; } | undefined; armsInterventionsModule?: { arms?: { type: string; name: string; description?: string | undefined; }[] | undefined; interventions?: { type: string; name: string; armNames: string[]; description?: string | undefined; }[] | undefined; } | undefined; designModule?: { studyType?: string | undefined; phases?: string[] | undefined; designInfo?: { allocation?: string | undefined; interventionModel?: string | undefined; primaryPurpose?: string | undefined; maskingInfo?: { masking: string; } | undefined; } | undefined; } | undefined; contactsLocationsModule?: { locations?: { city?: string | undefined; state?: string | undefined; country?: string | undefined; }[] | undefined; } | undefined; } | undefined; }, { protocolSection?: { identificationModule?: { nctId: string; orgStudyIdInfo?: { id: string; } | undefined; organization?: { class: string; fullName: string; } | undefined; briefTitle?: string | undefined; officialTitle?: string | undefined; acronym?: string | undefined; } | undefined; statusModule?: { overallStatus?: string | undefined; lastKnownStatus?: string | undefined; startDateStruct?: { date: string; type?: string | undefined; } | undefined; primaryCompletionDateStruct?: { date: string; type?: string | undefined; } | undefined; completionDateStruct?: { date: string; type?: string | undefined; } | undefined; } | undefined; sponsorCollaboratorsModule?: { responsibleParty?: { type: string; } | undefined; leadSponsor?: { name: string; class: string; } | undefined; collaborators?: { name: string; class: string; }[] | undefined; } | undefined; descriptionModule?: { briefSummary?: string | undefined; detailedDescription?: string | undefined; } | undefined; conditionsModule?: { conditions?: string[] | undefined; keywords?: string[] | undefined; } | undefined; armsInterventionsModule?: { arms?: { type: string; name: string; description?: string | undefined; }[] | undefined; interventions?: { type: string; name: string; armNames: string[]; description?: string | undefined; }[] | undefined; } | undefined; designModule?: { studyType?: string | undefined; phases?: string[] | undefined; designInfo?: { allocation?: string | undefined; interventionModel?: string | undefined; primaryPurpose?: string | undefined; maskingInfo?: { masking: string; } | undefined; } | undefined; } | undefined; contactsLocationsModule?: { locations?: { city?: string | undefined; state?: string | undefined; country?: string | undefined; }[] | undefined; } | undefined; } | undefined; }>, "many">; nextPageToken: z.ZodOptional<z.ZodString>; totalCount: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { studies: { protocolSection?: { identificationModule?: { nctId: string; orgStudyIdInfo?: { id: string; } | undefined; organization?: { class: string; fullName: string; } | undefined; briefTitle?: string | undefined; officialTitle?: string | undefined; acronym?: string | undefined; } | undefined; statusModule?: { overallStatus?: string | undefined; lastKnownStatus?: string | undefined; startDateStruct?: { date: string; type?: string | undefined; } | undefined; primaryCompletionDateStruct?: { date: string; type?: string | undefined; } | undefined; completionDateStruct?: { date: string; type?: string | undefined; } | undefined; } | undefined; sponsorCollaboratorsModule?: { responsibleParty?: { type: string; } | undefined; leadSponsor?: { name: string; class: string; } | undefined; collaborators?: { name: string; class: string; }[] | undefined; } | undefined; descriptionModule?: { briefSummary?: string | undefined; detailedDescription?: string | undefined; } | undefined; conditionsModule?: { conditions?: string[] | undefined; keywords?: string[] | undefined; } | undefined; armsInterventionsModule?: { arms?: { type: string; name: string; description?: string | undefined; }[] | undefined; interventions?: { type: string; name: string; armNames: string[]; description?: string | undefined; }[] | undefined; } | undefined; designModule?: { studyType?: string | undefined; phases?: string[] | undefined; designInfo?: { allocation?: string | undefined; interventionModel?: string | undefined; primaryPurpose?: string | undefined; maskingInfo?: { masking: string; } | undefined; } | undefined; } | undefined; contactsLocationsModule?: { locations?: { city?: string | undefined; state?: string | undefined; country?: string | undefined; }[] | undefined; } | undefined; } | undefined; }[]; nextPageToken?: string | undefined; totalCount?: number | undefined; }, { studies: { protocolSection?: { identificationModule?: { nctId: string; orgStudyIdInfo?: { id: string; } | undefined; organization?: { class: string; fullName: string; } | undefined; briefTitle?: string | undefined; officialTitle?: string | undefined; acronym?: string | undefined; } | undefined; statusModule?: { overallStatus?: string | undefined; lastKnownStatus?: string | undefined; startDateStruct?: { date: string; type?: string | undefined; } | undefined; primaryCompletionDateStruct?: { date: string; type?: string | undefined; } | undefined; completionDateStruct?: { date: string; type?: string | undefined; } | undefined; } | undefined; sponsorCollaboratorsModule?: { responsibleParty?: { type: string; } | undefined; leadSponsor?: { name: string; class: string; } | undefined; collaborators?: { name: string; class: string; }[] | undefined; } | undefined; descriptionModule?: { briefSummary?: string | undefined; detailedDescription?: string | undefined; } | undefined; conditionsModule?: { conditions?: string[] | undefined; keywords?: string[] | undefined; } | undefined; armsInterventionsModule?: { arms?: { type: string; name: string; description?: string | undefined; }[] | undefined; interventions?: { type: string; name: string; armNames: string[]; description?: string | undefined; }[] | undefined; } | undefined; designModule?: { studyType?: string | undefined; phases?: string[] | undefined; designInfo?: { allocation?: string | undefined; interventionModel?: string | undefined; primaryPurpose?: string | undefined; maskingInfo?: { masking: string; } | undefined; } | undefined; } | undefined; contactsLocationsModule?: { locations?: { city?: string | undefined; state?: string | undefined; country?: string | undefined; }[] | undefined; } | undefined; } | undefined; }[]; nextPageToken?: string | undefined; totalCount?: number | undefined; }>; /** * TypeScript type inferred from the output schema. */ export type SearchStudiesOutput = z.infer<typeof SearchStudiesOutputSchema>; /** * Searches for clinical studies using a combination of queries and filters. * Supports pagination, sorting, and geographic filtering. * * @param params - The validated input parameters for the tool. * @param context - The request context for logging and tracing. * @returns A promise that resolves with a paginated list of studies. * @throws {McpError} If the API request fails. */ export declare function searchStudiesLogic(params: SearchStudiesInput, context: RequestContext): Promise<SearchStudiesOutput>;