list_books
Retrieve books from your personal library database. Filter to show only unread books using the unread_only parameter for focused reading management.
Instructions
Lists books in the library. Set unread_only=True to see only the books you haven't read yet.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| unread_only | No |
Implementation Reference
- server.py:52-66 (handler)The `list_books` tool handler, implemented in `server.py`, interacts with an SQLite database to return a JSON list of books, optionally filtered by read status.
@mcp.tool() def list_books(unread_only: bool = False) -> str: """ Lists books in the library. Set unread_only=True to see only the books you haven't read yet. """ conn = get_db_connection() cursor = conn.cursor() if unread_only: cursor.execute("SELECT isbn, name, owned, read FROM books WHERE read = 0") else: cursor.execute("SELECT isbn, name, owned, read FROM books") books = [dict(row) for row in cursor.fetchall()] conn.close() return json.dumps(books, indent=2)