Skip to main content
Glama
biocontext-ai

BioContextAI Knowledgebase MCP

Official

bc_get_studies_by_condition

Search clinical trials by medical condition to find studies with breakdowns by status, study type, and phase for research planning.

Instructions

Search trials by condition with summary statistics. Returns paginated results with breakdowns by status, study type, and phase.

Returns: dict: Studies list with summary containing condition searched, total studies, status/study type/phase breakdowns or error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
conditionYesMedical condition/disease (e.g., 'cancer', 'diabetes')
statusNo'RECRUITING', 'ACTIVE_NOT_RECRUITING', 'COMPLETED', or 'ALL'ALL
study_typeNo'INTERVENTIONAL', 'OBSERVATIONAL', or 'ALL'ALL
location_countryNoCountry filter (e.g., 'United States')
page_sizeNoResults per page (1-1000)
sortNo'LastUpdatePostDate:desc', 'StudyFirstPostDate:desc', or 'EnrollmentCount:desc'LastUpdatePostDate:desc

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function for the bc_get_studies_by_condition tool. Decorated with @core_mcp.tool(), queries ClinicalTrials.gov API for studies matching the condition, with optional filters for status, type, location, pagination, and sorting. Returns studies with summary breakdowns.
    @core_mcp.tool()
    def get_studies_by_condition(
        condition: Annotated[str, Field(description="Medical condition/disease (e.g., 'cancer', 'diabetes')")],
        status: Annotated[
            Optional[str],
            Field(description="'RECRUITING', 'ACTIVE_NOT_RECRUITING', 'COMPLETED', or 'ALL'"),
        ] = "ALL",
        study_type: Annotated[Optional[str], Field(description="'INTERVENTIONAL', 'OBSERVATIONAL', or 'ALL'")] = "ALL",
        location_country: Annotated[Optional[str], Field(description="Country filter (e.g., 'United States')")] = None,
        page_size: Annotated[int, Field(description="Results per page (1-1000)", ge=1, le=1000)] = 50,
        sort: Annotated[
            str,
            Field(description="'LastUpdatePostDate:desc', 'StudyFirstPostDate:desc', or 'EnrollmentCount:desc'"),
        ] = "LastUpdatePostDate:desc",
    ) -> Union[Dict[str, Any], dict]:
        """Search trials by condition with summary statistics. Returns paginated results with breakdowns by status, study type, and phase.
    
        Returns:
            dict: Studies list with summary containing condition searched, total studies, status/study type/phase breakdowns or error message.
        """
        if not condition:
            return {"error": "Medical condition must be provided"}
    
        # Build query components
        query_parts = [f"AREA[ConditionSearch]{condition}"]
    
        if status and status != "ALL":
            query_parts.append(f"AREA[OverallStatus]{status}")
    
        if study_type and study_type != "ALL":
            query_parts.append(f"AREA[StudyType]{study_type}")
    
        if location_country:
            query_parts.append(f"AREA[LocationCountry]{location_country}")
    
        # Join query parts with AND
        query = " AND ".join(query_parts)
    
        url = f"https://clinicaltrials.gov/api/v2/studies?query.term={query}&pageSize={page_size}&sort={sort}&format=json"
    
        try:
            response = requests.get(url)
            response.raise_for_status()
            data = response.json()
    
            # Add summary statistics
            if "studies" in data:
                total_studies = data.get("totalCount", len(data["studies"]))
    
                # Count studies by status
                status_counts: dict[str, int] = {}
                study_type_counts: dict[str, int] = {}
                phase_counts: dict[str, int] = {}
    
                for study in data["studies"]:
                    # Extract status
                    status_module = study.get("protocolSection", {}).get("statusModule", {})
                    study_status = status_module.get("overallStatus", "Unknown")
                    status_counts[study_status] = status_counts.get(study_status, 0) + 1
    
                    # Extract study type
                    design_module = study.get("protocolSection", {}).get("designModule", {})
                    design_study_type = design_module.get("studyType", "Unknown")
                    study_type_counts[design_study_type] = study_type_counts.get(design_study_type, 0) + 1
    
                    # Extract phase for interventional studies
                    phases = design_module.get("phases", [])
                    if phases:
                        for phase in phases:
                            phase_counts[phase] = phase_counts.get(phase, 0) + 1
                    else:
                        phase_counts["N/A"] = phase_counts.get("N/A", 0) + 1
    
                # Add summary to response
                data["summary"] = {
                    "condition_searched": condition,
                    "total_studies": total_studies,
                    "studies_returned": len(data["studies"]),
                    "status_breakdown": status_counts,
                    "study_type_breakdown": study_type_counts,
                    "phase_breakdown": phase_counts,
                }
    
            return data
        except requests.exceptions.RequestException as e:
            return {"error": f"Failed to fetch studies by condition: {e!s}"}
Behavior3/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 mentions 'Returns paginated results' and 'summary statistics,' which are useful behavioral traits. However, it lacks details on rate limits, authentication needs, error handling, or data freshness, which are important for a search tool. The description does not contradict any annotations (none exist).

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 concise and well-structured, with two sentences that efficiently convey the tool's purpose and return format. The first sentence states the action and key features, while the second clarifies the output. There is no wasted text, though it could be slightly more front-loaded by integrating return details into the main statement.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (6 parameters, pagination, statistical breakdowns), the description is reasonably complete. It mentions pagination and summary statistics, and with an output schema present, it doesn't need to detail return values. However, it lacks context on data sources or limitations, which would enhance completeness for a search 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?

The input schema has 100% description coverage, so the schema fully documents all parameters. The description adds no additional parameter semantics beyond what the schema provides (e.g., it doesn't explain how 'condition' is normalized or how pagination works). The baseline score of 3 is appropriate as the schema handles the heavy lifting.

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 clearly states the tool's purpose: 'Search trials by condition with summary statistics.' It specifies the verb ('search'), resource ('trials'), and scope ('by condition'), and distinguishes it from siblings like 'bc_get_studies_by_intervention' and 'bc_search_studies' by focusing on condition-based filtering with statistical breakdowns.

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 does not mention sibling tools like 'bc_get_studies_by_intervention' (for intervention-based searches) or 'bc_search_studies' (which might offer broader search capabilities), leaving the agent without context for tool selection.

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/biocontext-ai/knowledgebase-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server