deck_createDeck
Create a new empty Anki flashcard deck by specifying its name. The tool prevents overwriting existing decks and returns the unique deck ID upon successful creation.
Instructions
Creates a new empty deck. Will not overwrite an existing deck with the same name. Returns the ID of the created deck.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deck | Yes | The name of the deck to create (e.g., 'Japanese::Tokyo'). |
Implementation Reference
- src/anki_mcp/deck_service.py:37-47 (handler)The core handler function for the 'deck_createDeck' tool (local name 'createDeck'), which creates a new Anki deck using the AnkiConnect API. Includes inline schema via Annotated and Field.@deck_mcp.tool( name="createDeck", description="Creates a new empty deck. Will not overwrite an existing deck with the same name. Returns the ID of the created deck.", ) async def create_deck_tool( deck: Annotated[ str, Field(description="The name of the deck to create (e.g., 'Japanese::Tokyo')."), ], ) -> int: return await anki_call("createDeck", deck=deck)
- src/anki_mcp/__init__.py:23-27 (registration)Registration of service MCPS into the main anki_mcp, specifically the 'deck' namespace import which prefixes deck_mcp tools like 'createDeck' to become 'deck_createDeck'.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-23 (helper)The supporting anki_call utility function that performs HTTP requests to AnkiConnect API, used by the deck_createDeck handler.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 deck_mcp FastMCP instance where the deck_createDeck tool is defined via decorator.deck_mcp = FastMCP(name="AnkiDeckService")