Skip to main content
Glama
Augmented-Nature

Ensembl MCP Server

get_variants

Retrieve genetic variants from a specified genomic region using Ensembl data. Filter results by species, consequence types, and output format to analyze DNA sequence variations.

Instructions

Get genetic variants in a genomic region

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
regionYesGenomic region (chr:start-end)
speciesNoSpecies name (default: homo_sapiens)
formatNoOutput format (default: json)
consequence_typeNoFilter by consequence types

Implementation Reference

  • The handler function that implements the get_variants tool. It validates input, queries the Ensembl API using /overlap/region (feature=variation) or falls back to /variation/region, and returns the variants data as JSON.
    private async handleGetVariants(args: any) {
      if (!isValidVariantArgs(args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid variant arguments');
      }
    
      try {
        const species = this.getDefaultSpecies(args.species);
        const format = args.format || 'json';
        const region = this.formatGenomicRegion(args.region);
    
        // Try overlap endpoint first as variation/region may not have data for all regions
        try {
          const response = await this.apiClient.get(`/overlap/region/${species}/${region}`, {
            params: { feature: 'variation' }
          });
    
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(response.data, null, 2),
              },
            ],
          };
        } catch (overlapError) {
          // Fallback to variation endpoint
          const params: any = { format };
    
          if (args.consequence_type) {
            params.consequence_type = args.consequence_type.join(',');
          }
    
          const response = await this.apiClient.get(`/variation/region/${species}/${region}`, { params });
    
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(response.data, null, 2),
              },
            ],
          };
        }
      } catch (error) {
        return this.handleError(error, 'fetching variants');
      }
    }
  • src/index.ts:684-695 (registration)
    Tool registration in the ListToolsRequestSchema response, defining the name, description, and input schema for get_variants.
    name: 'get_variants',
    description: 'Get genetic variants in a genomic region',
    inputSchema: {
      type: 'object',
      properties: {
        region: { type: 'string', description: 'Genomic region (chr:start-end)' },
        species: { type: 'string', description: 'Species name (default: homo_sapiens)' },
        format: { type: 'string', enum: ['json', 'vcf'], description: 'Output format (default: json)' },
        consequence_type: { type: 'array', items: { type: 'string' }, description: 'Filter by consequence types' },
      },
      required: ['region'],
    },
  • Type guard function that validates the input parameters for the get_variants tool.
    const isValidVariantArgs = (
      args: any
    ): args is { region: string; species?: string; format?: string; consequence_type?: string[] } => {
      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', 'vcf'].includes(args.format)) &&
        (args.consequence_type === undefined ||
         (Array.isArray(args.consequence_type) && args.consequence_type.every((c: any) => typeof c === 'string')))
      );
    };
  • src/index.ts:854-855 (registration)
    Registration/dispatch in the CallToolRequestSchema switch statement that routes calls to get_variants to its handler.
    case 'get_variants':
      return this.handleGetVariants(args);
  • TypeScript interface defining the structure of Ensembl variant data objects returned by the API.
    interface EnsemblVariant {
      id: string;
      seq_region_name: string;
      start: number;
      end: number;
      strand: number;
      allele_string: string;
      variant_class: string;
      source: string;
      most_severe_consequence: string;
      MAF?: number;
      minor_allele?: string;
      clinical_significance?: string[];
    }
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. While 'Get' implies a read-only operation, the description doesn't address critical behavioral aspects such as authentication requirements, rate limits, pagination, error handling, or what happens when no variants are found in the specified region. This leaves significant gaps in understanding how the tool behaves.

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 states the core purpose without unnecessary words. It's appropriately sized for a straightforward retrieval tool and front-loads the essential information, making it easy for an agent to parse quickly.

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 of genomic data retrieval and the absence of both annotations and an output schema, the description is insufficiently complete. It doesn't explain what the tool returns (e.g., variant details, format specifics), how results are structured, or any limitations beyond the basic purpose, leaving too much undefined for reliable agent use.

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?

The description adds no parameter semantics beyond what's already documented in the input schema, which has 100% coverage with clear descriptions for all four parameters. The baseline score of 3 reflects that the schema adequately documents parameters, but the description doesn't provide additional context about parameter interactions or usage examples.

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 verb 'Get' and the resource 'genetic variants in a genomic region', making the purpose immediately understandable. However, it doesn't explicitly differentiate this tool from sibling tools like 'get_variant_consequences' or 'get_sequence', which reduces clarity about its unique role in the toolset.

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 alternatives. With sibling tools like 'get_variant_consequences' and 'get_sequence' available, there's no indication of specific use cases, prerequisites, or exclusions that would help an agent choose appropriately among related genomic data retrieval tools.

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