Skip to main content
Glama
mohammadnajeeb

NCBI Gene MCP Server

fetch_gene_info

Retrieve detailed gene information from NCBI using a specific gene ID to access metadata, descriptions, and related data for research and analysis.

Instructions

Fetch detailed information for a specific gene ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gene_idYesNCBI Gene ID (e.g., '672' for BRCA1)

Implementation Reference

  • Core implementation of fetch_gene_info: queries NCBI Entrez esummary API, parses response, constructs GeneInfo object.
    def fetch_gene_info(self, gene_id: str) -> GeneInfo:
        """
        Fetch detailed information for a specific gene.
        
        Args:
            gene_id: NCBI Gene ID
            
        Returns:
            GeneInfo object with gene details
        """
        params = {
            "db": "gene",
            "id": gene_id
        }
        
        response = self._make_request("esummary", params)
        
        result = response.get("result", {})
        gene_data = result.get(gene_id)
        
        if not gene_data:
            raise Exception(f"No data found for gene ID: {gene_id}")
        
        # Extract organism information
        organism = gene_data.get("organism", {})
        organism_name = organism.get("scientificname", "Unknown") if isinstance(organism, dict) else str(organism)
        
        # Extract other aliases
        other_aliases = []
        if "otheraliases" in gene_data:
            aliases = gene_data["otheraliases"]
            if isinstance(aliases, str):
                other_aliases = [alias.strip() for alias in aliases.split(",")]
            elif isinstance(aliases, list):
                other_aliases = aliases
        
        return GeneInfo(
            gene_id=gene_id,
            name=gene_data.get("name", ""),
            description=gene_data.get("description", ""),
            organism=organism_name,
            chromosome=gene_data.get("chromosome"),
            map_location=gene_data.get("maplocation"),
            gene_type=gene_data.get("geneticsource"),
            other_aliases=other_aliases if other_aliases else None,
            summary=gene_data.get("summary")
        )
  • MCP tool registration: defines name, description, and input schema for fetch_gene_info in tools/list response.
    {
        "name": "fetch_gene_info",
        "description": "Fetch detailed information for a specific gene ID",
        "inputSchema": {
            "type": "object",
            "properties": {
                "gene_id": {
                    "type": "string",
                    "description": "NCBI Gene ID (e.g., '672' for BRCA1)"
                }
            },
            "required": ["gene_id"]
        }
    },
  • MCP server dispatch handler for fetch_gene_info tool call: validates input, calls bridge, formats JSON response.
    elif name == "fetch_gene_info":
        gene_id = arguments.get("gene_id")
        if not gene_id:
            raise ValueError("gene_id is required")
        
        result = self.bridge.fetch_gene_info(gene_id)
        gene_json = result.model_dump_json(indent=2)
        self.send_response({
            "content": [{
                "type": "text", 
                "text": f"Gene Information for ID {gene_id}:\n\n{gene_json}"
            }]
        })

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/mohammadnajeeb/ncbi_gene_mcp_client'

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