Skip to main content
Glama

Pharmacy MCP Gateway

Python 3.11+ MCP License Documentation

An MCP server and agent harness that makes pharmaceutical knowledge available through one traceable query contract. It combines public drug APIs, Taiwan TFDA/NHI data, hospital FHIR and inventory, organization databases, vector search, files, fixed web documents, and a trusted PK/DDI simulation catalog.

繁體中文 · Documentation · Architecture

Version 1.0 prerelease. Reference data only; not medical advice or a replacement for a pharmacist, physician, or validated clinical decision-support system.

Why this gateway

  • One agent entry point: query_pharmacy routes by capability or explicit source and isolates provider timeouts and failures.

  • Stable output: every MCP tool returns QueryResponse v1.0 through a shared JSON Schema. Text is a deterministic json, json_compact, or markdown rendering; MCP structuredContent remains authoritative.

  • Agent constraint: every tool carries forwarding rules and clients can load the pharmacy-query-contract MCP prompt.

  • Traceable compound results: provider payloads, provenance, warnings, and errors remain distinct. Successful data survives as partial if another source fails.

  • Hospital-ready boundaries: FHIR is read-only; file, SQL, vector, and web connectors are configured by operators instead of accepting arbitrary agent paths, SQL, endpoints, or URLs.

  • Drift detection: a scheduled health workflow probes 18 official API and dataset surfaces every week without downloading the large Taiwan datasets.

  • Deployable FastMCP: use stdio locally or mount the same tool catalog over SSE/Streamable HTTP; service creation and the ASGI export remain lazy.

  • Auditable simulation: trusted formulas include units, assumptions, limitations, provenance, fixtures, and fail-closed numerical validation.

Related MCP server: Taiwan Health MCP Server

Quick start

Requires Python 3.11+ and uv.

git clone https://github.com/u9401066/pharmacy-mcp.git
cd pharmacy-mcp
uv sync --all-extras
uv run pharmacy-mcp

Streamable HTTP and ASGI deployments use the same tools and output contract:

uv run pharmacy-mcp --transport streamable-http --host 127.0.0.1 --port 8000
uvicorn pharmacy_mcp.presentation.server:app --host 127.0.0.1 --port 8000

MCP client configuration:

{
  "mcpServers": {
    "pharmacy": {
      "command": "uv",
      "args": ["run", "pharmacy-mcp"],
      "cwd": "/absolute/path/to/pharmacy-mcp"
    }
  }
}

Recommended tool call:

{
  "query": "warfarin",
  "capabilities": ["identity", "label", "reimbursement", "formulary"],
  "sources": ["rxnorm", "dailymed", "tw-tfda", "tw-nhi", "local-formulary"],
  "limit": 10,
  "output_format": "json_compact",
  "locale": "zh-TW"
}

For a shell or non-MCP workflow:

uv run pharmacy-query warfarin \
  --source local-formulary \
  --capability formulary \
  --format json_compact

The Python API exposes the same contract through pharmacy_mcp.application.harness.PharmacyHarness.

Integrated knowledge

Area

Shipped adapters

Public drug knowledge

RxNorm/RxClass; all seven openFDA drug endpoints; DailyMed; PubChem; MedlinePlus Connect; PubMed; ClinicalTrials.gov; ChEMBL; Open Targets

Taiwan

TFDA permits, official NHI monthly drug items, coverage rules and terminology

Hospital

FHIR R4/R5 medication, order, dispense, inventory and supply; bundled formulary

Organization data

PDF, DOC/DOCX, CSV, XLS/XLSX, Markdown, text, read-only SQLite, vector gateway, fixed HTTPS pages

PK/DDI simulation

Trusted formula catalog, concentration-time estimates, mechanistic CYP inhibition screening, formula resources and validation fixtures

Licensed catalog

DrugBank, FDB and Micromedex are discoverable but never scraped or presented as enabled without a license

Call list_knowledge_sources for the runtime source of truth: capabilities, implementation state, credential needs, and whether an adapter is registered. See the complete data-source catalog.

Taiwan NHI and hospital setup

The NHI provider downloads the official monthly CSV on demand and atomically builds a versioned SQLite index. It can combine reimbursement code, price, ATC, effective dates, TFDA results, and coverage-rule metadata in one query. See Taiwan NHI compound queries.

Set PHARMACY_MCP_FHIR_BASE_URL to register the hospital adapter. Bearer tokens are read from SecretStr settings, and patient resources are queried only when an authorized caller explicitly supplies context.patient_id. Organization connectors use similarly explicit allowlists. Start with .env.example, FHIR and inventory, and organization connectors.

Output and agent rules

The canonical top-level fields are:

schema_version · status · data · sources · warnings · errors · meta

Unknown top-level fields are rejected. All 33 current tools, including calculation and simulation tools, use this envelope. Agents must preserve all seven fields, must not infer absent clinical facts, and must not flatten multiple providers into one implied authority. See the agent harness guide and response contract.

Development

uv sync --all-extras
uv run pytest
uv run ruff check src tests examples scripts
uv run mypy src
uv run mkdocs build --strict
uv run python scripts/check_source_health.py

The repository uses segmented Conventional Commits, an updated Memory Bank, CI across supported Python versions, weekly public-source health checks, and a GitHub Pages documentation workflow. See CONTRIBUTING.md and SECURITY.md.

License

Apache License 2.0. Upstream datasets and commercial knowledge bases retain their own terms, attribution requirements, and clinical-use restrictions.

Available Tools

33 tools
calculate_creatinine_clearanceA

Calculate creatinine clearance using Cockcroft-Gault formula for renal dosing adjustments. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: gender (required), age_years (required), weight_kg (required), serum_creatinine (required), +2 more. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

calculate_dose_by_bsaC

Calculate BSA-based dosage (mg/m²), commonly used in oncology. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: height_cm (required), weight_kg (required), dose_per_m2 (required), locale, +3 more. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

calculate_dose_by_weightC

Calculate weight-based dosage (mg/kg). Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: dose_per_kg (required), patient_weight_kg (required), locale, max_dose, +2 more. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

calculate_infusion_rateC

Calculate IV infusion rate. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: dose_unit (required), volume_ml (required), total_dose (required), duration_hours (required), +2 more. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

calculate_pediatric_doseC

Calculate pediatric dose from adult dose using weight, age, or BSA method. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: adult_dose (required), child_weight_kg (required), locale, method, +4 more. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

check_drug_interactionA

Check for interactions between two drugs. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: drug1 (required), drug2 (required), locale, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

check_food_drug_interactionA

Check for food-drug interactions for a specific drug. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: drug_name (required), locale, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

check_multi_drug_interactionsA

Check for interactions among multiple drugs (medication list review). Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: drugs (required), locale, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

convert_dose_unitsB

Convert between dose units (g, mg, mcg, ng). Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: value (required), to_unit (required), from_unit (required), locale, +1 more. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

explain_interaction_mechanismA

Explain the supported mechanistic DDI pathway for a drug pair, including required simulation parameters. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: drug1 (required), drug2 (required), locale, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

get_drug_dosageA

Get dosage and administration information for a drug. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: drug_name (required), locale, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

get_drug_infoA

Get comprehensive information about a drug including indications, dosage, warnings, and pharmacology. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: drug_name (required), locale, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

get_drug_warningsB

Get warnings, contraindications, and adverse reactions for a drug. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: drug_name (required), locale, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

get_formula_detailsA

Get full metadata for a trusted PK/DDI formula. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: formula_id (required), locale, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

get_formulary_itemA

Get hospital formulary item details by drug code. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: drug_code (required), locale, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

get_nhi_coverageA

Check whether a drug is covered by Taiwan National Health Insurance (NHI) and return coverage details. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: drug_name (required), locale, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

get_nhi_data_statusA

Inspect the Taiwan NHI official index freshness, row count, local path, and upstream dataset URL without forcing a download. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: locale, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

get_nhi_drug_priceB

Get NHI reimbursement price for a drug by NHI code. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: nhi_code (required), locale, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

get_renal_adjustmentA

Get renal dosing adjustment recommendation based on creatinine clearance (CrCl). Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: crcl (required), drug_code (required), locale, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

list_formula_catalogB

List trusted PK/DDI formulas available for simulation. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: locale, status, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

list_knowledge_sourcesA

List cataloged pharmacy knowledge sources, capabilities, readiness, credential requirements, and runtime registration state. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: state, locale, capability, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

list_nhi_coverage_rulesA

List all NHI coverage rules available in the local database. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: locale, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

list_prior_authorization_drugsA

List drugs requiring NHI prior authorization. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: locale, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

query_pharmacyA

Single pharmaceutical knowledge entry point. Query compatible public APIs, Taiwan NHI/TFDA, hospital FHIR inventory, SQL, files, vector search, and configured web sources concurrently. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: query (required), limit, locale, context, +3 more. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

search_drugC

Search for drugs by name. Returns results from RxNorm and FDA databases. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: query (required), locale, max_results, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

search_formularyA

Search hospital formulary by drug name or code. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: query (required), limit, locale, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

search_tfda_drugB

Search the Taiwan TFDA drug database for permits and product information. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: query (required), limit, locale, search_type, +1 more. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

simulate_concentration_timeB

Run a one-compartment concentration-time estimate. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: ke (required), vd (required), dose (required), time (required), +2 more. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

simulate_pk_interactionC

Run a PBPK-lite CYP reversible inhibition exposure estimate for a supported drug pair using explicit user-supplied parameters. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: fm (required), ki (required), drug1 (required), drug2 (required), +4 more. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

stop_orderB

Discontinue an active medication order. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: reason (required), order_id (required), locale, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

submit_orderC

Submit a medication order to the HIS service. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: dose (required), route (required), dose_unit (required), drug_code (required), +8 more. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

translate_drug_nameA

Translate drug names between English and Traditional Chinese where local mapping data is available. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: name (required), locale, output_format. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

validate_orderC

Validate a medication order before submission. Agent contract: use structuredContent as the source of truth; preserve schema_version/status/sources/warnings/errors/meta when forwarding the result and never infer missing clinical facts.

Inputs: dose (required), route (required), dose_unit (required), drug_code (required), +4 more. Returns: Canonical MCP response envelope. Agents MUST consume ``data`` and preserve the…

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 33 tools

    Disambiguation5/5

    Each tool targets a distinct operation: interaction checks (single/multi/food), drug info retrieval (search, get info, dosage, warnings), dose calculations (weight, BSA, pediatric, infusion, conversion), Taiwan-specific (NHI, TFDA, coverage, price, translation), formulary management (search, item, order validation, submit, stop), and PK simulations (formula catalog, mechanism, simulation). There is no meaningful overlap, and agents can clearly distinguish between them.

    Naming Consistency5/5

    All tool names use consistent snake_case with a verb_noun pattern (e.g., check_drug_interaction, get_drug_info, calculate_dose_by_weight, list_nhi_coverage_rules). The naming is descriptive and follows a predictable structure across all subdomains, with no mixing of conventions.

    Tool Count4/5

    33 tools is a high count, but it reflects the server's broad scope covering drug information, interactions, dose calculations, Taiwan NHI features, hospital formulary, and PK simulations. The tools are well-scoped and necessary for the comprehensive purpose, though the number edges above the typical 'well-scoped' range.

    Completeness4/5

    The tool surface covers core pharmacy operations: drug lookup, interaction checks, dose calculations, Taiwan-specific queries, formulary order management, and PK simulations. Minor gaps exist (e.g., drug-allergy checking, medication reconciliation), but the set is largely complete for its stated purpose in a Taiwan healthcare context.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables querying of Chinese-Western medicine interactions with comprehensive drug information, risk assessment, and clinical recommendations. Supports searching medicines, checking interactions individually or in batches, and provides safety guidance with severity classifications.
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Integrates Taiwan-specific medical data including ICD-10 codes, FDA drug databases, and nutrition information into the Model Context Protocol. It enables AI models to query clinical guidelines, verify medical codes, and convert health data into FHIR R4 standardized formats.
      MIT