get_book_details
Retrieve comprehensive book information including summaries and chapter breakdowns by providing a book identifier. Access key insights from business, self-help, and educational books through this tool.
Instructions
Get detailed information about a specific book
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| book_id | Yes |
Implementation Reference
- libralm_mcp_server.py:168-175 (handler)The handler function implementing the 'get_book_details' tool. It fetches detailed book information from the LibraLM API using the provided book_id and returns a structured BookInfo object.@mcp.tool() def get_book_details(book_id: str) -> BookInfo: """Get detailed information about a specific book""" try: data = _make_api_request(f"/books/{book_id}") return BookInfo(**data) except Exception as e: raise ValueError(f"Error getting details for book '{book_id}': {str(e)}")
- libralm_mcp_server.py:86-101 (schema)Pydantic model defining the output schema (BookInfo) for the get_book_details tool.class BookInfo(BaseModel): """Book information structure""" book_id: str title: str author: Optional[str] = None category: Optional[str] = None subtitle: Optional[str] = None summary: Optional[str] = None length: Optional[str] = None release_date: Optional[str] = None tier: Optional[str] = None has_summary: bool has_chapter_summaries: bool has_table_of_contents: bool
- libralm_mcp_server.py:103-127 (helper)Core helper function used by the tool to perform authenticated GET requests to the LibraLM API endpoints.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:168-168 (registration)FastMCP decorator that registers the get_book_details function as a tool.@mcp.tool()