deck_deleteDecks
Delete Anki decks and their cards by specifying deck names and confirming card deletion.
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 |
|---|---|---|---|
| decks | Yes | A list of deck names to delete. | |
| cardsToo | Yes | Must be true to confirm deletion of cards within the decks. |
Implementation Reference
- src/anki_mcp/deck_service.py:50-65 (handler)The handler function `delete_decks_tool` that implements the core logic of the `deck_deleteDecks` tool. It performs validation on the `cardsToo` parameter and invokes the AnkiConnect `deleteDecks` API via `anki_call`.@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:23-23 (registration)Registers the `deck_mcp` tools (including `deleteDecks`) with the `deck_` prefix in the main `anki_mcp` server, resulting in the tool name `deck_deleteDecks`.await anki_mcp.import_server("deck", deck_mcp)
- src/anki_mcp/deck_service.py:50-52 (registration)The `@deck_mcp.tool` decorator that registers the `delete_decks_tool` as the `deleteDecks` tool in the `deck_mcp` FastMCP instance.@deck_mcp.tool( name="deleteDecks", description="Deletes decks with the given names. The 'cardsToo' argument must be specified and set to true.",
- src/anki_mcp/common.py:8-23 (helper)The `anki_call` utility function used by the handler to make HTTP requests to the 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:55-62 (schema)Pydantic schema definitions for the tool's input parameters using Annotated and Field.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: