update_cards
Mark Anki cards as answered and update their ease levels after review sessions to track learning progress.
Instructions
After the user answers cards you've quizzed them on, use this tool to mark them answered and update their ease
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| answers | No |
Implementation Reference
- index.ts:234-254 (handler)The handler logic for the 'update_cards' tool within the CallToolRequestSchema handler. It processes the answers array, calls client.card.answerCards, handles success/failure, and returns a confirmation message.case "update_cards": { const answers = args.answers as { cardId: number; ease: number }[]; const result = await client.card.answerCards({ answers: answers }); const successfulCards = answers .filter((_, index) => result[index]) .map(card => card.cardId); const failedCards = answers.filter((_, index) => !result[index]); if (failedCards.length > 0) { const failedCardIds = failedCards.map(card => card.cardId); throw new Error(`Failed to update cards with IDs: ${failedCardIds.join(', ')}`); } return { content: [{ type: "text", text: `Updated cards ${successfulCards.join(", ")}` }] }; }
- index.ts:148-172 (schema)The input schema and registration for the 'update_cards' tool defined in the ListToolsRequestSchema handler, specifying the expected 'answers' array with cardId and ease.{ name: "update_cards", description: "After the user answers cards you've quizzed them on, use this tool to mark them answered and update their ease", inputSchema: { type: "object", properties: { answers: { type: "array", items: { type: "object", properties: { cardId: { type: "number", description: "Id of the card to answer" }, ease: { type: "number", description: "Ease of the card between 1 (Again) and 4 (Easy)" } } } } }, } },
- index.ts:145-221 (registration)The tool registration occurs in the ListToolsRequestSchema handler where 'update_cards' is listed among available tools.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: "update_cards", description: "After the user answers cards you've quizzed them on, use this tool to mark them answered and update their ease", inputSchema: { type: "object", properties: { answers: { type: "array", items: { type: "object", properties: { cardId: { type: "number", description: "Id of the card to answer" }, ease: { type: "number", description: "Ease of the card between 1 (Again) and 4 (Easy)" } } } } }, } }, { name: "add_card", description: "Create a new flashcard in Anki for the user. Must use HTML formatting only. IMPORTANT FORMATTING RULES:\n1. Must use HTML tags for ALL formatting - NO markdown\n2. Use <br> for ALL line breaks\n3. For code blocks, use <pre> with inline CSS styling\n4. Example formatting:\n - Line breaks: <br>\n - Code: <pre style=\"background-color: transparent; padding: 10px; border-radius: 5px;\">\n - Lists: <ol> and <li> tags\n - Bold: <strong>\n - Italic: <em>", inputSchema: { type: "object", properties: { front: { type: "string", description: "The front of the card. Must use HTML formatting only." }, back: { type: "string", description: "The back of the card. Must use HTML formatting only." } }, required: ["front", "back"] } }, { name: "get_due_cards", description: "Returns a given number (num) of cards due for review.", inputSchema: { type: "object", properties: { num: { type: "number", description: "Number of due cards to get" } }, required: ["num"] }, }, { name: "get_new_cards", description: "Returns a given number (num) of new and unseen cards.", inputSchema: { type: "object", properties: { num: { type: "number", description: "Number of new cards to get" } }, required: ["num"] }, } ] }; });