drug_getter
Retrieve detailed drug and chemical information from MyChem.info, including properties, identifiers, trade names, clinical indications, mechanism of action, and pharmacology details. Use this tool for accurate drug data after clarifying research goals with the 'think' tool.
Instructions
Get detailed drug/chemical information from MyChem.info.
⚠️ PREREQUISITE: Use the 'think' tool FIRST to understand your research goal!
This tool provides comprehensive drug information including:
- Chemical properties (formula, InChIKey)
- Drug identifiers (DrugBank, ChEMBL, PubChem)
- Trade names and brand names
- Clinical indications
- Mechanism of action
- Pharmacology details
- Links to drug databases
This tool fetches CURRENT drug information from MyChem.info, part of the
BioThings suite, ensuring you always have the latest drug data.
Example usage:
- Get information about imatinib (Gleevec)
- Look up details for DrugBank ID DB00619
- Find the mechanism of action for pembrolizumab
Note: For clinical trials about drugs, use trial_searcher. For articles about drugs, use article_searcher.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| drug_id_or_name | Yes | Drug name (e.g., 'aspirin', 'imatinib') or ID (e.g., 'DB00945', 'CHEMBL941') |
Implementation Reference
- src/biomcp/drugs/getter.py:145-162 (handler)Core MCP tool handler function _drug_details that executes the drug retrieval logicasync def _drug_details(drug_id_or_name: str) -> str: """Get drug/chemical information from MyChem.info. This tool retrieves comprehensive drug information including: - Drug identifiers (DrugBank, ChEMBL, PubChem, etc.) - Chemical properties (formula, InChIKey) - Trade names and synonyms - Clinical indications - Mechanism of action - Links to external databases Args: drug_id_or_name: Drug name (e.g., "aspirin") or ID (e.g., "DB00945", "CHEMBL25") Returns: Formatted drug information with external database links """ return await get_drug(drug_id_or_name, output_json=False)
- src/biomcp/drugs/getter.py:103-142 (handler)Primary get_drug function that fetches data from MyChem.info API, formats output, and handles errorsasync def get_drug(drug_id_or_name: str, output_json: bool = False) -> str: """Get drug information from MyChem.info. Args: drug_id_or_name: Drug ID (DrugBank, ChEMBL, etc.) or name output_json: Return JSON instead of formatted text Returns: Formatted drug information or JSON string """ try: client = BioThingsClient() drug_info = await client.get_drug_info(drug_id_or_name) if not drug_info: error_msg = f"Drug '{drug_id_or_name}' not found in MyChem.info" if output_json: return json.dumps({"error": error_msg}, indent=2) return error_msg # Build result dictionary result = drug_info.model_dump(by_alias=False, exclude_none=True) # Add external links _add_drug_links(drug_info, result) if output_json: return json.dumps(result, indent=2) # Format for text output _format_drug_output(drug_info, result) return result["_formatted"] except Exception as e: logger.error(f"Error getting drug info: {e}") error_msg = f"Error retrieving drug information: {e!s}" if output_json: return json.dumps({"error": error_msg}, indent=2) return error_msg
- src/biomcp/individual_tools.py:793-827 (registration)MCP tool registration for 'drug_getter' including input schema definition and docstring; wraps internal _drug_details handler@mcp_app.tool() @track_performance("biomcp.drug_getter") async def drug_getter( drug_id_or_name: Annotated[ str, Field( description="Drug name (e.g., 'aspirin', 'imatinib') or ID (e.g., 'DB00945', 'CHEMBL941')" ), ], ) -> str: """Get detailed drug/chemical information from MyChem.info. ⚠️ PREREQUISITE: Use the 'think' tool FIRST to understand your research goal! This tool provides comprehensive drug information including: - Chemical properties (formula, InChIKey) - Drug identifiers (DrugBank, ChEMBL, PubChem) - Trade names and brand names - Clinical indications - Mechanism of action - Pharmacology details - Links to drug databases This tool fetches CURRENT drug information from MyChem.info, part of the BioThings suite, ensuring you always have the latest drug data. Example usage: - Get information about imatinib (Gleevec) - Look up details for DrugBank ID DB00619 - Find the mechanism of action for pembrolizumab Note: For clinical trials about drugs, use trial_searcher. For articles about drugs, use article_searcher. """ return await _drug_details(drug_id_or_name)
- Pydantic input schema definition for drug_getter tool parameter using Annotated and Fielddrug_id_or_name: Annotated[ str, Field( description="Drug name (e.g., 'aspirin', 'imatinib') or ID (e.g., 'DB00945', 'CHEMBL941')" ), ],
- src/biomcp/drugs/getter.py:88-101 (helper)Helper function to format drug information into markdown text output with sections and linksdef _format_drug_output(drug_info, result: dict) -> None: """Format drug information for text output.""" output_lines = [f"## Drug: {drug_info.name or 'Unknown'}"] _format_basic_info(drug_info, output_lines) _format_clinical_info(drug_info, output_lines) if result.get("_links"): output_lines.append("\n### External Links") for name, url in result["_links"].items(): output_lines.append(f"- [{name}]({url})") result["_formatted"] = "\n".join(output_lines)