fetch_gene_info
Retrieve comprehensive details about a specific gene using its NCBI Gene ID, enabling accurate gene metadata and related information extraction for research and analysis.
Instructions
Fetch detailed information for a specific gene ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| gene_id | Yes | NCBI Gene ID (e.g., '672' for BRCA1) |
Implementation Reference
- MCP tool schema definition for fetch_gene_info, including input schema requiring 'gene_id' string{ "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 the fetch_gene_info tool that extracts parameters, calls bridge implementation, formats JSON response, and sends MCP content responseelif 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}" }] })
- ncbi_gene_mcp_client/bridge.py:125-172 (handler)Core implementation of fetch_gene_info: makes NCBI Entrez esummary API request, parses response, extracts and formats gene information into GeneInfo modeldef 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") )