batch_gene_lookup
Retrieve genomic data for multiple genes at once from Ensembl, supporting up to 200 gene IDs per query with JSON or XML output.
Instructions
Look up multiple genes simultaneously
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| gene_ids | Yes | List of gene IDs (max 200) | |
| species | No | Species name (default: homo_sapiens) | |
| format | No | Output format (default: json) |
Implementation Reference
- src/index.ts:1583-1609 (handler)The main handler function for the 'batch_gene_lookup' tool. Validates input, makes a POST request to Ensembl's /lookup/id endpoint with multiple gene IDs for batch lookup, and returns the formatted JSON response.private async handleBatchGeneLookup(args: any) { if (!isValidBatchArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid batch gene lookup arguments'); } try { const species = this.getDefaultSpecies(args.species); const format = args.format || 'json'; const geneData = { ids: args.gene_ids }; const response = await this.apiClient.post('/lookup/id', geneData, { params: { species, format }, }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return this.handleError(error, 'batch gene lookup'); } }
- src/index.ts:802-813 (registration)Tool registration in the ListTools response, defining the name, description, and input schema for batch_gene_lookup.name: 'batch_gene_lookup', description: 'Look up multiple genes simultaneously', inputSchema: { type: 'object', properties: { gene_ids: { type: 'array', items: { type: 'string' }, description: 'List of gene IDs (max 200)', minItems: 1, maxItems: 200 }, species: { type: 'string', description: 'Species name (default: homo_sapiens)' }, format: { type: 'string', enum: ['json', 'xml'], description: 'Output format (default: json)' }, }, required: ['gene_ids'], }, },
- src/index.ts:805-812 (schema)Input schema definition for the batch_gene_lookup tool, specifying parameters like gene_ids array (required, 1-200 items), optional species and format.type: 'object', properties: { gene_ids: { type: 'array', items: { type: 'string' }, description: 'List of gene IDs (max 200)', minItems: 1, maxItems: 200 }, species: { type: 'string', description: 'Species name (default: homo_sapiens)' }, format: { type: 'string', enum: ['json', 'xml'], description: 'Output format (default: json)' }, }, required: ['gene_ids'], },
- src/index.ts:257-270 (helper)Helper function to validate input arguments for batch_gene_lookup, checking gene_ids is non-empty array <=200 strings, and optional species/format.const isValidBatchArgs = ( args: any ): args is { gene_ids: string[]; species?: string; format?: string } => { return ( typeof args === 'object' && args !== null && Array.isArray(args.gene_ids) && args.gene_ids.length > 0 && args.gene_ids.length <= 200 && args.gene_ids.every((id: any) => typeof id === 'string' && id.length > 0) && (args.species === undefined || typeof args.species === 'string') && (args.format === undefined || ['json', 'xml'].includes(args.format)) ); };
- src/index.ts:876-879 (registration)Dispatch registration in the CallToolRequestSchema switch statement, routing calls to batch_gene_lookup to its handler.case 'batch_gene_lookup': return this.handleBatchGeneLookup(args); case 'batch_sequence_fetch': return this.handleBatchSequenceFetch(args);