compare_proteins
Analyze and align multiple protein sequences side-by-side to compare their features and structures using UniProt accession numbers. Supports output in JSON or TSV formats.
Instructions
Compare multiple proteins side-by-side with sequence and feature comparison
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accessions | Yes | Array of UniProt accession numbers (2-10) | |
| format | No | Output format (default: json) |
Implementation Reference
- src/index.ts:991-1033 (handler)The main handler function that validates input, fetches UniProt data for each accession, extracts key comparison metrics (accession, name, organism, length, mass, feature count, domain count), and returns a JSON comparison object.private async handleCompareProteins(args: any) { if (!isValidCompareProteinsArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid compare proteins arguments'); } try { const comparisons = []; for (const accession of args.accessions) { const response = await this.apiClient.get(`/uniprotkb/${accession}`, { params: { format: 'json' }, }); const protein = response.data; comparisons.push({ accession: protein.primaryAccession, name: protein.uniProtkbId, organism: protein.organism?.scientificName, length: protein.sequence?.length, mass: protein.sequence?.molWeight, features: protein.features?.length || 0, domains: protein.features?.filter((f: any) => f.type === 'Domain').length || 0, }); } return { content: [ { type: 'text', text: JSON.stringify({ comparison: comparisons }, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error comparing proteins: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/index.ts:464-473 (schema)JSON schema definition for the compare_proteins tool input, specifying accessions array (2-10 items) and optional format.name: 'compare_proteins', description: 'Compare multiple proteins side-by-side with sequence and feature comparison', inputSchema: { type: 'object', properties: { accessions: { type: 'array', items: { type: 'string' }, description: 'Array of UniProt accession numbers (2-10)', minItems: 2, maxItems: 10 }, format: { type: 'string', enum: ['json', 'tsv'], description: 'Output format (default: json)' }, }, required: ['accessions'], },
- src/index.ts:739-740 (registration)Registration of the compare_proteins tool handler in the CallToolRequestSchema switch statement.case 'compare_proteins': return this.handleCompareProteins(args);
- src/index.ts:116-128 (helper)Type guard and validation function for compare_proteins input arguments, ensuring valid accessions array and format.const isValidCompareProteinsArgs = ( args: any ): args is { accessions: string[]; format?: string } => { return ( typeof args === 'object' && args !== null && Array.isArray(args.accessions) && args.accessions.length > 1 && args.accessions.length <= 10 && args.accessions.every((acc: any) => typeof acc === 'string' && acc.length > 0) && (args.format === undefined || ['json', 'tsv'].includes(args.format)) ); };