Skip to main content
Glama
chrismannina

PubMed MCP Server

by chrismannina

get_article_details

Retrieve detailed PubMed article information including abstracts and citations by providing PMID identifiers for research analysis.

Instructions

Get detailed information for specific articles by PMID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pmidsYesList of PubMed IDs
include_abstractsNoInclude abstracts in response
include_citationsNoInclude citation count and metrics

Implementation Reference

  • MCP tool handler _handle_get_article_details: validates input arguments, calls PubMedClient.get_article_details, formats articles using _format_article_details, and constructs MCPResponse.
    async def _handle_get_article_details(self, arguments: Dict[str, Any]) -> MCPResponse:
        """Handle getting detailed article information."""
        try:
            pmids = arguments.get("pmids", [])
            if not pmids:
                return MCPResponse(
                    content=[{"type": "text", "text": "PMIDs parameter is required"}], is_error=True
                )
    
            include_abstracts = arguments.get("include_abstracts", True)
            include_citations = arguments.get("include_citations", False)
    
            articles = await self.pubmed_client.get_article_details(
                pmids=pmids,
                include_abstracts=include_abstracts,
                include_citations=include_citations,
                cache=self.cache,
            )
    
            content = []
            content.append(
                {"type": "text", "text": f"**Article Details for {len(articles)} Articles**\n"}
            )
    
            if articles:
                for i, article in enumerate(articles, 1):
                    article_text = self._format_article_details(article, i)
                    content.append({"type": "text", "text": article_text})
            else:
                content.append(
                    {"type": "text", "text": "No articles found for the provided PMIDs."}
                )
    
            return MCPResponse(content=content)
    
        except Exception as e:
            logger.error(f"Error in get_article_details: {e}")
            return MCPResponse(
                content=[{"type": "text", "text": f"Error: {str(e)}"}], is_error=True
            )
  • Tool schema definition specifying input parameters: required pmids array, optional include_abstracts and include_citations booleans.
    {
        "name": "get_article_details",
        "description": ("Get detailed information for specific articles by PMID"),
        "inputSchema": {
            "type": "object",
            "properties": {
                "pmids": {
                    "type": "array",
                    "items": {"type": "string"},
                    "description": "List of PubMed IDs",
                },
                "include_abstracts": {
                    "type": "boolean",
                    "default": True,
                    "description": "Include abstracts in response",
                },
                "include_citations": {
                    "type": "boolean",
                    "default": False,
                    "description": "Include citation count and metrics",
                },
            },
            "required": ["pmids"],
        },
    },
  • Registration of get_article_details tool in the handler_map dictionary, mapping to the _handle_get_article_details method.
    handler_map = {
        "search_pubmed": self._handle_search_pubmed,
        "get_article_details": self._handle_get_article_details,
        "search_by_author": self._handle_search_by_author,
        "find_related_articles": self._handle_find_related_articles,
        "export_citations": self._handle_export_citations,
        "search_mesh_terms": self._handle_search_mesh_terms,
        "search_by_journal": self._handle_search_by_journal,
        "get_trending_topics": self._handle_get_trending_topics,
        "analyze_research_trends": self._handle_analyze_research_trends,
        "compare_articles": self._handle_compare_articles,
        "get_journal_metrics": self._handle_get_journal_metrics,
        "advanced_search": self._handle_advanced_search,
    }
  • PubMedClient.get_article_details: validates PMIDs, checks/sets cache, fetches details via EFetch API using _fetch_article_details and parses into Article objects.
    async def get_article_details(
        self,
        pmids: List[str],
        include_abstracts: bool = True,
        include_citations: bool = False,
        cache: Optional[CacheManager] = None,
    ) -> List[Article]:
        """
        Get detailed article information for specific PMIDs.
    
        Args:
            pmids: List of PubMed IDs
            include_abstracts: Include abstracts
            include_citations: Include citation metrics
            cache: Cache manager instance
    
        Returns:
            List of Article objects
        """
        # Validate PMIDs
        valid_pmids = [pmid for pmid in pmids if validate_pmid(pmid)]
        if len(valid_pmids) != len(pmids):
            logger.warning(f"Some invalid PMIDs provided: {set(pmids) - set(valid_pmids)}")
    
        if not valid_pmids:
            return []
    
        # Check cache
        if cache:
            cache_key = cache.generate_key(
                "article_details",
                pmids=valid_pmids,
                include_abstracts=include_abstracts,
                include_citations=include_citations,
            )
            cached_result = cache.get(cache_key)
            if cached_result:
                return [Article(**article) for article in cached_result]
    
        articles = await self._fetch_article_details(
            valid_pmids,
            include_full_details=True,
            include_citations=include_citations,
        )
    
        # Cache the result
        if cache:
            cache.set(cache_key, [article.model_dump() for article in articles])
    
        return articles
  • _format_article_details helper: formats detailed Article object into rich text string for MCP response, including authors, journal, abstract, keywords, MeSH, links.
        def _format_article_details(self, article, index: int) -> str:
            """Format detailed article information."""
            # Authors with affiliations
            authors_text = ""
            for i, author in enumerate(article.authors[:5], 1):
                authors_text += f"{i}. {author.first_name or author.initials or ''} {author.last_name}"
                if author.affiliation:
                    authors_text += (
                        f" ({author.affiliation[:50]}...)"
                        if len(author.affiliation) > 50
                        else f" ({author.affiliation})"
                    )
                authors_text += "\n"
    
            if len(article.authors) > 5:
                authors_text += f"... and {len(article.authors) - 5} more authors\n"
    
            # Keywords
            keywords_str = ", ".join(article.keywords[:10]) if article.keywords else "No keywords"
    
            # DOI and links
            links_text = ""
            if article.doi:
                links_text += f"DOI: https://doi.org/{article.doi}\n"
            if article.pmc_id:
                links_text += f"PMC: https://www.ncbi.nlm.nih.gov/pmc/articles/{article.pmc_id}\n"
            links_text += f"PubMed: https://pubmed.ncbi.nlm.nih.gov/{article.pmid}\n"
    
            article_text = f"""
    **{index}. {article.title}**
    
    **Authors:**
    {authors_text}
    
    **Journal:** {article.journal.title}
    **Publication Date:** {format_date(article.pub_date)}
    **Volume/Issue:** {article.journal.volume or 'N/A'}/{article.journal.issue or 'N/A'}
    
    **Abstract:**
    {article.abstract or 'No abstract available'}
    
    **Keywords:** {keywords_str}
    
    **MeSH Terms:** {format_mesh_terms(article.mesh_terms)}
    
    **Article Types:** {', '.join(article.article_types) if article.article_types else 'Not specified'}
    
    **Links:**
    {links_text}
    """
            return article_text
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Get' implies a read-only operation, it doesn't specify whether this requires authentication, has rate limits, returns structured data, or handles errors. For a tool with 3 parameters and no annotation coverage, this leaves significant behavioral questions unanswered.

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 a single, efficient sentence that immediately conveys the core functionality. Every word earns its place - 'Get detailed information' establishes the action, 'for specific articles' defines scope, and 'by PMID' specifies the key identifier. No wasted words or unnecessary elaboration.

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

Completeness2/5

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

For a tool with 3 parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what 'detailed information' includes beyond the parameter hints, doesn't describe the response format, and provides no context about PubMed integration or data freshness. The combination of missing behavioral context and output uncertainty creates significant gaps.

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

Parameters3/5

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

Schema description coverage is 100%, so all parameters are documented in the schema. The description adds no additional parameter information beyond what's in the schema - it doesn't explain PMID format, abstract inclusion implications, or citation metrics details. The baseline score of 3 reflects adequate but minimal value addition over the comprehensive schema.

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 verb 'Get' and resource 'detailed information for specific articles by PMID', making the purpose immediately understandable. It distinguishes from siblings like 'search_by_author' or 'advanced_search' by focusing on retrieval of specific articles rather than searching or analysis. However, it doesn't explicitly differentiate from 'compare_articles' or 'find_related_articles' which might also work with PMIDs.

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. It doesn't mention when to choose this over 'search_pubmed' for article retrieval, or when 'compare_articles' might be more appropriate for multi-article analysis. There's no discussion of prerequisites, limitations, or optimal use cases.

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/chrismannina/pubmed-mcp'

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