Skip to main content
Glama
biocontext-ai

BioContextAI Knowledgebase MCP

Official

bc_get_ensembl_id_from_gene_symbol

Retrieve the Ensembl ID for a specific gene symbol by querying the Ensembl database. Specify the species to ensure accurate results, enabling precise gene identification in biological research.

Instructions

Query the Ensembl database for the Ensembl ID of a given gene name.

Always provide the species parameter to ensure the correct protein is returned.

Args: gene_symbol (str): The name of the gene to search for (e.g., "TP53"). species (str): Taxonomy ID (e.g., 10090) as string (default: "9606").

Returns: dict: Gene data or error message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gene_symbolYesThe name of the gene to search for (e.g., 'TP53')
speciesNoTaxonomy ID (e.g., 10090) or species name as string9606

Implementation Reference

  • The core handler function for the 'bc_get_ensembl_id_from_gene_symbol' tool. It uses the Ensembl REST API to fetch the Ensembl stable ID (ENSG*) from a given gene symbol and species taxonomy ID.
    @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}"}
  • Imports the handler function, which triggers automatic registration via the @core_mcp.tool() decorator when the module is imported.
    from ._get_ensembl_id_from_gene_symbol import get_ensembl_id_from_gene_symbol __all__ = [ "get_ensembl_id_from_gene_symbol", ]
  • Defines the FastMCP instance 'core_mcp' with prefix 'BC', used by the @core_mcp.tool() decorator to register tools with 'bc_' prefix.
    core_mcp = FastMCP( # type: ignore "BC", instructions="Provides access to biomedical knowledge bases.", )

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/biocontext-ai/knowledgebase-mcp'

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