Skip to main content
Glama

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
NameRequiredDescriptionDefault
queryYesSearch query (disease name, synonym, description)
sizeNoNumber of results to return (1-500, default: 25)
formatNoOutput format (default: json)

Implementation Reference

  • 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, }; } }
  • 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);
  • 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)) ); };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Augmented-Nature/OpenTargets-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server