get_entity
Retrieve detailed information about WormBase entities like genes, proteins, phenotypes, and expression patterns to access nematode genomics data.
Instructions
Get information about any WormBase entity type. Use this for entity types not covered by specific tools.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | Yes | Entity type | |
| id | Yes | Entity identifier | |
| widgets | No | Specific widgets to fetch |
Implementation Reference
- src/index.ts:245-267 (registration)MCP tool registration for 'get_entity', including description, input schema using Zod and ENTITY_TYPES, and async handler that calls WormBaseClient.getEntity and returns JSON-formatted response or error.// Tool: Get Generic Entity server.tool( "get_entity", "Get information about any WormBase entity type. Use this for entity types not covered by specific tools.", { type: z.enum(ENTITY_TYPES).describe("Entity type"), id: z.string().describe("Entity identifier"), widgets: z.array(z.string()).optional().describe("Specific widgets to fetch"), }, async ({ type, id, widgets }) => { try { const data = await client.getEntity(type, id, widgets); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } catch (error) { return { content: [{ type: "text", text: `Error fetching entity: ${error}` }], isError: true, }; } } );
- src/types.ts:2-45 (schema)Definition of ENTITY_TYPES enum used in the input schema for the 'type' parameter of get_entity tool.export const ENTITY_TYPES = [ "gene", "protein", "transcript", "cds", "pseudogene", "phenotype", "disease", "strain", "variation", "transgene", "rnai", "anatomy_term", "life_stage", "go_term", "interaction", "expression_cluster", "expr_pattern", "paper", "person", "laboratory", "clone", "sequence", "feature", "operon", "gene_class", "molecule", "antibody", "construct", "motif", "homology_group", "rearrangement", "transposon", "transposon_family", "pcr_oligo", "position_matrix", "microarray_results", "structure_data", "analysis", "gene_cluster", "expr_profile", ] as const; export type EntityType = (typeof ENTITY_TYPES)[number];
- src/index.ts:254-266 (handler)Handler function for the get_entity tool: fetches data using WormBaseClient.getEntity and returns formatted text content or error.async ({ type, id, widgets }) => { try { const data = await client.getEntity(type, id, widgets); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } catch (error) { return { content: [{ type: "text", text: `Error fetching entity: ${error}` }], isError: true, }; } }
- src/client.ts:111-132 (helper)Core helper method in WormBaseClient that implements fetching entity data from WormBase REST API by querying widgets for the given type and ID, with data cleaning.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; }