Skip to main content
Glama

model_createModel

Create custom note types in Anki by defining field names, card templates, and optional CSS. Use this tool to design tailored flashcard models for enhanced learning content.

Instructions

Creates a new model (note type). Returns the created model object.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cardTemplatesYesList of card template definitions. Each dict needs 'Name', 'Front', 'Back'.
cssNoOptional CSS for the model.
inOrderFieldsYesList of field names in order.
isClozeNoSet to true if this is a Cloze model.
modelIdNoOptional model ID to use.
modelNameYesThe name for the new model.

Implementation Reference

  • Handler function for the 'createModel' tool in the model_mcp FastMCP server. Constructs parameters and calls AnkiConnect's 'createModel' action via anki_call. This becomes the 'model_createModel' tool when model_mcp is imported into the main server.
    @model_mcp.tool( name="createModel", description="Creates a new model (note type). Returns the created model object.", ) async def create_model_tool( modelName: Annotated[str, Field(description="The name for the new model.")], inOrderFields: Annotated[ List[str], Field(description="List of field names in order.") ], cardTemplates: Annotated[ List[Dict[str, Any]], Field( description="List of card template definitions. Each dict needs 'Name', 'Front', 'Back'." ), ], css: Annotated[ Optional[str], Field(description="Optional CSS for the model.") ] = None, isCloze: Annotated[ Optional[bool], Field(description="Set to true if this is a Cloze model.") ] = False, modelId: Annotated[ Optional[int], Field(description="Optional model ID to use.") ] = None, ) -> Dict[str, Any]: params: Dict[str, Any] = { "modelName": modelName, "inOrderFields": inOrderFields, "cardTemplates": cardTemplates, "isCloze": isCloze, } if css is not None: params["css"] = css if modelId is not None: params["modelId"] = modelId return await anki_call("createModel", **params)
  • Imports the model_mcp server into the main anki_mcp server with the 'model' prefix, registering all model tools (including 'createModel' as 'model_createModel').
    await anki_mcp.import_server("model", model_mcp)
  • Pydantic-based input schema definition for the tool parameters using Annotated and Field, including descriptions for model name, fields, templates, CSS, cloze flag, and model ID.
    async def create_model_tool( modelName: Annotated[str, Field(description="The name for the new model.")], inOrderFields: Annotated[ List[str], Field(description="List of field names in order.") ], cardTemplates: Annotated[ List[Dict[str, Any]], Field( description="List of card template definitions. Each dict needs 'Name', 'Front', 'Back'." ), ], css: Annotated[ Optional[str], Field(description="Optional CSS for the model.") ] = None, isCloze: Annotated[ Optional[bool], Field(description="Set to true if this is a Cloze model.") ] = False, modelId: Annotated[ Optional[int], Field(description="Optional model ID to use.") ] = None, ) -> Dict[str, Any]:
  • Utility function that performs HTTP POST to AnkiConnect API endpoint, used by all service handlers including model_createModel to invoke the underlying 'createModel' 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

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