Skip to main content
Glama

get_variation

Retrieve genetic variation details from WormBase, including molecular data, phenotypes, and associated strains for C. elegans research.

Instructions

Get information about a genetic variation/allele including molecular details, phenotypes, and strains.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesVariation identifier - allele name (e.g., 'e1370') or WormBase variation ID
widgetsNoSpecific widgets to fetch: overview, molecular_details, phenotypes, references

Implementation Reference

  • src/index.ts:156-176 (registration)
    Registers the MCP tool 'get_variation' with name, description, input schema, and handler function.
    server.tool( "get_variation", "Get information about a genetic variation/allele including molecular details, phenotypes, and strains.", { id: z.string().describe("Variation identifier - allele name (e.g., 'e1370') or WormBase variation ID"), widgets: z.array(z.string()).optional().describe("Specific widgets to fetch: overview, molecular_details, phenotypes, references"), }, async ({ id, widgets }) => { try { const data = await client.getEntity("variation", id, widgets); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } catch (error) { return { content: [{ type: "text", text: `Error fetching variation: ${error}` }], isError: true, }; } } );
  • The handler function for the 'get_variation' tool. It calls WormBaseClient.getEntity with type 'variation' and returns formatted JSON response or error.
    async ({ id, widgets }) => { try { const data = await client.getEntity("variation", id, widgets); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } catch (error) { return { content: [{ type: "text", text: `Error fetching variation: ${error}` }], isError: true, }; } }
  • Zod input schema defining parameters for the 'get_variation' tool: id (required string) and optional widgets array.
    id: z.string().describe("Variation identifier - allele name (e.g., 'e1370') or WormBase variation ID"), widgets: z.array(z.string()).optional().describe("Specific widgets to fetch: overview, molecular_details, phenotypes, references"), },
  • Core helper method WormBaseClient.getEntity that fetches specified widgets from WormBase REST API for any entity type (used with 'variation' for get_variation tool).
    async getEntity( type: EntityType, id: string, widgets?: string[] ): Promise<Record<string, unknown>> { const defaultWidgets = ["overview"]; const requestedWidgets = widgets || defaultWidgets; const result: Record<string, unknown> = { id, type }; for (const widget of requestedWidgets) { try { const url = `${this.baseUrl}/rest/widget/${type}/${encodeURIComponent(id)}/${widget}`; const data = await this.fetch<any>(url); result[widget] = this.cleanWidgetData(data); } catch (error) { result[widget] = { error: `Failed to fetch ${widget}` }; } } return result; }
  • Helper method to clean and simplify raw data from WormBase API widgets, used in getEntity.
    private cleanWidgetData(data: any): Record<string, unknown> { if (!data) return {}; // The API typically wraps data in a "fields" object const fields = data.fields || data; // Clean and simplify the data structure const cleaned: Record<string, unknown> = {}; for (const [key, value] of Object.entries(fields)) { if (value === null || value === undefined) continue; // Handle nested data structures if (typeof value === "object" && value !== null) { const obj = value as Record<string, unknown>; if ("data" in obj) { cleaned[key] = obj.data; } else if ("id" in obj && "label" in obj) { // Entity reference cleaned[key] = { id: obj.id, label: obj.label, class: obj.class || obj.taxonomy, }; } else { cleaned[key] = this.simplifyValue(value); } } else { cleaned[key] = value; } } return cleaned; }

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/WormBase/wormbase-mcp'

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