model_modelFieldAdd
Add a custom field to an existing Anki flashcard model to organize and customize your study material.
Instructions
Adds a new field to an existing model.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| modelName | Yes | Name of the model to modify. | |
| fieldName | Yes | Name of the new field to add. | |
| index | No | Optional 0-based index to insert the field at. |
Implementation Reference
- src/anki_mcp/model_service.py:130-141 (handler)The handler function `add_model_field_tool` that executes the tool logic by preparing parameters and calling `anki_call('modelFieldAdd', **params)`.async def add_model_field_tool( modelName: Annotated[str, Field(description="Name of the model to modify.")], fieldName: Annotated[str, Field(description="Name of the new field to add.")], index: Annotated[ Optional[int], Field(description="Optional 0-based index to insert the field at."), ] = None, ) -> None: params: Dict[str, Any] = {"modelName": modelName, "fieldName": fieldName} if index is not None: params["index"] = index return await anki_call("modelFieldAdd", **params)
- src/anki_mcp/model_service.py:127-142 (registration)Registers the tool named 'modelFieldAdd' on the `model_mcp` FastMCP instance.@model_mcp.tool( name="modelFieldAdd", description="Adds a new field to an existing model." ) async def add_model_field_tool( modelName: Annotated[str, Field(description="Name of the model to modify.")], fieldName: Annotated[str, Field(description="Name of the new field to add.")], index: Annotated[ Optional[int], Field(description="Optional 0-based index to insert the field at."), ] = None, ) -> None: params: Dict[str, Any] = {"modelName": modelName, "fieldName": fieldName} if index is not None: params["index"] = index return await anki_call("modelFieldAdd", **params)
- src/anki_mcp/__init__.py:26-26 (registration)Registers the `model_mcp` tools under the 'model' prefix in the main `anki_mcp`, resulting in tool name 'model_modelFieldAdd'.await anki_mcp.import_server("model", model_mcp)
- Pydantic schema definitions for the tool inputs using Annotated and Field.modelName: Annotated[str, Field(description="Name of the model to modify.")], fieldName: Annotated[str, Field(description="Name of the new field to add.")], index: Annotated[ Optional[int], Field(description="Optional 0-based index to insert the field at."), ] = None, ) -> None: