Skip to main content
Glama
h-lu

Paper Search MCP Server

by h-lu

download_pubmed

Explains that PubMed does not host PDFs and provides alternative methods to download academic papers from other sources.

Instructions

PubMed does NOT support direct PDF downloads.

PubMed is a metadata database - it does not host PDFs.

INSTEAD (try in order):
1. download_scihub(doi) - if published before 2023
2. download_semantic(id) - last resort

Args:
    paper_id: PMID (unused).
    save_path: Unused.

Returns:
    Error message with alternatives.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paper_idYes
save_pathNo

Implementation Reference

  • Handler function for download_pubmed tool. Registered via @mcp.tool(). Delegates to _download helper with 'pubmed' platform. Includes input schema via type hints and comprehensive docstring explaining limitations.
    @mcp.tool()
    async def download_pubmed(paper_id: str, save_path: Optional[str] = None) -> str:
        """PubMed does NOT support direct PDF downloads.
        
        PubMed is a metadata database - it does not host PDFs.
        
        INSTEAD (try in order):
        1. download_scihub(doi) - if published before 2023
        2. download_semantic(id) - last resort
        
        Args:
            paper_id: PMID (unused).
            save_path: Unused.
        
        Returns:
            Error message with alternatives.
        """
        return await _download('pubmed', paper_id, save_path)
  • Generic _download helper function called by download_pubmed. Retrieves the platform searcher (PubMedSearcher for 'pubmed') from SEARCHERS dict and invokes its download_pdf method, handling errors including NotImplementedError.
    async def _download(
        searcher_name: str, 
        paper_id: str, 
        save_path: Optional[str] = None
    ) -> str:
        """通用下载函数"""
        if save_path is None:
            save_path = get_download_path()
        
        searcher = SEARCHERS.get(searcher_name)
        if not searcher:
            return f"Error: Unknown searcher {searcher_name}"
        
        try:
            return searcher.download_pdf(paper_id, save_path)
        except NotImplementedError as e:
            return str(e)
        except Exception as e:
            logger.error(f"Download failed for {searcher_name}: {e}")
            return f"Error downloading: {str(e)}"
  • PubMedSearcher.download_pdf method, the core platform-specific implementation called by the generic _download. Raises NotImplementedError with helpful message since PubMed is metadata-only.
    def download_pdf(self, paper_id: str, save_path: str) -> str:
        """尝试下载 PubMed 论文 PDF(不支持)
    
        PubMed 是索引数据库,不提供直接 PDF 下载。
        请使用 DOI 或 PubMed Central 获取全文。
        
        Raises:
            NotImplementedError: 始终抛出
        """
        raise NotImplementedError(
            "PubMed does not provide direct PDF downloads. "
            "Please use the paper's DOI to access the publisher's website, "
            "or check if the paper is available on PubMed Central (PMC)."
        )
  • SEARCHERS dictionary that instantiates all platform searchers, including PubMedSearcher for the 'pubmed' key used by download_pubmed.
    SEARCHERS = {
        'arxiv': ArxivSearcher(),
        'pubmed': PubMedSearcher(),
        'biorxiv': BioRxivSearcher(),
        'medrxiv': MedRxivSearcher(),
        'google_scholar': GoogleScholarSearcher(),
        'iacr': IACRSearcher(),
        'semantic': SemanticSearcher(),
        'crossref': CrossRefSearcher(),
        'repec': RePECSearcher(),
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/h-lu/paper-search-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server