Skip to main content
Glama

trial_outcomes_getter

Retrieve detailed trial outcome measures and results, including primary and secondary outcomes, data, and adverse events, using the NCT ID for completed clinical trials with posted data.

Instructions

Fetch outcome measures and results for a clinical trial.

Retrieves detailed outcome information including:
- Primary outcome measures
- Secondary outcome measures
- Results data (if available)
- Adverse events (if reported)

Note: Results are only available for completed trials that have posted data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nct_idYesNCT ID (e.g., 'NCT06524388')

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler function 'trial_outcomes_getter'. This is the main entrypoint registered with the MCP server. It defines the tool schema via Annotated parameters, handles the tool call, passes a call_benefit, and delegates to the core _trial_outcomes implementation.
    @mcp_app.tool()
    @track_performance("biomcp.trial_outcomes_getter")
    async def trial_outcomes_getter(
        nct_id: Annotated[
            str,
            Field(description="NCT ID (e.g., 'NCT06524388')"),
        ],
    ) -> str:
        """Fetch outcome measures and results for a clinical trial.
    
        Retrieves detailed outcome information including:
        - Primary outcome measures
        - Secondary outcome measures
        - Results data (if available)
        - Adverse events (if reported)
    
        Note: Results are only available for completed trials that have posted data.
        """
        return await _trial_outcomes(
            call_benefit="Fetch trial outcome measures and results for efficacy assessment",
            nct_id=nct_id,
        )
  • Core helper function _trial_outcomes that fetches outcomes data from ClinicalTrials.gov API using the shared get_trial function with Outcomes module. This contains the domain-specific logic invoked by the tool handler.
    async def _trial_outcomes(
        call_benefit: Annotated[
            str,
            "Define and summarize why this function is being called and the intended benefit",
        ],
        nct_id: str,
    ) -> str:
        """
        Retrieves outcome measures, results (if available), and
        adverse event data for a single clinical trial.
    
        Parameters:
        - call_benefit: Define and summarize why this function is being called and the intended benefit
        - nct_id: A single NCT ID (string, e.g., "NCT04280705")
    
        Process: Fetches the `OutcomesModule` and `ResultsSection`
                 from the ClinicalTrials.gov v2 API for the NCT ID.
        Output: A Markdown formatted string detailing primary/secondary
                outcomes, participant flow, results tables (if posted),
                and adverse event summaries. Returns an error if invalid.
        """
        return await get_trial(nct_id, Module.OUTCOMES)
  • Shared helper function get_trial that performs the actual HTTP request to ClinicalTrials.gov API, parses the response, handles errors, and renders to Markdown. Used by all trial section getters including outcomes.
    async def get_trial(
        nct_id: str,
        module: Module = Module.PROTOCOL,
        output_json: bool = False,
    ) -> str:
        """Get details of a clinical trial by module."""
        fields = ",".join(modules[module])
        params = {"fields": fields}
        url = f"{CLINICAL_TRIALS_BASE_URL}/{nct_id}"
    
        logger.debug(f"Fetching trial {nct_id} with module {module.value}")
        logger.debug(f"URL: {url}, Params: {params}")
    
        parsed_data: dict[str, Any] | None
        error_obj: http_client.RequestError | None
        parsed_data, error_obj = await http_client.request_api(
            url=url,
            request=params,
            method="GET",
            tls_version=TLSVersion.TLSv1_2,
            response_model_type=None,
            domain="clinicaltrials",
        )
    
        data_to_return: dict[str, Any]
    
        if error_obj:
            logger.error(
                f"API Error for {nct_id}: {error_obj.code} - {error_obj.message}"
            )
            data_to_return = {
                "error": f"API Error {error_obj.code}",
                "details": error_obj.message,
            }
        elif parsed_data:
            # ClinicalTrials.gov API returns data wrapped in a "studies" array
            # Extract the first study if it exists
            if isinstance(parsed_data, dict) and "studies" in parsed_data:
                studies = parsed_data.get("studies", [])
                if studies and len(studies) > 0:
                    data_to_return = studies[0]
                    data_to_return["URL"] = (
                        f"https://clinicaltrials.gov/study/{nct_id}"
                    )
                else:
                    logger.warning(f"No studies found in response for {nct_id}")
                    data_to_return = {
                        "error": f"No studies found for {nct_id}",
                        "details": "API returned empty studies array",
                    }
            else:
                # Handle case where API returns data in unexpected format
                logger.debug(
                    f"Unexpected response format for {nct_id}: {type(parsed_data)}"
                )
                data_to_return = parsed_data
                data_to_return["URL"] = (
                    f"https://clinicaltrials.gov/study/{nct_id}"
                )
        else:
            logger.warning(
                f"No data received for {nct_id} with module {module.value}"
            )
            data_to_return = {
                "error": f"No data found for {nct_id} with module {module.value}",
                "details": "API returned no data",
            }
    
        if output_json:
            return json.dumps(data_to_return, indent=2)
        else:
            return render.to_markdown(data_to_return)
  • Import statement that brings in the core trial getter functions, including _trial_outcomes, for use by the MCP tool handlers.
    from biomcp.trials.getter import (
        _trial_locations,
        _trial_outcomes,
        _trial_protocol,
        _trial_references,
    )
    from biomcp.trials.search import _trial_searcher
  • Pydantic schema definition for the tool input parameter 'nct_id' via Annotated Field.
    nct_id: Annotated[
        str,
        Field(description="NCT ID (e.g., 'NCT06524388')"),
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. It discloses that this is a read operation ('fetch', 'retrieves') and adds important behavioral context about data availability constraints ('Results are only available for completed trials that have posted data'), but doesn't mention other traits like rate limits, authentication needs, or error conditions.

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 appropriately sized and front-loaded with the core purpose in the first sentence. The bullet points efficiently detail what information is retrieved, and the note provides crucial context without unnecessary elaboration. Every sentence earns its place.

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 moderate complexity, no annotations, and the presence of an output schema (which handles return values), the description is reasonably complete. It covers purpose, scope, and data availability constraints, though it could benefit from more behavioral context about how the tool handles edge cases or errors.

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 already documents the single parameter (nct_id) adequately. The description doesn't add any parameter-specific information beyond what's in the schema, which is acceptable given the high schema coverage.

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 with specific verbs ('fetch', 'retrieves') and resource ('outcome measures and results for a clinical trial'), and distinguishes it from sibling tools like trial_getter or trial_searcher by focusing specifically on outcomes and results data.

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 provides clear context about when results are available ('only available for completed trials that have posted data'), which helps guide usage. However, it doesn't explicitly mention when to use this tool versus alternatives like trial_getter or trial_searcher, which might provide overlapping or different information.

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

Related 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/genomoncology/biomcp'

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