answer_cards
Process and record user responses to flashcards by submitting card IDs and ease ratings (1-4) for effective spaced repetition learning.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| answers | Yes | Array of card answers |
Implementation Reference
- src/tools/cards.ts:11-46 (registration)Exact implementation of the 'answer_cards' MCP tool: registers the tool with input schema (array of {cardId, ease}) and handler that invokes ankiClient.card.answerCards, processes results, and returns formatted response.'answer_cards', { answers: z .array( z.object({ cardId: z.number().describe('ID of the card to answer'), ease: z .number() .min(1) .max(4) .describe('Ease rating: 1 (Again), 2 (Hard), 3 (Good), 4 (Easy)'), }) ) .describe('Array of card answers'), }, async ({ answers }) => { try { const results = await ankiClient.card.answerCards({ answers }); const successCount = results.filter(Boolean).length; const failureCount = results.length - successCount; return { content: [ { type: 'text', text: `Answered ${successCount} cards successfully, ${failureCount} failed. Results: ${JSON.stringify(results)}`, }, ], }; } catch (error) { throw new Error( `Failed to answer cards: ${error instanceof Error ? error.message : String(error)}` ); } } );
- src/tools/cards.ts:12-25 (schema)Zod schema defining the input parameters for the 'answer_cards' tool.{ answers: z .array( z.object({ cardId: z.number().describe('ID of the card to answer'), ease: z .number() .min(1) .max(4) .describe('Ease rating: 1 (Again), 2 (Hard), 3 (Good), 4 (Easy)'), }) ) .describe('Array of card answers'), },
- src/tools/cards.ts:26-45 (handler)Handler function that executes the tool logic: calls AnkiConnect's answerCards, counts successes/failures, and returns a text response.async ({ answers }) => { try { const results = await ankiClient.card.answerCards({ answers }); const successCount = results.filter(Boolean).length; const failureCount = results.length - successCount; return { content: [ { type: 'text', text: `Answered ${successCount} cards successfully, ${failureCount} failed. Results: ${JSON.stringify(results)}`, }, ], }; } catch (error) { throw new Error( `Failed to answer cards: ${error instanceof Error ? error.message : String(error)}` ); } }