Skip to main content
Glama
fegizii

Semantic Scholar MCP Server

by fegizii

get_author

Retrieve detailed academic author information from Semantic Scholar by providing an author ID and optional field specifications.

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

TableJSON Schema
NameRequiredDescriptionDefault
author_idYes
fieldsNo

Implementation Reference

  • The handler function for the get_author tool. It is decorated with @mcp.tool() which handles both implementation and registration in FastMCP. Retrieves author details via Semantic Scholar API and formats output including recent papers.
    @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 used in author-related tools to format author information for display.
    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}"
  • General helper function used by get_author to make API requests to Semantic Scholar, handling errors and authentication.
    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)}"}

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/fegizii/SemanticScholarMCP'

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