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
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Gene identifier |
Implementation Reference
- src/client.ts:178-182 (handler)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, }; } } );
- src/index.ts:227-229 (schema)Zod input schema defining the 'id' parameter for the get_ontology tool.{ id: z.string().describe("Gene identifier"), },
- src/client.ts:237-270 (helper)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; }