pubmed-mcp-server
The PubMed MCP Server integrates with PubMed's biomedical literature database, enabling AI agents and research tools to search, retrieve, analyze, and visualize scientific publications:
Search PubMed Articles: Query articles using keywords, filters, date ranges, and sorting options
Fetch PubMed Content: Retrieve article information by PMID or search history, with customizable detail levels (abstract, full XML, MEDLINE text) and pagination
Find Related Articles: Identify similar articles, citations, or references to a given PMID
Generate Citations: Create formatted citations in RIS, BibTeX, APA, or MLA styles
Generate Research Plans: Create structured JSON research plans with detailed inputs
Visualize Data: Generate customizable charts (bar, line, scatter) from publication metadata as PNG images
Automate Research Workflows: Programmatically access PubMed data for AI-driven research and evidence-based decision-making
Integrate with NCBI APIs: Leverage NCBI E-utilities with built-in error handling and rate limit compliance
Connects AI agents to NCBI's PubMed and E-utilities, enabling search, retrieval, and analysis of biomedical literature. Provides tools for searching articles, fetching detailed content, finding related articles, generating citations, creating research plans, and visualizing data through charts.
Generates SVG chart visualizations from PubMed data, supporting bar, line, and scatter chart types for data representation.
Built with TypeScript for type safety and robust input validation, ensuring secure and reliable interactions with PubMed's biomedical data.
Utilizes Vega-Lite specifications to render SVG charts from PubMed data, enabling visualization of biomedical research trends and statistics.
Processes PubMed article data in XML format, providing JSON representation of the PubMedArticle XML structure through the fetch_pubmed_content tool.
Uses Zod for schema validation of inputs and outputs when interacting with PubMed, ensuring type safety and proper data formatting.
Click on "Install 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 about CRISPR gene editing in cancer therapy"
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.
Public Hosted Server: https://pubmed.caseyjhand.com/mcp
Tools
10 tools for working with PubMed, PubMed Central, and Europe PMC data:
Tool | Description |
| Search PubMed with full query syntax, field-specific filters, date ranges, pagination, and optional brief summaries |
| Search Europe PMC for preprints, patents, Agricola, and EPMC-only OA records that don't surface in PubMed. Cursor-based pagination. |
| Fetch full article metadata by PMIDs — abstract, authors, journal, MeSH terms, grants |
| Fetch full-text articles via a chain: NCBI PMC EFetch → Europe PMC |
| Generate formatted citations in APA 7th, MLA 9th, BibTeX, RIS, or Vancouver (ICMJE/NLM) |
| Find similar articles, citing articles, or references for a given PMID |
| Spell-check biomedical queries using NCBI's ESpell service |
| Search and explore MeSH vocabulary — tree numbers, scope notes, entry terms |
| Resolve partial bibliographic references to PubMed IDs via ECitMatch |
| Convert between DOI, PMID, and PMCID using the PMC ID Converter API |
pubmed_search_articles
Search PubMed with full NCBI query syntax and filters.
Free-text queries with PubMed's full boolean and field-tag syntax
Field-specific filters: author, journal, MeSH terms, language, species
Common filters: has abstract, free full text
Date range filtering by publication, modification, or Entrez date
Publication type filtering (Review, Clinical Trial, Meta-Analysis, etc.)
Sort by relevance, publication date, author, or journal
Pagination via offset for paging through large result sets
Optional brief summaries for top N results via ESummary
Returns the original query plus the fully applied PubMed query and normalized filter metadata
pubmed_fetch_articles
Fetch full article metadata by PubMed IDs.
Batch fetch up to 200 articles at once (auto-switches to POST for batches >= 100)
Returns structured data: title, abstract, authors with deduplicated affiliations, journal info, DOI
Direct links to PubMed and PubMed Central (when available)
Optional MeSH terms, grant information, and publication types
Handles PubMed's inconsistent XML (structured abstracts, missing fields, varying date formats)
pubmed_fetch_fulltext
Fetch full-text articles via a three-stage chain: NCBI PMC EFetch → Europe PMC fullTextXML → Unpaywall.
Accepts exactly one of
pmcids(direct PMC IDs),pmids(PubMed IDs, auto-resolved), ordois(auto-resolved to PMC via the ID Converter; preprints and EPMC-only OA fall through to Europe PMC / Unpaywall)NCBI PMC and Europe PMC both return structured JATS; output records origin via
viaSource: "pmc" | "europepmc" | "unpaywall"Europe PMC layer (enabled by default; disable with
EUROPEPMC_ENABLED=false) recovers PMC-counterpart records that NCBI PMC EFetch missed, and resolves DOI input to PMC counterparts when one exists. EPMC'sfullTextXMLis PMC-keyed, so preprints (PPR), patents (PAT), and Agricola (AGR) are reachable viapubmed_europepmc_searchfor metadata but have no full text via this chain.Unpaywall layer (enabled by setting
UNPAYWALL_EMAIL) resolves DOIs to legal OA copies; extracts HTML landing pages to Markdown via Defuddle or PDFs to text via unpdfDiscriminated output contract —
source: "pmc"(structured sections, regardless of whether it came from PMC or EPMC) orsource: "unpaywall"(best-effort body +contentFormat:html-markdownorpdf-text)Structured unavailable reasons (
not-found,no-pmc-fallback-disabled,no-epmc-fulltext,no-doi,no-oa,fetch-failed,parse-failed,service-error) so callers can retry or explain to users without parsing textEach
unavailableentry carriesidType(pmid/pmcid/doi) andtriedTiers— per-tier outcomes (not-attempted,miss,no-fulltext,service-error, …) in execution order, so callers can see which stage failed and whySection filtering by title (case-insensitive match, e.g.
["methods", "results"]) and configurable max sections apply to PMC outputUp to 10 articles per request
pubmed_europepmc_search
Search Europe PMC (EBI/EMBL-EBI), a broader open-access biomedical corpus than PubMed alone.
Surfaces records PubMed search can't reach — preprints (
source: PPR), patents (source: PAT), Agricola (source: AGR), plus everything in PubMed (MED) and PMC (PMC). On recent queries this can mean dozens of relevant hits with zero PubMed overlap.Default sources
["MED", "PMC", "PPR"]; passsourcesto includePAT/AGRCursor-based pagination via
cursorMark(unlikepubmed_search_articles, which uses offset) —*for the first page, returnnextCursorMarkfor the nextOutput discriminator on
sourceplus optionalpmid/pmcId/doicross-walkingDisabled when
EUROPEPMC_ENABLED=false; tool is not registered in that case
pubmed_format_citations
Generate formatted citations for articles.
Five citation styles: APA 7th, MLA 9th, BibTeX, RIS, Vancouver (ICMJE/NLM)
Request multiple styles per article in a single call
Hand-rolled formatters — zero external dependencies, fully Workers-compatible
Up to 50 articles per request
Reports formatted counts and unavailable PMIDs for partial-result handling
pubmed_find_related
Find articles related to a source article via ELink.
Three relationship types:
similar(content similarity),cited_by,referencesResults enriched with title, authors, publication date, and source via ESummary
Results returned in NCBI's relevance order
pubmed_spell_check
Spell-check a biomedical query using NCBI's ESpell.
Returns the original query, corrected query, and whether a suggestion was found
Useful for query refinement before searching
pubmed_lookup_mesh
Search and explore the MeSH (Medical Subject Headings) vocabulary.
Search MeSH terms by name with exact-heading matching
Detailed records with tree numbers, scope notes, and entry terms by default
Useful for building precise PubMed queries with controlled vocabulary
pubmed_lookup_citation
Resolve partial bibliographic references to PubMed IDs via NCBI ECitMatch.
Match citations by journal, year, volume, first page, and/or author name
More fields = better match accuracy; at least one field required
Batch up to 25 citations per request
Deterministic matching — more reliable than free-text search for known references
Returns explicit
matched,not_found, andambiguousstatuses with recovery detail
pubmed_convert_ids
Convert between article identifiers (DOI, PMID, PMCID) using the PMC ID Converter API.
Batch up to 50 IDs per request
Accepts DOIs, PMIDs, or PMCIDs (all IDs must be the same type)
Only resolves articles indexed in PubMed Central
Per-ID success/error reporting — partial batches return resolved mappings alongside structured errors for unresolvable IDs, not a batch-level failure
Related MCP server: PubMed MCP Server
Resource and prompt
Type | Name | Description |
Resource |
| PubMed database metadata via EInfo (field list, record count, last update) |
Prompt |
| Generate a structured 4-phase biomedical research plan outline |
Features
Built on @cyanheads/mcp-ts-core:
Declarative tool definitions — single file per tool, framework handles registration and validation
Unified error handling across all tools
Pluggable auth (
none,jwt,oauth)Swappable storage backends:
in-memory,filesystem,Supabase,Cloudflare KV/R2/D1Structured logging with optional OpenTelemetry tracing
Runs locally (stdio/HTTP) or on Cloudflare Workers from the same codebase
PubMed-specific:
Complete NCBI E-utilities integration (ESearch, EFetch, ESummary, ELink, ESpell, EInfo, ECitMatch) plus PMC ID Converter
Sequential request queue with configurable delay for NCBI rate limit compliance
NCBI-specific XML parser with
isArrayhints for PubMed's inconsistent XML structureHand-rolled citation formatters (APA, MLA, BibTeX, RIS, Vancouver) — zero deps, Workers-compatible
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 reason about 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", typedunavailablereasons,viaSourceandtriedTiersfields — 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/mcpPrerequisites
Bun v1.3.2 or higher.
Optional: NCBI API key for higher rate limits (10 req/s vs 3 req/s).
Installation
Clone the repository:
git clone https://github.com/cyanheads/pubmed-mcp-server.gitNavigate into the directory:
cd pubmed-mcp-serverInstall dependencies:
bun installConfiguration
All configuration is validated at startup via Zod schemas in src/config/server-config.ts. Key environment variables:
Variable | Description | Default |
| Transport: |
|
| HTTP server port |
|
| HTTP endpoint path where the MCP server is mounted |
|
| Public origin override for TLS-terminating reverse-proxy deployments (landing page, Server Card, RFC 9728 metadata). | none |
| Authentication: |
|
| Log level ( |
|
| Opt-in Bun-only forced-GC pressure loop (ms). Drains the per-request |
|
| Directory for log files (Node.js only). |
|
| Storage backend: |
|
| NCBI API key for higher rate limits (10 req/s vs 3 req/s) | none |
| Contact email sent with NCBI requests (recommended by NCBI) | none |
| Minimum gap between NCBI request starts in ms | 334 (100 with key) |
| Max concurrent in-flight NCBI requests |
|
| Retry attempts for failed NCBI requests | 6 |
| Per-request HTTP timeout in ms |
|
| Total deadline across all retry attempts for one NCBI call, in ms |
|
| Contact email for Unpaywall. When set, | none |
| Per-request HTTP timeout for Unpaywall lookups and content fetches, in ms |
|
| Enable Europe PMC search tool and the |
|
| Optional contact email sent with Europe PMC requests (EBI courtesy). | none |
| Minimum gap between Europe PMC request starts in ms |
|
| Retry attempts for failed Europe PMC requests |
|
| Per-request HTTP timeout for Europe PMC calls, in ms |
|
| Enable OpenTelemetry |
|
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:stdioRun checks and tests:
bun run devcheck # Lints, formats, type-checks, and more bun run test # Runs the test suite
Project structure
Directory | Purpose |
| Tool definitions ( |
| Resource definitions. Database info resource. |
| Prompt definitions. Research plan prompt. |
| NCBI E-utilities service layer — API client, queue, parser, formatter. |
| Europe PMC service — search + |
| Unpaywall service — DOI → OA location resolution and content fetch (HTML/PDF). |
| Server-specific environment variable parsing and validation with Zod. |
| Unit and integration tests, mirroring the |
Development guide
See CLAUDE.md for development guidelines and architectural rules. The short version:
Handlers throw, framework catches — no
try/catchin tool logicUse
ctx.logfor logging,ctx.statefor storageRegister new tools and resources in the
createApp()arrays
Contributing
Issues and pull requests are welcome. Run checks and tests before submitting:
bun run devcheck
bun run testLicense
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.
Maintenance
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/cyanheads/pubmed-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server