Skip to main content
Glama

model_createModel

Create custom note types in Anki by defining fields and card templates to organize flashcards according to your learning needs.

Instructions

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

Input Schema

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

Implementation Reference

  • Handler function executing the logic for tool 'model_createModel' by calling AnkiConnect's 'createModel' API.
    @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)
  • Registers the 'model_mcp' FastMCP server (containing the createModel tool) into the main 'anki_mcp' with 'model_' prefix, resulting in 'model_createModel'.
    await anki_mcp.import_server("model", model_mcp)
  • Creates the 'model_mcp' FastMCP instance where the 'createModel' tool is registered (later prefixed).
    model_mcp = FastMCP(name="AnkiModelService")
  • Utility function that performs HTTP POST to AnkiConnect API, used by the handler to invoke 'createModel'.
    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