Skip to main content
Glama

variant_getter

Retrieve detailed genetic variant information, including gene location, population frequencies, clinical significance, and functional predictions, using HGVS, rsID, or MyVariant ID formats.

Instructions

Fetch comprehensive details for a specific genetic variant.

Retrieves all available information for a variant including:
- Gene location and consequences
- Population frequencies across databases
- Clinical significance from ClinVar
- Functional predictions
- External annotations (TCGA cancer data, conservation scores)

Accepts various ID formats:
- HGVS: NM_004333.4:c.1799T>A
- rsID: rs113488022
- MyVariant ID: chr7:g.140753336A>T

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
include_externalNoInclude external annotations (TCGA, 1000 Genomes, functional predictions)
variant_idYesVariant ID (HGVS, rsID, or MyVariant ID like 'chr7:g.140753336A>T')

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool registration and handler function for 'variant_getter'. Defines input schema via Annotated parameters and docstring. Delegates to internal _variant_details function.
    @mcp_app.tool()
    @track_performance("biomcp.variant_getter")
    async def variant_getter(
        variant_id: Annotated[
            str,
            Field(
                description="Variant ID (HGVS, rsID, or MyVariant ID like 'chr7:g.140753336A>T')"
            ),
        ],
        include_external: Annotated[
            bool,
            Field(
                description="Include external annotations (TCGA, 1000 Genomes, functional predictions)"
            ),
        ] = True,
    ) -> str:
        """Fetch comprehensive details for a specific genetic variant.
    
        Retrieves all available information for a variant including:
        - Gene location and consequences
        - Population frequencies across databases
        - Clinical significance from ClinVar
        - Functional predictions
        - External annotations (TCGA cancer data, conservation scores)
    
        Accepts various ID formats:
        - HGVS: NM_004333.4:c.1799T>A
        - rsID: rs113488022
        - MyVariant ID: chr7:g.140753336A>T
        """
        return await _variant_details(
            call_benefit="Fetch comprehensive variant annotations for interpretation",
            variant_id=variant_id,
            include_external=include_external,
        )
  • Internal helper function _variant_details called by the variant_getter tool handler. Defines additional parameters and calls the core get_variant function.
    async def _variant_details(
        call_benefit: Annotated[
            str,
            "Define and summarize why this function is being called and the intended benefit",
        ],
        variant_id: str,
        include_external: Annotated[
            bool,
            "Include annotations from external sources (TCGA, 1000 Genomes, cBioPortal)",
        ] = True,
        assembly: Annotated[
            str,
            "Genome assembly (hg19 or hg38). Default: hg19",
        ] = DEFAULT_ASSEMBLY,
    ) -> str:
        """
        Retrieves detailed information for a *single* genetic variant.
    
        Parameters:
        - call_benefit: Define and summarize why this function is being called and the intended benefit
        - variant_id: A variant identifier ("chr7:g.140453136A>T")
        - include_external: Include annotations from TCGA, 1000 Genomes, cBioPortal, and Mastermind
        - assembly: Genome assembly (hg19 or hg38). Default: hg19
    
        Process: Queries the MyVariant.info GET endpoint, optionally fetching
                additional annotations from external databases
        Output: A Markdown formatted string containing comprehensive
                variant annotations (genomic context, frequencies,
                predictions, clinical data, external annotations). Returns error if invalid.
        Note: Use the variant_searcher to find the variant id first.
        """
        return await get_variant(
            variant_id,
            output_json=False,
            include_external=include_external,
            assembly=assembly,
        )
  • Core implementation get_variant function that queries MyVariant.info API, processes response, adds links/filters/external annotations/OncoKB, and renders to markdown or JSON.
    async def get_variant(  # noqa: C901
        variant_id: str,
        output_json: bool = False,
        include_external: bool = False,
        assembly: str = DEFAULT_ASSEMBLY,
    ) -> str:
        """
        Get variant details from MyVariant.info using the variant identifier.
    
        The identifier can be a full HGVS-style string (e.g. "chr7:g.140453136A>T")
        or an rsID (e.g. "rs113488022"). The API response is expected to include a
        "hits" array; this function extracts the first hit.
    
        Args:
            variant_id: Variant identifier (HGVS or rsID)
            output_json: Return JSON format if True, else Markdown
            include_external: Include external annotations (TCGA, 1000 Genomes, cBioPortal)
            assembly: Genome assembly (hg19 or hg38), defaults to hg19
    
        Returns:
            Formatted variant data as JSON or Markdown string
    
        If output_json is True, the result is returned as a formatted JSON string;
        otherwise, it is rendered as Markdown.
        """
        response, error = await http_client.request_api(
            url=f"{MYVARIANT_GET_URL}/{variant_id}",
            request={"fields": "all", "assembly": assembly},
            method="GET",
            domain="myvariant",
        )
    
        # Handle errors gracefully with user-friendly messages
        if error:
            data_to_return = _format_error_response(error, variant_id)
            # Skip all processing for error responses
            if output_json:
                return json.dumps(data_to_return, indent=2)
            else:
                return render.to_markdown(data_to_return)
    
        data_to_return = ensure_list(response)
    
        # Inject database links into the variant data
        data_to_return = inject_links(data_to_return)
        data_to_return = filter_variants(data_to_return)
    
        # Collect OncoKB annotations separately for markdown appendage
        oncokb_annotations: list[str] = []
    
        # Add external annotations if requested
        if include_external and data_to_return:
            logger.info(
                f"Adding external annotations for {len(data_to_return)} variants"
            )
            aggregator = ExternalVariantAggregator()
    
            for _i, variant_data in enumerate(data_to_return):
                logger.info(
                    f"Processing variant {_i}: keys={list(variant_data.keys())}"
                )
                # Get enhanced annotations
                enhanced = await aggregator.get_enhanced_annotations(
                    variant_id,
                    include_tcga=True,
                    include_1000g=True,
                    include_cbioportal=True,
                    variant_data=variant_data,
                )
    
                # Add formatted annotations to the variant data
                formatted = format_enhanced_annotations(enhanced)
                logger.info(
                    f"Formatted external annotations: {formatted['external_annotations'].keys()}"
                )
                variant_data.update(formatted["external_annotations"])
    
                # Get formatted OncoKB annotation separately
                gene_aa = aggregator._extract_gene_aa_change(variant_data)
                # Handle case where method might be mocked as async in tests
                if inspect.iscoroutine(gene_aa) or inspect.isawaitable(gene_aa):
                    gene_aa = await gene_aa
                if gene_aa:
                    parts = gene_aa.split(" ", 1)
                    if len(parts) == 2:
                        gene, variant = parts
                        oncokb_formatted = await get_oncokb_annotation_for_variant(
                            gene, variant
                        )
                        if oncokb_formatted:
                            oncokb_annotations.append(oncokb_formatted)
    
        if output_json:
            return json.dumps(data_to_return, indent=2)
        else:
            # Render base markdown and append OncoKB annotations
            base_markdown = render.to_markdown(data_to_return)
            if oncokb_annotations:
                # Append OncoKB annotations as separate markdown sections
                return base_markdown + "\n" + "\n".join(oncokb_annotations)
            return base_markdown
  • Import of the _variant_details helper function used by the variant_getter tool.
    from biomcp.variants.getter import _variant_details
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 describes what information is retrieved (gene location, population frequencies, clinical significance, etc.) and mentions the tool accepts multiple ID formats, which adds useful context. However, it doesn't disclose important behavioral traits like rate limits, authentication requirements, error conditions, or whether this is a read-only operation.

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 perfectly structured and concise. It starts with a clear purpose statement, then provides a bulleted list of what information is retrieved, and ends with specific ID format examples. Every sentence earns its place with no wasted words, and information is front-loaded effectively.

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 an output schema exists (so return values don't need explanation in the description), the description provides good context about what information is retrieved and how to format inputs. However, for a tool with no annotations and potentially complex genetic data, it could benefit from more behavioral context about limitations, data sources, or typical use cases.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema already documents both parameters well. The description adds meaningful context by listing the specific ID formats accepted (HGVS, rsID, MyVariant ID) and mentioning what 'external annotations' include (TCGA cancer data, conservation scores), which provides additional semantic understanding beyond the schema's technical descriptions.

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 comprehensive details', 'retrieves all available information') and identifies the resource ('specific genetic variant'). It distinguishes itself from sibling 'variant_searcher' by focusing on detailed retrieval for a single variant rather than searching.

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 this tool (to get comprehensive details for a specific variant) and implies when not to use it (for searching multiple variants, which would use 'variant_searcher'). However, it doesn't explicitly name alternatives or provide exclusion criteria beyond the implied distinction.

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