model_modelTemplates
Retrieve card template content for Anki flashcard models to review or modify formatting and structure.
Instructions
Returns an object indicating the template content for each card of the specified model.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| modelName | Yes | The name of the model. |
Implementation Reference
- src/anki_mcp/model_service.py:39-46 (handler)The core handler function for the 'model_modelTemplates' tool (prefixed due to model_ namespace). It takes a modelName parameter, calls the AnkiConnect 'modelTemplates' API via anki_call helper, and returns the templates dictionary.@model_mcp.tool( name="modelTemplates", description="Returns an object indicating the template content for each card of the specified model.", ) async def get_model_templates_tool( modelName: Annotated[str, Field(description="The name of the model.")], ) -> Dict[str, Any]: return await anki_call("modelTemplates", modelName=modelName)
- src/anki_mcp/model_service.py:8-8 (registration)Creates the sub-MCP server 'model_mcp' (AnkiModelService) where the model_modelTemplates tool is registered via decorator.model_mcp = FastMCP(name="AnkiModelService")
- src/anki_mcp/__init__.py:26-26 (registration)Registers the model_mcp sub-server under the 'model' prefix to the main 'AnkiConnectMCP' server, enabling the full tool name 'model_modelTemplates'.await anki_mcp.import_server("model", model_mcp)
- src/anki_mcp/common.py:8-23 (helper)Shared helper function that performs HTTP requests to the AnkiConnect API (localhost:8765), used by the tool handler to execute the 'modelTemplates' action.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