model_updateModelStyling
Update the CSS styling for an existing model by specifying its name and providing the new CSS string. Modify Anki flashcard appearance using the Anki-MCP server.
Instructions
Modifies the CSS styling of an existing model by name.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | Model object. Must include 'name' (model name) and 'css' (the new CSS string). |
Implementation Reference
- src/anki_mcp/model_service.py:112-124 (handler)The core handler function for the 'model_updateModelStyling' tool (prefixed by service namespace). It validates input via Pydantic and proxies the call to AnkiConnect API.@model_mcp.tool( name="updateModelStyling", description="Modifies the CSS styling of an existing model by name.", ) async def update_model_styling_tool( model: Annotated[ Dict[str, Any], Field( description="Model object. Must include 'name' (model name) and 'css' (the new CSS string)." ), ], ) -> None: return await anki_call("updateModelStyling", model=model)
- src/anki_mcp/__init__.py:26-26 (registration)Registers the model service (including updateModelStyling tool) into the main Anki MCP server under the 'model_' namespace prefix.await anki_mcp.import_server("model", model_mcp)
- src/anki_mcp/common.py:8-23 (helper)Shared helper function used by all tool handlers to make HTTP requests to the AnkiConnect API backend.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
- Pydantic-based input schema definition for the tool, specifying the expected 'model' parameter structure.model: Annotated[ Dict[str, Any], Field( description="Model object. Must include 'name' (model name) and 'css' (the new CSS string)." ), ], ) -> None: