get_transcripts
Retrieve all transcripts for a specific gene, including structural details, using the Ensembl MCP Server. Specify a gene ID and optionally filter for canonical transcripts or adjust species.
Instructions
Get all transcripts for a gene with detailed structure
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| canonical_only | No | Return only canonical transcript (default: false) | |
| gene_id | Yes | Ensembl gene ID | |
| species | No | Species name (default: homo_sapiens) |
Implementation Reference
- src/index.ts:960-994 (handler)The core handler function for the 'get_transcripts' tool. Validates input, fetches gene data with expanded transcripts from Ensembl REST API (/lookup/id/{gene_id}?expand=1), filters optional canonical transcripts, and formats the response with gene info and transcript details.private async handleGetTranscripts(args: any) { if (!isValidTranscriptArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid transcript arguments'); } try { const species = this.getDefaultSpecies(args.species); const response = await this.apiClient.get(`/lookup/id/${args.gene_id}`, { params: { species, expand: 1 }, }); const gene = response.data; let transcripts = gene.Transcript || []; if (args.canonical_only) { transcripts = transcripts.filter((t: any) => t.is_canonical === 1); } return { content: [ { type: 'text', text: JSON.stringify({ gene_id: gene.id, gene_name: gene.display_name, transcript_count: transcripts.length, transcripts: transcripts, }, null, 2), }, ], }; } catch (error) { return this.handleError(error, 'fetching transcripts'); } }
- src/index.ts:283-294 (schema)Input validation type guard (schema) specifically for 'get_transcripts' tool arguments: requires gene_id string, optional species and canonical_only boolean.const isValidTranscriptArgs = ( args: any ): args is { gene_id: string; species?: string; canonical_only?: boolean } => { return ( typeof args === 'object' && args !== null && typeof args.gene_id === 'string' && args.gene_id.length > 0 && (args.species === undefined || typeof args.species === 'string') && (args.canonical_only === undefined || typeof args.canonical_only === 'boolean') ); };
- src/index.ts:584-595 (registration)Tool registration in ListToolsRequestSchema handler, including name, description, and input schema definition.name: 'get_transcripts', description: 'Get all transcripts for a gene with detailed structure', inputSchema: { type: 'object', properties: { gene_id: { type: 'string', description: 'Ensembl gene ID' }, species: { type: 'string', description: 'Species name (default: homo_sapiens)' }, canonical_only: { type: 'boolean', description: 'Return only canonical transcript (default: false)' }, }, required: ['gene_id'], }, },
- src/index.ts:838-838 (registration)Dispatch/registration of the tool handler in the CallToolRequestSchema switch statement.return this.handleGetTranscripts(args);
- src/index.ts:33-51 (schema)TypeScript interface defining the structure of EnsemblTranscript objects used in the tool's response.interface EnsemblTranscript { id: string; parent: string; display_name: string; biotype: string; start: number; end: number; strand: number; is_canonical?: number; length: number; version: number; Translation?: { id: string; start: number; end: number; length: number; }; Exon?: EnsemblExon[]; }