使用说明
# PubMed MCP服务器(SSE)
英语| 简体中文
用于生物医学研究人员的MCP服务器,使用以下命令搜索PubMed文献数据库 SSE(服务器发送事件) 运输。
特性
- PubMed搜索:查询世界上最大的生物医学文献数据库
- SSE运输:通过HTTP使用服务器发送的事件
入门指南
配置API密钥
- PubMed API密钥(从https://account.ncbi.nlm.nih.gov/settings/)
设置环境变量
创建 .env 文件:
PUBMED_API_KEY=your_actual_api_key_here
PORT=8080
运行SSE服务器
# Run the prebuilt binary (Windows and Linux builds provided)
./pubmed-mcp
服务器在配置的端口上侦听:
- SSE端点: http://localhost:8080/sse
- 消息端点: http://localhost:8080/message
配置Claude桌面或Cherry Studio
将此代码段添加到MCP客户端配置中:
{
"mcpServers": {
"pubmed-mcp-sse": {
"url": "http://localhost:8080/sse",
"transport": "sse"
}
}
}
从源代码构建
- 克隆项目
git clone https://github.com/Morii0603/PubMed-MCP.git
cd PubMed-MCP
- 安装依赖项
go mod download
- 构建
go build -o pubmed-mcp
可用工具
1.pubmed_search
使用高级过滤选项搜索PubMed数据库。
参数:
query(必需):搜索关键字,支持布尔运算符(AND、OR、NOT)和字段标签,例如“癌症和免疫疗法”、“糖尿病[ti]和治疗[tiab]”max_results(可选):结果数,默认10,最大100date_from(可选):开始日期为YYYY/MM/DD或YYYY格式,例如“2020/01/01”date_to(可选):结束日期,格式为YYYY/MM/DD或YYYY,例如“2024/12/31”date_type(可选):日期类型-“pdat”(发布日期,默认)、“edat”(Entrez日期)、“mdat”(修改日期)text_availability(可选):按文本可用性筛选:abstract-有摘要free_full_text-免费全文可用full_text-全文可用
article_attribute(可选):按文章属性筛选:has_abstract-有摘要has_associated_data-具有关联数据
article_type(可选):按文章类型筛选(逗号分隔):clinical_trial,meta_analysis,randomized_controlled_trial,review,systematic_review,case_reports,editorial,letter,practice_guideline,observational_study,comparative_study
language(可选):按语言筛选(逗号分隔):english,chinese,french,german,japanese,spanish,russian,italian,korean,portuguese
species(可选):按物种筛选:humans,animals,othersex(可选):按性别筛选:male,femaleage(可选):按年龄组筛选(逗号分隔):infant(0-23个月),child(0-18岁),preschool_child(2-5年),adolescent(13-18岁),adult(19岁以上),young_adult(19-24岁),middle_aged(45-64岁),aged(65岁以上),aged_80_over(80岁以上)
exclude_preprints(可选):设置为true以排除预印本文章journal(可选):按日志名称或ISSN筛选sort(可选):排序方式:relevance(默认),pub_date(最新优先),first_author,journal
示例提示:
Search PubMed for "heart failure treatment" with max 20 results, randomized controlled trials only, from 2020 to now, English language, human studies, adult patients, exclude preprints
响应格式:
{
"count": 150,
"query": "cancer immunotherapy",
"results": [
{
"title": "Advances in cancer immunotherapy",
"authors": ["Smith J", "Johnson A", "Brown R"],
"journal": "New England Journal of Medicine",
"pub_date": "2024 Jan",
"pmid": "12345678",
"url": "https://pubmed.ncbi.nlm.nih.gov/12345678/",
"abstract": "This article discusses..."
}
]
}
2.发布_高级_搜索
使用完全支持字段标记和布尔运算符的本地查询语法执行高级PubMed搜索。
参数:
query(必填):带字段标签和布尔运算符的PubMed原生查询max_results(可选):结果数,默认10,最大100sort(可选):排序顺序
字段标签参考:
| 标签 | 描述 | 示例 |
|---|---|---|
[ti] |
标题 | cancer[ti] |
[tiab] |
标题/摘要 | diabetes[tiab] |
[au] 作者 Smith J[au] |
||
[1au] |
第一作者 | Wang Y[1au] |
[lastau] |
最后作者 | Zhang L[lastau] |
[ad] |
隶属关系 | Harvard[ad] |
[mh] |
MeSH条款 | breast neoplasms[mh] |
[majr] |
MeSH主题 | diabetes mellitus[majr] |
[pt] |
出版物类型 | Meta-Analysis[pt] |
[ta] |
期刊缩写 | N Engl J Med[ta] |
[journal] |
期刊全名 | Nature[journal] |
[la] |
语言 | english[la] |
[pdat] |
出版日期 | 2020/01/01:2024/12/31[pdat] |
[sb] |
子集 | free full text[sb] |
[doi] |
DOI | 10.1056/NEJMoa2401234[doi] |
高级搜索示例:
# 1. Author + Title combination
Smith J[1au] AND cancer[ti]
# 2. MeSH term search
breast neoplasms[mh] AND tamoxifen[mh]
# 3. Date range
("2020/01/01"[pdat] : "2024/12/31"[pdat]) AND covid-19[tiab]
# 4. Complex combined search
(diabetes[mh] OR diabetes mellitus[tiab]) AND (meta-analysis[pt] OR systematic review[pt]) AND english[la]
# 5. Exclude preprints
cancer immunotherapy NOT preprint[pt]
3.出版
获取 详细文章信息 使用EFetch API从PubMed获得。返回全面的元数据,包括完整摘要、完整作者姓名、期刊详细信息、DOI、PMCID等。
参数:
pmids(必填):一个或多个PubMed ID(PMIDs),用逗号分隔,例如“12345678”或“1234567887654321”
示例提示:
Fetch detailed information for PubMed articles 12345678 and 87654321
响应格式:
{
"articles": [
{
"pmid": "12345678",
"title": "Advances in cancer immunotherapy",
"authors": ["Smith John", "Johnson Anne", "Brown Robert"],
"journal": "New England Journal of Medicine",
"journal_abbr": "N Engl J Med",
"pub_date": "2024 Jan 15",
"abstract": "Full abstract text here...",
"doi": "10.1056/NEJMoa2401234",
"pmcid": "PMC1234567",
"url": "https://pubmed.ncbi.nlm.nih.gov/12345678/"
}
],
"count": 1
}
4.出版物_摘要
获取 文章摘要信息 使用ESummary API从PubMed获得。返回简明的元数据,包括标题、作者、出版日期、期刊详细信息、卷、期、页和其他书目信息(没有完整的摘要文本)。
参数:
pmids(必填):一个或多个PubMed ID(PMIDs),用逗号分隔,例如“12345678”或“1234567887654321”
示例提示:
Get summaries for PubMed articles 12345678, 87654321, and 11223344
响应格式:
{
"summaries": [
{
"pmid": "12345678",
"title": "Advances in cancer immunotherapy",
"authors": ["Smith J", "Johnson A", "Brown R"],
"last_author": "Brown Robert",
"source": "N Engl J Med",
"full_journal_name": "The New England journal of medicine",
"pub_date": "2024 01",
"epub_date": "2024 01 10",
"volume": "390",
"issue": "2",
"pages": "123-135",
"doi": "10.1056/NEJMoa2401234",
"pmcid": "PMC1234567",
"issn": "0028-4793",
"pub_types": ["Journal Article", "Review"],
"languages": ["eng"],
"has_abstract": true,
"url": "https://pubmed.ncbi.nlm.nih.gov/12345678/"
}
],
"count": 1
}
备注
- API关键安全:不要承诺
.env文件 - 速率限制:PubMed API密钥使用率受限
- 网络:需要稳定的PubMed互联网接入
- SSE连接:确保防火墙允许SSE端口上的HTTP
故障排除
问题:无法访问PubMed
- 验证API密钥是否正确且处于活动状态
- 检查网络连接
问题:SSE服务器无法启动
- 确认端口空闲
- 确保环境变量设置正确
- 检查日志以了解详细信息
问题:MCP客户端无法连接
- 确认服务器正在运行
- 检查URL配置(http://localhost:8080/sse)
- 确保运输设置为sse
许可证
MIT许可证
资源
- https://pubmed.ncbi.nlm.nih.gov/
- https://www.ncbi.nlm.nih.gov/books/NBK25501/
- https://modelcontextprotocol.io/
- https://github.com/mark3labs/mcp-go