Skip to main content
Glama

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
NameRequiredDescriptionDefault
modelNameYesThe name of the model.

Implementation Reference

  • 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)
  • 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)
  • Defines the FastMCP instance for the model service where tools like modelTemplates are registered.
    model_mcp = FastMCP(name="AnkiModelService")
  • 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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ujisati/anki-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server