{"id":50993849,"url":"https://github.com/cyanheads/openfda-mcp-server","last_synced_at":"2026-06-20T06:32:36.641Z","repository":{"id":349036863,"uuid":"1200584163","full_name":"cyanheads/openfda-mcp-server","owner":"cyanheads","description":"Query FDA data on drugs, food, devices, and recalls via openFDA. STDIO or Streamable HTTP.","archived":false,"fork":false,"pushed_at":"2026-06-09T01:09:30.000Z","size":1215,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-09T03:09:39.781Z","etag":null,"topics":["adverse-events","cyanheads","drug-safety","fda","mcp","mcp-server","model-context-protocol","openfda","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@cyanheads/openfda-mcp-server","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cyanheads.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-04-03T15:31:28.000Z","updated_at":"2026-06-09T01:09:33.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/cyanheads/openfda-mcp-server","commit_stats":null,"previous_names":["cyanheads/openfda-mcp-server"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/cyanheads/openfda-mcp-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyanheads%2Fopenfda-mcp-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyanheads%2Fopenfda-mcp-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyanheads%2Fopenfda-mcp-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyanheads%2Fopenfda-mcp-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cyanheads","download_url":"https://codeload.github.com/cyanheads/openfda-mcp-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyanheads%2Fopenfda-mcp-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34560265,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-20T02:00:06.407Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adverse-events","cyanheads","drug-safety","fda","mcp","mcp-server","model-context-protocol","openfda","typescript"],"created_at":"2026-06-20T06:32:35.977Z","updated_at":"2026-06-20T06:32:36.611Z","avatar_url":"https://github.com/cyanheads.png","language":"TypeScript","funding_links":[],"categories":["Clinical Decision Support"],"sub_categories":["Clinical Validity Score"],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003e@cyanheads/openfda-mcp-server\u003c/h1\u003e\n  \u003cp\u003e\u003cb\u003eQuery FDA data on drugs, food, devices, and recalls via openFDA. STDIO or Streamable HTTP.\u003c/b\u003e\n  \u003cdiv\u003e14 Tools\u003c/div\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![npm](https://img.shields.io/npm/v/@cyanheads/openfda-mcp-server?style=flat-square\u0026logo=npm\u0026logoColor=white)](https://www.npmjs.com/package/@cyanheads/openfda-mcp-server) [![Version](https://img.shields.io/badge/Version-0.3.1-blue.svg?style=flat-square)](./CHANGELOG.md) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^1.29.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![TypeScript](https://img.shields.io/badge/TypeScript-^6.0.3-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.3.11-blueviolet.svg?style=flat-square)](https://bun.sh/)\n\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Install in Claude Desktop](https://img.shields.io/badge/Install_in-Claude_Desktop-D97757?style=for-the-badge\u0026logo=anthropic\u0026logoColor=white)](https://github.com/cyanheads/openfda-mcp-server/releases/latest/download/openfda-mcp-server.mcpb) [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=openfda-mcp-server\u0026config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBjeWFuaGVhZHMvb3BlbmZkYS1tY3Atc2VydmVyIl0sImVudiI6eyJPUEVORkRBX0FQSV9LRVkiOiJ5b3VyLWFwaS1rZXkifX0=) [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=for-the-badge\u0026logo=visualstudiocode\u0026logoColor=white)](https://vscode.dev/redirect?url=vscode:mcp/install?%7B%22name%22%3A%22openfda-mcp-server%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40cyanheads/openfda-mcp-server%22%5D%2C%22env%22%3A%7B%22OPENFDA_API_KEY%22%3A%22your-api-key%22%7D%7D)\n\n[![Framework](https://img.shields.io/badge/Built%20on-@cyanheads/mcp--ts--core-67E8F9?style=flat-square)](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)\n\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n**Public Hosted Server:** [https://openfda.caseyjhand.com/mcp](https://openfda.caseyjhand.com/mcp)\n\n\u003c/div\u003e\n\n---\n\n## Tools\n\nFourteen tools for querying FDA data across drugs, food, devices, animal/veterinary products, and recalls — plus an optional DataCanvas SQL surface for large result sets:\n\n| Tool | Description |\n|:---|:---|\n| `openfda_drug_profile` | One drug name → consolidated FDA profile: identity, label, adverse events, recalls, approval, shortage |\n| `openfda_search_adverse_events` | Search adverse event reports across drugs, food, and devices |\n| `openfda_search_animal_events` | Search adverse event reports for veterinary drugs and devices |\n| `openfda_search_drug_shortages` | Search FDA drug shortage records — status, availability, therapeutic category, manufacturer |\n| `openfda_search_tobacco_reports` | Search problem reports for tobacco products, e-cigarettes, and vaping devices |\n| `openfda_search_recalls` | Search enforcement reports and recall actions across drugs, food, and devices |\n| `openfda_count_values` | Aggregate and tally unique values for any field across any openFDA endpoint |\n| `openfda_describe_fields` | Return searchable field paths for an openFDA endpoint, grouped by category |\n| `openfda_get_drug_label` | Look up FDA drug labeling (package inserts / SPL documents) |\n| `openfda_search_drug_approvals` | Search the Drugs@FDA database for NDA/ANDA application approvals |\n| `openfda_search_device_clearances` | Search FDA device premarket notifications — 510(k) clearances and PMA approvals |\n| `openfda_lookup_ndc` | Look up drugs in the NDC (National Drug Code) Directory |\n| `openfda_dataframe_query` | Run read-only SQL over a result set staged on a DataCanvas (opt-in) |\n| `openfda_dataframe_describe` | List tables and column schemas staged on a DataCanvas (opt-in) |\n\n### `openfda_drug_profile`\n\nResolve one drug name to its FDA identity, then return a consolidated profile in a single call — replacing four or five chained lookups.\n\n- Resolves a brand or generic name to canonical FDA identifiers once (generic name, NDC, RxCUI, SPL set ID), then keys every sub-query off that identity to avoid the identifier drift that breaks naive tool chaining\n- Single-ingredient resolution: a single-drug query won't resolve to a combination product\n- Sections: label highlights, adverse-event summary (top reactions, serious count), recall history, Drugs@FDA approval, and current shortage status\n- Best-effort — a miss on any section returns `null` rather than failing the whole call; use the dedicated tool for a deep dive into any area\n\n---\n\n### `openfda_search_adverse_events`\n\nSearch adverse event reports across drugs, food, and devices. Use to investigate safety signals, find reports for a specific product, or explore reactions by demographics.\n\n- Category selection: `drug`, `food`, or `device` — each returns different field schemas\n- Elasticsearch query syntax for filtering by product, reaction, seriousness, date range\n- Pagination via `limit` (up to 1000) and `skip` (up to 25000)\n- Formatted output includes report ID, seriousness, patient demographics, reactions, drugs with characterization/indication/route, and all remaining fields\n\n---\n\n### `openfda_count_values`\n\nAggregate and tally unique values for any field across any openFDA endpoint. Returns ranked term-count pairs sorted by count descending.\n\n- Works across all 20 openFDA endpoints (drugs, food, devices, animal/veterinary, tobacco, other)\n- Use `.exact` suffix on field names for whole-phrase counting\n- Optional `search` filter to scope the aggregation\n- Returns up to 1000 terms per query\n\n---\n\n### `openfda_search_recalls`\n\nSearch enforcement reports and recall actions across drugs, food, and devices.\n\n- Supports `enforcement` (all categories) and `recall` (devices only) endpoints\n- Filter by classification (Class I/II/III), recalling firm, reason, status\n- Formatted output includes recall number, classification, product description, reason, distribution pattern\n\n---\n\n### `openfda_search_device_clearances`\n\nSearch FDA device premarket notifications — 510(k) clearances and PMA approvals.\n\n- Two pathways: `510k` (174K+ records, most common) and `pma` (higher-risk devices)\n- Filter by applicant, product code, advisory committee, device name\n- Formatted output adapts to pathway: 510(k) shows K-number/clearance type, PMA shows supplement info\n\n---\n\n### `openfda_get_drug_label`\n\nLook up FDA drug labeling (package inserts / SPL documents). Check indications, warnings, dosage, contraindications, active ingredients, or any structured label section.\n\n- Search by brand name, generic name, manufacturer, or set ID\n- Formatted output dynamically renders all label sections and openfda metadata present in the record\n- Large sections are automatically truncated to keep output readable\n- Default limit of 5 — labels are large documents\n\n---\n\n### `openfda_search_drug_approvals`\n\nSearch the Drugs@FDA database for drug application approvals (NDAs and ANDAs). Returns application details, sponsor info, and full submission history.\n\n- Filter by brand name, sponsor, submission type, review priority\n- Formatted output includes products with active ingredients, dosage forms, routes, and marketing status\n- Full submission history with type, status, date, and review priority\n- Pagination via `limit` (up to 1000) and `skip` (up to 25000)\n\n---\n\n### `openfda_lookup_ndc`\n\nLook up drugs in the NDC (National Drug Code) Directory. Identify drug products by NDC code, find active ingredients, packaging details, or manufacturer info.\n\n- Search by product NDC, brand name, generic name, manufacturer, or active ingredient\n- Returns product details, active ingredients with strengths, and packaging information\n- Sortable by listing expiration date or other fields\n\n---\n\n### `openfda_search_animal_events`\n\nSearch adverse event reports for veterinary drugs and devices submitted to the FDA Center for Veterinary Medicine (1.3M+ records).\n\n- Filter by animal species, breed, drug name, VeDDRA reaction term, or seriousness\n- Records include animal details (species, gender, age, weight), administered drugs, reactions, and outcomes\n- Formatted output surfaces key clinical fields; remaining fields rendered via catch-all\n\n---\n\n### `openfda_search_tobacco_reports`\n\nSearch problem reports submitted to the FDA for tobacco products, including e-cigarettes, vaping products, cigarettes, and smokeless tobacco.\n\n- Filter by product type, reported health problems (e.g. seizure, chest pain), product problems (e.g. battery explosion), or non-user involvement\n- Formatted output surfaces products, health effects, product defects, and report counts\n\n---\n\n### `openfda_search_drug_shortages`\n\nSearch FDA drug shortage records (1,700+ entries, refreshed daily). Returns shortage status, availability notes, therapeutic category, dosage form, manufacturer, and timeline.\n\n- Filter by status (`Current`, `Resolved`), therapeutic category, generic name, or manufacturer\n- The `openfda` block carries `brand_name`, `product_ndc`, and `rxcui` for chaining into `openfda_get_drug_label` or `openfda_lookup_ndc`\n- Pagination via `limit` (up to 1000) and `skip` (up to 25000)\n\n---\n\n### `openfda_describe_fields`\n\nReturn the searchable field paths for an openFDA endpoint, grouped by category with type and description. Use before constructing a search query to discover the correct dotted field paths.\n\n- Covers all major endpoints: `drug/event`, `drug/label`, `drug/shortages`, `drug/drugsfda`, `drug/ndc`, `drug/enforcement`, `food/event`, `food/enforcement`, `device/event`, `device/510k`, `device/pma`, `device/recall`, `device/enforcement`, `animalandveterinary/event`, `tobacco/problem`\n- Returns fields grouped by category (identifiers, dates, clinical fields, etc.) with data type and one-line description\n- Complements the reactive field hints that appear in `notice` enrichment when a search returns empty\n\n---\n\n### `openfda_dataframe_query` · `openfda_dataframe_describe`\n\nA DataCanvas SQL surface over staged result sets — **opt-in**, enabled with `CANVAS_PROVIDER_TYPE=duckdb`.\n\n- With canvas enabled, the multi-row search tools page the full matched set (up to openFDA's 25,000-row ceiling) into a DuckDB table and return an inline preview plus a `canvas_id` and `canvas_table`. `openfda_dataframe_query` runs read-only `SELECT` (GROUP BY, SUM/COUNT, joins) across the staged rows; `openfda_dataframe_describe` lists the table and column schemas needed to write valid SQL.\n- Scalar fields are stored as text (`CAST` for numeric math); nested openFDA blocks (`openfda`, `patient`, `products`, …) are JSON columns. Pass a `canvas_id` back into a search tool to accumulate result sets on one canvas for cross-table joins.\n- Off by default — without `CANVAS_PROVIDER_TYPE=duckdb` the search tools return inline results exactly as before and the two dataframe tools report that canvas is disabled. Requires the optional `@duckdb/node-api` dependency; unsupported on Cloudflare Workers.\n\n## Features\n\nBuilt on [`@cyanheads/mcp-ts-core`](https://www.npmjs.com/package/@cyanheads/mcp-ts-core):\n\n- Declarative tool definitions — single file per tool, framework handles registration and validation\n- Unified error handling across all tools\n- Pluggable auth (`none`, `jwt`, `oauth`)\n- Swappable storage backends: `in-memory`, `filesystem`, `Supabase`, `Cloudflare KV/R2/D1`\n- Structured logging with optional OpenTelemetry tracing\n- Runs locally (stdio/HTTP) or on Cloudflare Workers from the same codebase\n\nopenFDA-specific:\n\n- Generic API client for all openFDA endpoints with retry (exponential backoff) and rate-limit awareness\n- Automatic error normalization — 404 returns empty results, 429/5xx retries, 400 provides actionable messages\n- Optional API key support — works without a key (1K requests/day), increases to 120K/day with a free key\n- Optional DataCanvas spillover (`CANVAS_PROVIDER_TYPE=duckdb`) — stage large result sets as DuckDB tables and run SQL via `openfda_dataframe_query`\n\n## Getting Started\n\n### Public Hosted Instance\n\nA public instance is available at `https://openfda.caseyjhand.com/mcp` — no installation required. Point any MCP client at it via Streamable HTTP:\n\n```json\n{\n  \"mcpServers\": {\n    \"openfda-mcp-server\": {\n      \"type\": \"streamable-http\",\n      \"url\": \"https://openfda.caseyjhand.com/mcp\"\n    }\n  }\n}\n```\n\n### Via bunx (no install)\n\nAdd to your MCP client config:\n\n```json\n{\n  \"mcpServers\": {\n    \"openfda-mcp-server\": {\n      \"type\": \"stdio\",\n      \"command\": \"bunx\",\n      \"args\": [\"@cyanheads/openfda-mcp-server@latest\"],\n      \"env\": {\n        \"MCP_TRANSPORT_TYPE\": \"stdio\",\n        \"MCP_LOG_LEVEL\": \"info\",\n        \"OPENFDA_API_KEY\": \"your-key-here\"\n      }\n    }\n  }\n}\n```\n\nOr with npx (no Bun required):\n\n```json\n{\n  \"mcpServers\": {\n    \"openfda-mcp-server\": {\n      \"type\": \"stdio\",\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@cyanheads/openfda-mcp-server@latest\"],\n      \"env\": {\n        \"MCP_TRANSPORT_TYPE\": \"stdio\",\n        \"MCP_LOG_LEVEL\": \"info\",\n        \"OPENFDA_API_KEY\": \"your-key-here\"\n      }\n    }\n  }\n}\n```\n\nOr with Docker:\n\n```json\n{\n  \"mcpServers\": {\n    \"openfda-mcp-server\": {\n      \"type\": \"stdio\",\n      \"command\": \"docker\",\n      \"args\": [\"run\", \"-i\", \"--rm\", \"-e\", \"MCP_TRANSPORT_TYPE=stdio\", \"ghcr.io/cyanheads/openfda-mcp-server:latest\"]\n    }\n  }\n}\n```\n\nFor Streamable HTTP, set the transport and start the server:\n\n```sh\nMCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 bun run start:http\n# Server listens at http://localhost:3010/mcp\n```\n\n### Prerequisites\n\n- [Bun v1.3.0](https://bun.sh/) or higher.\n- Optional: [openFDA API key](https://open.fda.gov/apis/authentication/) for higher rate limits (120K requests/day vs 1K/day).\n\n### Installation\n\n1. **Clone the repository:**\n\n```sh\ngit clone https://github.com/cyanheads/openfda-mcp-server.git\n```\n\n2. **Navigate into the directory:**\n\n```sh\ncd openfda-mcp-server\n```\n\n3. **Install dependencies:**\n\n```sh\nbun install\n```\n\n## Configuration\n\nAll configuration is validated at startup via Zod schemas in `src/config/server-config.ts`. Key environment variables:\n\n| Variable | Description | Default |\n|:---|:---|:---|\n| `MCP_TRANSPORT_TYPE` | Transport: `stdio` or `http` | `stdio` |\n| `MCP_HTTP_PORT` | HTTP server port | `3010` |\n| `MCP_AUTH_MODE` | Authentication: `none`, `jwt`, or `oauth` | `none` |\n| `MCP_LOG_LEVEL` | Log level (`debug`, `info`, `warning`, `error`, etc.) | `info` |\n| `LOGS_DIR` | Directory for log files (Node.js only). | `\u003cproject-root\u003e/logs` |\n| `STORAGE_PROVIDER_TYPE` | Storage backend: `in-memory`, `filesystem`, `supabase`, `cloudflare-kv/r2/d1` | `in-memory` |\n| `OPENFDA_API_KEY` | Free API key from [open.fda.gov](https://open.fda.gov/apis/authentication/). Increases daily limit from 1K to 120K requests. | none |\n| `OPENFDA_BASE_URL` | Base URL override for testing against a proxy or mock. | `https://api.fda.gov` |\n| `CANVAS_PROVIDER_TYPE` | Set to `duckdb` to enable DataCanvas spillover — analytical SQL over staged result sets via `openfda_dataframe_query`. Requires the optional `@duckdb/node-api` dependency; unsupported on Cloudflare Workers. | `none` (disabled) |\n| `OTEL_ENABLED` | Enable OpenTelemetry | `false` |\n\n## Running the Server\n\n### Local Development\n\n- **Build and run the production version:**\n\n  ```sh\n  # One-time build\n  bun run rebuild\n\n  # Run the built server\n  bun run start:http\n  # or\n  bun run start:stdio\n  ```\n\n- **Run checks and tests:**\n  ```sh\n  bun run devcheck  # Lints, formats, type-checks, and more\n  bun run test      # Runs the test suite\n  ```\n\n## Project Structure\n\n| Directory | Purpose |\n|:---|:---|\n| `src/index.ts` | Entry point — `createApp()` with tool registration and service setup. |\n| `src/config/` | Server-specific env var parsing and validation with Zod. |\n| `src/services/openfda/` | openFDA API client with retry, rate-limit handling, and error normalization. |\n| `src/mcp-server/tools/definitions/` | Tool definitions (`*.tool.ts`). Fourteen openFDA tools. |\n\n## Development Guide\n\nSee [`CLAUDE.md`](./CLAUDE.md) for development guidelines and architectural rules. The short version:\n\n- Handlers throw, framework catches — no `try/catch` in tool logic\n- Use `ctx.log` for request-scoped logging\n- Register new tools in `src/mcp-server/tools/definitions/index.ts`\n\n## Contributing\n\nIssues and pull requests are welcome. Run checks and tests before submitting:\n\n```sh\nbun run devcheck\nbun run test\n```\n\n## License\n\nThis project is licensed under the Apache 2.0 License. See the [LICENSE](./LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyanheads%2Fopenfda-mcp-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcyanheads%2Fopenfda-mcp-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyanheads%2Fopenfda-mcp-server/lists"}