Skip to main content
Glama
pubverify-mcp

pubverify-mcp

README.md
# pubverify-mcp

**English** | [中文文档](README_zh.md)

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![Python 3.10+](https://img.shields.io/badge/Python-3.10%2B-3776AB.svg)](https://www.python.org/)
[![Zero Dependencies](https://img.shields.io/badge/Dependencies-0%20runtime-16A34A.svg)](#installation)
[![MCP](https://img.shields.io/badge/MCP-Stdio%20JSON--RPC%202.0-0F172A.svg)](#client-configuration)

A **zero-dependency**, pure-Python Stdio **Model Context Protocol (MCP)** server built for real biomedical research workflows: **true corresponding-author verification**, **hallucination-proof citation auditing**, **official PubMed NLM/AMA/APA/BibTeX export**, and **open-access PMC full-text reading**.

---

## Why `pubverify-mcp`?

Ordinary PubMed MCP servers wrap basic `esearch + efetch` and stop there. When researchers actually use AI assistants to compile a PI's publication list, audit manuscript references, write grant proposals, or read paper methods, basic wrappers break in predictable ways:

| Capability | Typical PubMed MCP | `pubverify-mcp` |
|---|---|---|
| **Corresponding-author detection** | Guesses last author (misses non-last co-corresponding) or checks email (false positives on journals that attach emails to every author) | **3-way cross-verification**: PMC JATS XML (`corresp="yes"`) → OpenAlex (`is_corresponding`) → selective email guard |
| **Errata / Corrigenda handling** | Mixed into article counts | Automatically flagged and separated from primary articles |
| **Hallucination & retraction audit** | Single-paper lookup or none | Batch-verifies up to 25 DOIs/PMIDs against CrossRef + PubMed with retraction & erratum alerts |
| **Publication-ready citations** | Hand-rolled strings or missing | Calls **NCBI's official Citation Exporter** for verbatim NLM / AMA / APA / MLA (auto-cleans `<sub>`/`<sup>` to Unicode like `RuO₂`), plus BibTeX & RIS |
| **PMC open-access full text** | Often breaks on nested `BioCCollection` JSON or dumps 100 KB into context | Unwraps `BioCCollection -> documents[].passages`, resolves PMID → PMCID, filters boilerplate references, and enforces `max_chars` |
| **Runtime footprint** | Heavy SDKs or 30+ noisy tools burning context tokens | **0 third-party dependencies** (Python 3.10+ stdlib only), **6 focused tools**, no API key required |

---

## Key Features

1. **Three-Way Corresponding-Author Verification (`search_author_papers`)**
   - PubMed XML does not contain a `<CorrespondingAuthor>` tag.
   - `pubverify-mcp` verifies correspondence using **PMC JATS XML** (`<contrib corresp="yes">` and `<xref ref-type="corresp">`) first, falls back to **OpenAlex** (`authorships[].is_corresponding`) for paywalled journals not in PMC (ACS, Elsevier, Wiley, Nature, etc.), and guards against all-author email dumps.
   - Supports name variants (`"Jane Doe"`, `"Doe, Jane"`, `"Doe J"`) while rejecting same-initial homonyms, and separates `Published Erratum` / `Corrigendum` records automatically.

2. **Batch Citation & Retraction Auditing (`verify_citations`)**
   - Verify up to **25 DOIs or PMIDs** in one call against CrossRef and PubMed.
   - Immediately catches hallucinated/non-existent DOIs, retracted publications, and linked errata.

3. **Official Citation Export (`format_citations`)**
   - Fetches official **NLM**, **AMA**, **APA**, or **MLA** citations directly from NCBI's `ctxp` Citation Exporter API.
   - Also generates clean **BibTeX** and **RIS** records from PubMed XML.
   - Converts inline HTML markup (`<sub>`, `<sup>`, `<i>`) into clean Unicode (e.g., `RuO<sub>2</sub>` → `RuO₂`).

4. **Section-Aware PMC Full-Text Reader (`fetch_pmc_fulltext`)**
   - Accepts either a `PMCID` or a numeric `PMID` (auto-resolves to `PMCID`).
   - Supports filtering specific sections (`abstract`, `intro`, `methods`, `results`, `discussion`, `concl`) and truncates safely within `max_chars` (default `30,000`, max `120,000`).

5. **Preprint & Multi-Source Fallback (`search_scholarly_source`)**
   - Queries **CrossRef**, **Europe PMC**, **bioRxiv**, **medRxiv**, or **OpenAlex** when you need preprints, citation counts, or non-MEDLINE records.

---

## Installation

Requires **Python 3.10+**. No API key is needed out of the box.

```bash
# Install directly from GitHub
pip install "git+https://github.com/drstrangerujn/pubverify-mcp.git"

# Or run isolated with uvx
uvx --from "git+https://github.com/drstrangerujn/pubverify-mcp.git" pubverify-mcp --version
```

Verify the installation:

```bash
pubverify-mcp --version
pubverify-mcp --list-tools
```

---

## Client Configuration

### Codex CLI

```bash
codex mcp add pubverify -- pubverify-mcp
```

Or add to `~/.codex/config.toml`:

```toml
[mcp_servers.pubverify]
command = "pubverify-mcp"
```

### Claude Desktop / Cursor / Windsurf / Antigravity

Add to your MCP config file (e.g. `claude_desktop_config.json`, `.cursor/mcp.json`, or `~/.gemini/config/mcp_config.json`):

```json
{
  "mcpServers": {
    "pubverify": {
      "command": "pubverify-mcp",
      "args": []
    }
  }
}
```

### Optional Environment Variables

Everything works keyless by default. For heavy batch workloads, you can pass optional env vars:

| Variable | Purpose |
|---|---|
| `NCBI_API_KEY` | Increases NCBI E-utilities rate limit from 3 req/s to 10 req/s |
| `PUBVERIFY_EMAIL` | Sent as `email` / `mailto` to NCBI & OpenAlex polite pools |

---

## Tool Reference

| Tool | Required Args | Key Optional Args | Returns |
|---|---|---|---|
| `search_pubmed` | `query` | `limit` (1–100), `year_from`, `year_to`, `sort` (`relevance` \| `pub+date`), `exclude_errata`, `include_abstract` | Normalized PubMed records with MeSH, DOI, PMCID, retraction & erratum flags |
| `search_author_papers` | `author` | `affiliation` (supports `OR` / `\|`), `topic`, `year_from`, `year_to`, `corresponding_only` (default `true`), `exclude_errata` (default `true`), `limit`, `include_abstract` | Verified corresponding-author papers with `evidence_source`, plus `excluded_non_corresponding` and `excluded_errata` audit lists |
| `verify_citations` | `items` (`[{id_type, value}]`, max 25) | — | `verified_count`, `missing_count`, `retracted_count`, and per-item bibliographic verification |
| `format_citations` | `pmids` (max 50) | `style` (`nlm` \| `ama` \| `apa` \| `mla` \| `bibtex` \| `ris`), `clean_html` (default `true`) | Per-PMID citations + ready-to-paste `formatted_text` |
| `fetch_pmc_fulltext` | `identifier` (`PMCID` or `PMID`) | `sections` (e.g. `["methods", "results"]`), `max_chars` (default `30000`) | Clean section map, `available_sections`, `truncated` flag, canonical PMC URL |
| `search_scholarly_source` | `source`, `query` | `limit` (1–30); `source` ∈ `crossref`, `europepmc`, `biorxiv`, `medrxiv`, `openalex` | Normalized records with DOIs / citation counts / retraction flags |

---

## Usage Examples (Natural-Language Prompts)

Once connected to your AI assistant, you can ask directly:

- **Compile a verified corresponding-author publication list:**
  > "Find all osteoarthritis papers published since 2024 where Jane Doe (Harvard Medical School) is a corresponding or co-corresponding author, exclude errata, and export them in official NLM format grouped by year."
- **Audit references before manuscript submission:**
  > "Verify these 18 DOIs and PMIDs from my draft—flag any non-existent DOIs, retracted papers, or published errata."
- **Extract Methods & Results without downloading PDFs manually:**
  > "Fetch the Methods and Results sections of PMID 35165404 from PMC and summarize the cohort size and statistical model."
- **Check preprints alongside PubMed:**
  > "Search bioRxiv and PubMed for spatial transcriptomics in synovial fibroblasts published in 2025–2026."

---

## Development & Testing

```bash
git clone https://github.com/drstrangerujn/pubverify-mcp.git
cd pubverify-mcp
pip install -e . pytest ruff build

ruff check src tests
pytest
python -m build
```

All unit tests run **100% offline** via injectable mock transports (`src/pubverify_mcp/http_client.py`) and cover PMC BioCCollection unwrapping, non-last co-corresponding verification, all-author email false-positive guards, retraction detection, HTML subscript cleanup, and MCP JSON-RPC framing.

## License

[MIT](LICENSE)

TDQS

A3.9/5.0

Scored across 6 tools

Disambiguation4/5

Most tools have clearly distinct purposes: verification, formatting, full-text retrieval, and cross-source search are separable. The main overlap is between search_pubmed, search_author_papers, and search_scholarly_source, though their descriptions clarify PubMed-wide search vs author-specific authorship verification vs non-PubMed/preprint sources.

Naming Consistency5/5

All six tools follow a consistent snake_case verb_noun pattern: search_pubmed, search_author_papers, verify_citations, format_citations, fetch_pmc_fulltext, and search_scholarly_source. The naming is predictable and readable.

Tool Count5/5

Six tools is well-scoped for a PubMed citation verification and formatting server. Each tool appears to earn its place by covering search, author verification, batch verification, citation formatting, full-text retrieval, and alternative scholarly sources.

Completeness4/5

The surface covers the core scholarly verification lifecycle: search, author-specific search, citation verification, formatting, full-text retrieval, and non-PubMed sources. Minor gaps include no dedicated single-record lookup by PMID/DOI outside the batch verification flow, but agents can work around this through existing search and verification tools.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues