Skip to main content
Glama
openags

Paper Search MCP

by openags

search_pubmed

Search academic papers from PubMed to find relevant research articles using query terms and return paper metadata for analysis.

Instructions

Search academic papers from PubMed.

Args: query: Search query string (e.g., 'machine learning'). max_results: Maximum number of papers to return (default: 10). Returns: List of paper metadata in dictionary format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
max_resultsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The `search_pubmed` tool handler in the MCP server, which orchestrates the call to the PubMedSearcher instance.
    async def search_pubmed(query: str, max_results: int = 10) -> List[Dict]:
        """Search academic papers from PubMed.
    
        Args:
            query: Search query string (e.g., 'machine learning').
            max_results: Maximum number of papers to return (default: 10).
        Returns:
            List of paper metadata in dictionary format.
        """
        papers = await async_search(pubmed_searcher, query, max_results)
        return papers if papers else []
  • The `PubMedSearcher.search` method which performs the actual API calls to PubMed to fetch academic papers.
    def search(self, query: str, max_results: int = 10) -> List[Paper]:
        search_params = {
            'db': 'pubmed',
            'term': query,
            'retmax': max_results,
            'retmode': 'xml'
        }
        search_response = requests.get(self.SEARCH_URL, params=search_params)
        search_root = ET.fromstring(search_response.content)
        ids = [id.text for id in search_root.findall('.//Id') if id.text]
        if not ids:
            return []
        
        fetch_params = {
            'db': 'pubmed',
            'id': ','.join(ids),
            'retmode': 'xml'
        }
        fetch_response = requests.get(self.FETCH_URL, params=fetch_params)
        fetch_root = ET.fromstring(fetch_response.content)
        
        papers = []
        for article in fetch_root.findall('.//PubmedArticle'):
            try:
                pmid_elem = article.find('.//PMID')
                pmid = pmid_elem.text.strip() if pmid_elem is not None and pmid_elem.text else ''
                if not pmid:
                    continue
    
                title_elem = article.find('.//ArticleTitle')
                title = ''.join(title_elem.itertext()).strip() if title_elem is not None else ''
                if not title:
                    continue
    
                authors = []
                for author in article.findall('.//Author'):
                    last_name = author.find('LastName')
                    initials = author.find('Initials')
                    if last_name is not None and last_name.text:
                        name = last_name.text.strip()
                        if initials is not None and initials.text:
                            name = f"{name} {initials.text.strip()}"
                        authors.append(name)
    
                abstract_parts = []
                for abstract_elem in article.findall('.//AbstractText'):
                    text = ''.join(abstract_elem.itertext()).strip()
                    if text:
                        abstract_parts.append(text)
                abstract = ' '.join(abstract_parts)
    
                year_elem = article.find('.//PubDate/Year')
                pub_date = year_elem.text if year_elem is not None else None
                published = datetime.strptime(pub_date, '%Y') if pub_date else None
                doi_elem = article.find('.//ELocationID[@EIdType="doi"]')
                doi = doi_elem.text if doi_elem is not None else ''
    
                if not doi and abstract:
                    doi = extract_doi(abstract)
    
                papers.append(Paper(
                    paper_id=pmid,
                    title=title,
                    authors=authors,
                    abstract=abstract,
                    url=f"https://pubmed.ncbi.nlm.nih.gov/{pmid}/",
                    pdf_url='',  # PubMed 无直接 PDF
                    published_date=published,
                    updated_date=published,
                    source='pubmed',
                    categories=[],
                    keywords=[],
                    doi=doi
                ))
            except Exception:
                continue
        return papers
  • Registration of the `pubmed_searcher` instance used by the handler.
    pubmed_searcher = PubMedSearcher()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states it's a search operation and mentions the return format ('List of paper metadata in dictionary format'), but doesn't disclose important behavioral traits like rate limits, authentication requirements, pagination behavior, error conditions, or what specific metadata fields are included. For a search tool with no annotation coverage, this leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with clear sections (Args, Returns), uses minimal words to convey essential information, and has no redundant content. Every sentence serves a purpose: stating the tool's function, explaining parameters, and describing the return format.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (which handles return value documentation) and only 2 parameters with good description coverage, the description is reasonably complete for a basic search operation. However, with no annotations and many similar sibling tools, it lacks important context about when to use this specific tool and behavioral constraints that would help an agent use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description compensates well by explaining both parameters: 'query' as a 'Search query string' with an example, and 'max_results' with its default value. This adds meaningful context beyond the bare schema, though it doesn't specify query syntax details or result limits beyond the default.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Search academic papers from PubMed.' This specifies the verb ('Search') and resource ('academic papers from PubMed'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'search_pmc' or 'search_europepmc' that might also search PubMed-related databases.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With many sibling tools like 'search_pmc', 'search_europepmc', and 'download_pubmed', there's no indication of what makes this tool distinct or when it should be preferred over other PubMed-related search or download tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/openags/paper-search-mcp'

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