pubmed_mcp_server2

masa061580/pubmed_mcp_server2

3.2

If you are the rightful owner of pubmed_mcp_server2 and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The PubMed MCP Server v2 is a comprehensive Model Context Protocol server designed to enhance access to the PubMed database for biomedical literature search, retrieval, and analysis.

Tools
6
Resources
0
Prompts
0

PubMed MCP Server v2 (Version 1.0.2)

A comprehensive Model Context Protocol (MCP) server that provides advanced access to the PubMed database for biomedical literature search, retrieval, and analysis. This server transforms natural language queries into optimized PubMed searches using MeSH terms and provides citation analysis capabilities.

šŸš€ Features

šŸ”§ Tools

  • search_pubmed: Search PubMed database with comprehensive article summaries, abstracts, and metadata
  • get_full_abstract: Retrieve complete, untruncated abstracts for specific articles by PMID
  • get_full_text: Extract full text content from PubMed Central (PMC) open access articles
  • export_ris: Export citations in RIS format for reference management software (Zotero, Mendeley, EndNote)
  • get_citation_counts: Analyze citation metrics and find citing articles using NCBI elink API
  • optimize_search_query ✨: Transform natural language queries into optimized PubMed searches with MeSH terms and field tags
  • find_similar_articles: Find articles similar to a given PMID using NCBI's similarity algorithm with relevance scores
  • batch_process šŸ†•: Process multiple PMIDs with multiple operations efficiently for bulk analysis

šŸ“š Resources

  • pubmed://search/{query}: Access search results as structured JSON resource

šŸ’” Prompts

  • generate_search_query: Interactive assistant for creating effective PubMed search strategies

šŸ“‹ Prerequisites

  • Node.js v18.x or higher
  • npm or yarn package manager

šŸŽÆ Usage

Method 1: NPM Package (Recommended)

Benefits: Easy installation, automatic updates, no local build required.

Claude Desktop Configuration

Add to your Claude Desktop configuration file:

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

{
  "mcpServers": {
    "pubmed": {
      "command": "npx",
      "args": ["-y", "pubmed_mcp_server2"]
    }
  }
}
Claude Code Configuration
claude mcp add pubmed -s project -- cmd /c npx pubmed_mcp_server2

Method 2: Local Development

Use case: For development, customization, or when you want to modify the source code.

šŸ› ļø Installation

  1. Clone this repository:
git clone https://github.com/YOUR_USERNAME/pubmed_mcp_server2.git
cd pubmed_mcp_server2
  1. Install dependencies:
npm install
  1. Build the server:
npm run build
Claude Desktop Integration (Local)

Add to your Claude Desktop configuration file:

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

{
  "mcpServers": {
    "pubmed-server": {
      "command": "node",
      "args": ["C:\\path\\to\\pubmed_mcp_server2\\dist\\index.js"],
      "env": {}
    }
  }
}

Replace the path with your actual installation directory.

Example Usage

1. Query Optimization
Input: "covid vaccine effectiveness in elderly"
→ Transforms to: ("COVID-19"[MeSH Terms] OR "SARS-CoV-2"[MeSH Terms]) AND ("Vaccination"[MeSH Terms]) AND ("Treatment Outcome"[MeSH Terms]) AND ("Aged"[MeSH Terms])
2. Basic Literature Search
search_pubmed: "diabetes treatment 2023"
→ Returns: Detailed articles with abstracts, PMIDs, DOIs, and citation metrics
3. Citation Analysis
get_citation_counts: "36038128, 30105375"
→ Returns: Citation counts and lists of citing articles for each PMID
4. Reference Management
export_ris: "36038128, 30105375"
→ Returns: RIS formatted citations ready for import into reference managers
5. Find Similar Articles
find_similar_articles: "36038128"
→ Returns: Up to 10 similar articles ranked by NCBI's similarity algorithm
→ Each result includes similarity score, title, authors, abstract preview
6. Batch Processing (NEW in v1.0.2)
batch_process: {pmids: ["36038128", "35105375"], operations: ["abstract", "citations"]}
→ Returns: Comprehensive analysis of multiple articles in one request
→ Supports: abstract, citations, similar, ris_export, full_text operations

🧠 MeSH Term Optimization

The server includes an extensive database of medical term mappings covering:

  • COVID-19 & Vaccines: covid, coronavirus, vaccination, immunization
  • Cardiovascular: heart attack, myocardial infarction, cardiovascular disease
  • Cancer: cancer, tumor, oncology, carcinoma
  • Mental Health: depression, anxiety, psychiatric disorders
  • Age Groups: elderly, children, pediatric, adolescent
  • Study Types: clinical trial, meta-analysis, systematic review, RCT
  • Treatment Types: therapy, surgery, medication, drug treatment

šŸ”§ Advanced Search Features

Field Tags Supported

  • [ti] - Title
  • [ab] - Abstract
  • [au] - Author
  • [ta] - Journal Title
  • [MeSH Terms] - Medical Subject Headings
  • [tw] - Text Word
  • [pt] - Publication Type
  • [pdat] - Publication Date

Boolean Operators

  • AND - All terms must be present
  • OR - Any of the terms can be present
  • NOT - Exclude specific terms
  • Parentheses for grouping complex queries

šŸ“Š API Endpoints & Rate Limiting

NCBI E-utilities APIs Used

  • ESearch: Search and retrieve primary IDs
  • EFetch: Retrieve full records and abstracts
  • ESummary: Retrieve document summaries
  • ELink: Find related articles and citations
  • Literature Citation Exporter: RIS format export

Rate Limiting & Limits

  • Search results: Maximum 100 articles per query
  • Citation analysis: Maximum 20 PMIDs per request
  • RIS export: Maximum 50 PMIDs per batch
  • Full text: Maximum 10 PMC articles per request
  • Similar articles: Maximum 50 similar articles per PMID (default: 10)
  • Batch processing: Maximum 50 PMIDs per batch with up to 5 concurrent operations
  • API delays: 200-600ms between requests to respect NCBI guidelines

āš™ļø Configuration

Customizable Parameters

Edit src/pubmed-api.ts to modify:

// Email for NCBI API (required by NCBI guidelines)
email: 'your-email@example.com'

// Rate limiting delays
const delayBetweenRequests = 200; // milliseconds

// Result limits
const maxResults = 100; // search results
const maxPmids = 20;    // citation analysis

šŸ” Error Handling

Comprehensive error handling for:

  • Network connectivity issues
  • Invalid PMIDs or queries
  • API rate limiting and timeouts
  • XML/JSON parsing errors
  • Missing full text content
  • Citation data unavailability

🚧 Development

Available Scripts

npm run build      # Compile TypeScript
npm run dev        # Build and run in development
npm run clean      # Remove compiled files
npm run start      # Start the compiled server

Project Structure

pubmed_mcp_server2/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ index.ts           # Main MCP server setup and tool registration
│   └── pubmed-api.ts      # PubMed API integration and utilities
ā”œā”€ā”€ dist/                  # Compiled JavaScript output
ā”œā”€ā”€ package.json           # Dependencies and scripts
ā”œā”€ā”€ tsconfig.json          # TypeScript configuration
└── README.md             # This file

Adding New Features

  1. New MeSH mappings: Add to MESH_MAPPINGS object in pubmed-api.ts
  2. New tools: Register in index.ts using server.registerTool()
  3. Field tags: Add to FIELD_TAGS object for query optimization

šŸ¤ Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes and test thoroughly
  4. Commit with descriptive messages: git commit -m "Add feature description"
  5. Push to your branch: git push origin feature-name
  6. Submit a pull request

šŸ“– Documentation

PubMed Search Tips

  1. Use MeSH terms for standardized medical vocabulary
  2. Combine multiple concepts with AND/OR operators
  3. Use field tags to target specific parts of articles
  4. Add date ranges to focus on recent research
  5. Filter by publication type for specific study designs

Reference Management Integration

The RIS export feature supports:

  • Zotero: File → Import
  • Mendeley: File → Import → RIS
  • EndNote: File → Import → File
  • Papers: Import → From File
  • RefWorks: Import → References

šŸ›”ļø Privacy & Ethics

  • No user data is stored or logged
  • All queries are sent directly to NCBI APIs
  • Complies with NCBI usage guidelines
  • Respects API rate limits and terms of service

šŸ“„ License

MIT License - see LICENSE file for details

šŸ™‹ā€ā™‚ļø Support

For issues, questions, or contributions:

  1. Check existing issues on GitHub
  2. Create a new issue with detailed description
  3. Include error messages and steps to reproduce

šŸ“¦ Installation Options

Quick Start (NPM)

npm install -g pubmed_mcp_server2

Update to Latest Version

npm update -g pubmed_mcp_server2

šŸ“ Version History

v1.0.2 (Latest)

  • šŸ†• Batch Processing: Process multiple PMIDs with multiple operations efficiently
  • šŸ”§ Flexible Input: Support for array, space-separated, and comma-separated PMID input
  • šŸ“Š Enhanced Analytics: Improved citation analysis and error reporting
  • ⚔ Performance: Optimized API rate limiting and concurrent processing

v1.0.1

  • šŸ†• Similar Articles: Find articles similar to a given PMID using NCBI's algorithm
  • šŸŽÆ Improved Relevance: Similarity scores and ranking
  • šŸ”§ Bug Fixes: Enhanced error handling and API stability

v1.0.0

  • šŸš€ Initial Release: Core PubMed search and analysis functionality
  • šŸ“– Full Features: Search, abstracts, citations, RIS export, query optimization

šŸ”— Related Resources