Skip to main content
Glama

trial_locations_getter

Fetch comprehensive clinical trial location details, including facility addresses, principal investigator info, contact data, and recruitment status, using the NCT ID. Ideal for accessing study teams and identifying nearby trials.

Instructions

Fetch contact and location details for a clinical trial.

Retrieves all study locations including:
- Facility names and addresses
- Principal investigator information
- Contact details (when recruiting)
- Recruitment status by site

Useful for finding trials near specific locations or contacting study teams.

Input Schema

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Primary handler function for the 'trial_locations_getter' MCP tool. Includes @mcp_app.tool() decorator for registration and Pydantic schema definition via Annotated types. Calls the core _trial_locations helper.
    @mcp_app.tool()
    @track_performance("biomcp.trial_locations_getter")
    async def trial_locations_getter(
        nct_id: Annotated[
            str,
            Field(description="NCT ID (e.g., 'NCT06524388')"),
        ],
    ) -> str:
        """Fetch contact and location details for a clinical trial.
    
        Retrieves all study locations including:
        - Facility names and addresses
        - Principal investigator information
        - Contact details (when recruiting)
        - Recruitment status by site
    
        Useful for finding trials near specific locations or contacting study teams.
        """
        return await _trial_locations(
            call_benefit="Fetch trial locations and contacts for enrollment information",
            nct_id=nct_id,
        )
  • Input schema definition for the tool: single parameter 'nct_id' as string with description.
    nct_id: Annotated[
        str,
        Field(description="NCT ID (e.g., 'NCT06524388')"),
    ],
  • Core helper function implementing the trial locations fetch logic by calling ClinicalTrials.gov API with specific module 'ContactsLocationsModule'.
    async def _trial_locations(
        call_benefit: Annotated[
            str,
            "Define and summarize why this function is being called and the intended benefit",
        ],
        nct_id: str,
    ) -> str:
        """
        Retrieves contact and location details for a single
        clinical trial identified by its NCT ID.
    
        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 `ContactsLocationsModule` from the
                 ClinicalTrials.gov v2 API for the given NCT ID.
        Output: A Markdown formatted string detailing facility names,
                addresses (city, state, country), and contact info.
                Returns an error message if the NCT ID is invalid.
        """
        return await get_trial(nct_id, Module.LOCATIONS)
  • Supporting utility function that performs the actual API request to ClinicalTrials.gov and formats the response for the locations module.
    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)
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It describes what data is retrieved (facility details, investigator info, contact details, recruitment status) which adds behavioral context beyond the input schema. However, it doesn't mention potential limitations 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 well-structured with a clear purpose statement, bulleted details, and a usage note. Every sentence adds value without redundancy, and it's appropriately sized for the tool's complexity.

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 that there's an output schema (which handles return values), no annotations, and simple parameters, the description is reasonably complete. It explains what the tool does and when to use it, though it could benefit from more behavioral details like data freshness or limitations.

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 the single parameter (nct_id) with its format. The description doesn't add any parameter-specific information beyond what's in the schema, maintaining the baseline score of 3 when schema coverage is high.

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 specific action ('Fetch contact and location details') and resource ('for a clinical trial'), with a bulleted list of what's retrieved. It distinguishes from siblings like trial_getter or trial_searcher by focusing on location-specific details rather than general trial information or search capabilities.

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 for when to use it ('Useful for finding trials near specific locations or contacting study teams'), but doesn't explicitly state when not to use it or name specific alternatives among the sibling tools (e.g., trial_getter for general trial info).

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