validate_accession
Verify the validity of UniProt accession numbers using a dedicated tool on the UniProt MCP Server. Ensure accurate data integration by validating accession inputs.
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 main handler function that implements the validate_accession tool. It validates input, attempts to fetch the UniProt entry via API, and returns a structured result indicating if the accession is valid and exists, including details on success or error message on failure.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:210-219 (schema)Type guard function used in the handler to validate the input arguments for the validate_accession tool, ensuring 'accession' is a non-empty string.const isValidAccessionValidateArgs = ( args: any ): args is { accession: string } => { return ( typeof args === 'object' && args !== null && typeof args.accession === 'string' && args.accession.length > 0 ); };
- src/index.ts:699-708 (registration)Tool registration entry in the ListToolsRequestSchema handler, defining the name, description, and input schema for 'validate_accession'.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)Switch case in the CallToolRequestSchema handler that routes calls to the 'validate_accession' tool to its handler function.case 'validate_accession': return this.handleValidateAccession(args);