model_modelTemplates
Retrieve template content for each card associated with a specific Anki model, enabling structured management and customization of flashcard layouts.
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)Handler function for the 'model_modelTemplates' tool. It calls the AnkiConnect 'modelTemplates' action with the provided modelName to retrieve the template content for each card.@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/__init__.py:26-26 (registration)Registers the model service (model_mcp) under the 'model' namespace in the main AnkiMCP server, which prefixes tool names like 'modelTemplates' to 'model_modelTemplates'.await anki_mcp.import_server("model", model_mcp)
- src/anki_mcp/model_service.py:8-8 (registration)Defines the FastMCP instance for the model service where tools like modelTemplates are registered.model_mcp = FastMCP(name="AnkiModelService")
- src/anki_mcp/common.py:8-24 (helper)Helper function used by all tools to make HTTP requests to the AnkiConnect server, handling the API call for actions like 'modelTemplates'.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