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.
PubMed MCP Server
Empower your AI agents and research tools with seamless PubMed integration!
An MCP (Model Context Protocol) server providing comprehensive access to PubMed's biomedical literature database. Enables LLMs and AI agents to search, retrieve, analyze, and visualize scientific publications through NCBI's E-utilities API with advanced research workflow capabilities.
Built on the cyanheads/mcp-ts-template
, this server follows a modular architecture with robust error handling, logging, and security features.
🚀 Core Capabilities: PubMed Tools 🛠️
This server equips your AI with specialized tools to interact with PubMed:
Tool Name | Description | Key Features |
---|---|---|
search_pubmed_articles | Searches PubMed for articles based on your query. (See Example) | - Filter by max results, sort order, date range, publication types.- Uses NCBI ESearch for PMIDs.- Optionally fetches brief summaries (title, authors, source, dates) via ESummary. |
fetch_pubmed_content | Retrieves detailed information for PubMed articles. Can use a list of PMIDs or ESearch history (queryKey/webEnv) with pagination. (See Example) | - Flexible detailLevel : abstract_plus (parsed details, optional MeSH/grant), full_xml (JSON representation of the PubMedArticle XML structure), medline_text (MEDLINE format), citation_data (minimal for citations).- Supports direct PMID list or queryKey /webEnv from ESearch history.- Supports retstart /retmax for pagination with history.- Uses NCBI EFetch. |
get_pubmed_article_connections | Finds related articles (cited by, similar, references) or formats citations for a PMID. (See Ex.1, Ex.2) | - Uses NCBI ELink for relationships.- Uses NCBI EFetch for citation data (RIS, BibTeX, APA, MLA).- Filter by max related results. |
pubmed_research_agent | Generates a standardized JSON research plan outline from component details. (See Example) | - Accepts granular inputs for all research phases.- Optionally embeds instructive prompts for agent execution.- Structures rough ideas into a formal, machine-readable plan for further processing. |
generate_pubmed_chart | Generates a chart image (SVG) from given input data. (See Bar, Line, Scatter) | - Supports 'bar', 'line', and 'scatter' chart types.- Takes data values and field specifications for axes and encoding.- Constructs a Vega-Lite specification internally and renders it as an SVG. |
Table of Contents
| Overview | Features | Installation |
| Configuration | Project Structure |
| Tools | Resources | Development | License |
Overview
The PubMed MCP Server acts as a bridge, allowing applications (MCP Clients) that understand the Model Context Protocol (MCP) – like advanced AI assistants (LLMs), IDE extensions, or custom research tools – to interact directly and efficiently with PubMed's vast biomedical literature database.
Instead of complex API integration or manual searches, your tools can leverage this server to:
- Automate research workflows: Search literature, fetch full article metadata, track citations, and generate research plans programmatically.
- Gain research insights: Access detailed publication data, author information, journal details, MeSH terms, and citation networks without leaving the host application.
- Integrate PubMed into AI-driven research: Enable LLMs to conduct literature reviews, analyze research trends, and support evidence-based decision making.
- Visualize research data: Generate charts and visualizations from publication metadata and search results.
Built on the robust mcp-ts-template
, this server provides a standardized, secure, and efficient way to expose PubMed functionality via the MCP standard. It achieves this by integrating with NCBI's E-utilities API, ensuring compliance with rate limits and providing comprehensive error handling.
Developer Note: This repository includes a .clinerules file that serves as a developer cheat sheet for your LLM coding agent with quick reference for the codebase patterns, file locations, and code snippets.
Features
Core Utilities
Leverages the robust utilities provided by the mcp-ts-template
:
- Logging: Structured, configurable logging (file rotation, console, MCP notifications) with sensitive data redaction.
- Error Handling: Centralized error processing, standardized error types (
McpError
), and automatic logging. - Configuration: Environment variable loading (
dotenv
) with comprehensive validation. - Input Validation/Sanitization: Uses
zod
for schema validation and custom sanitization logic. - Request Context: Tracking and correlation of operations via unique request IDs.
- Type Safety: Strong typing enforced by TypeScript and Zod schemas.
- HTTP Transport Option: Built-in Express server with SSE, session management, CORS support, and JWT authentication.
- Rate Limiting: Built-in request queuing and delay management for NCBI API compliance.
PubMed Integration
- NCBI E-utilities Integration: Comprehensive access to ESearch, EFetch, ELink, and ESummary APIs with automatic XML parsing.
- Advanced Search Capabilities: Complex query construction with date ranges, publication types, author filters, and MeSH term support.
- Full Article Metadata: Retrieve complete publication data including abstracts, authors, affiliations, journal information, DOIs, and citation data.
- Citation Network Analysis: Find related articles, citing articles, and reference lists through ELink integration.
- Research Planning: Generate structured research plans with automated literature search strategies.
- Data Visualization: Create SVG charts from publication metadata (bar charts, line graphs, scatter plots).
- Multiple Output Formats: Support for JSON, MEDLINE text, full XML, and formatted citations (RIS, BibTeX, APA, MLA).
- Batch Processing: Efficient handling of multiple PMIDs with pagination support.
Installation
Prerequisites
- Node.js (>=18.0.0)
- npm (comes with Node.js)
- NCBI API Key (recommended for higher rate limits) - Get one here
Install via npm (recommended)
Alternatively Install from Source
- Clone the repository:
- Install dependencies:
- Build the project:
Configuration
Environment Variables
Configure the server using environment variables. These environmental variables are set within your MCP client config/settings (e.g. claude_desktop_config.json
for Claude Desktop)
Variable | Description | Default |
---|---|---|
MCP_TRANSPORT_TYPE | Transport mechanism: stdio or http . | stdio |
MCP_HTTP_PORT | Port for the HTTP server (if MCP_TRANSPORT_TYPE=http ). | 3010 |
MCP_HTTP_HOST | Host address for the HTTP server (if MCP_TRANSPORT_TYPE=http ). | 127.0.0.1 |
MCP_ALLOWED_ORIGINS | Comma-separated list of allowed origins for CORS (if MCP_TRANSPORT_TYPE=http ). | (none) |
MCP_LOG_LEVEL | Logging level (debug , info , notice , warning , error , crit , alert , emerg ). | debug |
MCP_AUTH_SECRET_KEY | Required for HTTP transport. Minimum 32-character secret key for JWT authentication. | (none) |
NCBI_API_KEY | Recommended. Your NCBI API Key for higher rate limits and reliable access. | (none) |
NCBI_TOOL_IDENTIFIER | Tool identifier for NCBI E-utility requests. | @cyanheads/pubmed-mcp-server/<version> |
NCBI_ADMIN_EMAIL | Required. Administrative contact email for NCBI E-utility requests. | (none) |
NCBI_REQUEST_DELAY_MS | Milliseconds to wait between NCBI requests. | 100 (with API key), 334 (without) |
NCBI_MAX_RETRIES | Maximum number of retries for failed NCBI requests. | 3 |
LOGS_DIR | Directory for log file storage. | logs/ |
MCP Client Settings
Add to your MCP client settings (e.g., cline_mcp_settings.json
):
Note: You can see mcp.json for an example MCP client configuration file that includes the PubMed MCP Server.
Project Structure
The codebase follows a modular structure within the src/
directory:
For a detailed file tree, run npm run tree
or see docs/tree.md.
Tools
The PubMed MCP Server provides a comprehensive suite of tools for biomedical literature research, callable via the Model Context Protocol.
Tool Name | Description | Key Arguments |
---|---|---|
search_pubmed_articles | Searches PubMed for articles using queries, filters, and date ranges. | queryTerm , maxResults? , sortBy? , dateRange? , filterByPublicationTypes? , fetchBriefSummaries? |
fetch_pubmed_content | Fetches detailed article information using PMIDs or search history. | pmids? , queryKey? , webEnv? , detailLevel? , includeMeshTerms? , includeGrantInfo? |
get_pubmed_article_connections | Finds related articles, citations, and references for a given PMID. | sourcePmid , relationshipType? , maxRelatedResults? , citationStyles? |
pubmed_research_agent | Generates structured research plans with literature search strategies. | project_title_suggestion , primary_research_goal , research_keywords , organism_focus? , p1_* , etc. |
generate_pubmed_chart | Creates customizable SVG charts from structured publication data. | chartType , dataValues , xField , yField , title? , colorField? , seriesField? , sizeField? |
Note: All tools support comprehensive error handling and return structured JSON responses.
Examples
Comprehensive usage examples are available in the examples/
directory:
- Search PubMed Articles
- Fetch Article Content
- Article Connections
- Research Planning
- Chart Generation - Various SVG chart examples
Development
Build and Test
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
A bridge connecting AI agents to NCBI's PubMed database through the Model Context Protocol, enabling seamless searching, retrieval, and analysis of biomedical literature and data.
Related MCP Servers
- -securityFlicense-quality🔍 Enable AI assistants to search and access medRxiv papers through a simple MCP interface. The medRxiv MCP Server provides a bridge between AI assistants and medRxiv's preprint repository through the Model Context Protocol (MCP). It allows AI models to search for health sciences preprints and acceLast updated -1Python
- -securityAlicense-qualityAn MCP server enabling AI assistants to search and analyze pharmaceutical data through Cortellis. Features comprehensive drug search, ontology exploration, and real-time clinical trial data access.Last updated -PythonMIT License
- -securityAlicense-qualityA specialized Model Context Protocol server that enhances AI-assisted medical learning by connecting Claude Desktop to PubMed, NCBI Bookshelf, and user documents for searching, retrieving, and analyzing medical education content.Last updated -PythonMIT License
- -securityAlicense-quality🔍 Enable AI assistants to search, access, and analyze PubMed articles through a simple MCP interface.Last updated -13PythonMIT License