deck_deckNamesAndIds
Retrieve all deck names and their corresponding IDs to identify and manage Anki flashcard collections.
Instructions
Gets the complete list of deck names and their respective IDs. Returns a dictionary mapping deck names to their IDs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/anki_mcp/deck_service.py:11-16 (handler)The main handler function for the tool 'deckNamesAndIds' (prefixed to 'deck_deckNamesAndIds'), which calls the AnkiConnect API to retrieve deck names and IDs.@deck_mcp.tool( name="deckNamesAndIds", description="Gets the complete list of deck names and their respective IDs. Returns a dictionary mapping deck names to their IDs.", ) async def list_deck_names_and_ids_tool() -> Dict[str, int]: return await anki_call("deckNamesAndIds")
- src/anki_mcp/__init__.py:23-23 (registration)Registers the deck_mcp tools with the 'deck' prefix, making 'deckNamesAndIds' available as 'deck_deckNamesAndIds'.await anki_mcp.import_server("deck", deck_mcp)
- src/anki_mcp/common.py:8-23 (helper)Utility function used by the handler to make asynchronous HTTP requests to the AnkiConnect server.async def anki_call(action: str, **params: Any) -> Any: async with httpx.AsyncClient() as client: payload = {"action": action, "version": 6, "params": params} result = await client.post(ANKICONNECT_URL, json=payload) result.raise_for_status() result_json = result.json() error = result_json.get("error") if error: raise Exception(f"AnkiConnect error for action '{action}': {error}") response = result_json.get("result") if "result" in result_json: return response return result_json
- src/anki_mcp/__init__.py:6-6 (registration)Imports the deck_mcp instance containing the deck tools.from .deck_service import deck_mcp