Skip to main content
Glama
biocontext-ai

BioContextAI Knowledgebase MCP

Official

bc_search_drugs_by_therapeutic_class

Search for drugs based on their exact therapeutic or pharmacologic class using FDA database terms. Identify medications by class type (epc, moa, pe, or cs) with precise matching for accurate results.

Instructions

Search for drugs by their therapeutic or pharmacologic class.

IMPORTANT: Use get_available_pharmacologic_classes() first to see the exact class terms available in the FDA database. This function requires exact matches of the pharmacologic class terms as they appear in the FDA data.

Args: therapeutic_class (str): The exact therapeutic class term from FDA database. class_type (str): Type of classification - epc, moa, pe, or cs. limit (int): Maximum number of results to return.

Returns: dict: Search results for drugs in the specified therapeutic class.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
class_typeNoType of pharmacologic class: 'epc' (Established Pharmacologic Class), 'moa' (Mechanism of Action), 'pe' (Physiologic Effect), or 'cs' (Chemical Structure)epc
limitNoNumber of results to return
therapeutic_classYesExact therapeutic/pharmacologic class term from FDA database (use get_available_pharmacologic_classes first to see options)

Implementation Reference

  • The handler function for 'bc_search_drugs_by_therapeutic_class', decorated with @core_mcp.tool(). It constructs a query to the OpenFDA API using the provided therapeutic class and class_type, fetching matching drug information.
    @core_mcp.tool() def search_drugs_by_therapeutic_class( therapeutic_class: Annotated[ str, Field( description="Exact therapeutic/pharmacologic class term from FDA (use get_available_pharmacologic_classes first)" ), ], 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 results to return", ge=1, le=1000)] = 25, ) -> dict: """Search for drugs by therapeutic or pharmacologic class. Use get_available_pharmacologic_classes() first for exact terms. Returns: dict: FDA drug results array with application info, products, sponsor names 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 exact term as provided - no mapping since user should get this from get_available_pharmacologic_classes query = f'{field}:"{therapeutic_class}"' base_url = "https://api.fda.gov/drug/drugsfda.json" params: Any = {"search": query, "limit": limit} try: response = requests.get(base_url, params=params) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: return {"error": f"Failed to fetch drugs by therapeutic class: {e!s}"}
  • Definition of the core_mcp FastMCP server instance named 'BC'. Tools decorated with @core_mcp.tool() are registered here, and later imported with 'bc' prefix.
    core_mcp = FastMCP( # type: ignore "BC", instructions="Provides access to biomedical knowledge bases.", )
  • Import statement that loads the openfda module, executing the @core_mcp.tool() decorator for search_drugs_by_therapeutic_class during module initialization, thus registering the tool.
    from .openfda import *
  • Imports the core_mcp server (containing the tool) into the main mcp_app with namespace slugify('BC') = 'bc', resulting in the tool name 'bc_search_drugs_by_therapeutic_class'.
    for mcp in [core_mcp, *(await get_openapi_mcps())]: await mcp_app.import_server( mcp, slugify(mcp.name), )
  • Pydantic schema definition via Annotated and Field for the tool's input parameters: therapeutic_class (required str), class_type (str, default 'epc'), limit (int, 1-1000, default 25). Output is dict from API.
    def search_drugs_by_therapeutic_class( therapeutic_class: Annotated[ str, Field( description="Exact therapeutic/pharmacologic class term from FDA (use get_available_pharmacologic_classes first)" ), ], 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 results to return", ge=1, le=1000)] = 25, ) -> dict:

Other Tools

Related 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