get_strain
Retrieve C. elegans strain details including genotype, source, and phenotypes from WormBase. Use strain identifiers like 'N2' or 'CB1370' to access comprehensive biological data.
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:140-152 (handler)Handler function that executes the get_strain tool logic by calling WormBaseClient.getEntity with type 'strain' and returning formatted JSON response 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/index.ts:136-139 (schema)Input schema validation using Zod for the get_strain tool parameters: id (string) and optional widgets (array of strings).{ 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:133-153 (registration)Registration of the get_strain tool with the MCP server using server.tool(), specifying name, description, input schema, and handler function.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/client.ts:111-132 (helper)Core helper method in WormBaseClient that fetches data for any entity type (including 'strain') from WormBase REST API by requesting specified widgets and cleaning the response data.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; }