search_authors
Search for academic authors by name, retrieve formatted results, and customize output with fields, limit, and offset parameters using the Semantic Scholar Academic Graph API.
Instructions
Search for authors by name.
Args:
query: Author name or search query
limit: Maximum number of results (default: 10, max: 1000)
offset: Number of results to skip (default: 0)
fields: Comma-separated list of fields to return
Returns:
Formatted author search results
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fields | No | ||
| limit | No | ||
| offset | No | ||
| query | Yes |
Input Schema (JSON Schema)
{
"properties": {
"fields": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Fields"
},
"limit": {
"default": 10,
"title": "Limit",
"type": "integer"
},
"offset": {
"default": 0,
"title": "Offset",
"type": "integer"
},
"query": {
"title": "Query",
"type": "string"
}
},
"required": [
"query"
],
"title": "search_authorsArguments",
"type": "object"
}
Implementation Reference
- The main execution logic for the 'search_authors' tool. Queries the Semantic Scholar API's author/search endpoint with provided parameters, handles errors, formats results using the format_author helper, and returns a human-readable list of matching authors.@mcp.tool() async def search_authors( query: str, limit: int = 10, offset: int = 0, fields: Optional[str] = None ) -> str: """ Search for authors by name. Args: query: Author name or search query limit: Maximum number of results (default: 10, max: 1000) offset: Number of results to skip (default: 0) fields: Comma-separated list of fields to return Returns: Formatted author search results """ params = {"query": query, "limit": min(limit, 1000), "offset": offset} if fields: params["fields"] = fields else: params["fields"] = "authorId,name,paperCount,citationCount,hIndex" result = await make_api_request("author/search", params) if result is None: return "Error: Failed to fetch authors" if "error" in result: return f"Error: {result['error']}" authors = result.get("data", []) total = result.get("total", 0) if not authors: return "No authors found matching your query." formatted_authors = [] for i, author in enumerate(authors, 1): formatted_authors.append(f"{i}. {format_author(author)}") result_text = f"Found {total} total authors (showing {len(authors)}):\n\n" result_text += "\n\n".join(formatted_authors) return result_text
- src/semantic_scholar_mcp/server.py:289-289 (registration)The @mcp.tool() decorator registers the search_authors function with the FastMCP server instance (mcp = FastMCP("semantic-scholar") at line 13).@mcp.tool()
- Input schema defined by type hints and defaults: query (str, required), limit (int=10), offset (int=0), fields (Optional[str]). Output is str with formatted results. Docstring provides detailed descriptions used by MCP for tool schema generation.async def search_authors( query: str, limit: int = 10, offset: int = 0, fields: Optional[str] = None ) -> str: """ Search for authors by name. Args: query: Author name or search query limit: Maximum number of results (default: 10, max: 1000) offset: Number of results to skip (default: 0) fields: Comma-separated list of fields to return Returns: Formatted author search results """
- Supporting utility function that formats a single author's data into a multi-line string, called within search_authors to build the response.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}"