get_chemical_by_id
Retrieve detailed chemical information from the SureChEMBL patent database using a specific chemical identifier.
Instructions
Get detailed chemical information by SureChEMBL chemical ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chemical_id | Yes | SureChEMBL chemical ID (numeric) |
Implementation Reference
- src/index.ts:725-746 (handler)The main handler function that executes the tool logic: validates the chemical_id input, fetches data from SureChEMBL API (/chemical/id/{id}), and returns the JSON response.private async handleGetChemicalById(args: any) { if (!args || typeof args.chemical_id !== 'string') { throw new McpError(ErrorCode.InvalidParams, 'Invalid chemical ID'); } try { const response = await this.apiClient.get(`/chemical/id/${args.chemical_id}`); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to get chemical: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
- src/index.ts:399-409 (schema)Tool schema definition in the ListTools response, specifying the input parameters and requirements.{ name: 'get_chemical_by_id', description: 'Get detailed chemical information by SureChEMBL chemical ID', inputSchema: { type: 'object', properties: { chemical_id: { type: 'string', description: 'SureChEMBL chemical ID (numeric)' }, }, required: ['chemical_id'], }, },
- src/index.ts:555-556 (registration)Tool dispatch registration in the CallToolRequestSchema handler switch statement, routing calls to the handler function.case 'get_chemical_by_id': return await this.handleGetChemicalById(args);