Skip to main content
Glama

ensembl_variation

Analyze genomic variants to predict functional consequences, find linked variants, map phenotypes, and examine haplotypes using Ensembl's variant data across species.

Instructions

Variant analysis: VEP consequence prediction, variant lookup, LD analysis, phenotype mapping, haplotypes. Covers /variation/, /vep/, /ld/, /phenotype/ endpoints.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
variant_idNoVariant ID (e.g., 'rs699', 'rs1042779', 'COSM476') or HGVS notation (e.g., '17:g.7579472G>C')
regionNoGenomic region in format 'chr:start-end' for variant search (e.g., '17:7565096-7590856', 'X:1000000-2000000', '1:100000-200000')
hgvs_notationNoHGVS notation for VEP analysis (e.g., '17:g.7579472G>C', 'ENST00000288602.6:c.1799T>A', 'NM_007294.3:c.1799T>A')
analysis_typeNoType of variant analysis
speciesNoSpecies name (e.g., 'homo_sapiens', 'mus_musculus')homo_sapiens
consequence_typeNoFilter by consequence type (e.g., 'missense_variant', 'stop_gained', 'splice_donor_variant')
populationNoPopulation for LD analysis (e.g., '1000GENOMES:phase_3:EUR', '1000GENOMES:phase_3:AFR', '1000GENOMES:phase_3:ASN')
transcript_idNoTranscript ID for haplotype analysis (e.g., 'ENST00000288602', 'ENST00000350283')

Implementation Reference

  • The primary handler function that executes the 'ensembl_variation' tool. It normalizes the input arguments and calls the EnsemblApiClient's getVariationData method to perform the actual API requests.
    export async function handleVariation(args: any) {
      try {
        const normalizedArgs = normalizeEnsemblInputs(args);
        return await ensemblClient.getVariationData(normalizedArgs);
      } catch (error) {
        return {
          error: error instanceof Error ? error.message : "Unknown error",
          success: false,
        };
      }
    }
  • Defines the tool schema including name, description, and inputSchema validation for 'ensembl_variation' within the ensemblTools array used for tool listing.
    {
      name: "ensembl_variation",
      description:
        "Variant analysis: VEP consequence prediction, variant lookup, LD analysis, phenotype mapping, haplotypes. Covers /variation/*, /vep/*, /ld/*, /phenotype/* endpoints.",
      inputSchema: {
        type: "object",
        properties: {
          variant_id: {
            type: "string",
            description:
              "Variant ID (e.g., 'rs699', 'rs1042779', 'COSM476') or HGVS notation (e.g., '17:g.7579472G>C')",
          },
          region: {
            type: "string",
            description:
              "Genomic region in format 'chr:start-end' for variant search (e.g., '17:7565096-7590856', 'X:1000000-2000000', '1:100000-200000')",
          },
          hgvs_notation: {
            type: "string",
            description:
              "HGVS notation for VEP analysis (e.g., '17:g.7579472G>C', 'ENST00000288602.6:c.1799T>A', 'NM_007294.3:c.1799T>A')",
          },
          analysis_type: {
            type: "string",
            enum: ["variant_info", "vep", "ld", "phenotype", "haplotypes"],
            description: "Type of variant analysis",
          },
          species: {
            type: "string",
            description: "Species name (e.g., 'homo_sapiens', 'mus_musculus')",
            default: "homo_sapiens",
          },
          consequence_type: {
            type: "string",
            description:
              "Filter by consequence type (e.g., 'missense_variant', 'stop_gained', 'splice_donor_variant')",
          },
          population: {
            type: "string",
            description:
              "Population for LD analysis (e.g., '1000GENOMES:phase_3:EUR', '1000GENOMES:phase_3:AFR', '1000GENOMES:phase_3:ASN')",
          },
          transcript_id: {
            type: "string",
            description:
              "Transcript ID for haplotype analysis (e.g., 'ENST00000288602', 'ENST00000350283')",
          },
        },
        anyOf: [
          { required: ["variant_id"] },
          { required: ["region"] },
          { required: ["hgvs_notation"] },
        ],
      },
    },
  • index.ts:149-157 (registration)
    Registers the 'ensembl_variation' tool in the MCP server's request handler switch statement, dispatching calls to handleVariation.
    case "ensembl_variation":
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(await handleVariation(args), null, 2),
          },
        ],
      };
  • Core helper function in EnsemblApiClient that implements the variant analysis logic by routing to specific Ensembl REST API endpoints based on the analysis_type.
    async getVariationData(args: any): Promise<any> {
      const {
        variant_id,
        region,
        hgvs_notation,
        analysis_type,
        species = "homo_sapiens",
        consequence_type,
        population,
        transcript_id,
      } = args;
      const params: Record<string, string> = {};
    
      if (consequence_type) {
        params.consequence_type = consequence_type;
      }
      if (population) {
        params.population_name = population;
      }
    
      switch (analysis_type) {
        case "variant_info":
          if (variant_id) {
            return this.makeRequest(
              `/variation/${species}/${variant_id}`,
              params
            );
          } else if (region) {
            return this.makeRequest(`/overlap/region/${species}/${region}`, {
              ...params,
              feature: "variation",
            });
          }
          throw new Error(
            "Either variant_id or region required for variant info"
          );
    
        case "vep":
          if (hgvs_notation) {
            return this.makeRequest(
              `/vep/${species}/hgvs/${hgvs_notation}`,
              params
            );
          } else if (variant_id) {
            return this.makeRequest(`/vep/${species}/id/${variant_id}`, params);
          } else if (region) {
            // For region-based VEP, we need allele info - this is simplified
            return this.makeRequest(`/vep/${species}/region/${region}/1`, params);
          }
          throw new Error(
            "Either hgvs_notation, variant_id, or region required for VEP"
          );
    
        case "ld":
          if (!variant_id) throw new Error("variant_id required for LD analysis");
          return this.makeRequest(
            `/ld/${species}/${variant_id}/1000GENOMES:phase_3:EUR`,
            params
          );
    
        case "phenotype":
          if (variant_id) {
            return this.makeRequest(
              `/phenotype/variant/${species}/${variant_id}`,
              params
            );
          } else if (region) {
            return this.makeRequest(
              `/phenotype/region/${species}/${region}`,
              params
            );
          }
          throw new Error("Either variant_id or region required for phenotype");
    
        case "haplotypes":
          if (!transcript_id)
            throw new Error("transcript_id required for haplotype analysis");
          return this.makeRequest(
            `/transcript_haplotypes/${species}/${transcript_id}`,
            params
          );
    
        default:
          throw new Error(`Unknown analysis_type: ${analysis_type}`);
      }
    }
  • Supporting utility that normalizes tool inputs for Ensembl API compatibility, used by all handlers including handleVariation.
    export function normalizeEnsemblInputs(inputs: any): any {
      const normalized = { ...inputs };
    
      // Normalize assembly first as it affects other normalizations
      if (normalized.assembly) {
        normalized.assembly = normalizeAssemblyName(normalized.assembly);
      }
    
      // Normalize species with assembly context
      if (normalized.species) {
        normalized.species = normalizeSpeciesName(
          normalized.species,
          normalized.assembly
        );
      }
    
      // Normalize genomic regions with assembly context
      if (normalized.region) {
        normalized.region = normalizeGenomicRegion(
          normalized.region,
          normalized.assembly
        );
      }
    
      // Normalize cDNA coordinates
      if (normalized.cdna_coords) {
        normalized.cdna_coords = normalizeCdnaCoordinates(normalized.cdna_coords);
      }
    
      // Normalize gene identifiers
      if (normalized.gene_id || normalized.feature_id) {
        const geneField = normalized.gene_id ? "gene_id" : "feature_id";
        normalized[geneField] = normalizeGeneIdentifier(
          normalized[geneField],
          normalized.assembly
        );
      }
    
      // Normalize HGVS notation
      if (normalized.hgvs) {
        normalized.hgvs = normalizeHgvsNotation(
          normalized.hgvs,
          normalized.assembly
        );
      }
    
      // Normalize scaffold names
      if (normalized.scaffold) {
        normalized.scaffold = normalizeScaffoldName(
          normalized.scaffold,
          normalized.assembly
        );
      }
    
      // Handle coordinate system normalization if specified
      if (normalized.start && normalized.end && normalized.coordinate_system) {
        const coords = normalizeCoordinateSystem(
          Number(normalized.start),
          Number(normalized.end),
          normalized.coordinate_system
        );
        normalized.start = coords.start;
        normalized.end = coords.end;
        delete normalized.coordinate_system; // Remove the hint after using it
      }
    
      return normalized;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions analysis types and endpoints but fails to describe critical traits: whether operations are read-only or mutative, authentication needs, rate limits, error handling, or output format. For a tool with 8 parameters and complex genomic analysis, this lack of behavioral context is a significant gap.

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

Conciseness4/5

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

The description is appropriately concise and front-loaded, stating the core purpose in the first phrase. It uses a semicolon-separated list for analysis types and a brief endpoint summary, with no redundant sentences. However, the endpoint list ('Covers /variation/*, /vep/*, /ld/*, /phenotype/* endpoints.') could be integrated more smoothly, slightly affecting flow.

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 tool's complexity (8 parameters, no output schema, no annotations), the description is incomplete. It lacks output details, behavioral traits, and usage guidelines, which are crucial for an AI agent to invoke it correctly in genomic contexts. The high schema coverage helps with parameters, but overall, the description doesn't compensate for missing structured data.

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 schema description coverage is 100%, so the schema already documents all 8 parameters thoroughly. The description adds minimal value beyond the schema by listing analysis types (e.g., 'VEP consequence prediction') that map to the 'analysis_type' enum, but it doesn't provide additional syntax, format details, or interdependencies. 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: 'Variant analysis: VEP consequence prediction, variant lookup, LD analysis, phenotype mapping, haplotypes.' It provides specific verbs (prediction, lookup, analysis, mapping) and resources (variants, phenotypes, haplotypes), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'ensembl_lookup' or 'ensembl_feature_overlap,' which might offer overlapping genomic analysis capabilities.

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. It lists analysis types and endpoints but doesn't specify prerequisites, exclusions, or comparisons to sibling tools. For example, it doesn't clarify if this is the primary tool for variant data or when to choose it over 'ensembl_lookup' for similar queries, leaving the agent without usage context.

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/effieklimi/ensembl-mcp-server'

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