set_cards_ease_factors
Adjust ease factors for specified Anki cards by providing card IDs and corresponding ease factors to optimize learning intervals.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cardIds | Yes | Array of card IDs to set ease factors for | |
| easeFactors | Yes | Array of ease factors (must match the length of cardIds) |
Implementation Reference
- src/tools/cards.ts:350-375 (handler)Handler function that validates the input arrays have matching lengths, calls the Anki client's setEaseFactors method to update the ease factors for the given cards, counts successful updates, and returns a success message.async ({ cardIds, easeFactors }) => { try { if (cardIds.length !== easeFactors.length) { throw new Error('Number of card IDs must match number of ease factors'); } const results = await ankiClient.card.setEaseFactors({ cards: cardIds, easeFactors, }); const successCount = results.filter(Boolean).length; return { content: [ { type: 'text', text: `Successfully set ease factors for ${successCount} out of ${cardIds.length} cards`, }, ], }; } catch (error) { throw new Error( `Failed to set ease factors: ${error instanceof Error ? error.message : String(error)}` ); } }
- src/tools/cards.ts:344-349 (schema)Zod input schema defining cardIds as an array of numbers and easeFactors as an array of numbers, with descriptions indicating they must match in length.{ cardIds: z.array(z.number()).describe('Array of card IDs to set ease factors for'), easeFactors: z .array(z.number()) .describe('Array of ease factors (must match the length of cardIds)'), },
- src/tools/cards.ts:342-376 (registration)Registration of the 'set_cards_ease_factors' tool on the MCP server using server.tool(), providing the input schema and handler function inline within the registerCardTools function.server.tool( 'set_cards_ease_factors', { cardIds: z.array(z.number()).describe('Array of card IDs to set ease factors for'), easeFactors: z .array(z.number()) .describe('Array of ease factors (must match the length of cardIds)'), }, async ({ cardIds, easeFactors }) => { try { if (cardIds.length !== easeFactors.length) { throw new Error('Number of card IDs must match number of ease factors'); } const results = await ankiClient.card.setEaseFactors({ cards: cardIds, easeFactors, }); const successCount = results.filter(Boolean).length; return { content: [ { type: 'text', text: `Successfully set ease factors for ${successCount} out of ${cardIds.length} cards`, }, ], }; } catch (error) { throw new Error( `Failed to set ease factors: ${error instanceof Error ? error.message : String(error)}` ); } } );