Skip to main content
Glama

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
NameRequiredDescriptionDefault
deckNo

Implementation Reference

  • 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}."
  • 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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/samefarrar/mcp-ankiconnect'

If you have feedback or need assistance with the MCP directory API, please join our Discord server