Skip to main content
Glama

get_sequence

Retrieve DNA sequences for specified genomic coordinates, gene IDs, or transcript IDs. Supports multiple species, output formats (JSON or FASTA), and optional repeat masking. Part of the Ensembl MCP Server for genomic data access.

Instructions

Get DNA sequence for genomic coordinates or gene/transcript ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoOutput format (default: fasta)
maskNoRepeat masking type (optional)
multiple_sequencesNoReturn multiple sequences if applicable (default: false)
regionYesGenomic region (chr:start-end) or feature ID
speciesNoSpecies name (default: homo_sapiens)

Implementation Reference

  • The primary handler function for the 'get_sequence' tool. It validates input arguments using isValidSequenceArgs, determines the Ensembl REST API endpoint based on whether the region is a feature ID or genomic coordinates, adds optional parameters like masking, fetches the sequence data using axios, and returns formatted content (JSON or FASTA).
    private async handleGetSequence(args: any) { if (!isValidSequenceArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid sequence arguments'); } try { const species = this.getDefaultSpecies(args.species); const format = args.format || 'fasta'; const region = this.formatGenomicRegion(args.region); let endpoint: string; const params: any = {}; if (region.startsWith('ENS')) { // Feature ID endpoint = `/sequence/id/${region}`; params.type = 'genomic'; } else { // Genomic region endpoint = `/sequence/region/${species}/${region}`; } if (args.mask) { params.mask = args.mask; } if (args.multiple_sequences) { params.multiple_sequences = 1; } const response = await this.apiClient.get(endpoint, { params }); 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 sequence'); }
  • JSON Schema defining the input parameters for the 'get_sequence' tool, including required 'region' and optional fields for species, format, masking, and multiple sequences.
    inputSchema: { type: 'object', properties: { region: { type: 'string', description: 'Genomic region (chr:start-end) or feature ID' }, species: { type: 'string', description: 'Species name (default: homo_sapiens)' }, format: { type: 'string', enum: ['json', 'fasta'], description: 'Output format (default: fasta)' }, mask: { type: 'string', enum: ['hard', 'soft'], description: 'Repeat masking type (optional)' }, multiple_sequences: { type: 'boolean', description: 'Return multiple sequences if applicable (default: false)' }, }, required: ['region'], },
  • src/index.ts:842-843 (registration)
    Registration of the 'get_sequence' tool handler in the CallToolRequestSchema switch statement, mapping the tool name to its execution function.
    case 'get_sequence': return this.handleGetSequence(args);
  • src/index.ts:613-626 (registration)
    Tool registration in the ListToolsRequestSchema response, defining name, description, and input schema for 'get_sequence'.
    name: 'get_sequence', description: 'Get DNA sequence for genomic coordinates or gene/transcript ID', inputSchema: { type: 'object', properties: { region: { type: 'string', description: 'Genomic region (chr:start-end) or feature ID' }, species: { type: 'string', description: 'Species name (default: homo_sapiens)' }, format: { type: 'string', enum: ['json', 'fasta'], description: 'Output format (default: fasta)' }, mask: { type: 'string', enum: ['hard', 'soft'], description: 'Repeat masking type (optional)' }, multiple_sequences: { type: 'boolean', description: 'Return multiple sequences if applicable (default: false)' }, }, required: ['region'], }, },
  • Type guard function used by the handler to validate input arguments against the expected schema for 'get_sequence'.
    const isValidSequenceArgs = ( args: any ): args is { region: string; species?: string; format?: string; mask?: string; multiple_sequences?: boolean } => { return ( typeof args === 'object' && args !== null && typeof args.region === 'string' && args.region.length > 0 && (args.species === undefined || typeof args.species === 'string') && (args.format === undefined || ['json', 'fasta'].includes(args.format)) && (args.mask === undefined || ['hard', 'soft'].includes(args.mask)) && (args.multiple_sequences === undefined || typeof args.multiple_sequences === 'boolean') ); };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Augmented-Nature/Ensembl-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server