@cyanheads/pubmed-mcp-server
Search PubMed/Europe PMC, fetch articles and full text (PMC/EPMC/Unpaywall), citations, MeSH terms via MCP. STDIO or Streamable HTTP.
11 Tools • 1 Resource • 1 Prompt
Overview
Biomedical literature from PubMed, PubMed Central, and Europe PMC. Search it, fetch metadata and full text, resolve identifiers and partial citations, format references, and ground queries in MeSH vocabulary. Runs as a stdio process, a local Streamable HTTP server, or the public hosted endpoint above.
Resources
Prompts
Capability reference
pubmed_search_articles tool
- Full PubMed query syntax plus filters (author, journal, MeSH, publication type, language, species, abstract, free full text) and publication/modification/Entrez date ranges
- Up to 1,000 results per page and offsets up to 9,998, or
maxResults: 0 for the match count alone; summaryCount adds briefs for up to 50 hits
- Reports
totalCount, the effectiveQuery PubMed ran, and the appliedFilters
- Rejects blank filter values, impossible dates, and reversed date ranges before PubMed is called
pubmed_fetch_articles tool
- Up to 200 PMIDs per call; misses are listed in
unavailablePmids
- Abstract, authors, journal, DOI, publication types, linked retraction/erratum/comment notices, and links; MeSH terms on by default, grants via
includeGrants
recordType separates journal articles from Bookshelf chapters and books; opt-in maxResponseCharacters defers overflow to deferred.ids
pubmed_fetch_fulltext tool
pmcids, pmids, and dois in any mix, up to 10 distinct identifiers per call, tried against PMC, then Europe PMC, then Unpaywall (needs UNPAYWALL_EMAIL); an article several of them name is fetched and returned once, and viaSource names the tier that answered
source: "pmc" returns sections, tables, and figures; source: "unpaywall" returns a best-effort HTML or PDF text body
- Misses carry a typed
reason and triedTiers; sections, maxCharacters, overflowMode, and maxResponseCharacters bound the response, and truncation reports what was cut
- Adds preprints (
PPR), patents (PAT), and Agricola (AGR) to MED and PMC; defaults to MED, PMC, PPR
- Cursor pagination via
cursorMark / nextCursorMark, up to 100 per page; abstracts arrive as 400-character snippets
- Not registered when
EUROPEPMC_ENABLED=false
- Up to 25 records per call, addressed by a search hit's
source + epmcId, with the full abstract; unresolved ids land in notFound; opt-in maxResponseCharacters defers overflow to deferred.records
- Not registered when
EUROPEPMC_ENABLED=false
- Up to 50 PMIDs per call, in any mix of
apa, mla, bibtex, ris, and vancouver
- Bookshelf records cite as edited books, each chapter dated by its own last revision or contribution date; PMIDs that can't be fetched are reported as unavailable
similar, cited_by, or references, up to 50 per page with offset pagination
- Falls back to Europe PMC, then OpenAlex, and names the provider that answered; fails as
all_providers_failed if none can
- Returns
original, corrected, and hasSuggestion, fixing every misspelled token in one call
- Run it after a zero-hit or thin search, then retry
pubmed_search_articles with corrected
- Descriptors by name or free-text term, with an exact heading match pinned first; up to 50 per page, continued via
nextOffset
- Records carry
meshId; includeDetails (default on) adds tree numbers, scope notes, and entry terms
- Up to 25 partial citations per call; a journal or a four-digit year is required, and volume, first page, and author sharpen the match
- Each is matched independently and comes back
matched, not_found, or ambiguous, with recovery detail
- Up to 50 ids per call, all of one declared
idType (doi, pmid, pmcid); only PMC-indexed articles resolve
- One success or error row per id, in order, so a partial batch never fails
pubmed://database/info resource
- Live EInfo call for the
pubmed database, returned as application/json
count, lastUpdate, and fields[], whose names are the search tags pubmed_search_articles accepts
research_plan prompt
- Arguments:
title, goal, and keywords required; organism and includeAgentPrompts optional
- Returns a four-phase research plan;
includeAgentPrompts: "true" adds an agent-guidance block under each of its nine sub-steps, two of which point at tools: the literature review names pubmed_search_articles and pubmed_lookup_mesh, and the interpretation step names pubmed_search_articles
Features
Built on @cyanheads/mcp-ts-core: stdio and Streamable HTTP transports, pluggable auth (none / jwt / oauth), swappable storage (in-memory, filesystem, Supabase, Cloudflare KV/R2/D1), structured logging with optional OpenTelemetry tracing.
PubMed-specific:
- NCBI E-utilities (ESearch, EFetch, ESummary, ELink, ESpell, EInfo, ECitMatch) and the PMC ID Converter, with Europe PMC, OpenAlex, and Unpaywall filling the gaps
- Shared NCBI request queue: paced request starts, capped concurrency, a cooldown that holds every caller after an NCBI 429, and one deadline covering queue wait and retries
- XML parsing built for PubMed's inconsistent records: structured abstracts, missing fields, varying date formats
- Forgiving identifiers: a zero-padded PMID resolves as the PMID it spells in every tool that takes one;
pubmed_fetch_fulltext also matches DOIs case-insensitively and PMC IDs with or without the PMC prefix
- Hand-rolled citation formatters (APA, MLA, BibTeX, RIS, Vancouver) with no dependencies
Agent-friendly output:
- Provenance on every response: source labels, license fields, best-effort warnings on Unpaywall results, and effective-query echo on searches, so agents can judge what to trust
- Graceful partial failure: batch tools return per-item success/error rows instead of failing the request, with structured status codes and actionable next-step text
- Discriminated output contracts:
source: "pmc" | "unpaywall", typed unavailable reasons, viaSource and triedTiers fields, so callers branch on data, not string parsing
Getting started
Public Hosted Instance
A public instance is available at https://pubmed.caseyjhand.com/mcp — no installation required. Point any MCP client at it via Streamable HTTP:
{
"mcpServers": {
"pubmed-mcp-server": {
"type": "streamable-http",
"url": "https://pubmed.caseyjhand.com/mcp"
}
}
}
Self-Hosted / Local
Add the following to your MCP client configuration file.
{
"mcpServers": {
"pubmed-mcp-server": {
"type": "stdio",
"command": "bunx",
"args": ["@cyanheads/pubmed-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info",
"NCBI_API_KEY": "your-key-here"
}
}
}
}
Or with npx (no Bun required):
{
"mcpServers": {
"pubmed-mcp-server": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@cyanheads/pubmed-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info",
"NCBI_API_KEY": "your-key-here"
}
}
}
}
Or with Docker:
{
"mcpServers": {
"pubmed-mcp-server": {
"type": "stdio",
"command": "docker",
"args": ["run", "-i", "--rm", "-e", "MCP_TRANSPORT_TYPE=stdio", "ghcr.io/cyanheads/pubmed-mcp-server:latest"]
}
}
}
For Streamable HTTP, set the transport and start the server:
MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 bun run start:http
# Server listens at http://localhost:3010/mcp
Prerequisites
- Bun v1.4.0 or higher (or Node.js v24+).
- Optional: an NCBI API key raises the rate limit from 3 to 10 requests per second.
Installation
- Clone the repository:
git clone https://github.com/cyanheads/pubmed-mcp-server.git
- Navigate into the directory:
cd pubmed-mcp-server
- Install dependencies:
bun install
- Configure environment:
cp .env.example .env
# edit .env and set NCBI_API_KEY, NCBI_ADMIN_EMAIL, and UNPAYWALL_EMAIL as needed
Configuration
See .env.example for every server setting and the common framework overrides.
Running the server
Local development
Build and run the production version:
# One-time build
bun run rebuild
# Run the built server
bun run start:http
# or
bun run start:stdio
Run checks and tests:
bun run devcheck # Lints, formats, type-checks, and more
bun run test # Runs the test suite
Project structure
Development guide
See CLAUDE.md for development guidelines and architectural rules. The short version:
- Handlers throw, framework catches — no
try/catch in tool logic
- Use
ctx.log for logging, ctx.state for storage
- Register new tools and resources in the
createApp() arrays in src/index.ts
- Wrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields
Contributing
Issues are welcome. Run checks and tests before submitting:
bun run devcheck
bun run test
License
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.