Skip to main content
Glama
biocontext-ai

BioContextAI Knowledgebase MCP

Official

bc_get_drug_statistics

Retrieve general statistics from the FDA Drugs@FDA database including top sponsors, dosage forms, routes, and marketing statuses.

Instructions

Get general statistics about the FDA Drugs@FDA database. Includes top sponsors, dosage forms, routes, marketing status.

Returns: dict: Top sponsors, dosage_forms, administration_routes, marketing_statuses with counts or error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function for 'get_drug_statistics' tool. Fetches FDA drug statistics (top sponsors, dosage forms, routes, marketing statuses) from the openFDA Drugs@FDA API. Registered via @core_mcp.tool() decorator.
    @core_mcp.tool()
    def get_drug_statistics() -> dict:
        """Get general statistics about the FDA Drugs@FDA database. Includes top sponsors, dosage forms, routes, marketing status.
    
        Returns:
            dict: Top sponsors, dosage_forms, administration_routes, marketing_statuses with counts or error message.
        """
        statistics = {}
    
        try:
            # Get top sponsors
            base_url = "https://api.fda.gov/drug/drugsfda.json"
            sponsors_response = requests.get(base_url, params={"count": "sponsor_name", "limit": 10})  # type: ignore
            sponsors_response.raise_for_status()
            statistics["top_sponsors"] = sponsors_response.json()
    
            # Get dosage forms
            dosage_response = requests.get(base_url, params={"count": "products.dosage_form", "limit": 15})  # type: ignore
            dosage_response.raise_for_status()
            statistics["dosage_forms"] = dosage_response.json()
    
            # Get routes of administration
            routes_response = requests.get(base_url, params={"count": "products.route", "limit": 15})  # type: ignore
            routes_response.raise_for_status()
            statistics["administration_routes"] = routes_response.json()
    
            # Get marketing statuses
            status_response = requests.get(base_url, params={"count": "products.marketing_status", "limit": 10})  # type: ignore
            status_response.raise_for_status()
            statistics["marketing_statuses"] = status_response.json()
    
            return statistics
    
        except requests.exceptions.RequestException as e:
            return {"error": f"Failed to fetch FDA drug statistics: {e!s}"}
  • Tool registration using the FastMCP decorator on the get_drug_statistics function. The core_mcp instance is defined in src/biocontext_kb/core/_server.py.
    @core_mcp.tool()
    def get_drug_statistics() -> dict:
  • Exports get_drug_statistics in the package's __all__ list, and imports it from _count_drugs on line 6.
        "get_drug_statistics",
        "get_generic_equivalents",
        "search_drugs_by_therapeutic_class",
        "search_drugs_fda",
    ]
  • The core_mcp FastMCP server instance used to register tools via the @core_mcp.tool() decorator.
    from fastmcp import FastMCP
    
    core_mcp = FastMCP(  # type: ignore
        "BC",
        instructions="Provides access to biomedical knowledge bases.",
    )
  • Test for the get_drug_statistics tool, verifying it returns a dict with expected keys.
    async def test_get_drug_statistics():
        """Test the get_drug_statistics function."""
        async with Client(core_mcp) as client:
            result_text = await client.call_tool("get_drug_statistics", {})
            result = json.loads(result_text.content[0].text)
    
            assert isinstance(result, dict)
            # Should have multiple statistics sections
            if "error" not in result:
                assert any(
                    key in result for key in ["top_sponsors", "dosage_forms", "administration_routes", "marketing_statuses"]
                )
Behavior2/5

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

The description mentions it returns a dict with counts or an error message, but it lacks explicit disclosure of side effects like being read-only, requiring authentication, or having rate limits. Since no annotations are provided, the description should cover these behavioral traits.

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

Conciseness5/5

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

The description is extremely concise: two sentences plus a returns line. Every word adds value, no filler.

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

Completeness4/5

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

For a simple tool with no parameters and an output schema, the description provides sufficient context on the return format. It could mention if any setup is needed, but overall it's complete enough.

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

Parameters4/5

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

There are no input parameters, so the description's listing of output fields adds clarity beyond the empty schema. This compensates well for the lack of parameter information.

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 it returns general statistics about the FDA Drugs@FDA database and lists the specific fields included (sponsors, dosage forms, routes, marketing status). This distinguishes it from sibling tools that query specific drugs or fields, making its purpose unambiguous.

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

Usage Guidelines3/5

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

The description implies use for obtaining aggregate statistics, but it does not provide explicit guidance on when to use this tool versus alternatives (e.g., bc_count_drugs_by_field). No when-not-to-use or prerequisite information is given.

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

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/biocontext-ai/knowledgebase-mcp'

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