Skip to main content
Glama

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
NameRequiredDescriptionDefault
drug_id_or_nameYesDrug name (e.g., 'aspirin', 'imatinib') or ID (e.g., 'DB00945', 'CHEMBL941')

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core MCP tool handler function _drug_details that executes the drug retrieval logic
    async 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)
  • Primary get_drug function that fetches data from MyChem.info API, formats output, and handles errors
    async 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
  • 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 Field
    drug_id_or_name: Annotated[
        str,
        Field(
            description="Drug name (e.g., 'aspirin', 'imatinib') or ID (e.g., 'DB00945', 'CHEMBL941')"
        ),
    ],
  • Helper function to format drug information into markdown text output with sections and links
    def _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)
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behavioral traits: it specifies the data source ('MyChem.info, part of the BioThings suite'), emphasizes that information is current ('fetches CURRENT drug information'), and mentions the scope of data ('comprehensive drug information'). However, it lacks details on rate limits, error handling, or authentication needs, which would be beneficial for full transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and appropriately sized, with clear sections (prerequisite, bullet points of information, source details, examples, and exclusions). Most sentences earn their place by adding value, though the bulleted list could be slightly condensed. It is front-loaded with the core purpose and prerequisite, making it efficient for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (retrieving detailed drug data), the description is complete enough: it covers purpose, usage guidelines, behavioral context (source and currency), and exclusions. With an output schema present, it does not need to explain return values. The combination of description and structured fields (schema, output schema) provides sufficient context for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, clearly documenting the single parameter 'drug_id_or_name'. The description adds minimal semantic value beyond the schema, as it only implies usage through examples (e.g., 'imatinib', 'DB00619') without explaining parameter constraints or formats further. Given the high schema coverage, a baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('Get detailed drug/chemical information') and resources ('from MyChem.info'), distinguishing it from siblings like trial_searcher and article_searcher. It explicitly lists the types of information retrieved, making the purpose highly specific and differentiated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit usage guidelines: it includes a prerequisite ('Use the 'think' tool FIRST'), gives clear examples of when to use it (e.g., 'Get information about imatinib'), and specifies when not to use it by naming alternatives ('For clinical trials about drugs, use trial_searcher. For articles about drugs, use article_searcher'). This covers when, when-not, and alternatives comprehensively.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/genomoncology/biomcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server