Skip to main content
Glama
BACH-AI-Tools

Clinical Trials MCP Server

search_by_date_range

Find clinical trials by filtering based on start or completion date ranges to identify studies within specific timeframes.

Instructions

Search clinical trials by start or completion date range

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
startDateFromNoStart date from (YYYY-MM-DD format)
startDateToNoStart date to (YYYY-MM-DD format)
completionDateFromNoPrimary completion date from (YYYY-MM-DD format)
completionDateToNoPrimary completion date to (YYYY-MM-DD format)
conditionNoOptional condition filter
pageSizeNoNumber of results to return (default 10, max 100)

Implementation Reference

  • Handler function for search_by_date_range tool.
    private async handleSearchByDateRange(args: any) {
      const params: any = {
        format: "json",
        pageSize: args?.pageSize || 10,
      };
    
      if (args?.startDateFrom) {
        params["filter.studyStartDateFrom"] = args.startDateFrom;
      }
    
      if (args?.startDateTo) {
        params["filter.studyStartDateTo"] = args.startDateTo;
      }
    
      if (args?.completionDateFrom) {
        params["filter.primaryCompletionDateFrom"] = args.completionDateFrom;
      }
    
      if (args?.completionDateTo) {
        params["filter.primaryCompletionDateTo"] = args.completionDateTo;
      }
    
      if (args?.condition) {
        params["query.cond"] = args.condition;
      }
    
      try {
        const response: AxiosResponse<StudySearchResponse> =
          await this.axiosInstance.get("/studies", { params });
    
        const studies = response.data.studies || [];
        const results = studies.map((study) => ({
          ...this.formatStudySummary(study),
          dates: {
            startDate: study.protocolSection.statusModule.startDateStruct?.date,
            primaryCompletionDate:
              study.protocolSection.statusModule.primaryCompletionDateStruct
                ?.date,
          },
        }));
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  searchCriteria: {
                    startDateFrom: args?.startDateFrom,
                    startDateTo: args?.startDateTo,
                    completionDateFrom: args?.completionDateFrom,
                    completionDateTo: args?.completionDateTo,
                    condition: args?.condition,
                  },
                  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:397-436 (registration)
    Schema registration for search_by_date_range tool.
      name: "search_by_date_range",
      description:
        "Search clinical trials by start or completion date range",
      inputSchema: {
        type: "object",
        properties: {
          startDateFrom: {
            type: "string",
            description: "Start date from (YYYY-MM-DD format)",
            pattern: "^\\d{4}-\\d{2}-\\d{2}$",
          },
          startDateTo: {
            type: "string",
            description: "Start date to (YYYY-MM-DD format)",
            pattern: "^\\d{4}-\\d{2}-\\d{2}$",
          },
          completionDateFrom: {
            type: "string",
            description: "Primary completion date from (YYYY-MM-DD format)",
            pattern: "^\\d{4}-\\d{2}-\\d{2}$",
          },
          completionDateTo: {
            type: "string",
            description: "Primary completion date to (YYYY-MM-DD format)",
            pattern: "^\\d{4}-\\d{2}-\\d{2}$",
          },
          condition: {
            type: "string",
            description: "Optional condition filter",
          },
          pageSize: {
            type: "number",
            description:
              "Number of results to return (default 10, max 100)",
            minimum: 1,
            maximum: 100,
          },
        },
      },
    },

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.1

TDQS

A3.6/5.0
Behavior2/5

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

With no annotations provided, the description carries the full burden of disclosing behavior. It only states the basic search action and does not explain return format, pagination, how date ranges are applied (e.g., inclusive, AND/OR logic), or any defaults. This is a significant gap for a read/search operation.

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 one concise sentence, front-loaded with the action and resource. Every word earns its place, and there is no redundant information.

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?

The tool has 6 parameters, no annotations, and no output schema. The description is too minimal to provide complete context. It does not explain return value, required parameter combinations, or whether date ranges can be combined with other filters like condition. The schema covers parameters, but the description should compensate for missing annotations/output schema and does not.

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%, so the baseline is 3. The description adds no extra parameter semantics beyond what the schema already provides. The parameter names and schema descriptions are sufficient, but the description doesn't enhance understanding of how parameters combine.

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 uses the specific verb 'Search' with the resource 'clinical trials' and clearly states the search criterion ('by start or completion date range'). This distinguishes it from sibling tools like search_by_condition or search_by_location, making the purpose unmistakable.

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

Usage Guidelines4/5

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

The description clearly implies when to use the tool: when a date range filter is needed. It does not explicitly mention alternatives or exclusions, but the name and phrasing provide sufficient context for selecting it among sibling search tools.

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