card_setSpecificValueOfCard
Modify specific properties of an Anki flashcard by updating key-value pairs for a single card, returning success indicators for each change.
Instructions
Sets specific values of a single card. Use with caution. Returns list of booleans indicating success for each key.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| card | Yes | The ID of the card to modify. | |
| keys | Yes | List of card property keys to change (e.g., 'flags', 'odue'). | |
| newValues | Yes | List of new values corresponding to the keys. | |
| warning_check | No | Set to True for potentially risky operations. |
Implementation Reference
- src/anki_mcp/card_service.py:92-117 (handler)Handler function implementing the tool logic for 'card_setSpecificValueOfCard' (registered as 'setSpecificValueOfCard' on card_mcp, prefixed later). Includes input schema via Annotated Fields and calls AnkiConnect API.@card_mcp.tool( name="setSpecificValueOfCard", description="Sets specific values of a single card. Use with caution. Returns list of booleans indicating success for each key.", ) async def set_specific_card_value_tool( card: Annotated[int, Field(description="The ID of the card to modify.")], keys: Annotated[ List[str], Field( description="List of card property keys to change (e.g., 'flags', 'odue')." ), ], newValues: Annotated[ List[Any], Field(description="List of new values corresponding to the keys."), ], warning_check: Annotated[ Optional[bool], Field(description="Set to True for potentially risky operations."), ] = None, ) -> List[bool]: params: Dict[str, Any] = {"card": card, "keys": keys, "newValues": newValues} if warning_check is not None: params["warning_check"] = warning_check return await anki_call("setSpecificValueOfCard", **params)
- src/anki_mcp/card_service.py:8-8 (registration)Creation of the card_mcp FastMCP instance on which the tool is registered via decorator.card_mcp = FastMCP(name="AnkiCardService")
- src/anki_mcp/__init__.py:25-25 (registration)Mounts the card_mcp server into the main anki_mcp under 'card' namespace, prefixing tool names with 'card_' to produce 'card_setSpecificValueOfCard'.await anki_mcp.import_server("card", card_mcp)
- src/anki_mcp/common.py:8-24 (helper)Helper function used by the tool handler to invoke the AnkiConnect 'setSpecificValueOfCard' action via HTTP POST.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