semantic_scholar_get_author
Retrieve author profiles and publications from Semantic Scholar's academic database for research and citation analysis.
Instructions
Get author profile with optional publications list.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | Yes |
Implementation Reference
- The handler function get_author_details, decorated with @mcp.tool(name="semantic_scholar_get_author"), implements the core logic: fetches author profile and optional papers from Semantic Scholar API, handles JSON/markdown output.@mcp.tool(name="semantic_scholar_get_author") async def get_author_details(params: AuthorDetailsInput) -> str: """Get author profile with optional publications list.""" logger.info(f"Getting author: {params.author_id}") author = await _make_request("GET", f"author/{params.author_id}", params={"fields": ",".join(AUTHOR_FIELDS)}) result = {"author": author} if params.include_papers: papers = await _make_request("GET", f"author/{params.author_id}/papers", params={"fields": ",".join(PAPER_FIELDS), "limit": params.papers_limit}) result["papers"] = papers.get("data", []) if params.response_format == ResponseFormat.JSON: return json.dumps(result, indent=2) lines = ["## Author Profile", "", _format_author_markdown(author)] if result.get("papers"): lines.extend(["---", f"### Publications ({len(result['papers'])} shown)", ""]) for p in result["papers"]: lines.append(f"- **{p.get('title', '?')}** ({p.get('year', '')}) - {p.get('citationCount', 0)} citations") return "\n".join(lines)
- Pydantic BaseModel defining the input schema for the tool, including author_id, include_papers, papers_limit, and response_format.class AuthorDetailsInput(BaseModel): model_config = ConfigDict(str_strip_whitespace=True, extra="forbid") author_id: str = Field(..., description="Semantic Scholar author ID", min_length=1) include_papers: bool = Field(default=True, description="Include publications") papers_limit: int = Field(default=20, description="Max papers to return", ge=1, le=100) response_format: ResponseFormat = Field(default=ResponseFormat.MARKDOWN, description="Output format")
- Utility function to format author profile data into a readable Markdown string, used in the tool's markdown response.def _format_author_markdown(author: Dict[str, Any]) -> str: lines = [f"### {author.get('name', 'Unknown')}"] affiliations = author.get("affiliations") or [] if affiliations: lines.append(f"**Affiliations:** {', '.join(affiliations[:3])}") lines.append(f"**h-index:** {author.get('hIndex')} | **Papers:** {author.get('paperCount', 0)} | **Citations:** {author.get('citationCount', 0)}") if author.get("homepage"): lines.append(f"**Homepage:** {author['homepage']}") if author.get("url"): lines.append(f"**Profile:** [{author.get('authorId')}]({author['url']})") lines.append("") return "\n".join(lines)
- List of fields requested from the Semantic Scholar API for author data.AUTHOR_FIELDS: List[str] = [ "authorId", "externalIds", "url", "name", "aliases", "affiliations", "homepage", "paperCount", "citationCount", "hIndex" ]