search
Search WormBase for genes, proteins, phenotypes, strains, and other biological entities using natural language queries or specific IDs.
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:25-37 (handler)MCP tool handler for the 'search' tool: calls WormBaseClient.search(), formats results as JSON text content or error response.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 input schema defining parameters for the 'search' tool: query (required string), type (optional enum), limit (optional number default 10).{ 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/index.ts:17-38 (registration)Registration of the 'search' MCP tool via server.tool(), including name, description, schema, and handler.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/client.ts:37-55 (helper)WormBaseClient.search() method: performs search via WormMine API, parses results using parseWormMineResults, returns SearchResponse.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:87-99 (schema)TypeScript interfaces for SearchResponse and SearchResult used in the search tool's output.export interface SearchResult { id: string; label: string; class: string; taxonomy?: string; description?: string; } export interface SearchResponse { query: string; results: SearchResult[]; total: number; }