batch_protein_lookup
Retrieve protein data for multiple UniProt accessions in bulk, supporting JSON, TSV, or FASTA formats for efficient analysis and integration.
Instructions
Process multiple accessions efficiently
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accessions | Yes | Array of UniProt accession numbers (1-100) | |
| format | No | Output format (default: json) |
Implementation Reference
- src/index.ts:1532-1578 (handler)Executes batch lookup for multiple UniProt protein accessions by fetching data in chunks of 10, collecting results with success/error status, and returning JSON.private async handleBatchProteinLookup(args: any) { if (!isValidBatchLookupArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid batch lookup arguments'); } try { const results = []; // Process in chunks to avoid API limits const chunkSize = 10; for (let i = 0; i < args.accessions.length; i += chunkSize) { const chunk = args.accessions.slice(i, i + chunkSize); const chunkResults = await Promise.all( chunk.map(async (accession: string) => { try { const response = await this.apiClient.get(`/uniprotkb/${accession}`, { params: { format: args.format || 'json' }, }); return { accession, data: response.data, success: true }; } catch (error) { return { accession, error: error instanceof Error ? error.message : 'Unknown error', success: false }; } }) ); results.push(...chunkResults); } 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:611-618 (schema)Input schema defining parameters for batch_protein_lookup: array of accessions (1-100 strings) and optional format.inputSchema: { type: 'object', properties: { accessions: { type: 'array', items: { type: 'string' }, description: 'Array of UniProt accession numbers (1-100)', minItems: 1, maxItems: 100 }, format: { type: 'string', enum: ['json', 'tsv', 'fasta'], description: 'Output format (default: json)' }, }, required: ['accessions'], },
- src/index.ts:766-767 (registration)Tool handler registration in the CallToolRequestSchema switch statement.case 'batch_protein_lookup': return this.handleBatchProteinLookup(args);
- src/index.ts:143-155 (helper)Type guard function validating input arguments for batch_protein_lookup tool.const isValidBatchLookupArgs = ( args: any ): args is { accessions: string[]; format?: string } => { return ( typeof args === 'object' && args !== null && Array.isArray(args.accessions) && args.accessions.length > 0 && args.accessions.length <= 100 && args.accessions.every((acc: any) => typeof acc === 'string' && acc.length > 0) && (args.format === undefined || ['json', 'tsv', 'fasta'].includes(args.format)) ); };
- src/index.ts:609-619 (registration)Tool definition and schema registration in the ListToolsRequestSchema response.name: 'batch_protein_lookup', description: 'Process multiple accessions efficiently', inputSchema: { type: 'object', properties: { accessions: { type: 'array', items: { type: 'string' }, description: 'Array of UniProt accession numbers (1-100)', minItems: 1, maxItems: 100 }, format: { type: 'string', enum: ['json', 'tsv', 'fasta'], description: 'Output format (default: json)' }, }, required: ['accessions'], }, },