PubMed MCP Server
Provides tools for searching PubMed literature, retrieving article details, finding related articles, and downloading open-access full texts, enabling AI agents to access structured biomedical literature data.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@PubMed MCP Server search PubMed for recent studies on GLP-1 receptor agonists and type 2 diabetes"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
PubMed MCP Server v3.0
为 LLM Agent 提供结构化 PubMed 文献数据的 MCP 服务器。Agent 友好的响应模型,专注数据提供,分析交给 LLM。
LLM Agent <--MCP--> PubMed MCP Server <--API--> PubMed / PMC / Unpaywall核心能力: 文献搜索 / 智能缓存 / OA 全文下载 / Agentic 响应模型
快速开始
前置要求: Node.js v18.0.0+
1. 安装
# npm 全局安装
npm install -g mcp-pubmed-llm-server
# 或从源码构建
git clone git@github.com:PancrePal-xiaoyibao/mcp-pubmed-server-pancrpal.git
cd mcp-pubmed-server-pancrpal
npm install && npm run build2. 配置
cp .env.example .env编辑 .env:
PUBMED_API_KEY=你的NCBI_API密钥 # 可选,https://www.ncbi.nlm.nih.gov/account/settings/
PUBMED_EMAIL=你的邮箱 # 可选(建议填写)
ABSTRACT_MODE=quick # quick(1500字符) | deep(6000字符)
FULLTEXT_MODE=disabled # disabled | enabled | auto说明: API Key 和 Email 均非必填。无 Key 时匿名运行(3 次/秒),有 Key 时 10 次/秒。
3. 运行
# npm 包
mcp-pubmed-llm-server
# 或
npx mcp-pubmed-llm-server
# 源码开发
npm run dev
# 源码生产
npm run build && npm startRelated MCP server: mcp-elife
传输模式
模式 | 适用场景 | 启动方式 |
stdio | 本地 MCP 客户端集成 |
|
Streamable HTTP | 服务端远程部署 |
|
stdio 模式(默认)
npm start
# 或
node dist/index.js --mode=stdioStreamable HTTP 模式
npm run start:http
# 或
node dist/index.js --mode=streamableHttpDocker 部署:
cd docker
cp .env.example .env # 编辑填入配置
docker compose up -d --build验证:
curl http://localhost:8745/health
# {"status":"ok","mode":"streamableHttp","sessions":0}端点:
POST /mcp— MCP 协议消息GET /mcp— SSE 事件流DELETE /mcp— 关闭会话GET /health— 健康检查
MCP 客户端配置
Claude Desktop / Claude Code / Cline
{
"mcpServers": {
"pubmed": {
"command": "npx",
"args": ["-y", "mcp-pubmed-llm-server"],
"env": {
"PUBMED_API_KEY": "你的API密钥(可选)",
"PUBMED_EMAIL": "你的邮箱(可选)",
"ABSTRACT_MODE": "deep",
"FULLTEXT_MODE": "enabled"
}
}
}
}配置文件位置:
Claude Desktop:
~/Library/Application Support/Claude/claude_desktop_config.json(macOS)Claude Code:
~/.claude/config.jsonCline: VS Code 设置中的 MCP Servers
Cherry Studio
stdio 模式: 同上配置,type 设为 stdio
streamableHttp 模式: type 设为 streamableHttp,baseUrl 设为 http://<服务器IP>:8745/mcp
工具列表(8 个)
文献搜索
工具 | 说明 | 关键参数 |
| 文献搜索,支持 Boolean/MeSH 和分页 |
|
| 获取 PMID 完整信息(单个或批量) |
|
| 提取论文关键信息段落 |
|
| 查找相关/综述文献 |
|
缓存管理
工具 | 说明 | 关键参数 |
| 缓存统计、清理、清空 |
|
全文下载(需 FULLTEXT_MODE=enabled)
工具 | 说明 | 关键参数 |
| 检测 OA 状态和全文可用性 |
|
| 下载全文 PDF(单篇或批量) |
|
| 系统环境和 API Key 状态检测 | 无 |
搜索分页
pubmed_search 的 page 从 1 开始,每页最多返回 100 条。响应的
metadata.pagination 会给出当前页、总页数以及下一页页码。
{
"query": "\"Zhang Y\"[Author]",
"max_results": 100,
"page": 2,
"sort_by": "date"
}Agentic 响应模型
每个工具返回统一的 AgentResponse<T> 结构,为 AI Agent 优化:
{
"status": "success",
"data": { ... },
"metadata": {
"tool": "pubmed_search",
"executionMs": 1234,
"timestamp": "2025-01-01T00:00:00.000Z",
"pagination": { "total": 500, "returned": 20, "hasMore": true }
},
"suggestions": [
{
"tool": "pubmed_get_details",
"reason": "Get full metadata for specific articles of interest.",
"parameters": { "pmids": ["12345678"] }
}
]
}status— 成功/错误状态data— 类型化的返回数据metadata— 执行上下文(耗时、分页、缓存状态)suggestions— Agent 下一步操作建议(工具名 + 原因 + 参数)
API Key 池配置
支持多个 NCBI API Key 轮询/主备/随机负载均衡。
在项目根目录创建 api-keys.json(参见 api-keys.json.example):
{
"keys": [
{ "api_key": "KEY_1", "email": "user1@example.com" },
{ "api_key": "KEY_2", "email": "user2@example.com" }
],
"strategy": "round-robin"
}策略 | 说明 |
| 轮询(默认) |
| 主备切换 |
| 随机负载均衡 |
优先级:
api-keys.json> 环境变量 > 匿名模式健康管理: 连续 3 次失败自动下线,60 秒冷却后恢复
项目结构
src/
├── index.ts # 入口点
├── config.ts # 配置常量 + 环境变量
├── server.ts # MCP Server 编排器
├── types/ # TypeScript 类型定义
│ ├── article.ts # Article, SearchResult, OAInfo
│ ├── responses.ts # AgentResponse<T>, makeResponse/makeError
│ └── index.ts
├── api/
│ ├── pubmed-client.ts # PubMed EUtilities 客户端
│ └── key-pool.ts # API Key 号池(轮询/主备/随机)
├── cache/
│ ├── memory-cache.ts # 内存 LRU 缓存(5 分钟,100 条上限)
│ └── file-cache.ts # 文件持久化缓存(30 天过期)
├── services/
│ ├── fulltext.ts # OA 检测 + PDF 下载
│ └── system.ts # 系统环境检测
├── tools/
│ ├── definitions.ts # MCP 工具 Schema(8 个工具)
│ └── handlers.ts # 工具路由 + 处理逻辑
├── transport/
│ ├── stdio.ts # stdio 传输
│ └── streamable-http.ts # HTTP 传输(Express)
└── utils/
└── formatter.ts # 文章格式化(compact/standard/detailed)故障排除
问题 | 解决方案 |
依赖缺失 |
|
PubMed API 调用失败 | 检查网络;有 Key 时确认 Key 有效 |
Key 池全部不可用 | 检查 |
端口被占用 |
|
Docker 健康检查失败 | 检查 |
许可证
MIT License
Available Tools
5 toolspubmed_extract_infoARead-onlyIdempotent
Extract specific structured sections from a PubMed article. Use when you need only certain aspects (author details, structured abstract, keywords, DOI) rather than the full record. More token-efficient than get_details for targeted extraction.
Inputs: pmid (required), sections.
pubmed_get_detailsARead-onlyIdempotent
Retrieve complete metadata for specific PubMed articles by PMID. Accepts a single PMID or array of PMIDs (up to 20). Returns full article records including abstract, authors, journal, DOI, MeSH terms. Use when you have specific PMIDs from a previous search or citation and need the full record.
Inputs: pmids (required), format.
pubmed_manage_cacheADestructive
View cache statistics or perform maintenance. Use action="stats" to check hit rates and storage usage. Use action="clean" to remove expired entries, or action="clear" to wipe a specific cache layer.
Inputs: action, target.
pubmed_searchARead-onlyIdempotent
Search PubMed biomedical literature database. Returns articles matching your query with metadata, abstracts, and citations. Supports Boolean operators (AND, OR, NOT), MeSH terms, and field tags like [Title], [Author]. Use format="compact" for quick overviews when browsing, "detailed" for in-depth analysis. Use days_back to limit to recent publications.
Inputs: query (required), page, format, sort_by, +2 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Most tools have clearly distinct roles: search, related-article discovery, full-record retrieval, targeted extraction, and cache maintenance. However, pubmed_get_details and pubmed_extract_info both operate on specific articles and could be confused, though the descriptions clarify that get_details is for full records and extract_info is for targeted sections.
All tool names follow a consistent pattern with the 'pubmed_' prefix followed by a verb phrase: search, find_related, get_details, extract_info, manage_cache. The naming convention is uniform, readable, and makes the action of each tool predictable.
Five tools is well-scoped for a PubMed literature search and retrieval server. Each tool has a clear purpose, and the count is neither too thin nor overwhelming for the domain.
The server covers the core PubMed workflow: searching, finding related papers, retrieving full details, and extracting specific sections. Minor gaps exist such as citation formatting or advanced query helpers, but these are not essential for the primary search-and-retrieval use case.
Maintenance
Related MCP Connectors
Search PubMed/Europe PMC, fetch articles and full text (PMC/EPMC/Unpaywall), citations, MeSH terms.
Search biomedical literature, get article details, find related articles, and explore MeSH terms
PubMed MCP — wraps the NCBI E-utilities API (biomedical literature, free, no auth)
Search biomedical papers, inspect publication records, and traverse citation or semantic graphs.
Related MCP Servers
- AlicenseAqualityCmaintenanceProvides structured PubMed literature data for LLM agents, supporting search, caching, and open-access full-text downloads via the MCP protocol.536 npm11Apache 2.0
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to retrieve and search open-access life-sciences and biomedical journal articles from eLife via MCP.81 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables MCP agents to search academic literature across multiple scholarly engines, explore papers, authors, and references, inspect abstracts and full text, maintain saved paper collections, and export citations, BibTeX, abstracts, or full-text corpora.1Apache 2.0
- AlicenseAqualityBmaintenanceEnables AI agents to search 1m+ open-access papers, standards, textbooks, and legal documents, resolve identifiers such as RFCs, DOIs, and legal citations, download PDFs, and retrieve citations and metadata through MCP tools.9MIT