deck_deleteDecks
Delete specified Anki decks and their associated cards by providing deck names and confirming card deletion. Streamlines deck management within Anki-MCP server.
Instructions
Deletes decks with the given names. The 'cardsToo' argument must be specified and set to true.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cardsToo | Yes | Must be true to confirm deletion of cards within the decks. | |
| decks | Yes | A list of deck names to delete. |
Implementation Reference
- src/anki_mcp/deck_service.py:50-65 (handler)The handler function for the 'deck_deleteDecks' tool (prefixed name). It validates that cardsToo is true and proxies the call to AnkiConnect's deleteDecks API.@deck_mcp.tool( name="deleteDecks", description="Deletes decks with the given names. The 'cardsToo' argument must be specified and set to true.", ) async def delete_decks_tool( decks: Annotated[List[str], Field(description="A list of deck names to delete.")], cardsToo: Annotated[ bool, Field( description="Must be true to confirm deletion of cards within the decks." ), ], ) -> None: if not cardsToo: raise ValueError("cardsToo must be true to delete decks.") return await anki_call("deleteDecks", decks=decks, cardsToo=cardsToo)
- src/anki_mcp/__init__.py:22-27 (registration)Registration of the deck_mcp server into the main anki_mcp with 'deck' prefix, making tools available as 'deck_*' (e.g., deck_deleteDecks).async def setup(run_server: bool = True): await anki_mcp.import_server("deck", deck_mcp) await anki_mcp.import_server("note", note_mcp) await anki_mcp.import_server("card", card_mcp) await anki_mcp.import_server("model", model_mcp) await anki_mcp.import_server("media", media_mcp)
- src/anki_mcp/common.py:8-24 (helper)Helper function used by the tool handler to make HTTP calls to AnkiConnect API.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/deck_service.py:8-8 (registration)Creation of the sub-MCP instance where deck tools like deleteDecks are registered.deck_mcp = FastMCP(name="AnkiDeckService")