restock_book
Add stock to a book by specifying the book ID and quantity to increase inventory levels in the bookstore management system.
Instructions
Add stock to a book.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| book_id | Yes | ||
| quantity | Yes |
Implementation Reference
- src/bookstore_mcp/server.py:103-123 (handler)The main handler function for the 'restock_book' tool. It is decorated with @mcp.tool(), which registers it as an MCP tool. The function loads the books data, finds the specified book, adds the quantity to its stock, saves the data, and returns a success or error message.@mcp.tool() def restock_book(book_id: int, quantity: int): """Add stock to a book.""" if quantity <= 0: return {"success": False, "error": "Quantity must be > 0"} books = load_books() book = next((b for b in books if b["id"] == book_id), None) if not book: return {"success": False, "error": f"Book {book_id} not found"} book["count"] += quantity if save_books(books): return { "success": True, "message": f"Restocked {quantity} of '{book['title']}'", } else: return {"success": False, "error": "Save failed"}