bc_get_drug_statistics
Retrieve FDA Drugs@FDA database statistics, including top pharmaceutical sponsors, common dosage forms, routes of administration, and marketing status distribution, for comprehensive drug data insights.
Instructions
Get general statistics about the FDA Drugs@FDA database.
This function provides an overview of the database including:
Top pharmaceutical sponsors by number of approved drugs
Most common dosage forms
Most common routes of administration
Distribution of marketing statuses
Returns: dict: Statistical overview of the FDA drugs database.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The core handler function for the 'get_drug_statistics' tool (likely 'bc_get_drug_statistics' under BC namespace), decorated with @core_mcp.tool(). It aggregates statistics from multiple FDA API calls: top 10 sponsors, top 15 dosage forms and routes, top 10 marketing statuses.@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}"}
- src/biocontext_kb/core/_server.py:1-7 (registration)Definition of core_mcp = FastMCP("BC", ...), the MCP server instance named 'BC' used by @core_mcp.tool() decorators to register all tools including get_drug_statistics (potentially prefixed as bc_get_drug_statistics).from fastmcp import FastMCP core_mcp = FastMCP( # type: ignore "BC", instructions="Provides access to biomedical knowledge bases.", )
- src/biocontext_kb/core/openfda/__init__.py:6-6 (registration)Import of the get_drug_statistics handler function into the openfda module, making it available for use and registration via the decorator.from ._count_drugs import count_drugs_by_field, get_drug_statistics