Skip to main content
Glama

get_ontology

Retrieve Gene Ontology terms for a specific gene, providing molecular function, biological process, and cellular component annotations from the WormBase database.

Instructions

Get Gene Ontology (GO) terms for a gene including molecular function, biological process, and cellular component annotations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesGene identifier

Implementation Reference

  • Core handler function that fetches Gene Ontology annotations for a gene from the WormBase REST API endpoint and processes the data using cleanWidgetData helper.
    async getOntology(id: string): Promise<Record<string, unknown>> { const url = `${this.baseUrl}/rest/widget/gene/${encodeURIComponent(id)}/ontology`; const data = await this.fetch<any>(url); return this.cleanWidgetData(data); }
  • src/index.ts:224-243 (registration)
    Registers the 'get_ontology' MCP tool with name, description, input schema, and handler function that delegates to WormBaseClient.getOntology.
    server.tool( "get_ontology", "Get Gene Ontology (GO) terms for a gene including molecular function, biological process, and cellular component annotations.", { id: z.string().describe("Gene identifier"), }, async ({ id }) => { try { const data = await client.getOntology(id); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } catch (error) { return { content: [{ type: "text", text: `Error fetching ontology: ${error}` }], isError: true, }; } } );
  • Zod input schema defining the 'id' parameter for the get_ontology tool.
    { id: z.string().describe("Gene identifier"), },
  • Helper function used by getOntology to clean and simplify the raw API response data from WormBase widgets.
    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