Skip to main content
Glama

get_protein

Retrieve protein details including sequence, domains, motifs, and structure from the WormBase database for C. elegans research.

Instructions

Get detailed information about a protein including sequence, domains, motifs, and structure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesProtein identifier - WormBase protein ID
widgetsNoSpecific widgets to fetch: overview, sequences, motif_details, external_links, references

Implementation Reference

  • src/index.ts:64-84 (registration)
    Registration of the 'get_protein' MCP tool, including description, Zod input schema, and handler function that delegates to WormBaseClient.getEntity.
    server.tool( "get_protein", "Get detailed information about a protein including sequence, domains, motifs, and structure.", { id: z.string().describe("Protein identifier - WormBase protein ID"), widgets: z.array(z.string()).optional().describe("Specific widgets to fetch: overview, sequences, motif_details, external_links, references"), }, async ({ id, widgets }) => { try { const data = await client.getEntity("protein", id, widgets); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } catch (error) { return { content: [{ type: "text", text: `Error fetching protein: ${error}` }], isError: true, }; } } );
  • Core handler logic in WormBaseClient.getEntity method, which fetches protein data from WormBase REST API widgets and cleans the response. Called by get_protein tool handler with type='protein'.
    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 REST 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>; }
  • Data cleaning helper used by getEntity to process and simplify WormBase API responses.
    private cleanWidgetData(data: any): Record<string, unknown> { if (!data) return {}; // The API typically wraps data in a "fields" object const fields = data.fields || data; // Clean and simplify the data structure const cleaned: Record<string, unknown> = {}; for (const [key, value] of Object.entries(fields)) { if (value === null || value === undefined) continue; // Handle nested data structures if (typeof value === "object" && value !== null) { const obj = value as Record<string, unknown>; if ("data" in obj) { cleaned[key] = obj.data; } else if ("id" in obj && "label" in obj) { // Entity reference cleaned[key] = { id: obj.id, label: obj.label, class: obj.class || obj.taxonomy, }; } else { cleaned[key] = this.simplifyValue(value); } } else { cleaned[key] = value; } } return cleaned; }
  • Type definition for protein-specific widgets available for the get_protein tool.
    export const PROTEIN_WIDGETS = [ ...COMMON_WIDGETS, "sequences", "motif_details", "homology", "blast_details", ] as const;

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