Skip to main content
Glama
BACH-AI-Tools

Clinical Trials MCP Server

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
NameRequiredDescriptionDefault
interventionYesIntervention, drug, device, or treatment name
interventionTypeNoType of intervention
phaseNoStudy phase filter
pageSizeNoNumber of results to return (default 10, max 100)

Implementation Reference

  • 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"],
      },
    },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/BACH-AI-Tools/ClinicalTrials-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server