Skip to main content
Glama
biocontext-ai

BioContextAI Knowledgebase MCP

Official

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
NameRequiredDescriptionDefault

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}"}
  • 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),
  • 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 *
  • Exposes the get_drug_statistics handler function for import, facilitating its registration.
    from ._count_drugs import count_drugs_by_field, get_drug_statistics

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