check_availability
Verify book inventory status to confirm availability before purchase. Enter book ID and optional quantity to check stock levels.
Instructions
Check if book is available.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"book_id": "<book_id>"
},
"name": "check_availability"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| book_id | Yes | ||
| quantity | No |
Implementation Reference
- src/bookstore_mcp/server.py:86-100 (handler)The check_availability tool handler function. It loads books, finds the book by ID, and checks if the requested quantity is available, returning availability details.
@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, }