search_pathways
Use this tool to identify biological pathways by querying pathway names, processes, or keywords. Specify entity type and result count for precise searches via Reactome MCP Server.
Instructions
Search for biological pathways by name, description, or keywords
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query (pathway name, process, keywords) | |
| size | No | Number of results to return (1-100, default: 20) | |
| type | No | Type of entity to search for (default: pathway) |
Implementation Reference
- src/index.ts:352-426 (handler)Main handler function for search_pathways tool. Validates input arguments, queries the Reactome Content Service search API, extracts and filters search results by type, limits the number of results, formats them into a structured JSON response with pathway details including ID, name, type, species, description, and URL.private async handleSearchPathways(args: any) { if (!isValidSearchArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid search arguments'); } try { const params: any = { query: args.query, cluster: true, }; if (args.type) { params.types = args.type; } const response = await this.apiClient.get('/search/query', { params }); // Extract entries from all result groups let allEntries: any[] = []; if (response.data.results) { for (const group of response.data.results) { if (group.entries) { allEntries = allEntries.concat(group.entries); } } } // Filter by type if specified if (args.type) { const typeFilter = args.type.toLowerCase(); allEntries = allEntries.filter((entry: any) => entry.exactType?.toLowerCase().includes(typeFilter) || entry.typeName?.toLowerCase().includes(typeFilter) ); } // Limit results if specified if (args.size) { allEntries = allEntries.slice(0, args.size); } const formattedResults = { query: args.query, totalResults: response.data.numberOfMatches || 0, returnedResults: allEntries.length, results: allEntries.map((item: any) => ({ id: item.stId || item.id, name: item.name?.replace(/<[^>]*>/g, '') || 'Unknown', // Remove HTML tags type: item.exactType || item.typeName || 'Unknown', species: Array.isArray(item.species) ? item.species[0] : item.species || 'Unknown', description: (item.summation?.substring(0, 200) || 'No description available') + '...', url: `https://reactome.org/content/detail/${item.stId || item.id}` })) }; return { content: [ { type: 'text', text: JSON.stringify(formattedResults, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error searching pathways: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/index.ts:222-234 (schema)JSON Schema defining the input parameters for the search_pathways tool: required 'query' string, optional 'type' enum for filtering entity types, optional 'size' number (1-100).inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query (pathway name, process, keywords)' }, type: { type: 'string', enum: ['pathway', 'reaction', 'protein', 'complex', 'disease'], description: 'Type of entity to search for (default: pathway)' }, size: { type: 'number', description: 'Number of results to return (1-100, default: 20)', minimum: 1, maximum: 100 }, }, required: ['query'], },
- src/index.ts:327-328 (registration)Registration of the search_pathways tool handler in the CallToolRequestSchema switch statement, dispatching to handleSearchPathways method.case 'search_pathways': return this.handleSearchPathways(args);
- src/index.ts:29-38 (helper)Helper type guard function to validate input arguments for search_pathways tool, checking query is non-empty string, type is valid enum or undefined, size is number 1-100 or undefined.const isValidSearchArgs = (args: any): args is { query: string; type?: string; size?: number } => { return ( typeof args === 'object' && args !== null && typeof args.query === 'string' && args.query.length > 0 && (args.type === undefined || ['pathway', 'reaction', 'protein', 'complex', 'disease'].includes(args.type)) && (args.size === undefined || (typeof args.size === 'number' && args.size > 0 && args.size <= 100)) ); };
- src/index.ts:219-235 (registration)Tool registration in ListToolsRequestSchema response, including name, description, and inputSchema for search_pathways.{ name: 'search_pathways', description: 'Search for biological pathways by name, description, or keywords', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query (pathway name, process, keywords)' }, type: { type: 'string', enum: ['pathway', 'reaction', 'protein', 'complex', 'disease'], description: 'Type of entity to search for (default: pathway)' }, size: { type: 'number', description: 'Number of results to return (1-100, default: 20)', minimum: 1, maximum: 100 }, }, required: ['query'], }, },