get_book_summary
Retrieve the main summary for any book using its ID to quickly understand key insights and content overview without reading the entire book.
Instructions
Get the main summary for a book
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| book_id | Yes |
Implementation Reference
- libralm_mcp_server.py:158-165 (handler)The core handler function for the 'get_book_summary' tool. Decorated with @mcp.tool() for automatic registration and schema inference from signature and docstring. Fetches the book summary via API call to /books/{book_id}/summary.@mcp.tool() def get_book_summary(book_id: str) -> str: """Get the main summary for a book""" try: data = _make_api_request(f"/books/{book_id}/summary") return data.get("summary", "") except Exception as e: raise ValueError(f"Error getting summary for book '{book_id}': {str(e)}")
- libralm_mcp_server.py:103-127 (helper)Key helper function called by get_book_summary to perform the authenticated HTTP GET request to the LibraLM API, handle errors, and parse the response.def _make_api_request(endpoint: str) -> dict: """Make an authenticated request to the LibraLM API""" # Get API key and base URL from request context or environment api_key = get_api_key() base_url = get_api_base_url() headers = {"x-api-key": api_key, "Content-Type": "application/json"} url = f"{base_url}{endpoint}" response = requests.get(url, headers=headers) if response.status_code == 401: raise ValueError("Invalid API key. Please check your LibraLM API key.") elif response.status_code == 404: raise ValueError(f"Resource not found: {endpoint}") elif response.status_code != 200: raise ValueError( f"API request failed with status {response.status_code}: {response.text}" ) # Handle wrapped response format from Lambda result = response.json() if isinstance(result, dict) and "data" in result: return result["data"] return result
- libralm_mcp_server.py:158-158 (registration)The @mcp.tool() decorator registers the get_book_summary function as an MCP tool, automatically generating schema from function signature and docstring.@mcp.tool()