get_books_in_stock
Retrieve available books currently in stock from the bookstore inventory to check what items are ready for purchase or management.
Instructions
Get books with count > 0.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/bookstore_mcp/server.py:54-58 (handler)The handler function for the 'get_books_in_stock' tool, decorated with @mcp.tool() to register it. It filters and returns books where the stock count is greater than 0.@mcp.tool() def get_books_in_stock(): """Get books with count > 0.""" return [book for book in load_books() if book["count"] > 0]
- src/bookstore_mcp/server.py:9-14 (helper)Helper function used by get_books_in_stock to load the list of books from a JSON file.def load_books() -> list[dict]: try: with open(DATA_PATH, "r") as f: return json.load(f) except (FileNotFoundError, json.JSONDecodeError): return []