OpenFDA 标志

OpenFDA

社区
ythalorossy

A Model Context Protocol (MCP) server for querying drug information from the OpenFDA API.

发布者ythalorossy
代码仓库openfda
语言TypeScript
复刻数
2
星标数
4
可用工具
7
传输类型stdio
分类
许可协议MIT
链接
  • 将工具接入 AI 工作流

    OpenFDA 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 7 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 4 个 Star 和 2 个 Fork。

OpenFDA MCP Server

A Model Context Protocol (MCP) server for querying drug information from the OpenFDA API.

Features

2.0.0 registers one tool per openFDA drug endpoint, each with the same shape: a field + value search, limit/skip for paging, detail for the returned record shape, and (where the endpoint supports it) sort and count for ordering and frequency aggregation. Adding an endpoint means adding a row here, not rewriting the pattern.

  • drug-label — Search FDA structured product labels (SPL): prescribing and OTC drug info. field: drug_name (brand/generic/substance, tiered), ndc, spl_product_data_elements, effective_time, id, set_id, brand_name, generic_name, substance_name, manufacturer_name, route, product_type, application_number, unii, rxcui. detail: summary (default; identity plus the safety narrative, every field present, empty if absent), safety (warnings, contraindications, interactions and overdosage — see the migration table below for the 1.x tool this replaces), full (the raw upstream record). count: openfda.route.exact, openfda.product_type.exact, openfda.manufacturer_name.exact. sort: effective_time:desc/effective_time:asc. limit default 1, max 25.
  • drug-event — Search FAERS adverse event reports (voluntarily submitted side-effect reports; not evidence of causation). field: drug_name (unions patient.drug.openfda.generic_name, patient.drug.openfda.substance_name and patient.drug.medicinalproduct), brand_name, manufacturer_name, product_ndc, pharm_class, drug_characterization, indication, reaction, reaction_outcome, serious, seriousness_death, patient_sex, reporter_qualification, country, received_date, report_id. detail: summary (default; one row per report, FAERS codes decoded, (reaction, outcome) pairs deduplicated), full. Also takes seriousness (serious/non-serious/all, default all). sort: receivedate:desc/receivedate:asc; without sort, results are a deterministic earliest-report_id slice. count: patient.reaction.reactionmeddrapt.exact, patient.reaction.reactionoutcome, serious, patient.patientsex, occurcountry.exact, patient.drug.openfda.generic_name.exact (see the migration table below for the 1.x tool this replaces). limit default 10, max 50. Note: the searchable received_date field maps to receivedate, but the summary projection's returned report_date reads receiptdate — two different, near-duplicate FAERS date fields. Filtering by one and reading the other back will not, in general, show the same date.
  • drug-drugsfda — Search Drugs@FDA application data: approvals, sponsors, products and submissions. field: products.brand_name (default drug-name search, 98.79% populated), application_number, sponsor_name (stored uppercase upstream; normalised automatically), products.active_ingredients.name, products.dosage_form, products.route, products.marketing_status, products.reference_drug, products.te_code, openfda.brand_name, openfda.generic_name, openfda.substance_name, openfda.manufacturer_name, openfda.route, openfda.product_ndc (the openfda.* names are the openFDA-harmonised spelling of the same identifiers, but populated on only ~42% of applications — the precise alternative to products.brand_name, not the default), submissions.submission_type, submissions.submission_status, submissions.submission_status_date, submissions.submission_class_code, submissions.review_priority. detail: summary (default; application number, sponsor, openfda block and products — each product carries te_code, null when absent — plus a submission_count, with no submissions array), full (adds submissions, capped at 10 per record, plus submissions_truncated when more were omitted). count: sponsor_name, products.marketing_status, products.dosage_form.exact. limit default 5, max 100. Seven search paths openFDA publishes on this endpoint are deliberately not exposed here — see Migrating from 1.x below.
  • drug-ndc — Search the NDC Directory: every drug product currently listed with the FDA (packaging, labeler, marketing category and application number). This is the product registry, distinct from drug-label's ndc field, which searches labelling text by NDC — see the migration table below for the 1.x NDC lookup this tool is not a replacement for. field: product_ndc, packaging.package_ndc, generic_name, brand_name, active_ingredients.name, openfda.manufacturer_name, marketing_category, application_number, dosage_form, route, product_type, pharm_class, marketing_start_date, openfda.unii, openfda.rxcui, openfda.spl_set_id. detail: summary (default; identity, packaging and marketing status), full (raw upstream record). count: dosage_form.exact, route.exact, product_type.exact, marketing_category, openfda.manufacturer_name.exact. limit default 5, max 50.
  • drug-enforcement — Search FDA drug recall and enforcement reports. classification is the hazard level (Class I: reasonable probability of serious harm or death; II: temporary or reversible harm; III: unlikely harm) and status says whether a recall is Ongoing, Completed or Terminated — a recall appearing in results does not mean it is still in effect. field: product_description (default drug-name search, 100% populated), recall_number, event_id, code_info, recalling_firm, reason_for_recall, classification, status, voluntary_mandated, state, country, recall_initiation_date, report_date, termination_date, openfda.generic_name, openfda.brand_name, openfda.product_ndc (the last three are exact but populated on only ~18% of recalls — the precise alternative to product_description, not the default). detail: summary (default; every field above except the three openfda.* names, which are bundled as one openfda object), full (raw upstream record). count: classification.exact, status.exact, state.exact, voluntary_mandated.exact, recalling_firm.exact. sort: report_date:desc/report_date:asc/recall_initiation_date:desc. limit default 5, max 50.
  • drug-orangebook — Search the Orange Book: FDA-approved drug products with their therapeutic-equivalence ratings. Almost all data lives in the nested products array, which this tool flattens into one entry per product. field: products.brand_name, products.active_ingredients.name, products.application_number, products.application_type, products.application_full_name, products.application_name, products.therapeutic_equivalence_codes, products.reference_listed_drug, products.reference_standard, products.dosage_form, products.route, approval_date. detail: summary (default; approval_date, product_number and the flattened products array — reference_listed_drug and reference_standard are booleans always returned, false a fact rather than a missing value), full (raw upstream record). count: products.application_type, products.dosage_form.exact, products.route.exact, products.therapeutic_equivalence_codes. sort: approval_date:desc/approval_date:asc. limit default 5, max 50.
  • drug-shortages — Search FDA drug shortage reports. status is one of three values, live-verified 2026-09-21: Current (1153 records), To Be Discontinued (443), or Resolved (7) — a product appearing here is not necessarily short now, and To Be Discontinued is neither "current" nor "resolved" but the larger of the two non-Current states. openFDA sends an empty string, not null, for an absent date on this endpoint; this tool normalises those to null. field: generic_name (default), company_name, openfda.manufacturer_name, openfda.brand_name, openfda.substance_name, package_ndc, openfda.product_ndc, status, therapeutic_category, dosage_form, update_type, initial_posting_date, update_date. detail: summary (default; the openfda.* names are bundled as one openfda object), full (raw upstream record). count: status, dosage_form.exact, therapeutic_category, company_name.exact. sort: update_date:desc/update_date:asc/initial_posting_date:desc. limit default 10, max 50. Smallest drug dataset (~1,600 records); a coverage percentage here represents far fewer records than the same percentage elsewhere.

Every tool's response envelope carries matched_via (which field path actually matched), total (the upstream match count, not the number of records in this response), returned (how many records it does carry), limit, dropped_for_budget (how many rows were dropped to stay within the 60,000-character response budget — 0 when none were, never omitted), next_skip (the offset to resume paging from; null when the result set is exhausted or the next offset would exceed SKIP_MAX) and results. Page by next_skip, not skip + limit — the budget can drop trailing rows, so skip + limit silently steps over exactly the rows that were dropped. A search that matches nothing returns a plain no-results message, not an error.

limit means two different things depending on whether count is set: for a record search it caps rows returned, capped at that tool's max below; for an aggregation it caps buckets, defaulting to 100 (openFDA's own bucket ceiling) when omitted. This is an asymmetry on every tool except drug-drugsfda (whose record max is already 100): omitting limit under count can return up to 100 buckets, but an explicit limit is still rejected above the tool's record max — so a caller can receive more buckets than it can explicitly request. Record maxes: drug-label 25, drug-event 50, drug-drugsfda 100, drug-ndc 50, drug-enforcement 50, drug-orangebook 50, drug-shortages 50.

An aggregated response is trimmed to the same 60,000-character budget as a record response, and reports dropped_for_budget for the buckets it dropped — returned counts the buckets actually kept. It carries no next_skip: an aggregation has no result total and no skip semantics, so an offset to resume from would be a number with nothing behind it.

Route vocabularies differ across tools. drug-label's route field (openfda.route, the SPL route of administration) and drug-drugsfda's products.route field (the Drugs@FDA product route) are different controlled vocabularies. The same insulin glargine product is reported as SUBCUTANEOUS in one and INJECTION in the other, so joining or filtering on route across tools will silently miss matches.

  1. Set up your OpenFDA API Key

    The server reads OPENFDA_API_KEY from its process environment. It is launched by your MCP client, so the key belongs in the env block of your client configuration (shown below) — a .env file is not read.

    Get a key from OpenFDA API Key Registration. A key raises your limit from 40 to 240 requests per minute.

    Without a key, every tool call returns a configuration error rather than failing confusingly upstream. To run on the unauthenticated tier anyway, set OPENFDA_ALLOW_KEYLESS=1 — note that tier reports no rate-limit headers, so exhausting it surfaces as slow, intermittent failures.

    Note: Never commit your real API key to version control.

  2. Example MCP Server Configuration

    If you are integrating this server with a larger MCP system, your configuration might look like:

    json
     {
       "mcpServers": {
           "openfda": {
               "command": "npx",
               "args": [
                   "-y",
                   "@ythalorossy/openfda"
               ],
               "env": {
                   "OPENFDA_API_KEY": "*****************************************"
               },
               "timeout": 60000,
               "autoApprove": [
                   "drug-label",
                   "drug-event",
                   "drug-drugsfda",
                   "drug-ndc",
                   "drug-enforcement",
                   "drug-orangebook",
                   "drug-shortages"
               ]
           }
       }
     }

    Replace the asterisks with your actual API key.

Want to run it locally?

bash
git clone https://github.com/ythalorossy/openfda.git
cd openfda
npm install
npm run build

Then start the server:

bash
node dist/index.js

Or use it directly with npx:

bash
npx @ythalorossy/openfda

Configuration

Export OPENFDA_API_KEY in your shell before running locally: export OPENFDA_API_KEY=your_key.

Migrating from 1.x

2.0.0 replaces the nine get-* tools with one tool per openFDA drug endpoint. Pin 1.3.0 if you are not ready to migrate.

1.x tool2.0.0 call
get-drug-by-namedrug-label { field: "drug_name", value }
get-drug-by-generic-namedrug-label { field: "generic_name", value }
get-drugs-by-manufacturerdrug-label { field: "manufacturer_name", value }
get-drug-safety-infodrug-label { field: "drug_name", value, detail: "safety" }
get-drug-by-ndcdrug-label { field: "ndc", value }
get-drug-by-product-ndcdrug-label { field: "ndc", value }
get-drug-adverse-eventsdrug-event { field: "drug_name", value }
get-drug-adverse-event-countsdrug-event { value, count: "patient.reaction.reactionmeddrapt.exact" }
get-drugsfdadrug-drugsfda { field: "application_number", value } or { field: "products.brand_name", value }

drug-drugsfda field names carry no section prefix. 1.x grouped fields under a section parameter (application, products, submissions, openfda), so the table row above is illustrative, not literal: real field names are flat where 1.x had a section for the top-level application fields — application_number and sponsor_name carry no prefix — while products.*, submissions.* and openfda.* keep theirs. A caller who copies application.sponsor_name from 1.x muscle memory gets an unknown-field error; the correct value is sponsor_name.

get-drug-by-ndc did not search /drug/ndc.json. It searched labels by openfda.product_ndc, so it maps to drug-label ({ field: "ndc" }), not to drug-ndc. drug-ndc searches the actual NDC Directory — new capability this server did not previously expose — and returns different data than the label-based lookup 1.x actually performed: use drug-ndc for packaging, labeler and marketing-category questions, and drug-label for label text keyed off an NDC.

get-drug-by-product-ndc returned a pre-filtered available_packages — the label's package NDCs filtered down to the product you searched. drug-label's summary detail returns package_ndc unfiltered, so on a label that covers several products it mixes packages from all of them. Nothing is lost: summary also returns product_ndc[], so filtering by prefix is a one-line operation on the caller's side, and active_ingredient, purpose and dosage_and_administration are reachable via detail: "full" — but the convenience of a pre-filtered list is gone.

Seven Drugs@FDA search paths available in 1.x are deliberately not exposed on drug-drugsfda: openfda.application_number (a 42%-populated duplicate of the 100%-populated application_number), products.product_number and submissions.submission_number (per-application ordinals that match tens of thousands of unrelated records corpus-wide), and all four submissions.application_docs.{id,url,date,type} (opaque per-document values you must already possess in order to search by them). See docs/superpowers/notes/2026-09-20-field-selection.md (## drugsfda → "Deliberately not exposed") for the full reasoning. All seven remain reachable through the field-catalog resource a later release publishes, so nothing becomes unqueryable — they are simply no longer in the field enum.

Other behaviour changes:

  • Search-value injection is fixed. Every 1.x tool interpolated the caller's search value straight into the query string. A crafted value could append a clause and make the server report data for a different drug than the one named in its own matched_via — verified live: openfda.brand_name:"Advil" returns 39 records, openfda.brand_name:"Tylenol" returns 111, and the injected combination of the two returns 150. 2.0.0 escapes every value, and query assembly is confined to one file with a test enforcing it.
  • A search that matches nothing now returns a plain no-results message. Previously openFDA's HTTP 404 was reported as isError: true with "Failed to retrieve…", which was indistinguishable from an outage.
  • 'Unknown' placeholder strings are gone. Absent values are null or [], so a placeholder can no longer be mistaken for data.
  • get-drug-safety-info's scalar drug_name is now the array brand_name (on drug-label's detail: "safety").
  • Response headers are uniform across tools; the emoji/prose headers are gone.
  • Every response is capped at 60,000 characters, dropping trailing records and saying how many, rather than returning an unusable wall of text.

License

MIT

Buy me a Coffee

coff.ee/ythalorossy

安装

TypingMind
前提条件:

Node.js 18+

{
  "mcpServers": {
    "openfda": {
      "command": "npx",
      "args": [
        "@ythalorossy/openfda"
      ],
      "env": {
        "OPENFDA_API_KEY": "************"
      }
    }
  }
}

可用工具

  • get-drug-by-name

    Get drug by name. Use this tool to get the drug information by name. The drug name should be the brand name. It returns the brand name, generic name, manufacturer name, product NDC, product type, route, substance name, indications and usage, warnings, do not use, ask doctor, ask doctor or pharmacist, stop use, pregnancy or breast feeding.

  • get-drug-by-generic-name

    Get drug information by generic (active ingredient) name. Useful when you know the generic name but not the brand name. Returns all brand versions of the generic drug.

  • get-drug-adverse-events

    Get adverse event reports for a drug. This provides safety information about reported side effects and reactions. Use brand name or generic name.

  • get-drugs-by-manufacturer

    Get all drugs manufactured by a specific company. Useful for finding alternatives or checking manufacturer portfolios.

  • get-drug-safety-info

    Get comprehensive safety information for a drug including warnings, contraindications, drug interactions, and precautions. Use brand name.

  • get-drug-by-ndc

    Get drug information by National Drug Code (NDC). Accepts both product NDC (XXXXX-XXXX) and package NDC (XXXXX-XXXX-XX) formats. Also accepts NDC codes without dashes.

  • get-drug-by-product-ndc

    Get drug information by product NDC only (XXXXX-XXXX format). This ignores package variations and finds all packages for a product.

将 OpenFDA MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 OpenFDA 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 此 MCP 通过您设备上的 TypingMind MCP 连接器在本地运行。

本地连接器设置指南

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请保持终端窗口及其中的进程运行。
3

将 OpenFDA 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 OpenFDA MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "openfda": {
      "command": "npx",
      "args": [
        "-y",
        "@ythalorossy/openfda"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 OpenFDA MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 OpenFDA MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 OpenFDA 帮我完成这项任务吗?
OpenFDA
当然。我已阅读。
以下是我使用 OpenFDA 得到的结果。

常见问题

OpenFDA MCP 服务器有什么用途?

OpenFDA 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 OpenFDA MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您可以让 Claude、ChatGPT、Gemini 等不同 AI 模型,或您在 TypingMind 中配置的其他模型使用 OpenFDA,而无需为每个模型单独配置 MCP 服务器。

为什么在 TypingMind 中使用 OpenFDA MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是优秀的大语言模型聊天前端之一。连接 OpenFDA 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 OpenFDA MCP 连接到 TypingMind?

OpenFDA 通过 TypingMind 本地 MCP 连接器运行。当 MCP 服务器需要访问您计算机上的本地文件、桌面应用、命令行工具或私有资源时,这种方式最合适。

OpenFDA MCP 在 TypingMind 中提供哪些工具?

OpenFDA 提供 7 个 MCP 工具,您可以在 TypingMind 的插件页面启用这些工具,然后在聊天中使用,或将其分配给 AI 智能体。

使用 OpenFDA MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行掌控模型提供商、API 密钥、提示词和 MCP 配置。如果 OpenFDA 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇