Skip to main content
Glama

get_gene_tree

Generate a phylogenetic tree for a gene family using an Ensembl gene ID, with options for species, tree format, and clusterset ID. Accessible via the Ensembl MCP Server.

Instructions

Get phylogenetic tree for gene family

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clusterset_idNoSpecific clusterset ID (optional)
formatNoTree format (default: json)
gene_idYesEnsembl gene ID
speciesNoSpecies name (default: homo_sapiens)

Implementation Reference

  • The main handler function for the 'get_gene_tree' tool. Validates arguments, constructs the Ensembl REST API endpoint `/genetree/id/{gene_id}`, makes the API call, formats the response as JSON or other specified format, and handles errors.
    private async handleGetGeneTree(args: any) { if (!isValidGeneTreeArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid gene tree arguments'); } try { const format = args.format || 'json'; let endpoint = `/genetree/id/${args.gene_id}`; const params: any = {}; if (args.clusterset_id) { params.clusterset_id = args.clusterset_id; } if (format !== 'json') { params.format = format; } const response = await this.apiClient.get(endpoint, { params }); return { content: [ { type: 'text', text: typeof response.data === 'object' ? JSON.stringify(response.data, null, 2) : String(response.data), }, ], }; } catch (error) { return this.handleError(error, 'fetching gene tree'); } }
  • Type guard function validating input arguments for the get_gene_tree tool, ensuring required gene_id and optional parameters like species, format (json/newick/phyloxml), clusterset_id.
    const isValidGeneTreeArgs = ( args: any ): args is { gene_id: string; species?: string; format?: string; clusterset_id?: string } => { return ( typeof args === 'object' && args !== null && typeof args.gene_id === 'string' && args.gene_id.length > 0 && (args.species === undefined || typeof args.species === 'string') && (args.format === undefined || ['json', 'newick', 'phyloxml'].includes(args.format)) && (args.clusterset_id === undefined || typeof args.clusterset_id === 'string') ); };
  • src/index.ts:851-852 (registration)
    Switch case in CallToolRequestSchema handler that routes calls to the get_gene_tree tool to its handler function.
    case 'get_gene_tree': return this.handleGetGeneTree(args);
  • src/index.ts:669-681 (registration)
    Tool registration in ListToolsRequestSchema response, defining name, description, and inputSchema for get_gene_tree.
    name: 'get_gene_tree', description: 'Get phylogenetic tree for gene family', inputSchema: { type: 'object', properties: { gene_id: { type: 'string', description: 'Ensembl gene ID' }, species: { type: 'string', description: 'Species name (default: homo_sapiens)' }, format: { type: 'string', enum: ['json', 'newick', 'phyloxml'], description: 'Tree format (default: json)' }, clusterset_id: { type: 'string', description: 'Specific clusterset ID (optional)' }, }, required: ['gene_id'], }, },
  • Input validation schema matching the tool's inputSchema, used in the handler.
    const isValidGeneTreeArgs = ( args: any ): args is { gene_id: string; species?: string; format?: string; clusterset_id?: string } => { return ( typeof args === 'object' && args !== null && typeof args.gene_id === 'string' && args.gene_id.length > 0 && (args.species === undefined || typeof args.species === 'string') && (args.format === undefined || ['json', 'newick', 'phyloxml'].includes(args.format)) && (args.clusterset_id === undefined || typeof args.clusterset_id === 'string') ); };

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