get_interactions
Retrieve protein-protein, genetic, or regulatory interactions for C. elegans genes and proteins from the WormBase database to analyze biological relationships.
Instructions
Get protein-protein, genetic, or regulatory interactions for a gene or protein.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Gene or protein identifier | |
| interaction_type | No | Type of interactions to retrieve | all |
Implementation Reference
- src/index.ts:179-199 (registration)Registration of the 'get_interactions' MCP tool, including name, description, input schema, and inline handler function that delegates to WormBaseClient.server.tool( "get_interactions", "Get protein-protein, genetic, or regulatory interactions for a gene or protein.", { id: z.string().describe("Gene or protein identifier"), interaction_type: z.enum(["genetic", "physical", "regulatory", "all"]).optional().default("all").describe("Type of interactions to retrieve"), }, async ({ id, interaction_type }) => { try { const data = await client.getInteractions(id, interaction_type); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } catch (error) { return { content: [{ type: "text", text: `Error fetching interactions: ${error}` }], isError: true, }; } } );
- src/index.ts:182-185 (schema)Zod input schema for the tool parameters: id (required string) and optional interaction_type (enum).{ id: z.string().describe("Gene or protein identifier"), interaction_type: z.enum(["genetic", "physical", "regulatory", "all"]).optional().default("all").describe("Type of interactions to retrieve"), },
- src/index.ts:186-198 (handler)The MCP tool handler function: calls client.getInteractions, returns JSON-formatted content or error response.async ({ id, interaction_type }) => { try { const data = await client.getInteractions(id, interaction_type); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } catch (error) { return { content: [{ type: "text", text: `Error fetching interactions: ${error}` }], isError: true, }; } }
- src/client.ts:137-164 (helper)Core helper method in WormBaseClient that fetches interactions from WormBase REST API, cleans the data using cleanWidgetData, and filters by interaction type if specified.async getInteractions( id: string, interactionType: string = "all" ): Promise<InteractionData> { const url = `${this.baseUrl}/rest/widget/gene/${encodeURIComponent(id)}/interactions`; const data = await this.fetch<any>(url); const interactions = this.cleanWidgetData(data); if (interactionType === "all") { return interactions as InteractionData; } // Filter by interaction type const filtered: Record<string, unknown> = {}; const interactionsObj = interactions as Record<string, unknown>; if (interactionType === "physical" && interactionsObj.physical) { filtered.physical = interactionsObj.physical; } if (interactionType === "genetic" && interactionsObj.genetic) { filtered.genetic = interactionsObj.genetic; } if (interactionType === "regulatory" && interactionsObj.regulatory) { filtered.regulatory = interactionsObj.regulatory; } return filtered as InteractionData; }
- src/types.ts:152-164 (schema)TypeScript interfaces defining Interaction and InteractionData (output structure with optional arrays for physical, genetic, regulatory interactions).export interface Interaction { interactor: EntityData; type: string; direction?: string; phenotype?: EntityData; citations?: EntityData[]; } export interface InteractionData { physical?: Interaction[]; genetic?: Interaction[]; regulatory?: Interaction[]; }