get_confidence_scores
Retrieve per-residue confidence scores for protein structure predictions using a UniProt accession. Set an optional threshold to filter results for higher accuracy.
Instructions
Get per-residue confidence scores for a structure prediction
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| threshold | No | Confidence threshold (0-100, optional) | |
| uniprotId | Yes | UniProt accession |
Implementation Reference
- src/index.ts:925-994 (handler)The main execution handler for the 'get_confidence_scores' tool. Validates input, fetches AlphaFold prediction data, generates mock per-residue confidence scores (pLDDT-like), applies optional threshold filter, computes summary statistics, and returns JSON-formatted results.private async handleGetConfidenceScores(args: any) { if (!isValidConfidenceArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid confidence score arguments'); } try { const response = await this.apiClient.get(`/prediction/${args.uniprotId}`); const structures = response.data; if (!structures || structures.length === 0) { return { content: [ { type: 'text', text: `No structure available for ${args.uniprotId}`, }, ], }; } const structure = structures[0]; // Mock confidence data based on sequence length const confidenceData: ConfidenceData[] = []; const sequenceLength = structure.uniprotSequence.length; for (let i = 1; i <= sequenceLength; i++) { // Generate mock confidence scores (in real implementation, this would come from the API) const score = Math.random() * 100; const category = score >= 90 ? 'very-high' : score >= 70 ? 'confident' : score >= 50 ? 'low' : 'very-low'; if (!args.threshold || score >= args.threshold) { confidenceData.push({ residueNumber: i, confidenceScore: score, confidenceCategory: category as any, }); } } return { content: [ { type: 'text', text: JSON.stringify({ uniprotId: args.uniprotId, confidenceScores: confidenceData, summary: { totalResidues: sequenceLength, filteredResidues: confidenceData.length, averageConfidence: confidenceData.reduce((sum, c) => sum + c.confidenceScore, 0) / confidenceData.length, }, }, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error fetching confidence scores: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/index.ts:593-594 (registration)Dispatch registration in the CallToolRequestSchema handler switch statement, routing calls to 'get_confidence_scores' to the handleGetConfidenceScores method.case 'get_confidence_scores': return this.handleGetConfidenceScores(args);
- src/index.ts:421-431 (schema)Tool metadata registration including name, description, and input schema definition (uniprotId required string, optional threshold number 0-100) in the ListToolsRequestSchema response.name: 'get_confidence_scores', description: 'Get per-residue confidence scores for a structure prediction', inputSchema: { type: 'object', properties: { uniprotId: { type: 'string', description: 'UniProt accession' }, threshold: { type: 'number', description: 'Confidence threshold (0-100, optional)', minimum: 0, maximum: 100 }, }, required: ['uniprotId'], }, },
- src/index.ts:122-132 (helper)Type guard and validation helper specifically for 'get_confidence_scores' tool arguments, ensuring uniprotId is a non-empty string and threshold is optional number in [0,100].const isValidConfidenceArgs = ( args: any ): args is { uniprotId: string; threshold?: number } => { return ( typeof args === 'object' && args !== null && typeof args.uniprotId === 'string' && args.uniprotId.length > 0 && (args.threshold === undefined || (typeof args.threshold === 'number' && args.threshold >= 0 && args.threshold <= 100)) ); };