Skip to main content
Glama
biocontext-ai

BioContextAI Knowledgebase MCP

Official

bc_get_ensembl_id_from_gene_symbol

Convert gene symbols to Ensembl IDs for specified species to enable standardized gene identification in biomedical research.

Instructions

Get Ensembl gene ID from gene symbol. Returns the stable Ensembl ID (ENSG*) for the given gene symbol and species.

Returns: dict: Ensembl gene ID in format {'ensembl_id': 'ENSG...'} or error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gene_symbolYesGene name (e.g., 'TP53')
speciesNoTaxonomy ID (e.g., 9606 for human, 10090 for mouse)9606

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler function for the 'bc_get_ensembl_id_from_gene_symbol' tool (prefixed by 'bc_' from core_mcp). It queries the Ensembl REST API with the gene symbol and species taxonomy ID, extracts the ENSG ID using regex, and returns it or an error.
    @core_mcp.tool()
    def get_ensembl_id_from_gene_symbol(
        gene_symbol: Annotated[str, Field(description="Gene name (e.g., 'TP53')")],
        species: Annotated[
            str,
            Field(description="Taxonomy ID (e.g., 9606 for human, 10090 for mouse)"),
        ] = "9606",
    ) -> dict:
        """Get Ensembl gene ID from gene symbol. Returns the stable Ensembl ID (ENSG*) for the given gene symbol and species.
    
        Returns:
            dict: Ensembl gene ID in format {'ensembl_id': 'ENSG...'} or error message.
        """
        # Ensure at least one search parameter was provided
        if not gene_symbol:
            return {"error": "gene_symbol must be provided"}
    
        url = f"https://rest.ensembl.org/xrefs/symbol/{species}/{gene_symbol}"
    
        try:
            response = requests.get(url)
            response.raise_for_status()
    
            # Parse the Ensembl gene ID
            match = re.search(r"\b(ENSG\d+)\b", response.text)
    
            if match:
                return {"ensembl_id": match.group(1)}
            else:
                return {"error": "No Ensembl gene ID found in response"}
        except requests.exceptions.RequestException as e:
            return {"error": f"Failed to fetch Ensembl ID: {e!s}"}
  • Top-level registration of core_mcp (containing the tool) into the main BioContextAI MCP server, with slugified prefix 'bc' applied to all tools from core_mcp.
    for mcp in [core_mcp, *(await get_openapi_mcps())]:
        await mcp_app.import_server(
            mcp,
            slugify(mcp.name),
        )
  • Imports the ensembl module, which triggers loading of the tool handler and its @core_mcp.tool() decorator registration on core_mcp.
    from .ensembl import *
  • Explicit import of the tool handler function into the ensembl package __init__.py, enabling its registration when the package is imported.
    from ._get_ensembl_id_from_gene_symbol import get_ensembl_id_from_gene_symbol
  • Pydantic schema definitions for tool inputs using Annotated and Field for gene_symbol (required str) and species (optional str, default '9606'). Output is dict.
    def get_ensembl_id_from_gene_symbol(
        gene_symbol: Annotated[str, Field(description="Gene name (e.g., 'TP53')")],
        species: Annotated[
            str,
            Field(description="Taxonomy ID (e.g., 9606 for human, 10090 for mouse)"),
        ] = "9606",
    ) -> dict:
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 discloses the return format (dict with 'ensembl_id' or error message), which is helpful. However, it lacks details on error conditions, rate limits, authentication needs, or whether the operation is read-only (implied but not stated).

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 front-loaded with the core purpose in the first sentence, followed by return details. It uses two concise sentences with zero waste, efficiently conveying necessary information without redundancy.

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 low complexity (simple lookup), 100% schema coverage, and an output schema (implied by the Returns section), the description is mostly complete. It covers purpose, parameters via schema, and return format. However, without annotations, it could benefit from more behavioral context like error handling.

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 fully documents both parameters (gene_symbol and species with examples). The description adds no additional parameter semantics beyond what the schema provides, meeting the baseline for high 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 specific action ('Get Ensembl gene ID from gene symbol') and the resource involved (gene symbol and species). It explicitly distinguishes itself from siblings by focusing on Ensembl ID mapping, unlike tools for KEGG IDs, UniProt IDs, or other gene-related queries in the sibling list.

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 implies usage when needing Ensembl IDs from gene symbols, with a species parameter for specificity. However, it does not explicitly state when not to use it (e.g., for other ID types like KEGG or UniProt, which have separate sibling tools) or name alternatives, though the sibling list suggests clear distinctions.

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