Skip to main content
Glama
Augmented-Nature

Ensembl MCP Server

get_sequence

Retrieve DNA sequences from Ensembl using genomic coordinates or gene/transcript identifiers for analysis and research purposes.

Instructions

Get DNA sequence for genomic coordinates or gene/transcript ID

Input Schema

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

Implementation Reference

  • Core implementation of the get_sequence tool. Validates input using isValidSequenceArgs, determines Ensembl REST API endpoint based on whether input is a feature ID (ENS...) or genomic region, applies optional mask and multiple_sequences params, fetches sequence data, and returns in json or fasta format.
    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');
      }
    }
  • src/index.ts:842-843 (registration)
    Tool handler registration in the CallToolRequestSchema switch statement, dispatching calls to handleGetSequence.
    case 'get_sequence':
      return this.handleGetSequence(args);
  • src/index.ts:613-626 (registration)
    Tool definition and input schema registration in the ListToolsRequestSchema response, including name, description, and JSON schema for parameters.
      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 and validation function for get_sequence tool input arguments, ensuring correct types and values before processing.
    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')
      );
    };
  • Utility function used by handleGetSequence to normalize and validate the region parameter format.
    private formatGenomicRegion(region: string): string {
      // Handle different region formats and ensure proper formatting
      // Support formats like: chr1:1000-2000, 1:1000-2000, ENSG00000139618
      if (region.includes(':') && region.includes('-')) {
        // Already in proper format
        return region;
      } else if (region.startsWith('ENS')) {
        // Gene/transcript/exon ID
        return region;
      } else {
        // Assume it's a chromosome name, return as-is
        return region;
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states what the tool does but lacks critical behavioral details: it doesn't mention whether this is a read-only operation, potential rate limits, authentication needs, error handling, or what the output looks like (e.g., sequence format details). For a tool with 5 parameters and no output schema, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary words. It directly states what the tool does, making it easy to parse quickly. Every word earns its place, and there's no redundancy or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (5 parameters, no annotations, no output schema, and many sibling tools), the description is incomplete. It lacks behavioral context, usage differentiation, and output details. For a tool that retrieves biological data with multiple options, more guidance is needed to help an agent use it correctly without trial and error.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all parameters. The description adds minimal value beyond the schema: it implies 'region' accepts coordinates or IDs, but the schema already describes this as 'Genomic region (chr:start-end) or feature ID'. No additional syntax, examples, or constraints are provided. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get DNA sequence for genomic coordinates or gene/transcript ID'. It specifies the verb ('Get') and resource ('DNA sequence'), and indicates the input types (coordinates or IDs). However, it doesn't explicitly differentiate from siblings like 'get_cds_sequence' or 'translate_sequence', which also retrieve sequence-related data, leaving some ambiguity about when to choose this tool over those alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus sibling tools. With many sequence-related siblings (e.g., get_cds_sequence, translate_sequence, batch_sequence_fetch), there's no indication of context, exclusions, or alternatives. The agent must infer usage from tool names alone, which is insufficient for reliable selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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