get_protein_homologs
Identify homologous proteins across species using a UniProt accession number and target organism. Specify the number of results to retrieve for comparative analysis.
Instructions
Find homologous proteins across different species
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accession | Yes | UniProt accession number | |
| organism | No | Target organism to find homologs in | |
| size | No | Number of results to return (1-100, default: 25) |
Implementation Reference
- src/index.ts:1035-1084 (handler)The core handler function that implements the logic for the 'get_protein_homologs' tool. It validates input, fetches the reference protein, constructs a search query for homologs based on protein name and organism, queries the UniProt search API, and returns the results.private async handleGetProteinHomologs(args: any) { if (!isValidHomologArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid homolog search arguments'); } try { // Get the protein info first to build a homology search const proteinResponse = await this.apiClient.get(`/uniprotkb/${args.accession}`, { params: { format: 'json' }, }); const protein = proteinResponse.data; // Build search query for homologs let query = `reviewed:true`; if (protein.proteinDescription?.recommendedName?.fullName?.value) { query += ` AND (${protein.proteinDescription.recommendedName.fullName.value})`; } if (args.organism) { query += ` AND organism_name:"${args.organism}"`; } query += ` NOT accession:"${args.accession}"`; const response = await this.apiClient.get('/uniprotkb/search', { params: { query: query, format: 'json', size: args.size || 25, }, }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error finding homologs: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/index.ts:475-487 (schema)The tool registration entry including name, description, and input schema definition for 'get_protein_homologs' in the ListTools response.{ name: 'get_protein_homologs', description: 'Find homologous proteins across different species', inputSchema: { type: 'object', properties: { accession: { type: 'string', description: 'UniProt accession number' }, organism: { type: 'string', description: 'Target organism to find homologs in' }, size: { type: 'number', description: 'Number of results to return (1-100, default: 25)', minimum: 1, maximum: 100 }, }, required: ['accession'], }, },
- src/index.ts:741-742 (registration)The dispatch case in the CallToolRequestSchema handler that routes calls to the get_protein_homologs handler function.case 'get_protein_homologs': return this.handleGetProteinHomologs(args);
- src/index.ts:130-141 (helper)Type guard and validation helper function used to validate arguments for the get_protein_homologs tool.const isValidHomologArgs = ( args: any ): args is { accession: string; organism?: string; size?: number } => { return ( typeof args === 'object' && args !== null && typeof args.accession === 'string' && args.accession.length > 0 && (args.organism === undefined || typeof args.organism === 'string') && (args.size === undefined || (typeof args.size === 'number' && args.size > 0 && args.size <= 100)) ); };