search_by_author
Find PubMed articles by a specific author, filter by publication years, and retrieve recent publications.
Instructions
Search PubMed for all articles by a specific author.
Args: author: Author name in PubMed format. Examples: "Smith JA" (last name + initials — most precise) "Smith J" (last name + first initial) "John Smith" (full name, less reliable) max_results: Number of results to return (1-100, default 10). year_from: Restrict to articles published from this year. year_to: Restrict to articles published up to this year.
Returns: A list of articles by the author, sorted by most recent first. Returns an error message if the author name is empty or the query fails.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| author | Yes | ||
| max_results | No | ||
| year_from | No | ||
| year_to | No |
Implementation Reference
- main.py:619-650 (handler)The `search_by_author` function is defined as an MCP tool, which validates input and calls the `search_pubmed` helper function.
@mcp.tool() async def search_by_author( author: str, max_results: int = 10, year_from: Optional[int] = None, year_to: Optional[int] = None, ) -> str: """Search PubMed for all articles by a specific author. Args: author: Author name in PubMed format. Examples: "Smith JA" (last name + initials — most precise) "Smith J" (last name + first initial) "John Smith" (full name, less reliable) max_results: Number of results to return (1-100, default 10). year_from: Restrict to articles published from this year. year_to: Restrict to articles published up to this year. Returns: A list of articles by the author, sorted by most recent first. Returns an error message if the author name is empty or the query fails. """ if not author or not author.strip(): return _err("Author name must not be empty.") return await search_pubmed( query=f"{author.strip()}[author]", max_results=max_results, year_from=year_from, year_to=year_to, sort="date", )