PubMed MCP server

Enables AI systems to search, retrieve, and analyze biomedical literature from PubMed for evidence-based research, citation generation, and data visualization
Back to servers
Setup instructions
Provider
cyanheads
Release date
May 25, 2025
Language
Python
Stats
30 stars

The PubMed MCP Server provides a powerful bridge between AI applications and PubMed's vast biomedical literature database. It enables automated research workflows through the Model Context Protocol (MCP), allowing AI agents and research tools to search, retrieve, analyze, and visualize scientific literature without complex API integration.

Installation

Prerequisites

MCP Client Settings

Add the following to your MCP client's configuration file (e.g., cline_mcp_settings.json). This configuration uses npx to run the server, which will automatically install the package if not already present.

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

Manual Installation

Install via npm

npm install @cyanheads/pubmed-mcp-server

Install from Source

git clone https://github.com/cyanheads/pubmed-mcp-server.git
cd pubmed-mcp-server
npm install
npm run build

Configuration

Configure the server using environment variables, either in a .env file at the project root, directly in your environment, or in your MCP client configuration.

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) 3017
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_MODE Authentication mode for HTTP: jwt or oauth jwt
MCP_AUTH_SECRET_KEY Required for jwt auth. 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)
LOGS_DIR Directory for log file storage logs/
NODE_ENV Runtime environment (development, production) development

Available Tools

The server provides five specialized tools to interact with PubMed:

pubmed_search_articles

Searches PubMed for articles based on your query.

Key Parameters:

  • queryTerm: Your search query
  • maxResults: Maximum number of results to return
  • sortBy: Sorting method (relevance, date, etc.)
  • dateRange: Limit results to specific date range
  • filterByPublicationTypes: Filter by publication types
  • fetchBriefSummaries: Include brief summaries in results

pubmed_fetch_contents

Retrieves detailed information for PubMed articles.

Key Parameters:

  • pmids: PubMed IDs to fetch
  • queryKey: Query key from a previous search
  • webEnv: Web environment from a previous search
  • detailLevel: Level of detail to return
  • includeMeshTerms: Include MeSH terms
  • includeGrantInfo: Include grant information

pubmed_article_connections

Finds related articles, citations, and references for a PMID.

Key Parameters:

  • sourcePmid: Source PubMed ID
  • relationshipType: Type of connections to find
  • maxRelatedResults: Maximum number of related results
  • citationStyles: Citation style formats to return

pubmed_research_agent

Generates a standardized JSON research plan outline from component details.

Key Parameters:

  • project_title_suggestion: Suggested project title
  • primary_research_goal: Main research goal
  • research_keywords: Keywords for the research
  • organism_focus: Organism focus (if applicable)
  • Various other parameters for detailed research plan components

pubmed_generate_chart

Generates a chart image (PNG) from given input data.

Key Parameters:

  • chartType: Type of chart (bar, line, scatter, etc.)
  • dataValues: Data to visualize
  • xField: Field to use for x-axis
  • yField: Field to use for y-axis
  • title: Chart title
  • seriesField: Field for series grouping
  • sizeField: Field for determining point size

Running the Server

With stdio Transport (Default)

npm start

With HTTP Transport

MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3017 npm start

Testing with MCP Inspector

For stdio transport:

npm run inspector

For HTTP transport:

npm run inspector:http

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "pubmed-mcp-server" '{"command":"npx","args":["@cyanheads/pubmed-mcp-server"],"env":{"NCBI_API_KEY":"your_ncbi_api_key_here"},"disabled":false,"autoApprove":[]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "pubmed-mcp-server": {
            "command": "npx",
            "args": [
                "@cyanheads/pubmed-mcp-server"
            ],
            "env": {
                "NCBI_API_KEY": "your_ncbi_api_key_here"
            },
            "disabled": false,
            "autoApprove": []
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "pubmed-mcp-server": {
            "command": "npx",
            "args": [
                "@cyanheads/pubmed-mcp-server"
            ],
            "env": {
                "NCBI_API_KEY": "your_ncbi_api_key_here"
            },
            "disabled": false,
            "autoApprove": []
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later