search
Search WormBase for genes, proteins, phenotypes, strains, and other biological entities using natural language queries or specific IDs to retrieve genomics data.
Instructions
Search WormBase for genes, proteins, phenotypes, strains, and other biological entities. Supports natural language queries like 'genes involved in longevity' or specific IDs like 'WBGene00006763'.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query - can be a gene name (e.g., 'daf-2', 'unc-13'), WormBase ID (e.g., 'WBGene00006763'), or natural language description | |
| type | No | Entity type to search for. If not specified, searches all types. | |
| limit | No | Maximum number of results to return |
Implementation Reference
- src/index.ts:17-38 (registration)Registration of the 'search' MCP tool, including name, description, Zod input schema, and inline handler function.server.tool( "search", "Search WormBase for genes, proteins, phenotypes, strains, and other biological entities. Supports natural language queries like 'genes involved in longevity' or specific IDs like 'WBGene00006763'.", { query: z.string().describe("Search query - can be a gene name (e.g., 'daf-2', 'unc-13'), WormBase ID (e.g., 'WBGene00006763'), or natural language description"), type: z.enum(ENTITY_TYPES).optional().describe("Entity type to search for. If not specified, searches all types."), limit: z.number().optional().default(10).describe("Maximum number of results to return"), }, async ({ query, type, limit }) => { try { const results = await client.search(query, type, limit); return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }], }; } catch (error) { return { content: [{ type: "text", text: `Error searching WormBase: ${error}` }], isError: true, }; } } );
- src/index.ts:25-37 (handler)The MCP tool handler for 'search', which delegates to WormBaseClient.search() and formats the response as text content or error.async ({ query, type, limit }) => { try { const results = await client.search(query, type, limit); return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }], }; } catch (error) { return { content: [{ type: "text", text: `Error searching WormBase: ${error}` }], isError: true, }; } }
- src/index.ts:20-24 (schema)Zod schema defining the input parameters for the 'search' tool: query (required string), type (optional enum), limit (optional number).{ query: z.string().describe("Search query - can be a gene name (e.g., 'daf-2', 'unc-13'), WormBase ID (e.g., 'WBGene00006763'), or natural language description"), type: z.enum(ENTITY_TYPES).optional().describe("Entity type to search for. If not specified, searches all types."), limit: z.number().optional().default(10).describe("Maximum number of results to return"), },
- src/client.ts:37-55 (helper)WormBaseClient.search() method: performs HTTP search request to WormMine API, parses results, filters by type if specified, handles errors.async search( query: string, type?: EntityType, limit: number = 10 ): Promise<SearchResponse> { const url = `${this.wormmineUrl}/search?q=${encodeURIComponent(query)}&size=${limit}`; try { const response = await this.fetch<any>(url); const results = this.parseWormMineResults(response, type, limit); return { query, results, total: response.totalHits || results.length, }; } catch (error) { return { query, results: [], total: 0 }; } }
- src/types.ts:95-99 (schema)TypeScript interface defining the structure of the SearchResponse returned by the search implementation.export interface SearchResponse { query: string; results: SearchResult[]; total: number; }