check_availability
Check if a specific book is available in the bookstore inventory by providing the book ID and optional quantity needed.
Instructions
Check if book is available.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| book_id | Yes | ||
| quantity | No |
Implementation Reference
- src/bookstore_mcp/server.py:86-100 (handler)The core handler function for the 'check_availability' tool. It loads the books data, finds the book by ID, and checks if the requested quantity is available in stock. The @mcp.tool() decorator registers this function as an MCP tool.@mcp.tool() def check_availability(book_id: int, quantity: int = 1): """Check if book is available.""" books = load_books() book = next((b for b in books if b["id"] == book_id), None) if not book: return {"available": False, "error": f"Book {book_id} not found"} return { "book_id": book_id, "title": book["title"], "available_count": book["count"], "available": book["count"] >= quantity, }