Skip to main content
Glama

batch_protein_lookup

Retrieve protein data for multiple UniProt accessions at once in JSON, TSV, or FASTA format to analyze up to 100 entries efficiently.

Instructions

Process multiple accessions efficiently

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accessionsYesArray of UniProt accession numbers (1-100)
formatNoOutput format (default: json)

Implementation Reference

  • The handler function that implements the batch_protein_lookup tool. It validates input, processes accessions in chunks of 10 using Promise.all for parallel API calls to UniProt, collects results or errors per accession, and returns formatted JSON output.
    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, }; } }
  • The input schema definition for the batch_protein_lookup tool, specifying accessions array (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:608-619 (registration)
    Registration of the batch_protein_lookup tool in the ListToolsRequestSchema response, including name, description, and schema.
    { 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'], }, },
  • src/index.ts:766-767 (registration)
    Dispatch/registration of the handler in the CallToolRequestSchema switch statement.
    case 'batch_protein_lookup': return this.handleBatchProteinLookup(args);
  • Helper function to validate the input arguments for batch_protein_lookup, checking accessions array length and format.
    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)) ); };

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/UniProt-MCP-Server'

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