compare_proteins
Compare multiple protein sequences and features side-by-side using UniProt accession numbers to analyze similarities and differences.
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 handler function for the 'compare_proteins' tool. Validates input, fetches UniProt data for each accession, extracts key properties (accession, name, organism, sequence length, molecular weight, feature count, domain count), compiles a comparison array, and returns it as JSON.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:739-740 (registration)Registers the handler for 'compare_proteins' in the CallToolRequestSchema switch statement.case 'compare_proteins': return this.handleCompareProteins(args);
- src/index.ts:464-474 (registration)Registers the 'compare_proteins' tool in the ListToolsRequestSchema response, including name, description, and input schema.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:116-128 (schema)Input validation type guard function for 'compare_proteins' tool arguments, checking accessions array (2-10 strings) and optional 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)) ); };