Skip to main content
Glama
PubMed Advanced MCP Server

PubMed Advanced MCP Server

๐Ÿงฌ PubMed Advanced MCP Server

Python 3.10+ FastMCP License: MIT NCBI E-utilities

A comprehensive Model Context Protocol (MCP) server that exposes PubMed and PubMed Central research literature APIs as intelligent tools for LLM applications.

Built with โค๏ธ by Suyash Ekhande

Features โ€ข Quick Start โ€ข Tools โ€ข Examples โ€ข Architecture

https://github.com/user-attachments/assets/892978f7-88d8-4b26-992e-41ba87c1b1cf


๐ŸŒŸ Features

  • 16 Intelligent Tools organized into 5 categories for comprehensive biomedical literature access

  • 34M+ PubMed Articles - Search across the world's largest biomedical abstract database

  • 7M+ PMC Full-Text Articles - Access complete article content from PubMed Central

  • Smart Rate Limiting - Automatic compliance with NCBI rate limits (3-10 req/sec)

  • Cross-Database Linking - Connect articles to genes, proteins, clinical variants, and more

  • ID Conversion - Seamlessly convert between PMID, PMCID, DOI, and Manuscript IDs

  • BioC Format Support - Pre-parsed text for NLP and text mining applications

  • Pipeline Operations - Build complex multi-step queries using Entrez History Server

  • Batch Processing - Efficiently handle 10K+ articles with chunked operations

Related MCP server: mcp-pubmed

๐Ÿ“ฆ Installation

Prerequisites

  • Python 3.10 or higher

  • pip or uv package manager

Install from source

# Clone the repository
git clone https://github.com/yourusername/pubmed-advanced-mcp.git
cd pubmed-advanced-mcp

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Or install as package
pip install -e .
# Copy example environment file
cp .env.example .env

# Edit .env and add your NCBI API key
# Get one at: https://www.ncbi.nlm.nih.gov/account/

Note: Without an API key, you're limited to 3 requests/second. With an API key, you get 10 requests/second.

๐Ÿš€ Quick Start

Run the MCP Server

# Using Python directly (Streamable HTTP on port 8000)
python -m src.server

# With custom host/port
MCP_HOST=127.0.0.1 MCP_PORT=9000 python -m src.server

Transport: This server uses Streamable HTTP as the only transport protocol. It runs on http://0.0.0.0:8000/mcp by default.

Run with Docker

# Build the image
docker build -t pubmed-mcp .

# Run the container
docker run -d -p 8000:8000 --name pubmed-mcp pubmed-mcp

# Run with NCBI API key for higher rate limits
docker run -d -p 8000:8000 -e NCBI_API_KEY=your-api-key pubmed-mcp

๐Ÿ›  Available Tools

Category 1: Search & Discovery (5 tools)

Tool

Description

Example Use Case

pubmed_search

Search 34M+ PubMed abstracts

Find reviews on CAR-T therapy

pmc_search

Full-text search in PMC

Search methods sections for protocols

mesh_term_search

MeSH controlled vocabulary search

Find all cancer therapy articles

advanced_search

Multi-field Boolean queries

Complex author + topic + date searches

global_search

Cross-database hit counts

Discover data across NCBI

Category 2: Document Retrieval (4 tools)

Tool

Description

Example Use Case

fetch_article_summary

Get article metadata

Retrieve author and abstract info

fetch_full_article

Get complete article content

Download full PMC articles

fetch_bioc_article

BioC format for NLP

Text mining and NER tasks

batch_fetch_articles

Bulk article retrieval

Download 1000+ articles efficiently

Category 3: Cross-Reference & Linking (3 tools)

Tool

Description

Example Use Case

find_related_articles

Citation/similarity links

Build citation networks

link_to_databases

Cross-link to Gene, Protein, etc.

Find genes mentioned in articles

find_citations_by_authors

Author publication history

Track researcher output

Category 4: ID Conversion (2 tools)

Tool

Description

Example Use Case

convert_article_ids

Batch ID conversion

Convert DOIs to PMIDs

resolve_article_identifier

Single ID resolution

Look up article by any ID type

Category 5: Advanced Operations (2 tools)

Tool

Description

Example Use Case

build_search_pipeline

Multi-step query pipelines

Complex research workflows

batch_process_articles

Large-scale processing

Process 10K+ articles

๐Ÿ“– Usage Examples

User: Find recent reviews about CRISPR gene editing in cancer

AI uses: pubmed_search(
    query="CRISPR gene editing cancer",
    filters={"publication_types": ["Review"], "publication_date_start": "2023"},
    max_results=10
)
User: Find all articles about breast cancer treatment using MeSH terms

AI uses: mesh_term_search(
    mesh_term="Breast Neoplasms",
    qualifiers=["therapy", "drug therapy"],
    explode=True,
    max_results=50
)
User: What articles are similar to PMID 37000000?

AI uses: find_related_articles(
    pmid="37000000",
    relationship_type="similar",
    max_results=20
)

Convert Article IDs

User: Convert these DOIs to PMIDs: 10.1038/nature12373, 10.1126/science.1225829

AI uses: convert_article_ids(
    ids=["10.1038/nature12373", "10.1126/science.1225829"],
    from_type="auto"
)

Build a Research Pipeline

User: Find diabetes review articles that are linked to HLA genes

AI uses: build_search_pipeline(
    steps=[
        {"operation": "search", "database": "pubmed", 
         "parameters": {"query": "diabetes[mh] AND review[pt]"}},
        {"operation": "link", "database": "gene",
         "parameters": {"from_db": "pubmed"}}
    ]
)

Batch Processing

User: Get metadata for these 500 PMIDs for my literature review

AI uses: batch_fetch_articles(
    pmids=["12345678", "23456789", ...],  # 500 IDs
    include_metadata=True,
    include_abstract=True,
    batch_size=100
)

๐Ÿ— Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                         LLM / AI Agent Client                           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                     โ”‚
                        MCP Protocol (Streamable HTTP)
                                     โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    FastMCP Server (Python)                              โ”‚
โ”‚                                                                          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚                    16 MCP Tools                                    โ”‚ โ”‚
โ”‚  โ”‚  Search โ”‚ Retrieval โ”‚ Linking โ”‚ ID Conversion โ”‚ Advanced Ops      โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚                                   โ”‚                                      โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚              API Clients (with Rate Limiting)                      โ”‚ โ”‚
โ”‚  โ”‚  E-Utilities โ”‚ BioC API โ”‚ ID Converter โ”‚ Session Manager           โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                     โ”‚
                        HTTP/REST API Calls
                                     โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ–ผ                            โ–ผ                            โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ NCBI E-Utilitiesโ”‚      โ”‚ BioC APIs        โ”‚      โ”‚ ID Converter     โ”‚
โ”‚ (34M+ articles) โ”‚      โ”‚ (29M+ articles)  โ”‚      โ”‚ (200 IDs/batch)  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ Project Structure

pubmed-advanced-mcp/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ server.py                 # FastMCP server with all 16 tools
โ”‚   โ”œโ”€โ”€ config.py                 # Configuration management
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ clients/                  # API client modules
โ”‚   โ”‚   โ”œโ”€โ”€ base.py              # Base HTTP client with rate limiting
โ”‚   โ”‚   โ”œโ”€โ”€ eutilities.py        # NCBI E-Utilities client
โ”‚   โ”‚   โ”œโ”€โ”€ bioc_api.py          # BioC text mining API
โ”‚   โ”‚   โ”œโ”€โ”€ id_converter.py      # PMC ID Converter
โ”‚   โ”‚   โ””โ”€โ”€ session_manager.py   # Entrez History management
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ tools/                    # MCP Tool implementations
โ”‚   โ”‚   โ”œโ”€โ”€ search_tools.py      # 5 search tools
โ”‚   โ”‚   โ”œโ”€โ”€ retrieval_tools.py   # 4 retrieval tools
โ”‚   โ”‚   โ”œโ”€โ”€ linking_tools.py     # 3 linking tools
โ”‚   โ”‚   โ”œโ”€โ”€ id_conversion_tools.py # 2 ID tools
โ”‚   โ”‚   โ””โ”€โ”€ advanced_tools.py    # 2 advanced tools
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ schemas/                  # Pydantic models
โ”‚   โ”‚   โ””โ”€โ”€ tool_schemas.py      # Input/output schemas
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ utils/                    # Utilities
โ”‚       โ”œโ”€โ”€ rate_limiter.py      # Token bucket rate limiter
โ”‚       โ”œโ”€โ”€ query_builder.py     # E-utilities query builder
โ”‚       โ””โ”€โ”€ error_handler.py     # Custom exceptions
โ”‚
โ”œโ”€โ”€ docs/
โ”‚   โ”œโ”€โ”€ implementation/          # Implementation documentation
โ”‚   โ””โ”€โ”€ *.md                     # Original requirements
โ”‚
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ .env.example
โ””โ”€โ”€ README.md

โš™๏ธ Configuration

Environment Variables

Variable

Description

Default

NCBI_API_KEY

NCBI API key for higher rate limits

None (3 req/sec)

TOOL_NAME

Tool identifier for NCBI

pubmed-mcp-server

TOOL_EMAIL

Contact email (required by NCBI)

pubmed-mcp@example.com

Rate Limits

Scenario

Rate Limit

Without API Key

3 requests/second

With API Key

10 requests/second

Violation

IP blocked for 24+ hours

๐Ÿ”ฌ Sample Prompts for LLMs

Here are example prompts you can use with Claude or other LLM clients:

Literature Review

"Find all systematic reviews about COVID-19 vaccine efficacy published in 2023-2024. 
Include the abstracts and MeSH terms."

Gene-Disease Research

"Search for articles about TP53 mutations in breast cancer. Then link these articles 
to related gene records in NCBI Gene database."

Author Analysis

"Find all publications by Jennifer Doudna in the last 5 years and summarize 
her research focus areas."

ID Conversion

"I have these DOIs from my reference manager. Convert them to PMIDs so I can 
search for related articles: 10.1038/nature12373, 10.1126/science.1225829"

Text Mining Pipeline

"Get the full text of PMC7611378 in BioC format. I need it for named entity 
recognition to extract drug names and disease mentions."

๐Ÿงช Testing

Run Tests

# Install dev dependencies
pip install -e ".[dev]"

# Run all tests
pytest

# Run with verbose output
pytest -v

# Run specific test file
pytest tests/test_search_tools.py

๐Ÿ“š API Documentation

E-Utilities Query Syntax

The server supports full E-utilities query syntax:

# Basic search
cancer

# Field-specific search
cancer[ti]                    # Title
CRISPR[ab]                    # Abstract
"Zhang F"[au]                 # Author
Nature[ta]                    # Journal

# Boolean operators (MUST be uppercase)
cancer AND therapy
cancer OR tumor
cancer NOT lung

# Date ranges
cancer AND 2023[dp]           # Year
cancer AND 2020:2024[dp]      # Range

# MeSH terms
"Breast Neoplasms"[mh]        # MeSH heading
"Neoplasms/therapy"[mh]       # With qualifier

# Publication types
review[pt]
clinical trial[pt]

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository

  2. Create your feature branch (git checkout -b feature/AmazingFeature)

  3. Commit your changes (git commit -m 'Add some AmazingFeature')

  4. Push to the branch (git push origin feature/AmazingFeature)

  5. Open a Pull Request

Acknowledgments

  • NCBI for providing the E-utilities and related APIs

  • FastMCP for the excellent MCP framework

  • The biomedical research community for their contributions to PubMed


Made with โค๏ธ for the biomedical research community

Built by Suyash Ekhande

Available Tools

16 tools
batch_fetch_articlesA

Efficiently fetch multiple articles with rate limiting.

Handles large batches by chunking requests and respecting NCBI rate limits. Returns both successful and failed retrievals.

Inputs: pmids (required), batch_size, include_abstract, include_metadata. Returns: object

batch_process_articlesB

Process large sets of articles with batch operations.

Handles datasets of 10K+ articles efficiently with chunked processing and rate limiting.

Inputs: input_source (required), operation, batch_config, output_format. Returns: object

build_search_pipelineA

Build and execute a multi-step search pipeline.

Uses Entrez History Server to chain operations efficiently. Ideal for complex queries like: "Find diabetes reviews, then limit to articles linked to HLA genes"

Inputs: steps (required), output_step. Returns: object

convert_article_idsA

Convert article IDs between different formats.

Supports batch conversion (up to 200 IDs) between:

  • PMID (PubMed ID): e.g., "37000000"

  • PMCID (PubMed Central ID): e.g., "PMC7611378"

  • DOI: e.g., "10.1093/nar/gks1195"

  • Manuscript ID: e.g., "NIHMS1677310"

Inputs: ids (required), from_type, include_versions. Returns: object

fetch_article_summaryA

Fetch detailed article summary and metadata.

Returns comprehensive information including title, authors, abstract, MeSH terms, journal details, DOI, and more.

Inputs: pmid (required), database, include_full_metadata. Returns: object

fetch_bioc_articleA

Fetch article in BioC format for text mining.

BioC provides pre-parsed text ideal for NLP tasks:

  • Passage-level segmentation (title, abstract, sections)

  • Sentence-level boundaries

  • Ready for named entity recognition, relation extraction

Inputs: pmid, pmcid, format. Returns: object

fetch_full_articleA

Fetch complete article content.

For PubMed: Returns abstract and metadata (full text not available). For PMC: Returns full text if article is in PMC Open Access.

Inputs: pmid, pmcid, format. Returns: object

find_citations_by_authorsB

Find all publications by a specific author.

Inputs: author_name (required), max_results, date_range_end, date_range_start. Returns: object

resolve_article_identifierA

Resolve a single identifier to all available ID formats.

Automatically detects the ID type and returns all available identifiers for the article.

Inputs: identifier (required), auto_detect_type. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelogโ€ฆ

    TDQS

    B3.3/5.0

    Scored across 16 tools

    Disambiguation2/5

    Multiple tools have overlapping purposes: resolve_article_identifier and convert_article_ids both handle ID conversion; fetch_article_summary and fetch_full_article return similar data for PubMed; batch_fetch_articles and batch_process_articles are vaguely differentiated. Descriptions help but boundaries remain unclear, increasing the risk of misselection.

    Naming Consistency2/5

    Naming patterns are inconsistent. Some tools use verb-first names (fetch_, find_, convert_), while search tools use noun-based names (pubmed_search, advanced_search). The mix of conventions makes the tool set feel unpredictable.

    Tool Count3/5

    16 tools is on the heavier side for a PubMed-focused server. Several tools appear redundant (e.g., two ID converters, multiple search variants), making the count feel inflated. However, it is not extreme and still within a workable range.

    Completeness4/5

    The tool set covers the core PubMed/NCBI workflows: searching across databases, fetching summaries and full text, ID conversion, related articles, database links, and batch processing. Minor gaps exist (e.g., no direct author search, but find_citations_by_authors addresses this), but overall the domain is well-covered.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A specialized MCP server that provides a structured interface to the Europe PMC database for biological and clinical evidence retrieval. It enables LLMs to gather, rank, and synthesize published research focusing on therapeutic targets and disease associations.
      1
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      An MCP server that provides direct access to PubMed and PubMed Central via the NCBI E-utilities API. It enables AI models to search biomedical literature, retrieve detailed article metadata, and download open-access full texts.
      5
      MIT
    • A
      license
      C
      quality
      D
      maintenance
      A PubMed MCP server that enables LLMs to search, retrieve details, and download full-text articles from PubMed, with support for batch queries, cross-referencing, and EndNote export.
      13
      47 npm
      6
      Apache 2.0
    • A
      license
      A
      quality
      B
      maintenance
      A high-performance MCP server that gives LLMs access to 25 biomedical tools federated across 50+ upstream APIs for genes, variants, drugs, diseases, literature, clinical trials, and structural biology.
      43
      179 npm
      12
      Apache 2.0