Skip to main content
Glama
h-lu

Paper Search MCP Server

by h-lu

read_pubmed_paper

Retrieve PubMed paper content by providing alternative methods when direct access is unavailable, including Sci-Hub for pre-2023 publications or Semantic Scholar as a fallback.

Instructions

PubMed does NOT support direct paper reading.

INSTEAD (try in order):
1. read_scihub_paper(doi) - if published before 2023
2. read_semantic_paper(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

  • The primary handler function decorated with @mcp.tool(), which registers it as an MCP tool and executes the logic by calling the generic _read helper for the 'pubmed' platform.
    @mcp.tool()
    async def read_pubmed_paper(paper_id: str, save_path: Optional[str] = None) -> str:
        """PubMed does NOT support direct paper reading.
        
        INSTEAD (try in order):
        1. read_scihub_paper(doi) - if published before 2023
        2. read_semantic_paper(id) - last resort
        
        Args:
            paper_id: PMID (unused).
            save_path: Unused.
        
        Returns:
            Error message with alternatives.
        """
        return await _read('pubmed', paper_id, save_path)
  • Generic helper function _read that all read_*_paper tools call. It retrieves the platform searcher from SEARCHERS dict and calls its read_paper method, handling NotImplementedError by returning the error message.
    async def _read(
        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.read_paper(paper_id, save_path)
        except NotImplementedError as e:
            return str(e)
        except Exception as e:
            logger.error(f"Read failed for {searcher_name}: {e}")
            return f"Error reading paper: {str(e)}"
  • The platform-specific read_paper implementation in PubMedSearcher class. Since PubMed does not host full-text papers, it returns an instructional message directing users to alternatives like DOI or PMC.
    def read_paper(self, paper_id: str, save_path: str) -> str:
        """尝试读取 PubMed 论文(不支持)
        
        Returns:
            str: 说明信息
        """
        return (
            "PubMed papers cannot be read directly through this tool. "
            "Only metadata and abstracts are available through PubMed's API. "
            "Please use the paper's DOI to access the full text, "
            "or check if the paper is available on PubMed Central (PMC)."
        )
  • The @mcp.tool() decorator registers this function as an MCP tool named 'read_pubmed_paper', with input schema inferred from the function signature.
    @mcp.tool()
    async def read_pubmed_paper(paper_id: str, save_path: Optional[str] = None) -> str:
        """PubMed does NOT support direct paper reading.
        
        INSTEAD (try in order):
        1. read_scihub_paper(doi) - if published before 2023
        2. read_semantic_paper(id) - last resort
        
        Args:
            paper_id: PMID (unused).
            save_path: Unused.
        
        Returns:
            Error message with alternatives.
        """
        return await _read('pubmed', paper_id, save_path)

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