Skip to main content
Glama

get_variants

Retrieve genetic variants within a specified genomic region for a given species. Filter results by consequence types and export in JSON or VCF format using Ensembl MCP Server.

Instructions

Get genetic variants in a genomic region

Input Schema

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

Implementation Reference

  • The handler function for the 'get_variants' tool. Validates input using isValidVariantArgs, queries Ensembl REST API using /overlap/region/... with feature=variation first, falls back to /variation/region/..., formats response as JSON and returns it.
    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'); } }
  • Type guard and validation function for 'get_variants' tool input parameters: checks region (required string), optional species, format (json/vcf), and consequence_type array.
    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:684-695 (registration)
    Tool registration in ListToolsRequestSchema response, including name, description, and inputSchema definition.
    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'], },
  • src/index.ts:854-855 (registration)
    Dispatch case in CallToolRequestSchema handler that routes 'get_variants' calls to the handleGetVariants method.
    case 'get_variants': return this.handleGetVariants(args);

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