
PubMed
STDIOMCP server providing PubMed biomedical literature database access for AI and research tools.
MCP server providing PubMed biomedical literature database access for AI and research tools.
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.
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 (PNG) 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 a PNG. |
| Overview | Features | Installation |
| Configuration | Project Structure |
| Tools | Resources | Development | License |
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:
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.
Leverages the robust utilities provided by the mcp-ts-template
:
McpError
), and automatic logging.dotenv
) with comprehensive validation.zod
for schema validation and custom sanitization logic.npm install @cyanheads/pubmed-mcp-server
Clone the repository:
git clone https://github.com/cyanheads/pubmed-mcp-server.git cd pubmed-mcp-server
Install dependencies:
npm install
Build the project:
npm run build *or npm run rebuild*
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 |
LOGS_DIR | Directory for log file storage. | logs/ |
Add to your MCP client settings (e.g., cline_mcp_settings.json
):
{ "mcpServers": { "pubmed-mcp-server": { "command": "node", "args": ["/path/to/your/pubmed-mcp-server/dist/index.js"], "env": { "NCBI_API_KEY": "your_ncbi_api_key_here" }, "disabled": false, "autoApprove": [] } } }
Note: You can see mcp.json for an example MCP client configuration file that includes the PubMed MCP Server.
The codebase follows a modular structure within the src/
directory:
src/
├── index.ts # Entry point: Initializes and starts the server
├── config/ # Configuration loading (env vars, package info)
│ └── index.ts
├── mcp-server/ # Core MCP server logic and capability registration
│ ├── server.ts # Server setup, capability registration
│ ├── transports/ # Transport handling (stdio, http)
│ ├── resources/ # MCP Resource implementations
│ └── tools/ # MCP Tool implementations (subdirs per tool)
├── services/ # External service integrations
│ ├── NCBI/ # NCBI E-utilities API client and parsing
│ └── llm-providers/ # LLM provider integrations (optional)
├── types-global/ # Shared TypeScript type definitions
└── utils/ # Common utility functions (logger, error handler, etc.)
For a detailed file tree, run npm run tree
or see docs/tree.md.
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 PNG 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.
Comprehensive usage examples are available in the examples/
directory:
examples/
directory.# Build the project (compile TS to JS in dist/ and make executable) npm run build # Test the server locally using the MCP inspector tool (stdio transport) npm run inspector # Test the server locally using the MCP inspector tool (http transport) npm run inspector:http # Clean build artifacts npm run clean # Generate a file tree representation for documentation npm run tree # Clean build artifacts and then rebuild the project npm run rebuild # Format code with Prettier npm run format # Start the server using stdio (default) npm start # Or explicitly: npm run start:stdio # Start the server using HTTP transport npm run start:http
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.