bc_get_drug_statistics
Retrieve FDA drug database statistics including top sponsors, dosage forms, administration routes, and marketing statuses to analyze pharmaceutical data trends.
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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- Handler function for the tool logic, decorated with @core_mcp.tool(). Fetches and aggregates drug statistics from the FDA Drugs@FDA API including top sponsors, dosage forms, administration routes, and 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/app.py:34-38 (registration)Registers the core_mcp server (containing the get_drug_statistics tool) into the main BioContextAI MCP application with the prefix 'bc' (from slugify('BC')), making the tool available as 'bc_get_drug_statistics'.logger.info("Setting up MCP server...") for mcp in [core_mcp, *(await get_openapi_mcps())]: await mcp_app.import_server( mcp, slugify(mcp.name),
- src/biocontext_kb/core/__init__.py:13-13 (registration)Imports the openfda module, triggering the registration of get_drug_statistics on core_mcp via its @core_mcp.tool() decorator when the module is loaded.from .openfda import *
- src/biocontext_kb/core/openfda/__init__.py:6-6 (registration)Exposes the get_drug_statistics handler function for import, facilitating its registration.from ._count_drugs import count_drugs_by_field, get_drug_statistics