batch_protein_lookup
Look up multiple proteins simultaneously to retrieve Human Protein Atlas data on expression, localization, and pathology for up to 100 genes at once.
Instructions
Look up multiple proteins simultaneously
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| genes | Yes | Array of gene symbols (max 100) | |
| format | No | Output format (default: json) | |
| columns | No | Specific columns to include in results |
Implementation Reference
- src/index.ts:1219-1255 (handler)The handler function for the batch_protein_lookup tool. Validates input, fetches protein data for each gene concurrently using Promise.all and fetchProteinData, collects results with success/error status, and returns formatted JSON response.private async handleBatchProteinLookup(args: any) { if (!isValidBatchArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid batch lookup arguments'); } try { const results = await Promise.all( args.genes.map(async (gene: string) => { try { const data = await this.fetchProteinData(gene, args.format || 'json'); return { gene, data, success: true }; } catch (error) { return { gene, error: error instanceof Error ? error.message : 'Unknown error', success: false }; } }) ); return { content: [ { type: 'text', text: JSON.stringify({ batchResults: results }, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error in batch lookup: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/index.ts:625-633 (schema)Input schema definition for the batch_protein_lookup tool, specifying genes array (1-100 items), optional format and columns.inputSchema: { type: 'object', properties: { genes: { type: 'array', items: { type: 'string' }, description: 'Array of gene symbols (max 100)', minItems: 1, maxItems: 100 }, format: { type: 'string', enum: ['json', 'tsv'], description: 'Output format (default: json)' }, columns: { type: 'array', items: { type: 'string' }, description: 'Specific columns to include in results' }, }, required: ['genes'], },
- src/index.ts:622-634 (registration)Tool registration in the ListToolsRequestSchema handler, defining name, description, and input schema for batch_protein_lookup.{ name: 'batch_protein_lookup', description: 'Look up multiple proteins simultaneously', inputSchema: { type: 'object', properties: { genes: { type: 'array', items: { type: 'string' }, description: 'Array of gene symbols (max 100)', minItems: 1, maxItems: 100 }, format: { type: 'string', enum: ['json', 'tsv'], description: 'Output format (default: json)' }, columns: { type: 'array', items: { type: 'string' }, description: 'Specific columns to include in results' }, }, required: ['genes'], }, },
- src/index.ts:117-130 (helper)Type guard function used in the handler to validate batch_protein_lookup input arguments, checking genes array validity and optional format/columns.const isValidBatchArgs = ( args: any ): args is { genes: string[]; format?: string; columns?: string[] } => { return ( typeof args === 'object' && args !== null && Array.isArray(args.genes) && args.genes.length > 0 && args.genes.length <= 100 && args.genes.every((gene: any) => typeof gene === 'string' && gene.length > 0) && (args.format === undefined || ['json', 'tsv'].includes(args.format)) && (args.columns === undefined || Array.isArray(args.columns)) ); };