batch_gene_lookup
Search for multiple genes in parallel within the Ensembl MCP Server. Input gene IDs and species to retrieve genomic data in JSON or XML format, supporting efficient bulk gene lookup.
Instructions
Look up multiple genes simultaneously
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | Output format (default: json) | |
| gene_ids | Yes | List of gene IDs (max 200) | |
| species | No | Species name (default: homo_sapiens) |
Implementation Reference
- src/index.ts:1583-1609 (handler)The handler function that executes the batch_gene_lookup tool. It validates arguments, constructs a batch request to Ensembl's /lookup/id POST endpoint, and returns the 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:876-877 (registration)Registers the batch_gene_lookup tool handler in the CallToolRequestSchema switch statement.case 'batch_gene_lookup': return this.handleBatchGeneLookup(args);
- src/index.ts:802-812 (registration)Registers the batch_gene_lookup tool in the ListToolsRequestSchema response, including name, description, and input schema.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:804-811 (schema)JSON schema defining the input parameters for the batch_gene_lookup tool.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:257-270 (helper)Helper function (type guard) that validates the input arguments for the batch_gene_lookup tool.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)) ); };