get_protein_sequence
Retrieve the amino acid sequence of a protein using its UniProt accession number. Supports output in FASTA or JSON format for integration and analysis.
Instructions
Get the amino acid sequence for a protein
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accession | Yes | UniProt accession number | |
| format | No | Output format (default: fasta) |
Implementation Reference
- src/index.ts:912-944 (handler)The handler function that executes the tool logic: validates input arguments, fetches the protein sequence from UniProt REST API (`/uniprotkb/{accession}`) in 'fasta' or 'json' format, and returns the content or error.private async handleGetProteinSequence(args: any) { if (!isValidSequenceArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid sequence arguments'); } try { const format = args.format || 'fasta'; const response = await this.apiClient.get(`/uniprotkb/${args.accession}`, { params: { format }, }); return { content: [ { type: 'text', text: format === 'json' ? JSON.stringify(response.data, null, 2) : String(response.data), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error fetching sequence: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/index.ts:440-450 (registration)Registration of the 'get_protein_sequence' tool in the ListToolsRequestSchema response, including its name, description, and input schema.name: 'get_protein_sequence', description: 'Get the amino acid sequence for a protein', inputSchema: { type: 'object', properties: { accession: { type: 'string', description: 'UniProt accession number' }, format: { type: 'string', enum: ['fasta', 'json'], description: 'Output format (default: fasta)' }, }, required: ['accession'], }, },
- src/index.ts:103-113 (schema)Type guard and validation function for input arguments of get_protein_sequence tool, ensuring accession is a non-empty string and format is 'fasta' or 'json'.const isValidSequenceArgs = ( args: any ): args is { accession: string; format?: 'fasta' | 'json' } => { return ( typeof args === 'object' && args !== null && typeof args.accession === 'string' && args.accession.length > 0 && (args.format === undefined || ['fasta', 'json'].includes(args.format)) ); };
- src/index.ts:734-735 (registration)Tool dispatch/registration in the CallToolRequestSchema switch statement, routing calls to the handler.case 'get_protein_sequence': return this.handleGetProteinSequence(args);