Skip to main content
Glama

lookup_gene

Retrieve detailed gene information by Ensembl ID or symbol, including transcript and exon data, in JSON, FASTA, or GFF formats for specified species.

Instructions

Get detailed gene information by stable ID or symbol

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expandNoInclude transcript and exon details (default: false)
formatNoOutput format (default: json)
gene_idYesEnsembl gene ID or gene symbol (e.g., ENSG00000139618, BRCA2)
speciesNoSpecies name (default: homo_sapiens)

Implementation Reference

  • The core handler function for the 'lookup_gene' tool. It validates input arguments, calls the Ensembl REST API endpoint `/lookup/id/{gene_id}` with optional species, expand, and format parameters, and returns the gene information as formatted JSON.
    private async handleLookupGene(args: any) { if (!isValidGeneArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid gene lookup arguments'); } try { const species = this.getDefaultSpecies(args.species); const format = args.format || 'json'; let endpoint = `/lookup/id/${args.gene_id}`; const params: any = { species }; if (args.expand) { params.expand = 1; } if (format !== 'json') { params.format = format; } const response = await this.apiClient.get(endpoint, { params }); return { content: [ { type: 'text', text: typeof response.data === 'object' ? JSON.stringify(response.data, null, 2) : String(response.data), }, ], }; } catch (error) { return this.handleError(error, 'looking up gene'); } }
  • Tool metadata and input schema definition for 'lookup_gene' provided in the ListToolsRequestSchema response.
    { name: 'lookup_gene', description: 'Get detailed gene information by stable ID or symbol', inputSchema: { type: 'object', properties: { gene_id: { type: 'string', description: 'Ensembl gene ID or gene symbol (e.g., ENSG00000139618, BRCA2)' }, species: { type: 'string', description: 'Species name (default: homo_sapiens)' }, expand: { type: 'boolean', description: 'Include transcript and exon details (default: false)' }, format: { type: 'string', enum: ['json', 'fasta', 'gff'], description: 'Output format (default: json)' }, }, required: ['gene_id'], }, },
  • src/index.ts:835-837 (registration)
    Registers the 'lookup_gene' tool handler in the CallToolRequestSchema switch dispatcher.
    case 'lookup_gene': return this.handleLookupGene(args); case 'get_transcripts':
  • Input validation type guard function specifically for 'lookup_gene' tool arguments.
    const isValidGeneArgs = ( args: any ): args is { gene_id: string; species?: string; expand?: boolean; format?: string } => { return ( typeof args === 'object' && args !== null && typeof args.gene_id === 'string' && args.gene_id.length > 0 && (args.species === undefined || typeof args.species === 'string') && (args.expand === undefined || typeof args.expand === 'boolean') && (args.format === undefined || ['json', 'fasta', 'gff'].includes(args.format)) ); };

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/Augmented-Nature/Ensembl-MCP-Server'

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