Search and download scientific articles from PubMed's E-utilities API.
A Model Context Protocol (MCP) server that provides access to PubMed's E-utilities API for searching and downloading scientific articles. This server enables LLM applications to search PubMed's vast database of biomedical literature and retrieve article metadata, abstracts, and full content.
./setup.sh
This will create a virtual environment, install dependencies, and provide next steps.python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
# Edit .env file with your NCBI API key and email
Create a .env
file with the following optional configuration:
NCBI_API_KEY
: Your NCBI API key (increases rate limit from 3 to 10 requests/second)NCBI_EMAIL
: Your email address (recommended by NCBI for API usage tracking)Get your free NCBI API key at: https://www.ncbi.nlm.nih.gov/account/settings/
Activate the virtual environment (if not already active):
source venv/bin/activate # On Windows: venv\Scripts\activate
Run the server:
python server.py
The server will start and listen for MCP connections via stdio.
deactivate
search_articles
Search PubMed for articles matching a query.
Parameters:
query
(string, required): Search query (e.g., "COVID-19 vaccines", "machine learning AND healthcare")max_results
(int, optional): Maximum results to return (default: 20, max: 200)sort
(string, optional): Sort order - "relevance", "pub_date", or "first_author" (default: "relevance")Returns:
pmids
: List of PubMed IDstotal_count
: Total number of matching articlesquery_used
: The search query executedresults_returned
: Number of results returnedsort_order
: Sort order usedExample:
{
"query": "CRISPR gene editing",
"max_results": 10,
"sort": "pub_date"
}
download_article
Download article details by PubMed ID.
Parameters:
pmid
(string, required): PubMed ID (e.g., "33073741")format_type
(string, optional): Content format - "abstract", "medline", or "full" (default: "abstract")return_mode
(string, optional): Return format - "xml", "text", or "json" (default: "xml")Returns:
pmid
: The PubMed IDcontent
: Article content in requested formatformat_type
: Format type usedreturn_mode
: Return mode usedcontent_length
: Length of contentdownload_articles_batch
Download multiple articles in a single request.
Parameters:
pmids
(list, required): List of PubMed IDsformat_type
(string, optional): Content format (default: "abstract")return_mode
(string, optional): Return format (default: "xml")Returns:
pmids
: List of requested PMIDscontent
: Combined article contentarticle_count
: Number of articles requestedcontent_length
: Length of contentget_article_summaries
Get document summaries for articles (metadata without full content).
Parameters:
pmids
(list, required): List of PubMed IDsReturns:
pmids
: List of requested PMIDssummaries
: XML summary dataarticle_count
: Number of articles requested"COVID-19"
- Search for COVID-19 articles"machine learning"
- Search for machine learning articles"breast cancer"
- Search for breast cancer articles"COVID-19 AND vaccine"
- Articles about COVID-19 vaccines"machine learning AND healthcare"
- ML in healthcare"CRISPR[Title]"
- CRISPR in article titles only"Nature[Journal]"
- Articles from Nature journal"2023[PDAT]"
- Articles published in 2023"Smith J[Author]"
- Articles by author "Smith J"[Title]
- Search in title only[Author]
- Search by author[Journal]
- Search by journal name[PDAT]
- Search by publication date[MeSH]
- Search MeSH termsIf you configured your API key in the .env
file during installation:
{
"mcpServers": {
"pubmed": {
"command": "/path/to/pubmed-mcp/venv/bin/python",
"args": ["/path/to/pubmed-mcp/server.py"]
}
}
}
Alternatively, you can specify the API key directly in the Claude Desktop configuration:
{
"mcpServers": {
"pubmed": {
"command": "/path/to/pubmed-mcp/venv/bin/python",
"args": ["/path/to/pubmed-mcp/server.py"],
"env": {
"NCBI_API_KEY": "your_api_key_here",
"NCBI_EMAIL": "your_email@example.com"
}
}
}
}
Recommendation: Use Option 1 (.env file) for better security and easier management.
Note: Make sure to use the full path to the Python executable in the virtual environment (venv/bin/python
) to ensure the correct dependencies are available.
The server provides comprehensive error handling:
pubmed-mcp/
├── server.py # Main MCP server implementation
├── pubmed_client.py # PubMed API client wrapper
├── requirements.txt # Python dependencies
├── setup.sh # Automated setup script
├── .gitignore # Git ignore file
├── README.md # This file
├── .env.example # Environment variables template
└── venv/ # Virtual environment (created by setup)
mcp[cli]
- MCP Python SDKrequests
- HTTP client for PubMed APIpython-dotenv
- Environment variablestyping-extensions
- Type hints supportThis project is open source. Please check PubMed's terms of service for API usage guidelines.
For issues with this MCP server, please check:
For PubMed API documentation, visit: https://www.ncbi.nlm.nih.gov/books/NBK25500/
Search for messages and files within a Slack workspace using the Slack API.
An agent-based tool for web search and advanced research, including analysis of PDFs, documents, images, and YouTube transcripts.
Provides threat intelligence queries for IPs, domains, files, URLs, and vulnerabilities using the ThreatBook API.
Provides comprehensive queries for policy-related information, including government subsidies, benefits, and support for enterprises.
Search the web using Kagi's search API
An MCP server for web and local search using the Brave Search API.
Access Australian Pharmaceutical Benefits Scheme data for medicine information, pricing, and availability. Built with Python and FastAPI.
Get any answer from the Facebook Ads Library, conduct deep research including messaging, creative testing and comparisons in seconds.
RAG MCP for your Agentset data.
IP2Location.io API integration to retrieve the geolocation information for an IP address.