model_modelFieldRemove
Remove a specific field from an existing model in Anki flashcards using the MCP server, simplifying model customization and organization.
Instructions
Removes a field from an existing model.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fieldName | Yes | Name of the field to remove. | |
| modelName | Yes | Name of the model to modify. |
Implementation Reference
- src/anki_mcp/model_service.py:144-151 (handler)The core handler function for the 'model_modelFieldRemove' tool (local name 'modelFieldRemove'). It defines the input schema via Annotated Fields and executes the logic by calling AnkiConnect's 'modelFieldRemove' action through the anki_call helper.@model_mcp.tool( name="modelFieldRemove", description="Removes a field from an existing model." ) async def remove_model_field_tool( modelName: Annotated[str, Field(description="Name of the model to modify.")], fieldName: Annotated[str, Field(description="Name of the field to remove.")], ) -> None: return await anki_call("modelFieldRemove", modelName=modelName, fieldName=fieldName)
- src/anki_mcp/__init__.py:26-26 (registration)Registers the model service MCP under the 'model' prefix to the main Anki MCP server, which prefixes all model tools with 'model_', resulting in the full tool name 'model_modelFieldRemove'.await anki_mcp.import_server("model", model_mcp)
- src/anki_mcp/common.py:8-23 (helper)Helper utility function that performs HTTP requests to the AnkiConnect server (localhost:8765) to execute Anki actions, used by the tool handler.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