search_drugs
Search for approved drugs and clinical candidates by name, development phase, or therapeutic area. Filter and retrieve relevant results efficiently using the ChEMBL MCP Server.
Instructions
Search for approved drugs and clinical candidates
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| development_phase | No | Development phase filter (e.g., Approved, Phase III) | |
| limit | No | Number of results to return (1-1000, default: 25) | |
| query | Yes | Drug name or search query | |
| therapeutic_area | No | Therapeutic area filter |
Implementation Reference
- src/index.ts:1274-1310 (handler)The handler function that executes the search_drugs tool: validates input, searches ChEMBL molecule API with query, filters results for drugs (max_phase >=1), and returns formatted JSON response.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:591-599 (schema)Input schema for the search_drugs tool, defining parameters like query (required), development_phase, therapeutic_area, and limit.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)Registration of the search_drugs handler in the CallToolRequestSchema switch statement, dispatching calls to the handler function.case 'search_drugs': return await this.handleSearchDrugs(args);
- src/index.ts:588-600 (registration)Tool registration in the ListToolsRequestSchema response, including name, description, and input schema.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'], }, },