num_cards_due_today
Retrieve the count of Anki flashcard reviews due today, optionally filtered by deck, to optimize your study schedule and track daily progress.
Instructions
Get the number of cards due exactly today, with an optional deck filter.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deck | No |
Implementation Reference
- mcp_ankiconnect/server.py:219-229 (handler)Main handler function decorated with @mcp.tool() for registration and error handling. Counts cards due today using AnkiConnect search.@mcp.tool() @handle_anki_connection_error # Apply decorator async def num_cards_due_today(deck: Optional[str] = None) -> str: """Get the number of cards due exactly today, with an optional deck filter.""" async with get_anki_client() as anki: # Use the helper, specifying day=0 for today card_ids = await _find_due_card_ids(anki, deck, day=0) count = len(card_ids) deck_msg = f" in deck '{deck}'" if deck else " across all decks" return f"There are {count} cards due today{deck_msg}."
- mcp_ankiconnect/server.py:78-105 (helper)Supporting helper function that builds AnkiConnect search query for cards due on a specific day and retrieves the list of card IDs.async def _find_due_card_ids( client: AnkiConnectClient, deck: Optional[str] = None, day: Optional[int] = 0 ) -> List[int]: """Finds card IDs due on a specific day relative to today (0=today).""" if day < 0: raise ValueError("Day must be non-negative.") # Construct the search query # prop:due=0 means due today # prop:due=1 means due tomorrow (relative to review time) # prop:due<=N finds cards due today up to N days in the future. if day == 0: prop = "prop:due=0" # Due exactly today else: prop = f"prop:due<={day}" query = f"is:due -is:suspended {prop}" if deck: # Add deck to query, ensuring proper quoting for spaces query += f' "deck:{deck}"' logger.debug(f"Executing Anki card search query: {query}") card_ids = await client.find_cards(query=query) logger.info(f"Found {len(card_ids)} cards for query: {query}") return card_ids