note_updateNoteFields
Modify the fields of an existing Anki flashcard note to update its content and media attachments.
Instructions
Modifies the fields of an existing note.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| note | Yes | A dictionary representing the note to update. Must include 'id' and 'fields'. Optionally 'audio', 'video', or 'picture'. |
Implementation Reference
- src/anki_mcp/note_service.py:58-70 (handler)Handler function that defines and implements the 'updateNoteFields' tool (prefixed to 'note_updateNoteFields' on registration). It validates input via Pydantic and calls the AnkiConnect API.@note_mcp.tool( name="updateNoteFields", description="Modifies the fields of an existing note." ) async def update_note_fields_tool( note: Annotated[ Dict[str, Any], Field( description="A dictionary representing the note to update. Must include 'id' and 'fields'. Optionally 'audio', 'video', or 'picture'." ), ], ) -> None: return await anki_call("updateNoteFields", note=note)
- src/anki_mcp/__init__.py:24-24 (registration)Registers all tools from note_mcp (including updateNoteFields) into the main anki_mcp server with the 'note_' prefix, making it available as 'note_updateNoteFields'.await anki_mcp.import_server("note", note_mcp)
- src/anki_mcp/common.py:8-24 (helper)Shared helper function used by all tools to make HTTP requests to the AnkiConnect API, executing the actual 'updateNoteFields' action.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
- src/anki_mcp/note_service.py:62-69 (schema)Pydantic schema definition for the tool's input parameter 'note', specifying the required structure.note: Annotated[ Dict[str, Any], Field( description="A dictionary representing the note to update. Must include 'id' and 'fields'. Optionally 'audio', 'video', or 'picture'." ), ], ) -> None: return await anki_call("updateNoteFields", note=note)