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.
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": "get_book_by_id"
}
}Input 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)