model_modelNamesAndIds
Retrieve all Anki note type names with their corresponding IDs to manage and organize flashcard templates effectively.
Instructions
Gets the complete list of model (note type) names and their IDs. Returns a dictionary mapping model names to IDs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/anki_mcp/model_service.py:11-17 (handler)The core handler function for the 'model_modelNamesAndIds' tool. It invokes the AnkiConnect 'modelNamesAndIds' action via anki_call to fetch model names and IDs.@model_mcp.tool( name="modelNamesAndIds", description="Gets the complete list of model (note type) names and their IDs. Returns a dictionary mapping model names to IDs.", ) async def list_model_names_and_ids_tool() -> Dict[str, int]: return await anki_call("modelNamesAndIds")
- src/anki_mcp/__init__.py:26-26 (registration)Registers the model_mcp FastMCP instance with the prefix 'model' to the main anki_mcp server, resulting in tools prefixed like 'model_modelNamesAndIds'.await anki_mcp.import_server("model", model_mcp)
- src/anki_mcp/model_service.py:11-17 (schema)Defines the tool schema via FastMCP decorator: no input parameters, returns Dict[str, int] of model names to IDs.@model_mcp.tool( name="modelNamesAndIds", description="Gets the complete list of model (note type) names and their IDs. Returns a dictionary mapping model names to IDs.", ) async def list_model_names_and_ids_tool() -> Dict[str, int]: return await anki_call("modelNamesAndIds")
- src/anki_mcp/common.py:8-23 (helper)Helper function used by the handler to make HTTP POST requests 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