card_cardsToNotes
Retrieve note IDs associated with specific card IDs in Anki decks using the tool linked to the anki-mcp server. Ideal for organizing and managing flashcard-based learning materials.
Instructions
Returns an unordered array of note IDs for the given card IDs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cards | Yes | A list of card IDs. |
Implementation Reference
- src/anki_mcp/card_service.py:33-40 (handler)The handler function implementing the core logic of the 'card_cardsToNotes' tool. It takes a list of card IDs and returns the corresponding note IDs by delegating to AnkiConnect's 'cardsToNotes' action.@card_mcp.tool( name="cardsToNotes", description="Returns an unordered array of note IDs for the given card IDs.", ) async def convert_cards_to_notes_tool( cards: Annotated[List[int], Field(description="A list of card IDs.")], ) -> List[int]: return await anki_call("cardsToNotes", cards=cards)
- src/anki_mcp/card_service.py:8-8 (registration)Creation of the 'card_mcp' FastMCP server instance where the 'cardsToNotes' tool (prefixed as 'card_cardsToNotes') is registered.card_mcp = FastMCP(name="AnkiCardService")
- src/anki_mcp/__init__.py:25-25 (registration)Top-level registration of the 'card_mcp' service into the main 'anki_mcp' server, enabling the 'card_cardsToNotes' tool under the 'card_' prefix.await anki_mcp.import_server("card", card_mcp)
- src/anki_mcp/common.py:8-23 (helper)Shared helper function that makes asynchronous HTTP requests to the AnkiConnect API, invoked by the tool handler with action='cardsToNotes'.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