get_strain
Retrieve C. elegans strain details including genotype, source availability, and associated phenotypes from the WormBase database.
Instructions
Get information about a C. elegans strain including genotype, available from, and associated phenotypes.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Strain identifier - strain name (e.g., 'N2', 'CB1370') | |
| widgets | No | Specific widgets to fetch: overview, phenotypes, references |
Implementation Reference
- src/index.ts:132-153 (registration)MCP server.tool registration for the 'get_strain' tool, defining its name, description, input schema, and inline handler function.// Tool: Get Strain Information server.tool( "get_strain", "Get information about a C. elegans strain including genotype, available from, and associated phenotypes.", { id: z.string().describe("Strain identifier - strain name (e.g., 'N2', 'CB1370')"), widgets: z.array(z.string()).optional().describe("Specific widgets to fetch: overview, phenotypes, references"), }, async ({ id, widgets }) => { try { const data = await client.getEntity("strain", id, widgets); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } catch (error) { return { content: [{ type: "text", text: `Error fetching strain: ${error}` }], isError: true, }; } } );
- src/index.ts:136-139 (schema)Zod input schema for the get_strain tool: required 'id' string and optional 'widgets' array.{ id: z.string().describe("Strain identifier - strain name (e.g., 'N2', 'CB1370')"), widgets: z.array(z.string()).optional().describe("Specific widgets to fetch: overview, phenotypes, references"), },
- src/index.ts:140-152 (handler)Inline handler function for get_strain tool that calls WormBaseClient.getEntity("strain", id, widgets) and formats the response as text content or error.async ({ id, widgets }) => { try { const data = await client.getEntity("strain", id, widgets); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } catch (error) { return { content: [{ type: "text", text: `Error fetching strain: ${error}` }], isError: true, }; } }
- src/client.ts:111-132 (helper)WormBaseClient.getEntity generic helper method used by the handler to fetch widget data from WormBase REST API for the 'strain' entity type.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; }