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

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:

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