search_by_inchi
Find chemical compounds using InChI keys or strings to retrieve detailed information from the ChEMBL database.
Instructions
Search for compounds by InChI key or InChI string
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inchi | Yes | InChI key or InChI string | |
| limit | No | Number of results to return (1-1000, default: 25) |
Implementation Reference
- src/index.ts:879-907 (handler)Handler function that implements the core logic of the 'search_by_inchi' tool by querying the ChEMBL molecule search API with the provided InChI string or key.
private async handleSearchByInchi(args: any) { if (!args || typeof args.inchi !== 'string') { throw new McpError(ErrorCode.InvalidParams, 'Invalid InChI arguments'); } try { // ChEMBL supports InChI and InChI key searches const response = await this.apiClient.get('/molecule/search.json', { params: { q: args.inchi, limit: args.limit || 25, }, }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to search by InChI: ${error instanceof Error ? error.message : 'Unknown error'}` ); } } - src/index.ts:421-431 (schema)Input schema definition for the 'search_by_inchi' tool, specifying parameters 'inchi' (required string) and optional 'limit'.
name: 'search_by_inchi', description: 'Search for compounds by InChI key or InChI string', inputSchema: { type: 'object', properties: { inchi: { type: 'string', description: 'InChI key or InChI string' }, limit: { type: 'number', description: 'Number of results to return (1-1000, default: 25)', minimum: 1, maximum: 1000 }, }, required: ['inchi'], }, }, - src/index.ts:749-750 (registration)Registration/dispatch of the 'search_by_inchi' tool handler in the main tool execution switch statement.
case 'search_by_inchi': return await this.handleSearchByInchi(args);