search_by_intervention
Find clinical trials by specifying a treatment, drug, device, or intervention type. Filter results by study phase to identify relevant research studies.
Instructions
Search clinical trials by intervention or treatment type
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| intervention | Yes | Intervention, drug, device, or treatment name | |
| interventionType | No | Type of intervention | |
| phase | No | Study phase filter | |
| pageSize | No | Number of results to return (default 10, max 100) |
Implementation Reference
- src/index.ts:1317-1383 (handler)The handler function `handleSearchByIntervention` executes the logic to fetch clinical trials by intervention using the ClinicalTrials.gov API.
private async handleSearchByIntervention(args: any) { if (!args?.intervention) { throw new McpError( ErrorCode.InvalidParams, "Intervention parameter is required" ); } const params: any = { format: "json", pageSize: args?.pageSize || 10, "query.intr": args.intervention, }; if (args?.interventionType) { params["filter.interventionType"] = args.interventionType; } if (args?.phase) { params["filter.phase"] = args.phase; } try { const response: AxiosResponse<StudySearchResponse> = await this.axiosInstance.get("/studies", { params }); const studies = response.data.studies || []; const results = studies.map((study) => this.formatStudySummary(study)); return { content: [ { type: "text", text: JSON.stringify( { searchCriteria: { intervention: args.intervention, interventionType: args.interventionType, phase: args.phase, }, totalCount: response.data.totalCount || 0, resultsShown: results.length, studies: results, }, null, 2 ), }, ], }; } catch (error) { if (axios.isAxiosError(error)) { return { content: [ { type: "text", text: `Clinical Trials API error: ${ error.response?.data?.message || error.message }`, }, ], isError: true, }; } throw error; } } - src/index.ts:328-366 (registration)The tool `search_by_intervention` is registered in the list of tools with its schema definition.
name: "search_by_intervention", description: "Search clinical trials by intervention or treatment type", inputSchema: { type: "object", properties: { intervention: { type: "string", description: "Intervention, drug, device, or treatment name", minLength: 2, }, interventionType: { type: "string", description: "Type of intervention", enum: [ "DRUG", "DEVICE", "BIOLOGICAL", "PROCEDURE", "BEHAVIORAL", "OTHER", ], }, phase: { type: "string", description: "Study phase filter", enum: ["PHASE1", "PHASE2", "PHASE3", "PHASE4", "NA"], }, pageSize: { type: "number", description: "Number of results to return (default 10, max 100)", minimum: 1, maximum: 100, }, }, required: ["intervention"], }, },