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.
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"
}
}
}
}
npm install @cyanheads/pubmed-mcp-server
git clone https://github.com/cyanheads/pubmed-mcp-server.git
cd pubmed-mcp-server
npm install
npm run build
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 |
The server provides five specialized tools to interact with PubMed:
Searches PubMed for articles based on your query.
Key Parameters:
queryTerm: Your search querymaxResults: Maximum number of results to returnsortBy: Sorting method (relevance, date, etc.)dateRange: Limit results to specific date rangefilterByPublicationTypes: Filter by publication typesfetchBriefSummaries: Include brief summaries in resultsRetrieves detailed information for PubMed articles.
Key Parameters:
pmids: PubMed IDs to fetchqueryKey: Query key from a previous searchwebEnv: Web environment from a previous searchdetailLevel: Level of detail to returnincludeMeshTerms: Include MeSH termsincludeGrantInfo: Include grant informationFinds related articles, citations, and references for a PMID.
Key Parameters:
sourcePmid: Source PubMed IDrelationshipType: Type of connections to findmaxRelatedResults: Maximum number of related resultscitationStyles: Citation style formats to returnGenerates a standardized JSON research plan outline from component details.
Key Parameters:
project_title_suggestion: Suggested project titleprimary_research_goal: Main research goalresearch_keywords: Keywords for the researchorganism_focus: Organism focus (if applicable)Generates a chart image (PNG) from given input data.
Key Parameters:
chartType: Type of chart (bar, line, scatter, etc.)dataValues: Data to visualizexField: Field to use for x-axisyField: Field to use for y-axistitle: Chart titleseriesField: Field for series groupingsizeField: Field for determining point sizenpm start
MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3017 npm start
For stdio transport:
npm run inspector
For HTTP transport:
npm run inspector:http
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.
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.
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": []
}
}
}
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.
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.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.json2. 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