Skip to main content

pubmed-mcp

A minimal, auditable Model Context Protocol server for PubMed via NCBI E-utilities. Built for evidence synthesis: the server returns only what NCBI returns, and flags everything else.

Quick install

pip install pubmed-access-mcp

Or run without installing:

uvx pubmed-access-mcp

Tools

Tool Purpose
search_pubmed(query, max_results=20, sort="relevance", date_from=None, date_to=None) Returns PMIDs, total_matches, and query_translation (how PubMed parsed your query; log it in your methods).
fetch_abstracts(pmids) Returns title, authors, journal, date, DOI, publication types, retraction-notice flag, abstract (section labels kept), URL, up to 200 PMIDs per call.
search_with_access(query, max_results<=100, ...) Search, then list each hit as open-access PDF / landing page only / no open access found / unchecked.
check_access(pmids) Same classification for given PMIDs.
download_pdfs(pmids, folder=None) Saves open-access PDFs as PMID.pdf; paywalled papers are skipped, never bypassed.

Guarantees

  • Missing field => literal Data not provided in PubMed abstract. Nothing is inferred or paraphrased.
  • Requested PMIDs that NCBI did not return are listed in not_found.
  • publication_types is NCBI's own tag. No evidence level (CEBM/GRADE) is assigned by the server: abstracts alone are not enough to grade evidence.
  • has_retraction_notice is true only if the record carries an NCBI "RetractionIn" link.
  • Respects NCBI rate limits (3 req/s, 10 req/s with an API key) with retry/backoff.

Open access and PDFs

Sources are Unpaywall (via DOI) and PubMed Central (via PMCID). Set UNPAYWALL_EMAIL or NCBI_EMAIL. NO_OPEN_ACCESS_FOUND means no legal free copy is indexed, not that an institution cannot reach it. Every file is checked to start with %PDF and bot-check pages are rejected. Files go to PUBMED_PDF_DIR (default ~/pubmed_pdfs). No paywall bypass.

Register in your MCP client

After pip install pubmed-access-mcp

Add to your MCP client config (Claude Desktop, Antigravity, Cursor, etc.):

{"mcpServers": {"pubmed-scraper": {
  "command": "pubmed-access-mcp",
  "args": [],
  "env": {"NCBI_EMAIL": "you@example.com", "UNPAYWALL_EMAIL": "you@example.com"}}}}

With uvx (no install needed)

{"mcpServers": {"pubmed-scraper": {
  "command": "uvx",
  "args": ["pubmed-access-mcp"],
  "env": {"NCBI_EMAIL": "you@example.com", "UNPAYWALL_EMAIL": "you@example.com"}}}}

From source (development)

git clone https://github.com/ahsanmandhar-ui/pubmed-mcp.git
cd pubmed-mcp
python -m venv .venv && source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -r requirements.txt

Then point your MCP config to the absolute path of .venv/bin/python (or .venv\Scripts\python.exe) and server.py.

Optional env: NCBI_API_KEY (free, raises rate limit), NCBI_EMAIL (NCBI usage policy asks for one), NCBI_TOOL.

Put your real NCBI_API_KEY / email only in your GLOBAL config, never in a file you commit.

Install (for development / running tests)

python -m venv .venv && source .venv/bin/activate      # Windows: .venv\Scripts\activate
pip install -r requirements.txt
python tests/test_server.py                             # offline tests (synthetic fixture, no network)
python tests/test_access.py                             # offline open-access tests

Limitations

  • Abstract-level data only; no full text. Not a substitute for a full systematic-review search strategy across Embase, Cochrane, etc.
  • Search quality depends on your query syntax (MeSH, field tags); PubMed may translate it unexpectedly, so check query_translation.
  • Open-access coverage varies, and some publishers block automated downloads.
  • Live NCBI, Unpaywall, and PDF download behaviour was not covered by automated tests (they use synthetic fixtures).

License

Apache License 2.0, see LICENSE. Copyright 2024 ahsanmandhar-ui.

Metadata

Release files for pubmed-access-mcp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pubmed-access-mcp 0.1.0
File Size Uploaded
pubmed_access_mcp-0.1.0.tar.gz 17.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pubmed-access-mcp 0.1.0
File Interpreter ABI Platform
pubmed_access_mcp-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 33.4 kB

Release files / pubmed_access_mcp-0.1.0.tar.gz

Download URL pubmed_access_mcp-0.1.0.tar.gz
Size 17.5 kB
Tags Source
SHA-256 checksum
How to use checksums
931ee69fc15fdc5dcecf540d9950dbf9f870681e9fad9444df62ed74a643ef6c
BLAKE2b-256 checksum
How to use checksums
db6fbdbf688e26b726bdd95be4d4a9a47a65c902d5fdb0a66002e13320ff57ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / pubmed_access_mcp-0.1.0-py3-none-any.whl

Download URL pubmed_access_mcp-0.1.0-py3-none-any.whl
Size 15.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
05b37a3ccb75543f6a142fdaef9ff92dad427d89c91adea238699e8e6cb7711b
BLAKE2b-256 checksum
How to use checksums
e2e6608caea1c92aca74d5f6ed2e1fdaf03ca6ad15f4a046e6ebfa7d8565b606
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page