Skip to main content
Glama
BACH-AI-Tools

Clinical Trials MCP Server

search_by_eligibility_criteria

Find clinical trials matching specific eligibility requirements like age, condition, and inclusion/exclusion criteria to identify suitable studies for patients or research.

Instructions

Advanced search based on detailed eligibility criteria

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
minAgeNoMinimum age (e.g., "18 Years", "6 Months")
maxAgeNoMaximum age (e.g., "65 Years", "12 Years")
sexNoSex eligibility
healthyVolunteersNoWhether study accepts healthy volunteers
conditionNoMedical condition filter
exclusionKeywordsNoKeywords that should NOT appear in eligibility criteria
inclusionKeywordsNoKeywords that should appear in eligibility criteria
pageSizeNoNumber of results to return (default 10, max 100)

Implementation Reference

  • The handleSearchByEligibilityCriteria method implements the tool logic, including optional exclusion keyword filtering which is done client-side after the API call.
    async handleSearchByEligibilityCriteria(args) {
        const params = {
            format: "json",
            pageSize: args?.pageSize || 10,
        };
        if (args?.minAge) {
            params["filter.minimumAge"] = args.minAge;
        }
        if (args?.maxAge) {
            params["filter.maximumAge"] = args.maxAge;
        }
        if (args?.sex) {
            params["filter.sex"] = args.sex;
        }
        if (args?.healthyVolunteers !== undefined) {
            params["filter.healthyVolunteers"] = args.healthyVolunteers;
        }
        if (args?.condition) {
            params["query.cond"] = args.condition;
        }
        if (args?.inclusionKeywords) {
            params["query.eligibility"] = args.inclusionKeywords;
        }
        try {
            const response = await this.axiosInstance.get("/studies", { params });
            const studies = response.data.studies || [];
            let filteredStudies = studies;
            // Apply exclusion keyword filtering if specified
            if (args?.exclusionKeywords) {
                const exclusionWords = args.exclusionKeywords
                    .toLowerCase()
                    .split(/\s+/);
                filteredStudies = studies.filter((study) => {
                    const eligibilityCriteria = study.protocolSection.eligibilityModule?.eligibilityCriteria?.toLowerCase() ||
                        "";
                    return !exclusionWords.some((word) => eligibilityCriteria.includes(word));
                });
            }
            const results = filteredStudies.map((study) => ({
                ...this.formatStudySummary(study),
                eligibility: {
                    sex: study.protocolSection.eligibilityModule?.sex || "Unknown",
                    minimumAge: study.protocolSection.eligibilityModule?.minimumAge ||
                        "Not specified",
                    maximumAge: study.protocolSection.eligibilityModule?.maximumAge ||
                        "Not specified",
                    healthyVolunteers: study.protocolSection.eligibilityModule?.healthyVolunteers || false,
                    criteriaPreview: study.protocolSection.eligibilityModule?.eligibilityCriteria?.substring(0, 200) + "..." || "Not available",
                },
            }));
            return {
                content: [
                    {
                        type: "text",
                        text: JSON.stringify({
                            searchCriteria: {
                                minAge: args?.minAge,
                                maxAge: args?.maxAge,
                                sex: args?.sex,
                                healthyVolunteers: args?.healthyVolunteers,
                                condition: args?.condition,
                                inclusionKeywords: args?.inclusionKeywords,
                                exclusionKeywords: args?.exclusionKeywords,
                            },
                            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;
        }
    }
  • build/index.js:492-534 (registration)
    The tool search_by_eligibility_criteria is registered in the setupToolHandlers method with its schema definition.
        name: "search_by_eligibility_criteria",
        description: "Advanced search based on detailed eligibility criteria",
        inputSchema: {
            type: "object",
            properties: {
                minAge: {
                    type: "string",
                    description: 'Minimum age (e.g., "18 Years", "6 Months")',
                },
                maxAge: {
                    type: "string",
                    description: 'Maximum age (e.g., "65 Years", "12 Years")',
                },
                sex: {
                    type: "string",
                    description: "Sex eligibility",
                    enum: ["ALL", "FEMALE", "MALE"],
                },
                healthyVolunteers: {
                    type: "boolean",
                    description: "Whether study accepts healthy volunteers",
                },
                condition: {
                    type: "string",
                    description: "Medical condition filter",
                },
                exclusionKeywords: {
                    type: "string",
                    description: "Keywords that should NOT appear in eligibility criteria",
                },
                inclusionKeywords: {
                    type: "string",
                    description: "Keywords that should appear in eligibility criteria",
                },
                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

C2.9/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 behavioral disclosure. It only says 'Advanced search' and does not mention whether it is read-only, pagination behavior, default limits, or any other side effects or constraints. The description adds no behavioral context beyond the obvious search action.

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

Conciseness4/5

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

The description is a single concise sentence with no wasted words. However, it is so brief that it borders on under-specification, but structurally it is well-front-loaded and easy to parse. Given the tool's complexity, the brevity is not a structural flaw but rather a content gap addressed in other dimensions.

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?

This is a complex tool with 8 parameters, no annotations, and no output schema. The description is far too thin to adequately guide an agent. It does not explain what makes this search 'advanced,' how the criteria are applied, or what the returned data looks like. Significant gaps remain for such a parameter-rich 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 description coverage is 100%, so the schema already documents all 8 parameters. The description does not add any additional meaning to the parameters; it merely refers to 'detailed eligibility criteria' without elaborating on how parameters like inclusionKeywords or healthyVolunteers map to those criteria. It meets the baseline but adds no extra value.

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 is a search operation based on detailed eligibility criteria, which is a specific verb+resource. However, it does not distinguish itself from sibling search tools like search_by_condition, making 'advanced' vague and lacking differentiation.

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?

There is no guidance on when to use this tool versus alternatives. The description does not mention any exclusions, prerequisites, or specific scenarios where this search is preferred over other search tools, leaving the agent to infer usage from the name alone.

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