PubMed MCP Server
Provides tools for searching PubMed literature, retrieving article details, extracting key information, finding related articles, managing cache, and downloading open-access full-text PDFs via the PubMed, PMC, and Unpaywall APIs.
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 Serversearch for recent articles on CRISPR"
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: PubMed MCP Server
传输模式
模式 | 适用场景 | 启动方式 |
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 状态检测 | 无 |
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.
| Name | Required | Description | Default |
|---|---|---|---|
| pmid | Yes | PubMed article ID. | |
| sections | No | Which sections to extract. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The annotations already declare readOnlyHint=true, idempotentHint=true, and openWorldHint=true, so the safety profile is covered and the description does not need to repeat it. The description adds the token-efficiency observation and the scoping of sections, but does not disclose any deeper behavioral details such as output shape, error behavior, or section-level edge cases. This is adequate but not rich.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Three sentences with no filler: the purpose is front-loaded, the usage condition follows immediately, and the efficiency advantage is stated once. Every sentence contributes a distinct piece of guidance.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool has only two parameters, the schema covers both fully, and the annotations cover read-only and idempotent behavior. The description is sufficient for deciding when to call it. It falls slightly short of 5 because there is no output schema and the description does not describe the exact structure or format of the extracted sections, which would be useful for this kind of extraction tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% coverage, with clear descriptions for 'pmid' and enumerated 'sections'. The description mentions examples of sections ('author details, structured abstract, keywords, DOI) that overlap with those enum values, but adds little meaning beyond what the schema already provides. Baseline 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb ('Extract') with a clear resource ('specific structured sections from a PubMed article') and a concrete scope ('only certain aspects...rather than the full record'). It also differentiates from pubmed_get_details by naming the token-efficiency angle, so an agent can distinguish it immediately.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It explicitly says to use this tool 'when you need only certain aspects' and contrasts it with 'the full record'. It also names the alternative tool, pubmed_get_details, and the condition under which this one is preferable ('targeted extraction'), giving an agent actionable selection criteria.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| pmids | Yes | Single PMID string or array of PMIDs. | |
| format | No | Output format. | standard |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description adds behavioral detail beyond the readOnlyHint, idempotentHint, and openWorldHint annotations: it accepts a single PMID or an array up to 20, and returns fields such as abstract, authors, journal, DOI, and MeSH terms. It does not cover error behavior or rate limits, but annotations already establish the safety profile.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences with no filler. The main purpose and input mode are front-loaded, the return content is summarized efficiently, and the usage condition completes the guidance without redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a straightforward read-only lookup tool, the description covers input shape, batch limit, return content, and when to use it. The only notable gap is that the 'format' enum semantics are not described, leaving the agent to infer what 'concise' versus 'detailed' means.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the baseline is 3. The description restates the PMID input forms and adds useful output context, but it does not explain the 'format' parameter values (concise, standard, detailed) beyond the schema's minimal 'Output format' label.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a specific verb and resource: 'Retrieve complete metadata for specific PubMed articles by PMID.' It clearly distinguishes this tool from pubmed_search, pubmed_find_related, and pubmed_extract_info by emphasizing PMID-based retrieval of full records.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly states when to use it: 'Use when you have specific PMIDs from a previous search or citation and need the full record.' It provides clear context but does not explicitly name alternatives or state when not to use it.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| action | No | Cache operation to perform. | stats |
| target | No | Which cache layer to operate on. | all |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The annotations already flag destructiveHint=true, and the description adds meaningful nuance by specifying that 'clean' removes expired entries while 'clear' wipes a cache layer, and 'stats' is a read-only operation. This helps the agent understand the varying destructiveness of each action beyond the single annotation flag.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is compact, front-loaded with the core purpose, and uses a clean pattern of action-to-purpose mapping. Every sentence contributes necessary operational guidance with no filler or redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a two-parameter tool with enum-restricted values and a clear maintenance scope, the description covers the available actions, their effects, and the target layer concept. There is no output schema, but the described behavior is sufficient for an agent to select and invoke the tool correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema already provides full documentation for both parameters with enum values and descriptions, so the baseline is 3. The description enriches the 'action' parameter by explaining the real-world intent of each value, but it does not add material meaning for 'target' beyond what the schema states.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly identifies a cache-management tool with specific operations: viewing statistics, cleaning expired entries, and clearing cache layers. This clearly distinguishes it from the sibling PubMed search tools, which perform content queries rather than cache maintenance.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives explicit guidance on which action value to use for each intended outcome: stats for hit rates/storage, clean for expired entries, clear for wiping a layer. There is no explicit 'when not to use' statement, but the distinction from sibling tools is evident and the action-level guidance is clear.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | PubMed search query. Supports Boolean logic and MeSH terms. | |
| format | No | Response detail level. compact=minimal, standard=balanced, detailed=full metadata+structured abstract. | standard |
| sort_by | No | Sort order for results. | relevance |
| days_back | No | Only return articles published within the last N days. 0 = no limit. | |
| max_results | No | Number of results to return (1-100). |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already declare readOnlyHint, idempotentHint, and openWorldHint, so safety is covered. The description adds value by disclosing that results include metadata, abstracts, and citations, and by mentioning supported query features like Boolean operators and MeSH terms. No contradictions with annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is four sentences, front-loaded with the core purpose, and every sentence provides useful information without redundancy. It is compact and well-structured.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description covers the main output contents and several key parameters, and the schema covers the remaining parameters. With no output schema, the description explains that results contain metadata, abstracts, and citations. It could arguably mention sort_by or max_results usage, but it is otherwise complete for a search tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, providing a baseline of 3. The description adds meaningful extra detail beyond the schema for query, mentioning field tags like [Title] and [Author], and gives usage guidance for format and days_back, which helps the agent choose parameter values.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states 'Search PubMed biomedical literature database' and describes the output as 'articles matching your query with metadata, abstracts, and citations.' This specific verb+resource phrasing distinguishes it from sibling tools like pubmed_get_details or pubmed_find_related.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear in-tool guidance for format and days_back, but it does not explicitly say when to use this tool versus alternatives like pubmed_get_details or pubmed_find_related. Usage guidance is mostly implied by the search-oriented purpose.
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.
5 tool updates
v3.0.0- First observed
pubmed_extract_info - First observed
pubmed_find_related - First observed
pubmed_get_details - First observed
pubmed_manage_cache - First observed
pubmed_search
TDQS
Scored across 5 tools
Each tool has a clear primary purpose: search, fetch full records, extract specific fields, find related articles, and manage cache. However, pubmed_get_details and pubmed_extract_info could be confused by an agent, as both retrieve article information, though the descriptions differentiate full records from targeted extraction.
All tool names follow a consistent pattern: 'pubmed_' prefix followed by a verb or verb_noun phrase (search, get_details, extract_info, find_related, manage_cache). The naming is uniform, snake_case, and clearly indicates the operation performed.
Five tools is a well-scoped set for a PubMed MCP server, covering core literature search and retrieval without redundancy. The count feels appropriately moderate, not overwhelming or thin.
The toolset covers the full typical workflow: search for articles, retrieve full details, extract specific sections, discover related articles, and manage cache for efficiency. No obvious critical gaps exist for a literature search domain.
Maintenance
Related MCP Connectors
Search PubMed/Europe PMC, fetch articles and full text (PMC/EPMC/Unpaywall), citations, MeSH terms.
PubMed MCP — wraps the NCBI E-utilities API (biomedical literature, free, no auth)
Search biomedical literature, get article details, find related articles, and explore MeSH terms
Search biomedical papers, inspect publication records, and traverse citation or semantic graphs.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that provides direct access to PubMed and PubMed Central via the NCBI E-utilities API. It enables AI models to search biomedical literature, retrieve detailed article metadata, and download open-access full texts.5MIT
- AlicenseAqualityDmaintenanceEnables AI agents to search and read PubMed academic literature directly, without requiring an NCBI API key.21MIT
- AlicenseNot gradedqualityAmaintenanceEnables PubMed literature search, metadata retrieval, BibTeX export, and evidence table generation for biomedical research agents.2MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to retrieve and search open-access life-sciences and biomedical journal articles from eLife via MCP.3 npmMIT