calculate_descriptors
Compute molecular descriptors and physicochemical properties for chemical compounds using ChEMBL IDs or SMILES strings to analyze molecular characteristics.
Instructions
Calculate molecular descriptors and physicochemical properties
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chembl_id | No | ChEMBL compound ID | |
| smiles | No | SMILES string (alternative to ChEMBL ID) |
Implementation Reference
- src/index.ts:1502-1582 (handler)The main handler function for the 'calculate_descriptors' tool. It fetches molecule data from ChEMBL API if chembl_id is provided, extracts and organizes various molecular descriptors and physicochemical properties from the molecule_properties and molecule_structures, and returns them in a structured JSON format. For SMILES input only, it returns an error message indicating ChEMBL ID is required.private async handleCalculateDescriptors(args: any) { if (!args || (!args.chembl_id && !args.smiles)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid descriptor calculation arguments'); } try { let molecule; if (args.chembl_id) { const response = await this.apiClient.get(`/molecule/${args.chembl_id}.json`); molecule = response.data; } else { // For SMILES input, we can only provide limited info return { content: [ { type: 'text', text: JSON.stringify({ message: 'SMILES-based descriptor calculation requires ChEMBL ID', smiles: args.smiles, }, null, 2), }, ], }; } const props = molecule.molecule_properties || {}; const structures = molecule.molecule_structures || {}; const descriptors = { chembl_id: molecule.molecule_chembl_id, basic_properties: { molecular_weight: props.full_mwt || props.molecular_weight, exact_mass: props.full_mwt, molecular_formula: props.molecular_formula, }, lipophilicity: { alogp: props.alogp, logp: props.alogp, }, hydrogen_bonding: { hbd: props.hbd, hba: props.hba, }, polar_surface_area: { psa: props.psa, tpsa: props.psa, }, complexity: { rotatable_bonds: props.rtb, aromatic_rings: props.aromatic_rings, heavy_atoms: props.heavy_atoms, num_atoms: props.num_atoms, }, drug_likeness_metrics: { ro5_violations: props.num_ro5_violations, ro3_pass: props.ro3_pass, cx_logp: props.cx_logp, cx_logd: props.cx_logd, }, structures: { smiles: structures.canonical_smiles, inchi: structures.standard_inchi, inchi_key: structures.standard_inchi_key, }, }; return { content: [ { type: 'text', text: JSON.stringify(descriptors, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to calculate descriptors: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
- src/index.ts:649-658 (schema)The input schema definition for the 'calculate_descriptors' tool, registered in the ListToolsRequestSchema handler. It accepts optional chembl_id or smiles strings.name: 'calculate_descriptors', description: 'Calculate molecular descriptors and physicochemical properties', inputSchema: { type: 'object', properties: { chembl_id: { type: 'string', description: 'ChEMBL compound ID' }, smiles: { type: 'string', description: 'SMILES string (alternative to ChEMBL ID)' }, }, required: [], },
- src/index.ts:791-792 (registration)The registration of the tool handler in the CallToolRequestSchema switch statement within setupToolHandlers method.case 'predict_solubility': return await this.handlePredictSolubility(args);