Skip to main content
Glama
WormBase

WormBase MCP Server

Official
by WormBase

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
NameRequiredDescriptionDefault
idYesStrain identifier - strain name (e.g., 'N2', 'CB1370')
widgetsNoSpecific 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,
          };
        }
      }
    );
  • 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"),
    },
  • 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,
        };
      }
    }
  • 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;
    }

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