search_by_inchi
Identify chemical compounds using InChI keys or strings, with customizable result limits, on the ChEMBL MCP Server for precise compound searches.
Instructions
Search for compounds by InChI key or InChI string
Input Schema
TableJSON 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)The handler function that executes the 'search_by_inchi' tool. It validates the input, queries the ChEMBL API's molecule/search endpoint using the provided InChI as the search query 'q', and returns the JSON response.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)The input schema definition for the 'search_by_inchi' tool as returned by ListToolsRequestSchema. Defines required 'inchi' string parameter 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)The switch case in the CallToolRequestSchema handler that routes calls to 'search_by_inchi' to the handleSearchByInchi method.case 'search_by_inchi': return await this.handleSearchByInchi(args);