get_book_by_id
Retrieve detailed information about a specific book using its unique identifier. This tool helps users find book details by ID for inventory lookup or purchase verification.
Instructions
Get book by ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| book_id | Yes |
Implementation Reference
- src/bookstore_mcp/server.py:33-37 (handler)The main handler function for the 'get_book_by_id' tool. It is decorated with @mcp.tool() for registration and implements the logic to load books from JSON and return the matching book by ID.@mcp.tool() def get_book_by_id(book_id: int): """Get book by ID.""" books = load_books() return next((book for book in books if book["id"] == book_id), None)