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.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list_books"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| unread_only | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
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)