Skip to main content
Glama

get_translation

Convert biological identifiers, such as gene symbols to Ensembl IDs, using Biomart MCP. Specify source and target attributes to retrieve translated results quickly with caching for efficiency.

Instructions

Translates a single identifier from one attribute type to another.

This function allows conversion between different identifier types, such as
converting a gene symbol to an Ensembl ID. Results are cached to improve performance.

Args:
    mart (str): The mart identifier (e.g., "ENSEMBL_MART_ENSEMBL")
    dataset (str): The dataset identifier (e.g., "hsapiens_gene_ensembl")
    from_attr (str): The source attribute name (e.g., "hgnc_symbol")
    to_attr (str): The target attribute name (e.g., "ensembl_gene_id")
    target (str): The identifier value to translate (e.g., "TP53")

Returns:
    str: The translated identifier, or an error message if not found.

Example:
    get_translation("ENSEMBL_MART_ENSEMBL", "hsapiens_gene_ensembl", "hgnc_symbol", "ensembl_gene_id", "TP53")
    >>> "ENSG00000141510"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
datasetYes
from_attrYes
martYes
targetYes
to_attrYes

Implementation Reference

  • The complete handler function for the 'get_translation' MCP tool, including the @mcp.tool() decorator, type hints, docstring schema, and execution logic. It retrieves a cached translation dictionary and looks up the target identifier.
    @mcp.tool()
    def get_translation(mart: str, dataset: str, from_attr: str, to_attr: str, target: str):
        """
        Translates a single identifier from one attribute type to another.
    
        This function allows conversion between different identifier types, such as
        converting a gene symbol to an Ensembl ID. Results are cached to improve performance.
    
        Args:
            mart (str): The mart identifier (e.g., "ENSEMBL_MART_ENSEMBL")
            dataset (str): The dataset identifier (e.g., "hsapiens_gene_ensembl")
            from_attr (str): The source attribute name (e.g., "hgnc_symbol")
            to_attr (str): The target attribute name (e.g., "ensembl_gene_id")
            target (str): The identifier value to translate (e.g., "TP53")
    
        Returns:
            str: The translated identifier, or an error message if not found.
    
        Example:
            get_translation("ENSEMBL_MART_ENSEMBL", "hsapiens_gene_ensembl", "hgnc_symbol", "ensembl_gene_id", "TP53")
            >>> "ENSG00000141510"
        """
        try:
            result_dict = _get_translation_dict(mart, dataset, from_attr, to_attr)
            if target not in result_dict:
                print(f"Target '{target}' not found in translation", file=sys.stderr)
                return f"Error: Target '{target}' not found"
            return result_dict[target]
        except Exception as e:
            print(f"Error in translation: {str(e)}", file=sys.stderr)
            return f"Error: {str(e)}"
  • Supporting helper function _get_translation_dict, cached with lru_cache, that queries Biomart to create a dictionary mapping values from 'from_attr' to 'to_attr'. Used by get_translation and batch_translate tools.
    def _get_translation_dict(mart: str, dataset: str, from_attr: str, to_attr: str):
        """
        Helper function to get and cache a translation dictionary.
        """
        try:
            server = get_server()
            dataset_obj = server[mart][dataset]
            df = dataset_obj.query(attributes=[from_attr, to_attr])
            return dict(zip(df.iloc[:, 0], df.iloc[:, 1]))
        except Exception as e:
            print(f"Error getting translation dictionary: {str(e)}", file=sys.stderr)
            return {}
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by disclosing key behaviors: it's a translation operation with caching for performance, returns a string result or error message, and provides a concrete example of the expected output format. It doesn't mention rate limits, authentication needs, or error handling specifics.

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 and appropriately sized: purpose statement, behavioral context, parameter documentation, return value explanation, and a concrete example. Every sentence adds value with no redundancy or fluff.

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?

For a 5-parameter tool with no annotations and no output schema, the description provides excellent parameter documentation and behavioral context. The main gap is the lack of explicit error handling details beyond 'error message if not found' - more specifics about error formats or conditions would help.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by providing detailed parameter explanations with clear examples for all 5 parameters. Each parameter's purpose and example values are clearly documented, adding significant value beyond the bare schema.

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: 'Translates a single identifier from one attribute type to another' with specific examples like converting gene symbols to Ensembl IDs. It distinguishes from sibling 'batch_translate' by specifying 'single identifier' translation.

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 (single identifier translation) and implies when not to use it (batch operations should use 'batch_translate'). However, it doesn't explicitly name alternatives or provide exclusion criteria beyond the single vs. batch 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/jzinno/biomart-mcp'

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