bc_get_available_pharmacologic_classes
Retrieve pharmacologic class options from the FDA database to identify available categories for drug searches. Specify class type (e.g., EPC, MOA, PE, CS) and limit results for streamlined research.
Instructions
Get available pharmacologic classes from the FDA database.
This function retrieves the actual pharmacologic class values available in the FDA database, which can then be used with search_drugs_by_therapeutic_class. Always call this function first to see available options before searching.
Args: class_type (str): Type of classification - epc, moa, pe, or cs. limit (int): Maximum number of unique classes to return.
Returns: dict: Available pharmacologic class values in the FDA database.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| class_type | No | Type of pharmacologic class: 'epc' (Established Pharmacologic Class), 'moa' (Mechanism of Action), 'pe' (Physiologic Effect), or 'cs' (Chemical Structure) | epc |
| limit | No | Number of unique classes to return |
Implementation Reference
- The handler function get_available_pharmacologic_classes decorated with @core_mcp.tool(), implementing the logic to query OpenFDA API for available pharmacologic classes based on class_type (epc, moa, pe, cs). Returns list of classes with counts or error. Tool name becomes 'bc_get_available_pharmacologic_classes' after prefixing.@core_mcp.tool() def get_available_pharmacologic_classes( class_type: Annotated[ str, Field( description="Class type: 'epc' (Established Pharmacologic Class), 'moa' (Mechanism of Action), 'pe' (Physiologic Effect), or 'cs' (Chemical Structure)" ), ] = "epc", limit: Annotated[int, Field(description="Number of unique classes to return", ge=1, le=1000)] = 100, ) -> dict: """Get available pharmacologic classes from FDA database. Call this first to see available options. Returns: dict: Class type, field, available_classes array with term/count, total_found or error message. """ # Map class type to the appropriate OpenFDA field class_field_mapping = { "epc": "openfda.pharm_class_epc", # Established Pharmacologic Class "moa": "openfda.pharm_class_moa", # Mechanism of Action "pe": "openfda.pharm_class_pe", # Physiologic Effect "cs": "openfda.pharm_class_cs", # Chemical Structure } if class_type.lower() not in class_field_mapping: return {"error": "class_type must be one of: epc, moa, pe, cs"} field = class_field_mapping[class_type.lower()] # Use the count endpoint to get unique values base_url = "https://api.fda.gov/drug/drugsfda.json" params: Any = {"count": field, "limit": limit} try: response = requests.get(base_url, params=params) response.raise_for_status() data = response.json() return { "class_type": class_type, "field": field, "available_classes": data.get("results", []), "total_found": len(data.get("results", [])), } except requests.exceptions.RequestException as e: return {"error": f"Failed to fetch available pharmacologic classes: {e!s}"}
- src/biocontext_kb/app.py:35-39 (registration)Main application imports core_mcp server (named 'BC') with slugified prefix 'bc', adding 'bc_' prefix to all tools including 'get_available_pharmacologic_classes' making it 'bc_get_available_pharmacologic_classes'.for mcp in [core_mcp, *(await get_openapi_mcps())]: await mcp_app.import_server( mcp, slugify(mcp.name), )
- src/biocontext_kb/core/openfda/__init__.py:1-2 (registration)Package __init__.py imports the handler function, triggering the @core_mcp.tool() registration upon module load.from ._advanced_search import ( get_available_pharmacologic_classes,
- src/biocontext_kb/core/_server.py:3-6 (registration)Creates the core_mcp FastMCP server instance named 'BC', which is the namespace used for biocontext core tools.core_mcp = FastMCP( # type: ignore "BC", instructions="Provides access to biomedical knowledge bases.", )