openfda_label_searcher
Search FDA drug product labels (SPL) for prescribing information. Find approved indications, dosage guidelines, contraindications, warnings, drug interactions, adverse reactions, and special population considerations. Plan research strategy using the 'think' tool first.
Instructions
Search FDA drug product labels (SPL) for prescribing information.
⚠️ PREREQUISITE: Use the 'think' tool FIRST to plan your research strategy!
Searches official FDA drug labels for:
- Approved indications and usage
- Dosage and administration guidelines
- Contraindications and warnings
- Drug interactions and adverse reactions
- Special population considerations
Label sections include: indications, dosage, contraindications, warnings,
adverse, interactions, pregnancy, pediatric, geriatric, overdose
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api_key | No | Optional OpenFDA API key (overrides OPENFDA_API_KEY env var) | |
| boxed_warning | No | Filter for drugs with boxed warnings | |
| indication | No | Search for drugs indicated for this condition | |
| limit | No | Maximum number of results | |
| name | No | Drug name to search for | |
| page | No | Page number (1-based) | |
| section | No | Specific label section (e.g., 'contraindications', 'warnings') |
Implementation Reference
- src/biomcp/individual_tools.py:1357-1418 (handler)MCP tool handler for 'openfda_label_searcher'. Registers the tool with @mcp_app.tool(), defines input schema with Pydantic Annotated Fields, and delegates to the core search_drug_labels helper function.@track_performance("biomcp.openfda_label_searcher") async def openfda_label_searcher( name: Annotated[ str | None, Field(description="Drug name to search for"), ] = None, indication: Annotated[ str | None, Field(description="Search for drugs indicated for this condition"), ] = None, boxed_warning: Annotated[ bool, Field(description="Filter for drugs with boxed warnings"), ] = False, section: Annotated[ str | None, Field( description="Specific label section (e.g., 'contraindications', 'warnings')" ), ] = None, limit: Annotated[ int, Field(description="Maximum number of results", ge=1, le=100), ] = 25, page: Annotated[ int, Field(description="Page number (1-based)", ge=1), ] = 1, api_key: Annotated[ str | None, Field( description="Optional OpenFDA API key (overrides OPENFDA_API_KEY env var)" ), ] = None, ) -> str: """Search FDA drug product labels (SPL) for prescribing information. ⚠️ PREREQUISITE: Use the 'think' tool FIRST to plan your research strategy! Searches official FDA drug labels for: - Approved indications and usage - Dosage and administration guidelines - Contraindications and warnings - Drug interactions and adverse reactions - Special population considerations Label sections include: indications, dosage, contraindications, warnings, adverse, interactions, pregnancy, pediatric, geriatric, overdose """ from biomcp.openfda import search_drug_labels skip = (page - 1) * limit return await search_drug_labels( name=name, indication=indication, boxed_warning=boxed_warning, section=section, limit=limit, skip=skip, api_key=api_key, )
- Core helper function search_drug_labels that constructs OpenFDA API query parameters, makes HTTP request to drug labels endpoint, processes response, and formats results for display.async def search_drug_labels( name: str | None = None, indication: str | None = None, boxed_warning: bool = False, section: str | None = None, limit: int = OPENFDA_DEFAULT_LIMIT, skip: int = 0, api_key: str | None = None, ) -> str: """ Search FDA drug product labels (SPL). Args: name: Drug name to search for indication: Search for drugs indicated for this condition boxed_warning: Filter for drugs with boxed warnings section: Specific label section to search limit: Maximum number of results skip: Number of results to skip api_key: Optional OpenFDA API key (overrides OPENFDA_API_KEY env var) Returns: Formatted string with drug label information """ if not name and not indication and not section and not boxed_warning: return ( "⚠️ Please specify a drug name, indication, or label section to search.\n\n" "Examples:\n" "- Search by name: --name 'pembrolizumab'\n" "- Search by indication: --indication 'melanoma'\n" "- Search by section: --section 'contraindications'" ) # Build and execute search search_query = build_label_search_query( name, indication, boxed_warning, section ) params = { "search": search_query, "limit": min(limit, OPENFDA_MAX_LIMIT), "skip": skip, } response, error = await make_openfda_request( OPENFDA_DRUG_LABELS_URL, params, "openfda_drug_labels", api_key ) if error: return f"⚠️ Error searching drug labels: {error}" if not response or not response.get("results"): return _format_no_results(name, indication, section) results = response["results"] total = ( response.get("meta", {}).get("results", {}).get("total", len(results)) ) # Build output output = ["## FDA Drug Labels\n"] output.extend(_format_search_summary(name, indication, section, total)) # Display results output.append( f"### Results (showing {min(len(results), 5)} of {total}):\n" ) for i, result in enumerate(results[:5], 1): output.extend(format_label_summary(result, i)) # Add tip for getting full labels if total > 0 and results and "set_id" in results[0]: output.append( "\n💡 **Tip**: Use `biomcp openfda label-get <label_id>` to retrieve " "the complete label for any drug." ) output.append(f"\n{OPENFDA_DISCLAIMER}") return "\n".join(output)
- src/biomcp/individual_tools.py:1357-1418 (registration)Tool registration via @mcp_app.tool() decorator in individual_tools.py, which registers openfda_label_searcher with the MCP server.@track_performance("biomcp.openfda_label_searcher") async def openfda_label_searcher( name: Annotated[ str | None, Field(description="Drug name to search for"), ] = None, indication: Annotated[ str | None, Field(description="Search for drugs indicated for this condition"), ] = None, boxed_warning: Annotated[ bool, Field(description="Filter for drugs with boxed warnings"), ] = False, section: Annotated[ str | None, Field( description="Specific label section (e.g., 'contraindications', 'warnings')" ), ] = None, limit: Annotated[ int, Field(description="Maximum number of results", ge=1, le=100), ] = 25, page: Annotated[ int, Field(description="Page number (1-based)", ge=1), ] = 1, api_key: Annotated[ str | None, Field( description="Optional OpenFDA API key (overrides OPENFDA_API_KEY env var)" ), ] = None, ) -> str: """Search FDA drug product labels (SPL) for prescribing information. ⚠️ PREREQUISITE: Use the 'think' tool FIRST to plan your research strategy! Searches official FDA drug labels for: - Approved indications and usage - Dosage and administration guidelines - Contraindications and warnings - Drug interactions and adverse reactions - Special population considerations Label sections include: indications, dosage, contraindications, warnings, adverse, interactions, pregnancy, pediatric, geriatric, overdose """ from biomcp.openfda import search_drug_labels skip = (page - 1) * limit return await search_drug_labels( name=name, indication=indication, boxed_warning=boxed_warning, section=section, limit=limit, skip=skip, api_key=api_key, )
- Input schema defined via Pydantic Annotated and Field descriptions in the handler function parameters.name: Annotated[ str | None, Field(description="Drug name to search for"), ] = None, indication: Annotated[ str | None, Field(description="Search for drugs indicated for this condition"), ] = None, boxed_warning: Annotated[ bool, Field(description="Filter for drugs with boxed warnings"), ] = False, section: Annotated[ str | None, Field( description="Specific label section (e.g., 'contraindications', 'warnings')" ), ] = None, limit: Annotated[ int, Field(description="Maximum number of results", ge=1, le=100), ] = 25, page: Annotated[ int, Field(description="Page number (1-based)", ge=1), ] = 1, api_key: Annotated[ str | None, Field( description="Optional OpenFDA API key (overrides OPENFDA_API_KEY env var)" ), ] = None, ) -> str: