search_diseases
Search for diseases by name, synonym, or description using a structured query. Retrieve results in JSON or TSV format for gene-drug-disease association research.
Instructions
Search for diseases by name, synonym, or description
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | Output format (default: json) | |
| query | Yes | Search query (disease name, synonym, description) | |
| size | No | Number of results to return (1-500, default: 25) |
Implementation Reference
- src/index.ts:373-430 (handler)The handler function that validates input arguments, executes a GraphQL query to the Open Targets API to search for diseases matching the provided query, limits the number of results, processes the response, and returns the JSON-formatted search results or an error message.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 (registration)Registers the 'search_diseases' tool in the MCP server's tool list, providing its name, description, and input schema for validation.{ 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)In the tool dispatcher switch statement, routes calls to the 'search_diseases' tool to its handler method.case 'search_diseases': return this.handleSearchDiseases(args);
- src/index.ts:27-36 (schema)Type guard function that validates the input arguments for the search_diseases tool, ensuring query is a non-empty string and optional size/format parameters are valid.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)) ); };
- src/index.ts:379-390 (helper)GraphQL query definition used by the handler to search for diseases in the Open Targets platform.const query = ` query SearchDiseases($queryString: String!) { search(queryString: $queryString, entityNames: ["disease"]) { hits { id name description entity } } } `;