compound_lookup
Retrieve chemical compound properties from PubChem and ChEMBL including molecular weight, SMILES, LogP, and drug-likeness assessment. Optionally fetch bioactivity and clinical trial phase data.
Instructions
Look up chemical compound properties from PubChem and ChEMBL. Returns molecular weight, SMILES, LogP, TPSA, H-bond donors/acceptors, Lipinski rule-of-5 drug-likeness assessment, synonyms, and optionally bioactivity and clinical trial phase data.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| identifier | Yes | Compound identifier: name, CID, SMILES, InChI, or CAS number | |
| id_type | No | Type of identifier provided (default: name) | name |
| include_bioactivity | No | Include bioactivity data from ChEMBL (slower, default: false) | |
| properties | No | Specific properties to return (default: all) |
Implementation Reference
- tools/compound_lookup.py:237-265 (handler)The main handler function compound_lookup_handler that executes the compound lookup logic. Accepts identifier, id_type, include_bioactivity, and optionally properties. Calls _lookup_pubchem and optionally _lookup_chembl, returning combined results.
async def compound_lookup_handler(arguments: dict) -> dict: identifier = arguments.get("identifier", "") id_type = arguments.get("id_type", "name") include_bioactivity = arguments.get("include_bioactivity", False) if not identifier: return {"error": "identifier parameter is required"} async with aiohttp.ClientSession() as session: pubchem_result = await _lookup_pubchem(session, identifier, id_type) chembl_result = {} if include_bioactivity and "error" not in pubchem_result: chembl_result = await _lookup_chembl( session, inchikey=pubchem_result.get("inchikey"), compound_name=identifier if id_type == "name" else None, ) result = { "identifier": identifier, "id_type": id_type, "fetched_at": datetime.now(timezone.utc).isoformat(), "pubchem": pubchem_result, } if chembl_result: result["chembl"] = chembl_result return result - tools/compound_lookup.py:42-67 (schema)Input schema (TOOL_SCHEMA) defining the compound_lookup tool parameters: identifier (string, required), id_type (enum: name/cid/smiles/inchi/cas), include_bioactivity (boolean), properties (array of strings).
TOOL_SCHEMA = { "type": "object", "properties": { "identifier": { "type": "string", "description": "Compound identifier: name, CID, SMILES, InChI, or CAS number", }, "id_type": { "type": "string", "enum": ["name", "cid", "smiles", "inchi", "cas"], "description": "Type of identifier provided (default: name)", "default": "name", }, "include_bioactivity": { "type": "boolean", "description": "Include bioactivity data from ChEMBL (slower, default: false)", "default": False, }, "properties": { "type": "array", "items": {"type": "string"}, "description": "Specific properties to return (default: all)", }, }, "required": ["identifier"], } - tools/compound_lookup.py:272-287 (registration)The register() function that registers compound_lookup with the tool registry, including name, description, input_schema, price, stripe_price_id, handler, and category.
def register(registry) -> None: from server import ToolDefinition registry.register(ToolDefinition( name=TOOL_NAME, description=( "Look up chemical compound properties from PubChem and ChEMBL. " "Returns molecular weight, SMILES, LogP, TPSA, H-bond donors/acceptors, " "Lipinski rule-of-5 drug-likeness assessment, synonyms, and optionally " "bioactivity and clinical trial phase data." ), input_schema=TOOL_SCHEMA, price_per_call_usd=TOOL_PRICE_USD, stripe_price_id=TOOL_STRIPE_PRICE, handler=compound_lookup_handler, category="chemistry", )) - tools/compound_lookup.py:237-265 (handler)Main handler function for compound_lookup tool.
async def compound_lookup_handler(arguments: dict) -> dict: identifier = arguments.get("identifier", "") id_type = arguments.get("id_type", "name") include_bioactivity = arguments.get("include_bioactivity", False) if not identifier: return {"error": "identifier parameter is required"} async with aiohttp.ClientSession() as session: pubchem_result = await _lookup_pubchem(session, identifier, id_type) chembl_result = {} if include_bioactivity and "error" not in pubchem_result: chembl_result = await _lookup_chembl( session, inchikey=pubchem_result.get("inchikey"), compound_name=identifier if id_type == "name" else None, ) result = { "identifier": identifier, "id_type": id_type, "fetched_at": datetime.now(timezone.utc).isoformat(), "pubchem": pubchem_result, } if chembl_result: result["chembl"] = chembl_result return result