search_drugs
Find approved drugs and clinical candidates by name, development phase, or therapeutic area using the ChEMBL database.
Instructions
Search for approved drugs and clinical candidates
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Drug name or search query | |
| development_phase | No | Development phase filter (e.g., Approved, Phase III) | |
| therapeutic_area | No | Therapeutic area filter | |
| limit | No | Number of results to return (1-1000, default: 25) |
Implementation Reference
- src/index.ts:1274-1310 (handler)The main handler function that implements the logic for the 'search_drugs' tool. It performs input validation, queries the ChEMBL molecule search API, filters results for approved drugs and clinical candidates (max_phase >= 1), and returns formatted JSON results.private async handleSearchDrugs(args: any) { if (!args || typeof args.query !== 'string') { throw new McpError(ErrorCode.InvalidParams, 'Invalid drug search arguments'); } try { // Search for drugs using molecule endpoint with max_phase filter const params: any = { q: args.query, limit: args.limit || 25, }; const response = await this.apiClient.get('/molecule/search.json', { params }); const molecules = response.data.molecules || []; // Filter for drugs (molecules with max_phase >= 1) const drugs = molecules.filter((m: any) => m.max_phase && m.max_phase >= 1); return { content: [ { type: 'text', text: JSON.stringify({ query: args.query, total_results: drugs.length, drugs: drugs, }, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to search drugs: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
- src/index.ts:588-600 (schema)The input schema definition for the 'search_drugs' tool, specifying parameters like query (required), development_phase, therapeutic_area, and limit.name: 'search_drugs', description: 'Search for approved drugs and clinical candidates', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Drug name or search query' }, development_phase: { type: 'string', description: 'Development phase filter (e.g., Approved, Phase III)' }, therapeutic_area: { type: 'string', description: 'Therapeutic area filter' }, limit: { type: 'number', description: 'Number of results to return (1-1000, default: 25)', minimum: 1, maximum: 1000 }, }, required: ['query'], }, },
- src/index.ts:778-779 (registration)The registration that maps the tool name 'search_drugs' to its handler function in the CallToolRequestSchema switch statement.case 'search_drugs': return await this.handleSearchDrugs(args);