Skip to main content
Glama

model_modelFieldAdd

Adds a custom field to an existing Anki flashcard model, enabling enhanced data organization and flexibility in card creation.

Instructions

Adds a new field to an existing model.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fieldNameYesName of the new field to add.
indexNoOptional 0-based index to insert the field at.
modelNameYesName of the model to modify.

Implementation Reference

  • Handler function implementing the tool logic for modelFieldAdd (exposed as model_modelFieldAdd), which constructs parameters and calls AnkiConnect's modelFieldAdd via anki_call.
    @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)
  • Registers the model_mcp FastMCP instance under the 'model' prefix, making tools like modelFieldAdd available as model_modelFieldAdd in the main AnkiConnectMCP server.
    await anki_mcp.import_server("model", model_mcp)
  • Helper function used by the handler to perform HTTP POST requests to AnkiConnect API, handling errors and returning results.
    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