validate_accession
Validate UniProt accession numbers to ensure data accuracy and prevent errors in protein database queries.
Instructions
Check if accession numbers are valid
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accession | Yes | UniProt accession number to validate |
Implementation Reference
- src/index.ts:1852-1895 (handler)The handler function for the 'validate_accession' tool. It validates a UniProt accession by attempting to fetch the protein data from the UniProt API. Returns validation result including whether it exists, entry type, etc.private async handleValidateAccession(args: any) { if (!isValidAccessionValidateArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid accession validation arguments'); } try { const response = await this.apiClient.get(`/uniprotkb/${args.accession}`, { params: { format: 'json' }, }); const validationResult = { accession: args.accession, isValid: true, entryType: response.data.entryType, primaryAccession: response.data.primaryAccession, exists: true, }; return { content: [ { type: 'text', text: JSON.stringify(validationResult, null, 2), }, ], }; } catch (error) { const validationResult = { accession: args.accession, isValid: false, exists: false, error: error instanceof Error ? error.message : 'Unknown error', }; return { content: [ { type: 'text', text: JSON.stringify(validationResult, null, 2), }, ], }; } }
- src/index.ts:698-708 (registration)Registration of the 'validate_accession' tool in the ListTools response, including name, description, and input schema.{ name: 'validate_accession', description: 'Check if accession numbers are valid', inputSchema: { type: 'object', properties: { accession: { type: 'string', description: 'UniProt accession number to validate' }, }, required: ['accession'], }, },
- src/index.ts:782-783 (registration)Dispatch case in the CallToolRequestSchema handler that routes to the validate_accession handler.case 'validate_accession': return this.handleValidateAccession(args);
- src/index.ts:210-219 (helper)Helper function to validate the input arguments for the validate_accession tool.const isValidAccessionValidateArgs = ( args: any ): args is { accession: string } => { return ( typeof args === 'object' && args !== null && typeof args.accession === 'string' && args.accession.length > 0 ); };