get_gene
Retrieve comprehensive C. elegans gene data including function, expression, phenotypes, and orthologs from WormBase to support genetic research and analysis.
Instructions
Get detailed information about a C. elegans gene including description, function, expression, phenotypes, and orthologs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Gene identifier - WormBase ID (e.g., 'WBGene00006763') or gene name (e.g., 'daf-2', 'unc-13') | |
| widgets | No | Specific widgets to fetch: overview, expression, phenotype, interactions, homology, sequences, genetics, external_links, references |
Implementation Reference
- src/index.ts:48-60 (handler)MCP tool handler for 'get_gene': calls client.getGene, formats JSON response, handles errorsasync ({ id, widgets }) => { try { const data = await client.getGene(id, widgets); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } catch (error) { return { content: [{ type: "text", text: `Error fetching gene: ${error}` }], isError: true, }; } }
- src/index.ts:44-47 (schema)Zod input schema defining parameters id (string) and optional widgets (array of strings) for the get_gene tool{ id: z.string().describe("Gene identifier - WormBase ID (e.g., 'WBGene00006763') or gene name (e.g., 'daf-2', 'unc-13')"), widgets: z.array(z.string()).optional().describe("Specific widgets to fetch: overview, expression, phenotype, interactions, homology, sequences, genetics, external_links, references"), },
- src/index.ts:41-61 (registration)Registration of the 'get_gene' tool with McpServer using server.tool(name, description, schema, handler)server.tool( "get_gene", "Get detailed information about a C. elegans gene including description, function, expression, phenotypes, and orthologs.", { id: z.string().describe("Gene identifier - WormBase ID (e.g., 'WBGene00006763') or gene name (e.g., 'daf-2', 'unc-13')"), widgets: z.array(z.string()).optional().describe("Specific widgets to fetch: overview, expression, phenotype, interactions, homology, sequences, genetics, external_links, references"), }, async ({ id, widgets }) => { try { const data = await client.getGene(id, widgets); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } catch (error) { return { content: [{ type: "text", text: `Error fetching gene: ${error}` }], isError: true, }; } } );
- src/client.ts:77-106 (helper)WormBaseClient.getGene method: resolves gene ID if necessary, fetches specified widgets from WormBase REST API, cleans data, handles errors per widgetasync getGene( id: string, widgets?: string[] ): Promise<Record<string, unknown>> { // Resolve gene name to WBGene ID if needed let geneId = id; if (!id.startsWith("WBGene")) { const resolved = await this.resolveGeneId(id); if (resolved) { geneId = resolved; } } const defaultWidgets = ["overview", "phenotype", "expression", "ontology"]; const requestedWidgets = widgets || defaultWidgets; const result: Record<string, unknown> = { id: geneId, query: id }; for (const widget of requestedWidgets) { try { const url = `${this.baseUrl}/rest/widget/gene/${encodeURIComponent(geneId)}/${widget}`; const data = await this.fetch<any>(url); result[widget] = this.cleanWidgetData(data); } catch (error) { result[widget] = { error: `Failed to fetch ${widget}` }; } } return result; }