get_cds_sequence
Retrieve coding sequence (CDS) for Ensembl transcripts to analyze gene coding regions and protein translation.
Instructions
Get coding sequence (CDS) for a transcript
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| transcript_id | Yes | Ensembl transcript ID | |
| species | No | Species name (default: homo_sapiens) | |
| format | No | Output format (default: fasta) |
Implementation Reference
- src/index.ts:1081-1112 (handler)The main handler function that validates input, calls Ensembl API /sequence/id/{transcript_id}?type=cds to retrieve the coding sequence, handles JSON/FASTA output formats, and manages errors.private async handleGetCdsSequence(args: any) { if (!isValidCdsArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid CDS sequence arguments'); } try { const species = this.getDefaultSpecies(args.species); const format = args.format || 'fasta'; const response = await this.apiClient.get(`/sequence/id/${args.transcript_id}`, { params: { type: 'cds', species, }, }); return { content: [ { type: 'text', text: format === 'json' ? JSON.stringify(response.data, null, 2) : typeof response.data === 'string' ? response.data : JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return this.handleError(error, 'fetching CDS sequence'); } }
- src/index.ts:628-639 (registration)Tool registration in ListToolsRequestSchema handler, including name, description, and input schema definition.name: 'get_cds_sequence', description: 'Get coding sequence (CDS) for a transcript', inputSchema: { type: 'object', properties: { transcript_id: { type: 'string', description: 'Ensembl transcript ID' }, species: { type: 'string', description: 'Species name (default: homo_sapiens)' }, format: { type: 'string', enum: ['json', 'fasta'], description: 'Output format (default: fasta)' }, }, required: ['transcript_id'], }, },
- src/index.ts:296-307 (schema)Type guard function for validating input arguments to the get_cds_sequence tool.const isValidCdsArgs = ( args: any ): args is { transcript_id: string; species?: string; format?: string } => { return ( typeof args === 'object' && args !== null && typeof args.transcript_id === 'string' && args.transcript_id.length > 0 && (args.species === undefined || typeof args.species === 'string') && (args.format === undefined || ['json', 'fasta'].includes(args.format)) ); };
- src/index.ts:846-847 (registration)Dispatch case in CallToolRequestSchema handler that routes calls to the get_cds_sequence handler function.case 'translate_sequence': return this.handleTranslateSequence(args);