Skip to main content
Glama
BACH-AI-Tools

OpenFDA Drug Label MCP Server

OpenFDA Drug Label MCP Server

一个用于查询 FDA 药物标签信息的 MCP(Model Context Protocol)服务器,专为药物不良反应智能体设计。

🚀 使用 npx 快速启动(推荐)

无需安装,直接在 Cursor / Cherry Studio 的 MCP 配置中使用:

{
  "mcpServers": {
    "openfda": {
      "command": "npx",
      "args": ["-y", "bach-openfda"]
    }
  }
}

保存配置后重启,npx 会自动从 npm 下载并运行最新版本的 bach-openfda。

包地址: https://www.npmjs.com/package/bach-openfda


Related MCP server: OpenFDA FastMCP Server

功能特性

  • 药物标签搜索: 通过药物名称、活性成分、制造商等搜索 FDA 药物标签

  • 不良反应查询: 获取特定药物的不良反应信息

  • 警告信息: 查询药物的警告和注意事项

  • 适应症信息: 获取药物的适应症和用法信息

可用工具

1. search_drug_labels

搜索 FDA 药物标签,支持复杂查询语法。

参数:

  • search (string): 搜索查询,如 "aspirin", "openfda.brand_name:tylenol"

  • count (string): 按字段统计结果

  • skip (number): 跳过记录数(分页)

  • limit (number): 返回记录数限制 (1-1000)

2. get_drug_adverse_reactions

获取特定药物的不良反应信息。

参数:

  • drug_name (string, 必需): 药物名称

  • limit (number): 返回记录数限制 (1-100)

3. get_drug_warnings

获取药物的警告和注意事项。

参数:

  • drug_name (string, 必需): 药物名称

  • limit (number): 返回记录数限制 (1-100)

4. get_drug_indications

获取药物的适应症和用法信息。

参数:

  • drug_name (string, 必需): 药物名称

  • limit (number): 返回记录数限制 (1-100)

安装和运行

本地开发

# 安装依赖
npm install

# 开发模式运行
npm run dev

# 构建
npm run build

# 生产模式运行
npm start

Ubuntu 服务器部署

1. 环境准备

# 更新系统
sudo apt update && sudo apt upgrade -y

# 安装Node.js 18+
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs

# 验证安装
node --version
npm --version

2. 部署 MCP 服务器

# 创建项目目录
mkdir -p ~/mcp-servers/openfda
cd ~/mcp-servers/openfda

# 上传项目文件(使用scp或git clone)
# 方法1: 使用git
git clone <your-repo-url> .

# 方法2: 使用scp从本地上传
# scp -r /path/to/mcp-openfda/* user@your-server:~/mcp-servers/openfda/

# 安装依赖
npm install

# 构建项目
npm run build

# 测试运行
npm start

3. 使用 PM2 管理进程(推荐)

# 全局安装PM2
sudo npm install -g pm2

# 创建PM2配置文件
cat > ecosystem.config.js << 'EOF'
module.exports = {
  apps: [{
    name: 'mcp-openfda',
    script: 'dist/index.js',
    cwd: '/home/ubuntu/mcp-servers/openfda',
    instances: 1,
    autorestart: true,
    watch: false,
    max_memory_restart: '1G',
    env: {
      NODE_ENV: 'production'
    }
  }]
}
EOF

# 启动服务
pm2 start ecosystem.config.js

# 设置开机自启
pm2 startup
pm2 save

# 查看状态
pm2 status
pm2 logs mcp-openfda

4. 配置防火墙(如果需要网络访问)

# 如果需要通过网络访问,可以配置nginx反向代理
sudo apt install nginx

# 创建nginx配置
sudo tee /etc/nginx/sites-available/mcp-openfda << 'EOF'
server {
    listen 80;
    server_name your-domain.com;  # 替换为你的域名或IP

    location / {
        proxy_pass http://localhost:3000;  # 如果MCP服务器监听3000端口
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_cache_bypass $http_upgrade;
    }
}
EOF

# 启用站点
sudo ln -s /etc/nginx/sites-available/mcp-openfda /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx

远程调用配置

方法 1: 通过 SSH 隧道

在客户端机器上创建 SSH 隧道:

# 创建SSH隧道,将本地端口转发到服务器
ssh -L 3000:localhost:3000 user@your-server-ip

# 然后在MCP客户端配置中使用 localhost:3000

方法 2: 网络 MCP 服务器

如果需要通过网络直接访问,需要修改 MCP 服务器以支持网络传输:

// 在src/index.ts中添加网络传输支持
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";

// 替换stdio传输为网络传输
const transport = new SSEServerTransport("/message", response);

方法 3: 使用 Docker 部署

# 创建Dockerfile
cat > Dockerfile << 'EOF'
FROM node:18-alpine

WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production

COPY dist/ ./dist/
COPY src/ ./src/

EXPOSE 3000

CMD ["npm", "start"]
EOF

# 构建和运行
docker build -t mcp-openfda .
docker run -d -p 3000:3000 --name mcp-openfda-server mcp-openfda

使用示例

在 Claude Desktop 中配置

在 Claude Desktop 的配置文件中添加:

{
  "mcpServers": {
    "openfda": {
      "command": "node",
      "args": ["/path/to/mcp-openfda/dist/index.js"],
      "env": {}
    }
  }
}

远程服务器配置

{
  "mcpServers": {
    "openfda": {
      "command": "ssh",
      "args": [
        "user@your-server-ip",
        "cd ~/mcp-servers/openfda && node dist/index.js"
      ],
      "env": {}
    }
  }
}

API 使用示例

// 搜索阿司匹林的信息
await searchDrugLabels({
  search: "aspirin",
  limit: 5,
});

// 获取布洛芬的不良反应
await getDrugAdverseReactions("ibuprofen", 3);

// 查询泰诺的警告信息
await getDrugWarnings("tylenol", 2);

注意事项

  1. API 限制: OpenFDA API 有速率限制,建议合理控制请求频率

  2. 数据准确性: 返回的数据仅供参考,不应作为医疗建议

  3. 网络安全: 如果部署在公网,请确保适当的安全措施

  4. 日志监控: 建议配置日志监控以跟踪 API 使用情况

故障排除

常见问题

  1. 连接失败: 检查网络连接和防火墙设置

  2. 权限错误: 确保 Node.js 进程有适当的文件权限

  3. 端口冲突: 检查端口是否被其他服务占用

日志查看

# PM2日志
pm2 logs mcp-openfda

# 系统日志
sudo journalctl -u nginx -f

许可证

MIT License

Available Tools

5 tools
ae_pipeline_ragC

Advanced RAG pipeline for drug safety analysis. Fetches, extracts, chunks, retrieves and summarizes FDA drug label data in one call to prevent LLM response truncation.

ParametersJSON Schema
NameRequiredDescriptionDefault
drugNoDrug name to focus the analysis on. Example: 'aspirin', 'ibuprofen'
queryNoNatural language query about drug safety. Example: 'cardiovascular side effects and warnings'
top_kNoNumber of most relevant text chunks to return (1-10)
filtersNoAdditional filters for data retrieval
conditionNoMedical condition context. Example: 'hypertension', 'pain management'

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations, the description must fully disclose behavioral traits. It lists pipeline steps (fetch, extract, chunk, retrieve, summarize) but does not mention output format, external API calls, rate limits, permissions, or potential side effects. The truncation rationale is vague and unhelpful.

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

Conciseness4/5

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

The description is compact at two sentences. The first sentence delivers the core purpose; the second adds context, though it is slightly awkward. Overall, it is appropriately sized without excessive verbosity.

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

Completeness2/5

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

This is a complex tool with 5 parameters, a nested filters object, no output schema, and no annotations. The description omits essential details such as return value structure, expected latency, and when to prefer this over simpler sibling tools, making the overall picture incomplete.

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?

Schema coverage is 100% and each parameter has a self-explanatory description, so the baseline of 3 applies. The tool description adds no additional context about parameter interactions, defaults, or precedence beyond what the schema provides.

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

Purpose4/5

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

The description states a clear purpose: a RAG pipeline that fetches, extracts, chunks, retrieves, and summarizes FDA drug label data, distinguishing itself from sibling tools that focus on individual aspects. However, the phrase 'Advanced RAG pipeline' is technical jargon and 'to prevent LLM response truncation' is ambiguous, slightly reducing clarity.

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

Usage Guidelines2/5

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

No explicit when-to-use or when-not-to-use guidance is given. The phrase 'in one call' implies it replaces multiple separate calls, but no alternatives are named and no exclusion criteria are provided, leaving the agent to infer usage context.

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

get_drug_adverse_reactionsB

Get adverse reactions information for a specific drug from FDA labels

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of records to return
drug_nameYesName of the drug to search for adverse reactions

TDQS

B3.2/5.0
Behavior2/5

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

No annotations are provided, so the description bears the full burden. It only mentions the data source (FDA labels) but does not describe the return format, handling of missing drugs, pagination behavior, or any constraints. The 'get' verb implies read-only but adds no deeper behavioral insights.

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 a single, focused sentence that directly states the purpose without any filler. It is front-loaded with the verb and resource, making it easy to scan and understand.

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

Completeness2/5

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

With no annotations or output schema, the description is minimal and leaves out important behavioral details, such as what the returned 'adverse reactions information' looks like, how many records are returned, or how it compares to sibling tools. For a simple getter it is minimally sufficient but clearly incomplete.

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?

Both parameters are already fully described in the schema (100% coverage). The description adds context by noting 'specific drug' and 'from FDA labels', but it does not clarify the behavior of the limit parameter beyond what the schema already states. Baseline 3 is appropriate since the schema carries the detailed parameter semantics.

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 identifies the action (get), the resource (adverse reactions information), the specific target (a specific drug), and the source (FDA labels). It naturally differentiates from sibling tools like get_drug_warnings and get_drug_indications.

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

Usage Guidelines2/5

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

There is no guidance on when to use this tool versus alternatives such as search_drug_labels or ae_pipeline_rag. The description only states what it does, not the preferred context or scenarios to avoid.

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

get_drug_indicationsA

Get indications and usage information for a specific drug from FDA labels

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of records to return
drug_nameYesName of the drug to search for indications

TDQS

A4/5.0
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 disclosing behavior. It clearly states the data source (FDA labels) and the type of content returned (indications and usage), but it does not explain behavior around the 'limit' parameter, error handling, or response format. This is adequate for a simple read operation but not rich in detail.

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 a single, concise sentence that conveys the essential purpose without any redundant words. It is well-structured and easy to parse.

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?

For a simple two-parameter read operation, the description is largely complete: it states the action, the resource, and the data source. It does not specify the response shape or the effect of 'limit', but given the absence of an output schema and the basic nature of the tool, this is a minor gap rather than a critical omission.

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?

Schema description coverage is 100%, as both 'drug_name' and 'limit' have descriptive inline comments. The tool description aligns with the primary parameter 'drug_name' but adds no extra meaning beyond what the schema already provides. The baseline of 3 is appropriate.

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 uses a specific verb 'Get' with the resource 'indications and usage information' for 'a specific drug', clearly defining the tool's purpose. It naturally distinguishes itself from sibling tools like get_drug_adverse_reactions and get_drug_warnings by focusing on indications/usage rather than adverse events or warnings.

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

Usage Guidelines4/5

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

The phrase 'for a specific drug' implies that the tool is intended for precise lookups when a drug name is known, contrasting with broader search tools like search_drug_labels. However, it lacks explicit statements about when not to use this tool or explicit naming of alternatives, so it stops short of a 5.

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

get_drug_warningsC

Get warnings and precautions for a specific drug from FDA labels

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of records to return
drug_nameYesName of the drug to search for warnings

TDQS

C2.9/5.0
Behavior2/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 only states the data source ('FDA labels') without explaining return behavior, pagination, the effect of the 'limit' parameter, or any potential side effects. This is minimal and lacks needed context for an agent to anticipate tool behavior.

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 a single, concise sentence with no unnecessary words. It is front-loaded with the verb and resource, making it quick to parse.

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

Completeness2/5

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

The tool has no output schema, and the description does not explain what a warning record looks like, whether the result is a list, or how the limit parameter affects results. While parameters are well-documented, the lack of return-value context makes the description incomplete for an agent to understand the full tool behavior.

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?

The schema description coverage is 100% with clear descriptions for both 'drug_name' and 'limit'. The tool description itself does not add parameter-specific meaning beyond the schema, but the schema already provides sufficient semantics, so the baseline of 3 is appropriate.

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

Purpose4/5

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

The description uses a specific verb ('Get') and resource ('warnings and precautions for a specific drug from FDA labels'), clearly stating the tool's function. It does not explicitly distinguish from sibling tools like 'get_drug_adverse_reactions' or 'get_drug_indications', but the resource is distinct enough to infer the purpose.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It does not mention situations where other tools (e.g., search_drug_labels or get_drug_adverse_reactions) might be more appropriate, nor does it state any exclusions or prerequisites.

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

search_drug_labelsB

Search FDA drug labels using OpenFDA API. Returns drug labeling information including indications, contraindications, warnings, and adverse reactions.

ParametersJSON Schema
NameRequiredDescriptionDefault
skipNoNumber of records to skip (for pagination)
countNoField to count results by. Example: 'openfda.manufacturer_name.exact'
limitNoMaximum number of records to return (1-1000)
searchNoSearch query. Can search by drug name, active ingredient, manufacturer, etc. Example: 'aspirin', 'ibuprofen', 'openfda.brand_name:tylenol'

TDQS

B3.4/5.0
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It does not disclose rate limits, authentication requirements, pagination behavior, or whether the operation is read-only. The return format is only vaguely implied.

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?

A single, information-dense sentence that front-loads the primary purpose and expected return. No wasted words or redundant details.

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

Completeness2/5

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

With no output schema and no annotations, the description should provide more behavioral and usage context. It does not explain how search syntax works, what the response structure looks like, or when to prefer sibling tools. The 4-parameter tool needs more guidance for correct invocation.

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?

The input schema has 100% description coverage for all 4 parameters, including examples. The description adds no additional parameter semantics, so the baseline score of 3 is appropriate.

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 uses a specific verb ('Search FDA drug labels') and clearly states the resource and return content (indications, contraindications, warnings, adverse reactions). This distinguishes it from sibling tools that target specific sections.

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

Usage Guidelines3/5

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

The description implies a general search use case but provides no explicit guidance on when to use this vs. sibling tools like get_drug_adverse_reactions or get_drug_warnings. No exclusions or alternative recommendations are given.

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

Tool Schema Changelog

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

  1. 5 tool updatesv1.0.1
    • First observedae_pipeline_rag
    • First observedget_drug_adverse_reactions
    • First observedget_drug_indications
    • First observedget_drug_warnings
    • First observedsearch_drug_labels

TDQS

A3.6/5.0

Scored across 5 tools

Disambiguation3/5

The three specific getters (adverse reactions, warnings, indications) are clearly distinct, but search_drug_labels and ae_pipeline_rag both fetch broad drug label data, creating some overlap. The descriptions help distinguish them (general search vs. advanced safety pipeline), but the boundary is not entirely sharp.

Naming Consistency4/5

Most tools follow a consistent verb_noun pattern (search_drug_labels, get_drug_adverse_reactions, get_drug_warnings, get_drug_indications). The outlier is ae_pipeline_rag, which uses an acronym and lacks a verb, making it a minor deviation from the otherwise predictable naming convention.

Tool Count5/5

With 5 tools, the server is well-scoped for its purpose of querying FDA drug labels. Each tool covers a meaningful aspect (general search, specific sections, and a comprehensive pipeline) without excessive redundancy or missing core functionality.

Completeness4/5

The tool set covers the primary drug safety sections (adverse reactions, warnings, indications) and provides a full search capability. Minor gaps exist (e.g., no explicit contraindications or dosage getter), but agents can retrieve these via search_drug_labels or ae_pipeline_rag, so the surface is not severely incomplete.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers