search_diseases
Search for diseases by name, synonym, or description to find relevant medical conditions in the OpenTargets platform for research purposes.
Instructions
Search for diseases by name, synonym, or description
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query (disease name, synonym, description) | |
| size | No | Number of results to return (1-500, default: 25) | |
| format | No | Output format (default: json) |
Implementation Reference
- src/index.ts:373-431 (handler)The main handler function for the search_diseases tool. Validates input arguments, executes a GraphQL query against Open Targets API to search for diseases, limits the results, formats the response as JSON, and handles errors.private async handleSearchDiseases(args: any) { if (!isValidDiseaseSearchArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid disease search arguments'); } try { const query = ` query SearchDiseases($queryString: String!) { search(queryString: $queryString, entityNames: ["disease"]) { hits { id name description entity } } } `; const response = await this.graphqlClient.post('', { query, variables: { queryString: args.query } }); // Limit results on client side const hits = response.data.data?.search?.hits || []; const limitedHits = hits.slice(0, args.size || 25); const result = { ...response.data, data: { search: { hits: limitedHits, total: hits.length } } }; return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error searching diseases: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/index.ts:223-235 (schema)The input schema and metadata (name, description) for the search_diseases tool, registered in the ListTools response.{ name: 'search_diseases', description: 'Search for diseases by name, synonym, or description', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query (disease name, synonym, description)' }, size: { type: 'number', description: 'Number of results to return (1-500, default: 25)', minimum: 1, maximum: 500 }, format: { type: 'string', enum: ['json', 'tsv'], description: 'Output format (default: json)' }, }, required: ['query'], }, },
- src/index.ts:294-295 (registration)The switch case in the CallToolRequestHandler that registers and dispatches search_diseases tool calls to the handler function.case 'search_diseases': return this.handleSearchDiseases(args);
- src/index.ts:27-36 (helper)Type guard and validation function specifically for validating the input arguments of the search_diseases tool.const isValidDiseaseSearchArgs = (args: any): args is { query: string; size?: number; format?: string } => { return ( typeof args === 'object' && args !== null && typeof args.query === 'string' && args.query.length > 0 && (args.size === undefined || (typeof args.size === 'number' && args.size > 0 && args.size <= 500)) && (args.format === undefined || ['json', 'tsv'].includes(args.format)) ); };