npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@cyanheads/pubmed-mcp-server

v1.4.5

Published

Production-ready PubMed Model Context Protocol (MCP) server that empowers AI agents and research tools with comprehensive access to PubMed's article database. Enables advanced, automated LLM workflows for searching, retrieving, analyzing, and visualizing

Readme

Version MCP SDK License Status TypeScript


🛠️ Tools Overview

This server provides five powerful tools for accessing and analyzing biomedical literature from PubMed:

| Tool Name | Description | | :--- | :--- | | pubmed_search_articles | Searches PubMed for articles based on your query. | | pubmed_fetch_contents | Retrieves detailed information for specific PubMed articles by PMID. | | pubmed_article_connections | Finds related articles (cited by, similar, references) or formats citations. | | pubmed_research_agent | Generates a standardized JSON research plan from component details. | | pubmed_generate_chart | Generates a chart image (PNG) from structured publication data. |

pubmed_search_articles

Search and discover millions of biomedical articles using free-text queries and advanced filters.

Key Features:

  • Free-text search across all article fields (title, abstract, author, journal).
  • Filter by publication date range and specific publication types (e.g., "Review", "Clinical Trial").
  • Sort results by relevance, publication date, author, or journal name.
  • Optionally fetch brief summaries for top results in the same call.

Example Use Cases:

  • "Find recent review articles on CRISPR gene editing."
  • "Show me all publications by Dr. Anthony Fauci in 2023."
  • "List the latest articles on neuroinflammation in the journal 'Nature'."

📖 View detailed examples →


pubmed_fetch_contents

Retrieve detailed, structured metadata for specific articles using their PubMed IDs (PMIDs).

Key Features:

  • Fetch single or multiple articles (up to 200 at once).
  • Use ESearch history (queryKey, WebEnv) for batch retrieval of large sets.
  • Choose from multiple detail levels:
    • abstract_plus: Rich, parsed data including abstract, authors, journal, DOI, and keywords.
    • full_xml: The complete, raw PubMedArticle XML structure in JSON format.
    • medline_text: The classic MEDLINE plain-text format.
    • citation_data: Minimal data required for generating citations.
  • Include optional data like MeSH terms and grant information.

Example Use Cases:

  • "Get the full abstract and author list for PMID 31772153."
  • "Fetch citation data for these three PMIDs: 31535994, 29749963, 33836086."
  • "Retrieve the MEDLINE record for PMID 12345678."

📖 View detailed examples →


pubmed_article_connections

Explore the citation network and generate formatted citations for any article.

Key Features:

  • Discover related literature by finding:
    • pubmed_similar_articles: Articles with similar content.
    • pubmed_citedin: Articles that have cited the source article.
    • pubmed_references: Articles that the source article references.
  • Generate citations in multiple standard formats in a single call:
    • ris: Research Information Systems format for reference managers.
    • bibtex: For use with LaTeX and BibTeX.
    • apa_string and mla_string: Plain-text citations in APA and MLA style.

Example Use Cases:

  • "Find 5 articles that are similar to PMID 30310041."
  • "Who has cited the paper with PMID 29089531?"
  • "Get the BibTeX and RIS citation for PMID 33577065."

📖 View detailed examples →

📖 View a second example →


pubmed_research_agent

Bootstrap a new research project by generating a formal, structured research plan.

Key Features:

  • Assembles a comprehensive JSON-based research plan from high-level inputs.
  • Outlines every phase of research: conception, data collection, analysis, and dissemination.
  • Includes sections for hypotheses, literature search strategies, experimental design, and data analysis pipelines.
  • Can optionally embed detailed prompts to guide a research agent in executing the plan.

Example Use Cases:

  • "Draft a research plan to investigate the role of TREM2 in Alzheimer's disease."
  • "Outline a project on the effects of intermittent fasting on metabolic health, including a PubMed search strategy."
  • "Create a formal plan for a comparative multi-omics analysis of gut microbiome data."

📖 View detailed examples →


pubmed_generate_chart

Visualize publication trends and data with server-side chart generation.

Key Features:

  • Create PNG charts from structured data arrays.
  • Supports a wide range of chart types: bar, line, scatter, pie, doughnut, bubble, radar, and polarArea.
  • Customize chart title, dimensions, axes, and data series.
  • Ideal for quickly visualizing search results or publication metadata.

Example Use Cases:

  • "Plot the number of articles published on 'immunotherapy' per year since 2015."
  • "Create a bar chart showing the top 10 journals by publication count for 'nanotechnology'."
  • "Make a scatter plot of articles by citation count vs. publication year."

📖 View detailed examples →


✨ Features

This server is built on the mcp-ts-template and inherits its rich feature set:

  • Robust Error Handling: A unified McpError system ensures consistent, structured error responses.
  • Full-Stack Observability: Deep insights with structured logging (Winston) and optional, auto-instrumented OpenTelemetry for traces and metrics.
  • HTTP/STDIO Transports: Flexible deployment with support for both standard I/O and a high-performance Hono-based HTTP server.
  • Pluggable Authentication: Secure your HTTP transport with out-of-the-box support for none, jwt, or oauth modes.
  • Input Validation: All tool inputs are rigorously validated against Zod schemas.
  • Request Context: AsyncLocalStorage provides end-to-end tracing of operations via unique request IDs.
  • Edge-Ready: Write code once and run it on your local machine or at the edge.

Plus, specialized features for PubMed:

  • Official API Integration: Type-safe, comprehensive access to the NCBI E-utilities API (ESearch, EFetch, ELink).
  • Compliant & Resilient: Built-in rate limiting and retry logic to ensure compliance with NCBI policies.
  • Optimized Data Handling: Automatic parsing and normalization of complex XML responses into clean, agent-consumable JSON.

🚀 Getting Started

MCP Client Settings

Add the following to your MCP Client configuration file (e.g., cline_mcp_settings.json). This ensures the server is automatically installed and run when needed.

{
  "mcpServers": {
    "pubmed-mcp-server": {
      "command": "npx",
      "args": ["@cyanheads/pubmed-mcp-server"],
      "env": {
        "MCP_LOG_LEVEL": "info",
        "MCP_TRANSPORT_TYPE": "http",
        "MCP_HTTP_PORT": "3017",
        "NCBI_API_KEY": "YOUR_NCBI_API_KEY_HERE"
      }
    }
  }
}

Prerequisites

Manual Installation

  1. Clone the repository: git clone https://github.com/cyanheads/pubmed-mcp-server.git
  2. Navigate into the directory: cd pubmed-mcp-server
  3. Install dependencies: npm install
  4. Build the project: npm run build

⚙️ Configuration

Configure the server via environment variables. For local development, create a .env file in the project root.

| Variable | Description | Default | | :--- | :--- | :--- | | MCP_TRANSPORT_TYPE | Transport mechanism: stdio or http. | stdio | | MCP_HTTP_PORT | Port for the HTTP server. | 3017 | | MCP_AUTH_MODE | Auth mode for HTTP transport: none, jwt, or oauth. | jwt | | MCP_AUTH_SECRET_KEY| Required for jwt auth. 32+ character secret key. | (none) | | MCP_LOG_LEVEL | Logging level (debug, info, warning, error). | debug | | NCBI_API_KEY | Recommended. Your NCBI API Key for higher rate limits. | (none) | | LOGS_DIR | Directory for log file storage. | logs/ |

▶️ Running the Server

  • Start in STDIO mode (default): npm start
  • Start in HTTP mode: npm run start:http
  • Run local checks and tests: npm run devcheck (lint, format, type-check) and npm test

📂 Project Structure

| Directory | Purpose & Contents | | :--- | :--- | | src/mcp-server/tools | Tool definitions (logic.ts & registration.ts per tool). This is where you add new capabilities. | | src/mcp-server/transports | Implementations for HTTP and STDIO transports, including authentication middleware. | | src/services/ncbi | The core NCBI service client, parsers, and request queue manager. | | src/utils | Core utilities for logging, error handling, performance, and security. | | src/config | Environment variable parsing and validation with Zod. | | tests/ | Unit and integration tests, mirroring the src/ directory structure. |

🧑‍💻 Agent Development Guide

For strict rules when using this server with an AI agent, refer to the .clinerules/clinerules.md file in this repository. Key principles include:

  • Logic Throws, Handlers Catch: Never use try/catch in your tool's core logic. Always throw a structured McpError on failure. Handlers are responsible for catching and formatting the final response.
  • Pass the Context: Always pass the RequestContext object through your call stack for logging and tracing.
  • Singleton Services: Access external services (like the NcbiService) via their singleton getter (getNcbiService()) within the logic file.

🤝 Contributing

Issues and pull requests are welcome! If you plan to contribute, please run the local checks and tests before submitting your PR.

npm run devcheck
npm test

📜 License

This project is licensed under the Apache 2.0 License. See the LICENSE file for details.