Skip to main content
Glama
WormBase

WormBase MCP Server

Official
by WormBase

get_phenotype

Retrieve detailed phenotype information from WormBase, including associated genes, RNAi experiments, and variations, using a phenotype identifier.

Instructions

Get detailed information about a phenotype including associated genes, RNAi experiments, and variations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesPhenotype identifier - WormBase phenotype ID (e.g., 'WBPhenotype:0000643')
widgetsNoSpecific widgets to fetch: overview, rnai, variation, transgene, references

Implementation Reference

  • src/index.ts:87-107 (registration)
    MCP tool registration for 'get_phenotype', including description, Zod input schema, and handler function that delegates to WormBaseClient.getEntity
    server.tool(
      "get_phenotype",
      "Get detailed information about a phenotype including associated genes, RNAi experiments, and variations.",
      {
        id: z.string().describe("Phenotype identifier - WormBase phenotype ID (e.g., 'WBPhenotype:0000643')"),
        widgets: z.array(z.string()).optional().describe("Specific widgets to fetch: overview, rnai, variation, transgene, references"),
      },
      async ({ id, widgets }) => {
        try {
          const data = await client.getEntity("phenotype", id, widgets);
          return {
            content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
          };
        } catch (error) {
          return {
            content: [{ type: "text", text: `Error fetching phenotype: ${error}` }],
            isError: true,
          };
        }
      }
    );
  • Input schema for get_phenotype tool using Zod validation for 'id' and optional 'widgets' array
    {
      id: z.string().describe("Phenotype identifier - WormBase phenotype ID (e.g., 'WBPhenotype:0000643')"),
      widgets: z.array(z.string()).optional().describe("Specific widgets to fetch: overview, rnai, variation, transgene, references"),
    },
  • Handler function that executes the tool logic: fetches phenotype data via client and returns JSON or error
    async ({ id, widgets }) => {
      try {
        const data = await client.getEntity("phenotype", id, widgets);
        return {
          content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
        };
      } catch (error) {
        return {
          content: [{ type: "text", text: `Error fetching phenotype: ${error}` }],
          isError: true,
        };
      }
    }
  • Core helper method getEntity used by the handler to query WormBase REST API for phenotype widgets and clean the 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;
    }
  • Private fetch helper used by getEntity to make HTTP requests to WormBase API
    private async fetch<T>(url: string): Promise<T> {
      const response = await fetch(url, {
        headers: {
          "Accept": "application/json",
          "Accept-Language": "en-US,en;q=0.9",
          "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
          "Sec-Fetch-Dest": "empty",
          "Sec-Fetch-Mode": "cors",
          "Sec-Fetch-Site": "cross-site",
        },
      });
    
      if (!response.ok) {
        throw new Error(`HTTP ${response.status}: ${response.statusText}`);
      }
    
      return response.json() as Promise<T>;
    }

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