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,
                },
            },
        },
    },
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. It mentions 'advanced search' but doesn't disclose behavioral traits like whether this is a read-only operation, potential rate limits, authentication needs, or what happens with partial criteria. The description is too minimal to provide meaningful behavioral context for a search tool with 8 parameters.

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?

Extremely concise single sentence with zero waste. Every word contributes to the core message, though the message itself is under-specified. The structure is front-loaded with the essential concept.

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 8 parameters, no annotations, and no output schema, the description is incomplete. It doesn't specify what resource is being searched (clinical trials/studies), what the return format looks like, or how results are structured. With many sibling tools, more context is needed to distinguish this tool's specific role.

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 thoroughly. The description adds no additional meaning about parameters beyond implying they relate to 'eligibility criteria'. Baseline 3 is appropriate when schema does the heavy lifting.

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

Purpose3/5

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

The description 'Advanced search based on detailed eligibility criteria' states the general purpose (search with eligibility criteria) but is vague about what resource is being searched. It doesn't specify this searches for clinical trials/studies, nor does it distinguish from siblings like 'search_by_condition' or 'search_by_intervention' which also search studies.

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 on when to use this tool versus alternatives. With many sibling search tools (e.g., 'search_by_condition', 'search_by_location'), the description provides no context about when eligibility-based search is preferred over other search methods or what makes it 'advanced'.

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