A PubMed MCP server implemented by Golang.
PubMed MCP Server (SSE)
English | 简体中文
An MCP server for biomedical researchers that searches the PubMed literature database using SSE (Server-Sent Events) transport.
Features
- PubMed search: Query the world's largest biomedical literature database
- SSE transport: Uses Server-Sent Events over HTTP
Getting Started
Configure API key
- PubMed API Key (obtain from https://account.ncbi.nlm.nih.gov/settings/)
Set environment variables
Create a .env file:
PUBMED_API_KEY=your_actual_api_key_here
PORT=8080
Run the SSE server
# Run the prebuilt binary (Windows and Linux builds provided)
./pubmed-mcp
The server listens on the configured port:
- SSE endpoint: http://localhost:8080/sse
- Message endpoint: http://localhost:8080/message
Configure Claude Desktop or Cherry Studio
Add this snippet to your MCP client config:
{
"mcpServers": {
"pubmed-mcp-sse": {
"url": "http://localhost:8080/sse",
"transport": "sse"
}
}
}
Build from source
- Clone the project
git clone https://github.com/Morii0603/PubMed-MCP.git
cd PubMed-MCP
- Install dependencies
go mod download
- Build
go build -o pubmed-mcp
Available tools
1. pubmed_search
Search the PubMed database with advanced filtering options.
Parameters:
query(required): Search keywords, supports boolean operators (AND, OR, NOT) and field tags, e.g., "cancer AND immunotherapy", "diabetes[ti] AND treatment[tiab]"max_results(optional): Number of results, default 10, max 100date_from(optional): Start date in YYYY/MM/DD or YYYY format, e.g., "2020/01/01"date_to(optional): End date in YYYY/MM/DD or YYYY format, e.g., "2024/12/31"date_type(optional): Date type - "pdat" (publication date, default), "edat" (Entrez date), "mdat" (modification date)text_availability(optional): Filter by text availability:abstract- has abstractfree_full_text- free full text availablefull_text- full text available
article_attribute(optional): Filter by article attributes:has_abstract- has abstracthas_associated_data- has associated data
article_type(optional): Filter by article type (comma-separated):clinical_trial,meta_analysis,randomized_controlled_trial,review,systematic_review,case_reports,editorial,letter,practice_guideline,observational_study,comparative_study
language(optional): Filter by language (comma-separated):english,chinese,french,german,japanese,spanish,russian,italian,korean,portuguese
species(optional): Filter by species:humans,animals,othersex(optional): Filter by sex:male,femaleage(optional): Filter by age group (comma-separated):infant(0-23 months),child(0-18 years),preschool_child(2-5 years),adolescent(13-18 years),adult(19+ years),young_adult(19-24 years),middle_aged(45-64 years),aged(65+ years),aged_80_over(80+ years)
exclude_preprints(optional): Set to true to exclude preprint articlesjournal(optional): Filter by journal name or ISSNsort(optional): Sort by:relevance(default),pub_date(newest first),first_author,journal
Example prompt:
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
Response format:
{
"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_advanced_search
Execute advanced PubMed search using native query syntax with full support for field tags and boolean operators.
Parameters:
query(required): PubMed native query with field tags and boolean operatorsmax_results(optional): Number of results, default 10, max 100sort(optional): Sort order
Field Tags Reference:
| Tag | Description | Example |
|-----|-------------|---------|
| [ti] | Title | cancer[ti] |
| [tiab] | Title/Abstract | diabetes[tiab] |
| [au] | Author | Smith J[au] |
| [1au] | First Author | Wang Y[1au] |
| [lastau] | Last Author | Zhang L[lastau] |
| [ad] | Affiliation | Harvard[ad] |
| [mh] | MeSH Terms | breast neoplasms[mh] |
| [majr] | MeSH Major Topic | diabetes mellitus[majr] |
| [pt] | Publication Type | Meta-Analysis[pt] |
| [ta] | Journal Abbreviation | N Engl J Med[ta] |
| [journal] | Full Journal Name | Nature[journal] |
| [la] | Language | english[la] |
| [pdat] | Publication Date | 2020/01/01:2024/12/31[pdat] |
| [sb] | Subset | free full text[sb] |
| [doi] | DOI | 10.1056/NEJMoa2401234[doi] |
Advanced Search Examples:
# 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. pubmed_fetch
Fetch detailed article information from PubMed using EFetch API. Returns comprehensive metadata including full abstract, complete author names, journal details, DOI, PMCID, etc.
Parameters:
pmids(required): One or more PubMed IDs (PMIDs) separated by commas, e.g., "12345678" or "12345678,87654321"
Example prompt:
Fetch detailed information for PubMed articles 12345678 and 87654321
Response format:
{
"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. pubmed_summary
Get article summary information from PubMed using ESummary API. Returns concise metadata including title, authors, publication date, journal details, volume, issue, pages, and other bibliographic information (without full abstract text).
Parameters:
pmids(required): One or more PubMed IDs (PMIDs) separated by commas, e.g., "12345678" or "12345678,87654321"
Example prompt:
Get summaries for PubMed articles 12345678, 87654321, and 11223344
Response format:
{
"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
}
Notes
- API key safety: Do not commit the
.envfile - Rate limits: PubMed API key usage is rate-limited
- Network: Requires stable internet access to PubMed
- SSE connectivity: Ensure firewalls allow HTTP on the SSE port
Troubleshooting
Issue: Cannot reach PubMed
- Verify the API key is correct and active
- Check network connectivity
Issue: SSE server fails to start
- Confirm the port is free
- Ensure environment variables are set correctly
- Inspect logs for details
Issue: MCP client cannot connect
- Confirm the server is running
- Check the URL config (http://localhost:8080/sse)
- Ensure transport is set to sse
License
MIT License
Resources
- https://pubmed.ncbi.nlm.nih.gov/
- https://www.ncbi.nlm.nih.gov/books/NBK25501/
- https://modelcontextprotocol.io/
- https://github.com/mark3labs/mcp-go