get_author
Retrieve detailed information about a specific academic author using their unique author ID. Specify desired fields to access tailored insights from the Semantic Scholar Academic Graph API.
Instructions
Get detailed information about a specific author.
Args:
author_id: Author ID
fields: Comma-separated list of fields to return
Returns:
Detailed author information
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| author_id | Yes | ||
| fields | No |
Input Schema (JSON Schema)
{
"properties": {
"author_id": {
"title": "Author Id",
"type": "string"
},
"fields": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Fields"
}
},
"required": [
"author_id"
],
"title": "get_authorArguments",
"type": "object"
}
Implementation Reference
- The handler function for the 'get_author' tool. It fetches author details from Semantic Scholar API using make_api_request, formats the response with author stats and recent papers, and is registered via the @mcp.tool() decorator.@mcp.tool() async def get_author(author_id: str, fields: Optional[str] = None) -> str: """ Get detailed information about a specific author. Args: author_id: Author ID fields: Comma-separated list of fields to return Returns: Detailed author information """ params = {} if fields: params["fields"] = fields else: params["fields"] = "authorId,name,paperCount,citationCount,hIndex,papers" result = await make_api_request(f"author/{author_id}", params) if result is None: return "Error: Failed to fetch author" if "error" in result: return f"Error: {result['error']}" author = result name = author.get("name", "Unknown Name") author_id = author.get("authorId", "") paper_count = author.get("paperCount", 0) citation_count = author.get("citationCount", 0) h_index = author.get("hIndex", 0) papers = author.get("papers", []) result_text = f"""Name: {name} Author ID: {author_id} Total Papers: {paper_count} Total Citations: {citation_count} H-Index: {h_index} Recent Papers ({len(papers)} shown):""" if papers: for i, paper in enumerate(papers[:10], 1): title = paper.get("title", "Unknown Title") year = paper.get("year", "Unknown") citations = paper.get("citationCount", 0) result_text += f"\n{i}. {title} ({year}) - {citations} citations" return result_text
- Helper function to format author information, used in author-related tools like search_authors (similar formatting used in get_author).def format_author(author: Dict[str, Any]) -> str: """Format an author for display.""" name = author.get("name", "Unknown Name") author_id = author.get("authorId", "") paper_count = author.get("paperCount", 0) citation_count = author.get("citationCount", 0) h_index = author.get("hIndex", 0) return f"Name: {name}\nAuthor ID: {author_id}\nPapers: {paper_count}\nCitations: {citation_count}\nH-Index: {h_index}"
- Core helper function used by get_author to make API requests to Semantic Scholar.async def make_api_request( endpoint: str, params: Optional[Dict[str, Any]] = None, method: str = "GET" ) -> Optional[Dict[str, Any]]: """Make a request to the Semantic Scholar API.""" url = f"{BASE_URL}/{endpoint.lstrip('/')}" headers = { "Accept": "application/json", "User-Agent": f"semantic-scholar-mcp/{USER_AGENT_VERSION}", } if API_KEY: headers["x-api-key"] = API_KEY try: async with httpx.AsyncClient(timeout=API_TIMEOUT) as client: if method == "GET": response = await client.get(url, headers=headers, params=params) elif method == "POST": response = await client.post(url, headers=headers, json=params) else: raise ValueError(f"Unsupported HTTP method: {method}") response.raise_for_status() return response.json() except httpx.HTTPStatusError as e: if e.response.status_code == 403: if not API_KEY: return { "error": "Rate limit exceeded. The shared public rate limit (1000 req/sec) may be exceeded. Get a free API key from https://www.semanticscholar.org/product/api for dedicated limits." } else: return { "error": f"API key may be invalid or rate limit exceeded: {str(e)}" } elif e.response.status_code == 429: return { "error": "Rate limit exceeded. Please wait a moment and try again, or get an API key for dedicated higher limits." } else: return {"error": f"HTTP error: {str(e)}"} except httpx.HTTPError as e: return {"error": f"HTTP error: {str(e)}"} except Exception as e: return {"error": f"Request failed: {str(e)}"}