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.

153 lines (152 loc) 4.95 kB
/** * @fileoverview Defines the TypeScript types for the ClinicalTrials.gov API. * These types are based on the API's OpenAPI specification and are used * throughout the server for type safety and data consistency. * @module src/services/clinical-trials-gov/types */ import { z } from "zod"; /** * Zod schema for a single clinical study, mirroring the ClinicalTrials.gov API structure. * This provides runtime validation and serves as the single source of truth for the Study type. */ export const StudySchema = z.object({ protocolSection: z .object({ identificationModule: z .object({ nctId: z.string(), orgStudyIdInfo: z.object({ id: z.string() }).optional(), organization: z .object({ fullName: z.string(), class: z.string(), }) .optional(), briefTitle: z.string().optional(), officialTitle: z.string().optional(), acronym: z.string().optional(), }) .optional(), statusModule: z .object({ overallStatus: z.string().optional(), lastKnownStatus: z.string().optional(), startDateStruct: z .object({ date: z.string(), type: z.string().optional(), }) .optional(), primaryCompletionDateStruct: z .object({ date: z.string(), type: z.string().optional(), }) .optional(), completionDateStruct: z .object({ date: z.string(), type: z.string().optional(), }) .optional(), }) .optional(), sponsorCollaboratorsModule: z .object({ responsibleParty: z.object({ type: z.string() }).optional(), leadSponsor: z .object({ name: z.string(), class: z.string(), }) .optional(), collaborators: z .array(z.object({ name: z.string(), class: z.string(), })) .optional(), }) .optional(), descriptionModule: z .object({ briefSummary: z.string().optional(), detailedDescription: z.string().optional(), }) .optional(), conditionsModule: z .object({ conditions: z.array(z.string()).optional(), keywords: z.array(z.string()).optional(), }) .optional(), armsInterventionsModule: z .object({ arms: z .array(z.object({ name: z.string(), type: z.string(), description: z.string().optional(), })) .optional(), interventions: z .array(z.object({ type: z.string(), name: z.string(), description: z.string().optional(), armNames: z.array(z.string()), })) .optional(), }) .optional(), designModule: z .object({ studyType: z.string().optional(), phases: z.array(z.string()).optional(), designInfo: z .object({ allocation: z.string().optional(), interventionModel: z.string().optional(), primaryPurpose: z.string().optional(), maskingInfo: z.object({ masking: z.string() }).optional(), }) .optional(), }) .optional(), contactsLocationsModule: z .object({ locations: z .array(z.object({ city: z.string().optional(), state: z.string().optional(), country: z.string().optional(), })) .optional(), }) .optional(), }) .optional(), }); /** * Zod schema for a paged list of studies. */ export const PagedStudiesSchema = z.object({ studies: z.array(StudySchema), nextPageToken: z.string().optional(), totalCount: z.number().optional(), }); /** * Represents the possible status values for a study. */ export var Status; (function (Status) { Status["ActiveNotRecruiting"] = "ACTIVE_NOT_RECRUITING"; Status["Completed"] = "COMPLETED"; Status["EnrollingByInvitation"] = "ENROLLING_BY_INVITATION"; Status["NotYetRecruiting"] = "NOT_YET_RECRUITING"; Status["Recruiting"] = "RECRUITING"; Status["Suspended"] = "SUSPENDED"; Status["Terminated"] = "TERMINATED"; Status["Withdrawn"] = "WITHDRAWN"; Status["Unknown"] = "UNKNOWN"; })(Status || (Status = {}));