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.

205 lines (204 loc) 8.68 kB
/** * @fileoverview Defines the core logic, schemas, and types for the `clinicaltrials_analyze_trends` tool. * @module src/mcp-server/tools/analyzeTrends/logic */ import { z } from "zod"; import { type RequestContext } from "../../../utils/index.js"; /** * Defines the types of analysis that can be performed. */ export declare const AnalysisTypeSchema: z.ZodEnum<["countByStatus", "countByCountry", "countBySponsorType", "countByPhase"]>; /** * Zod schema for the `clinicaltrials_analyze_trends` tool input. */ export declare const AnalyzeTrendsInputSchema: z.ZodObject<Pick<{ 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>; }, "filter" | "query"> & { analysisType: z.ZodUnion<[z.ZodEnum<["countByStatus", "countByCountry", "countBySponsorType", "countByPhase"]>, z.ZodArray<z.ZodEnum<["countByStatus", "countByCountry", "countBySponsorType", "countByPhase"]>, "many">]>; }, "strip", z.ZodTypeAny, { analysisType: "countByStatus" | "countByCountry" | "countBySponsorType" | "countByPhase" | ("countByStatus" | "countByCountry" | "countBySponsorType" | "countByPhase")[]; 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; 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; }, { analysisType: "countByStatus" | "countByCountry" | "countBySponsorType" | "countByPhase" | ("countByStatus" | "countByCountry" | "countBySponsorType" | "countByPhase")[]; 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; 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; }>; /** * TypeScript type inferred from the input schema. */ export type AnalyzeTrendsInput = z.infer<typeof AnalyzeTrendsInputSchema>; /** * Zod schema for the analysis result. */ export declare const AnalysisResultSchema: z.ZodObject<{ analysisType: z.ZodEnum<["countByStatus", "countByCountry", "countBySponsorType", "countByPhase"]>; totalStudies: z.ZodNumber; results: z.ZodRecord<z.ZodString, z.ZodNumber>; }, "strip", z.ZodTypeAny, { analysisType: "countByStatus" | "countByCountry" | "countBySponsorType" | "countByPhase"; totalStudies: number; results: Record<string, number>; }, { analysisType: "countByStatus" | "countByCountry" | "countBySponsorType" | "countByPhase"; totalStudies: number; results: Record<string, number>; }>; /** * Defines the structure for the analysis result. */ export type AnalysisResult = z.infer<typeof AnalysisResultSchema>; /** * Zod schema for the output of the `clinicaltrials_analyze_trends` tool. */ export declare const AnalyzeTrendsOutputSchema: z.ZodObject<{ analysis: z.ZodArray<z.ZodObject<{ analysisType: z.ZodEnum<["countByStatus", "countByCountry", "countBySponsorType", "countByPhase"]>; totalStudies: z.ZodNumber; results: z.ZodRecord<z.ZodString, z.ZodNumber>; }, "strip", z.ZodTypeAny, { analysisType: "countByStatus" | "countByCountry" | "countBySponsorType" | "countByPhase"; totalStudies: number; results: Record<string, number>; }, { analysisType: "countByStatus" | "countByCountry" | "countBySponsorType" | "countByPhase"; totalStudies: number; results: Record<string, number>; }>, "many">; }, "strip", z.ZodTypeAny, { analysis: { analysisType: "countByStatus" | "countByCountry" | "countBySponsorType" | "countByPhase"; totalStudies: number; results: Record<string, number>; }[]; }, { analysis: { analysisType: "countByStatus" | "countByCountry" | "countBySponsorType" | "countByPhase"; totalStudies: number; results: Record<string, number>; }[]; }>; /** * TypeScript type inferred from the output schema. */ export type AnalyzeTrendsOutput = z.infer<typeof AnalyzeTrendsOutputSchema>; /** * Performs a statistical analysis on a set of clinical trials matching the given criteria. * It fetches all studies (up to a limit) and aggregates data based on the specified analysis type. * * @param params - The validated input parameters for the tool. * @param context - The request context for logging and tracing. * @returns A promise that resolves with the structured analysis results. * @throws {McpError} If the query returns more studies than the analysis limit. */ export declare function analyzeTrendsLogic(params: AnalyzeTrendsInput, context: RequestContext): Promise<AnalyzeTrendsOutput>;