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,
          },
        },
      },
    },
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. While 'Search' implies a read-only operation, it doesn't specify whether this is a safe query, what permissions are needed, whether results are paginated, or what format the output takes. For a search tool with 6 parameters and no annotations, this is insufficient behavioral context.

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 states the tool's core purpose without unnecessary words. It's appropriately sized and front-loaded with the essential 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?

For a search tool with 6 parameters, no annotations, and no output schema, the description is incomplete. It doesn't address behavioral aspects (safety, permissions, pagination), doesn't differentiate from sibling tools, and provides no guidance on parameter interactions or result format. The 100% schema coverage helps with parameters, but other contextual gaps remain significant.

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 schema already documents all 6 parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't explain relationships between date parameters or how condition filtering interacts with date ranges). Baseline 3 is appropriate when 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 tool's purpose: 'Search clinical trials by start or completion date range'. It specifies the verb ('Search'), resource ('clinical trials'), and scope ('by start or completion date range'). However, it doesn't explicitly differentiate from sibling tools like 'search_by_condition' or 'search_by_intervention', which would require a 5.

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. With multiple sibling search tools available (e.g., 'search_by_condition', 'search_by_location'), there's no indication of when date-range filtering is appropriate versus other search criteria. This leaves the agent without contextual usage instructions.

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