Skip to main content
Glama
BACH-AI-Tools

Clinical Trials MCP Server

get_similar_studies

Find related clinical trials by matching conditions, interventions, sponsors, or phases to a specific NCT ID study.

Instructions

Find clinical trials similar to a specific study by NCT ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nctIdYesNCT ID of the reference study (e.g., NCT00000419)
similarityTypeNoType of similarity to search forCONDITION
pageSizeNoNumber of results to return (default 10, max 50)

Implementation Reference

  • The handleGetSimilarStudies function is the handler that executes the logic for finding similar clinical trials based on a provided NCT ID. It retrieves the reference study, determines the similarity type (CONDITION, SPONSOR, or PHASE), performs a new search on the ClinicalTrials.gov API using criteria extracted from the reference study, and filters out the reference study from the results.
    private async handleGetSimilarStudies(args: any) {
      if (!args?.nctId || !/^NCT\d{8}$/.test(args.nctId)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          "Valid NCT ID is required (format: NCT########)"
        );
      }
    
      try {
        // First get the reference study to extract similarity criteria
        const referenceResponse: AxiosResponse<StudySearchResponse> =
          await this.axiosInstance.get("/studies", {
            params: {
              format: "json",
              "query.term": args.nctId,
              pageSize: 1,
            },
          });
    
        if (
          !referenceResponse.data.studies ||
          referenceResponse.data.studies.length === 0
        ) {
          return {
            content: [
              {
                type: "text",
                text: `Reference study not found: ${args.nctId}`,
              },
            ],
            isError: true,
          };
        }
    
        const referenceStudy = referenceResponse.data.studies[0];
        const similarityType = args.similarityType || "CONDITION";
        let searchParams: any = {
          format: "json",
          pageSize: args?.pageSize || 10,
        };
    
        // Build search based on similarity type
        switch (similarityType) {
          case "CONDITION":
            const condition =
              referenceStudy.protocolSection.conditionsModule?.conditions?.[0];
            if (condition) {
              searchParams["query.cond"] = condition;
            }
            break;
          case "SPONSOR":
            const sponsor =
              referenceStudy.protocolSection.sponsorCollaboratorsModule
                ?.leadSponsor?.name;
            if (sponsor) {
              searchParams["query.spons"] = sponsor;
            }
            break;
          case "PHASE":
            const phase =
              referenceStudy.protocolSection.designModule?.phases?.[0];
            if (phase) {
              searchParams["filter.phase"] = phase;
            }
            break;
        }
    
        const response: AxiosResponse<StudySearchResponse> =
          await this.axiosInstance.get("/studies", { params: searchParams });
    
        const studies = response.data.studies || [];
        const results = studies
          .filter(
            (study) =>
              study.protocolSection.identificationModule.nctId !== args.nctId
          ) // Exclude reference study
          .map((study) => this.formatStudySummary(study));
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  referenceStudy: {
                    nctId: args.nctId,
                    title:
                      referenceStudy.protocolSection.identificationModule
                        .briefTitle,
                  },
                  similarityType,
                  totalCount: response.data.totalCount || 0,
                  resultsShown: results.length,
                  similarStudies: 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:531-558 (registration)
    Tool registration definition for "get_similar_studies" in the server's tool list.
      name: "get_similar_studies",
      description:
        "Find clinical trials similar to a specific study by NCT ID",
      inputSchema: {
        type: "object",
        properties: {
          nctId: {
            type: "string",
            description:
              "NCT ID of the reference study (e.g., NCT00000419)",
            pattern: "^NCT\\d{8}$",
          },
          similarityType: {
            type: "string",
            description: "Type of similarity to search for",
            enum: ["CONDITION", "INTERVENTION", "SPONSOR", "PHASE"],
            default: "CONDITION",
          },
          pageSize: {
            type: "number",
            description: "Number of results to return (default 10, max 50)",
            minimum: 1,
            maximum: 50,
          },
        },
        required: ["nctId"],
      },
    },
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It implies a read-only search operation but doesn't disclose rate limits, authentication needs, result format, pagination behavior, or what constitutes 'similarity' beyond the parameter types. This is inadequate for a tool with potential complexity.

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 single, efficient sentence that directly states the tool's purpose with zero wasted words. It's appropriately sized and front-loaded, making it easy to parse quickly.

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?

Given no annotations, no output schema, and a tool that performs similarity matching (which can be complex), the description is insufficient. It doesn't explain what the tool returns, how similarity is calculated, error conditions, or behavioral constraints, leaving significant gaps for agent understanding.

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 description coverage is 100%, providing full parameter documentation. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't explain how 'similarityType' affects results or provide examples of similarity matching). Baseline 3 is appropriate since the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the verb ('Find') and resource ('clinical trials similar to a specific study'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'search_by_condition' or 'search_by_intervention' that might also find similar studies through different mechanisms, missing full sibling distinction.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a valid NCT ID), exclusions, or how it differs from sibling search tools that might achieve similar outcomes, leaving usage context ambiguous.

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

Install Server

Other Tools

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