get_chemical_by_id
Retrieve detailed chemical information from the SureChEMBL database by entering a specific SureChEMBL chemical ID. Useful for accessing patent-related chemical data efficiently.
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 execution logic for the 'get_chemical_by_id' tool. Validates the chemical_id input, fetches data from the SureChEMBL API endpoint `/chemical/id/{chemical_id}`, formats the response as JSON text content, and handles errors.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 (registration)Registers the 'get_chemical_by_id' tool in the MCP server's list of available tools, including its description and input schema definition.{ 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)Switch case in the CallToolRequestSchema handler that routes calls to the specific tool handler method.case 'get_chemical_by_id': return await this.handleGetChemicalById(args);
- src/index.ts:402-408 (schema)Input schema definition specifying that the tool requires a 'chemical_id' string parameter.inputSchema: { type: 'object', properties: { chemical_id: { type: 'string', description: 'SureChEMBL chemical ID (numeric)' }, }, required: ['chemical_id'], },