Skip to main content
Glama
chrismannina

PubMed MCP Server

by chrismannina

search_by_author

Find PubMed articles written by a specific author. Search by author name to retrieve relevant publications and co-author information for research purposes.

Instructions

Search for articles by a specific author

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
author_nameYesAuthor name to search for
max_resultsNoMaximum number of results
include_coauthorsNoInclude co-author information

Implementation Reference

  • Handler function _handle_search_by_author that parses arguments, calls PubMedClient.search_by_author, formats and returns MCPResponse with search results.
    async def _handle_search_by_author(self, arguments: Dict[str, Any]) -> MCPResponse:
        """Handle author-based search."""
        try:
            author_name = arguments.get("author_name", "")
            if not author_name:
                return MCPResponse(
                    content=[{"type": "text", "text": "Author name is required"}], is_error=True
                )
    
            max_results = arguments.get("max_results", 20)
            include_coauthors = arguments.get("include_coauthors", True)
    
            search_result = await self.pubmed_client.search_by_author(
                author_name=author_name,
                max_results=max_results,
                include_coauthors=include_coauthors,
                cache=self.cache,
            )
    
            content = []
            content.append(
                {
                    "type": "text",
                    "text": f"**Publications by {author_name}**\n\n"
                    f"Total Articles: {search_result.total_results}\n"
                    f"Showing: {search_result.returned_results}\n",
                }
            )
    
            for i, article_data in enumerate(search_result.articles, 1):
                article_text = self._format_article_summary(article_data, i)
                content.append({"type": "text", "text": article_text})
    
            return MCPResponse(content=content)
    
        except Exception as e:
            logger.error(f"Error in search_by_author: {e}")
            return MCPResponse(
                content=[{"type": "text", "text": f"Error: {str(e)}"}], is_error=True
            )
  • Input schema definition for the search_by_author tool, specifying parameters like author_name (required), max_results, and include_coauthors.
    {
        "name": "search_by_author",
        "description": "Search for articles by a specific author",
        "inputSchema": {
            "type": "object",
            "properties": {
                "author_name": {"type": "string", "description": "Author name to search for"},
                "max_results": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "default": 20,
                    "description": "Maximum number of results",
                },
                "include_coauthors": {
                    "type": "boolean",
                    "default": True,
                    "description": "Include co-author information",
                },
            },
            "required": ["author_name"],
        },
    },
  • Registration of search_by_author tool in the handler_map dictionary, mapping it to the _handle_search_by_author 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.search_by_author method that performs the actual PubMed API search using author query, fetches details, handles caching, and returns SearchResult.
    async def search_by_author(
        self,
        author_name: str,
        max_results: int = 20,
        include_coauthors: bool = True,
        cache: Optional[CacheManager] = None,
    ) -> SearchResult:
        """Search articles by author name."""
        start_time = time.time()
    
        if cache:
            cache_key = cache.generate_key(
                "author_search",
                author=author_name,
                max_results=max_results,
                include_coauthors=include_coauthors,
            )
            cached_result = cache.get(cache_key)
            if cached_result:
                # Convert cached article dicts back to Article objects
                cached_articles = [
                    Article(**article_data) for article_data in cached_result["articles"]
                ]
                cached_result["articles"] = cached_articles
                return SearchResult(**cached_result)
    
        # Build author search query
        search_query = f'"{author_name}"[Author]'
    
        search_params = self._build_params(
            db="pubmed", term=search_query, retmax=str(max_results), retmode="json", sort="pub_date"
        )
    
        search_response = await self._make_request("esearch.fcgi", search_params)
        search_data = search_response.json()
    
        search_result = search_data.get("esearchresult", {})
        pmids = search_result.get("idlist", [])
        total_results = int(search_result.get("count", 0))
    
        articles = []
        if pmids:
            articles = await self._fetch_article_details(pmids, include_full_details=True)
    
        result_data = {
            "query": f"Author: {author_name}",
            "total_results": total_results,
            "returned_results": len(articles),
            "articles": articles,  # Store Article objects directly
            "search_time": time.time() - start_time,
            "suggestions": [],
        }
    
        # Cache the result (store as dicts for serialization)
        if cache:
            cache_data = {**result_data, "articles": [article.model_dump() for article in articles]}
            cache.set(cache_key, cache_data)
    
        return SearchResult(**result_data)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states the basic action ('Search for articles') without adding context such as permissions needed, rate limits, pagination behavior, or what the search returns (e.g., list format, error handling). For a search tool with zero annotation coverage, this is a significant gap in transparency.

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 directly states the tool's purpose without any wasted words. It is appropriately sized and front-loaded, making it easy for an agent to parse quickly. Every part of the sentence earns its place by conveying essential information.

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?

Given the tool's complexity (a search function with 3 parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't explain return values, error conditions, or behavioral traits, leaving gaps that could hinder an agent's ability to use the tool effectively. The description should provide more context to compensate for the missing structured data.

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%, meaning the input schema fully documents all parameters (author_name, max_results, include_coauthors). The description adds no additional meaning beyond what the schema provides, such as examples or usage tips. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 as 'Search for articles by a specific author,' which includes a specific verb ('Search') and resource ('articles') with a clear filter criterion ('by a specific author'). It distinguishes from general search tools but doesn't explicitly differentiate from sibling tools like 'search_by_journal' or 'advanced_search,' which might also involve article searches with different filters.

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 sibling tools like 'advanced_search' or 'search_by_journal,' nor does it specify contexts, prerequisites, or exclusions for usage. This leaves the agent without explicit direction for tool selection.

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