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

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.1

TDQS

B3.2/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description must disclose typical search behaviors. It only states the search function and does not mention return format, pagination, authentication, or other operational characteristics. The description adds minimal behavioral context beyond the parameter schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a concise single sentence that effectively communicates the core action and scope. No filler or redundant words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no annotations and no output schema, the description is insufficient for an agent to fully understand the tool's behavior. It does not describe result structure, pagination behavior, or how optional filters affect outcomes. A single sentence is inadequate for a 4-parameter search tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3. The description summarizes the intervention field but adds no additional meaning beyond the schema's parameter descriptions; the `interventionType` and `phase` filters are not elaborated.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool searches clinical trials using intervention or treatment type as the filter dimension. It distinguishes from sibling tools like search_by_condition or search_by_location by identifying the specific search aspect.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives such as search_by_condition or search_studies. The description implies usage for intervention-based searches but does not offer any exclusion criteria or comparative context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.