Skip to main content
Glama
biocontext-ai

BioContextAI Knowledgebase MCP

Official

bc_search_drugs_by_therapeutic_class

Search FDA-approved drugs by therapeutic or pharmacologic class to identify medications for specific treatment approaches. Retrieve drug details including application information, products, and sponsor names.

Instructions

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.

Input Schema

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main handler function for the tool, decorated as @core_mcp.tool(). Queries OpenFDA API using the specified therapeutic class and class_type (default 'epc'). Includes input schema via Annotated Fields.
    @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}"}
  • Main registration point where core_mcp (containing the tool) is imported into the top-level mcp_app with prefix 'bc' (from slugify('BC')), exposing the tool as 'bc_search_drugs_by_therapeutic_class'.
    for mcp in [core_mcp, *(await get_openapi_mcps())]:
        await mcp_app.import_server(
            mcp,
            slugify(mcp.name),
        )
    logger.info("MCP server setup complete.")
  • Definition of the core_mcp FastMCP instance named 'BC', on which the tool is registered via @core_mcp.tool() decorator.
    core_mcp = FastMCP(  # type: ignore
        "BC",
        instructions="Provides access to biomedical knowledge bases.",
    )
  • Supporting helper tool to retrieve available therapeutic/pharmacologic classes from OpenFDA, recommended to call first for exact terms.
    @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}"}
  • Pydantic schema definitions for tool inputs via Annotated and Field.
    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}"}
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the return format ('FDA drug results array with application info, products, sponsor names or error message'), which is helpful. However, it doesn't disclose important behavioral aspects like rate limits, authentication requirements, or whether this is a read-only operation versus a mutation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly front-loaded with the core purpose in the first sentence, followed by usage guidance and return format. Every sentence earns its place - the first states what the tool does, the second provides critical usage guidance, and the third clarifies the return format.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the presence of an output schema (which handles return values) and 100% schema coverage for parameters, the description provides adequate context. It covers the core purpose, usage guidance, and return format overview. The main gap is the lack of behavioral transparency around rate limits and authentication, but with structured fields covering parameters and outputs, this is reasonably complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the schema already documents all three parameters thoroughly. The description adds minimal value beyond what's in the schema - it mentions the need for 'exact terms' which reinforces the schema's guidance but doesn't provide additional semantic context about parameter interactions or edge cases.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Search for drugs') and resource ('by therapeutic or pharmacologic class'), with the FDA context providing additional specificity. It distinguishes itself from sibling tools like 'bc_search_drugs_fda' by focusing specifically on class-based searching rather than general FDA drug searches.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance to 'use get_available_pharmacologic_classes() first for exact terms,' which directly addresses when to use this tool versus alternatives. This creates a clear workflow dependency and helps the agent understand the proper sequence of operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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