get_cards_intervals
Retrieve study intervals for specified Anki flashcards, returning all intervals or just the most recent based on user preference.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cardIds | Yes | Array of card IDs to get intervals for | |
| complete | No | If true, returns all intervals; if false, returns only the most recent |
Implementation Reference
- src/tools/cards.ts:388-409 (handler)The handler function that implements the core logic of the 'get_cards_intervals' tool. It fetches intervals from Anki via ankiClient and returns formatted results.async ({ cardIds, complete = false }) => { try { const intervals = await ankiClient.card.getIntervals({ cards: cardIds, complete }); const result = cardIds.map((cardId, index) => ({ cardId, intervals: intervals[index], })); return { content: [ { type: 'text', text: `Intervals (${complete ? 'complete history' : 'most recent'}): ${JSON.stringify(result, null, 2)}`, }, ], }; } catch (error) { throw new Error( `Failed to get intervals: ${error instanceof Error ? error.message : String(error)}` ); } }
- src/tools/cards.ts:381-387 (schema)The Zod input schema defining parameters for the tool: required array of cardIds and optional complete boolean.{ cardIds: z.array(z.number()).describe('Array of card IDs to get intervals for'), complete: z .boolean() .optional() .describe('If true, returns all intervals; if false, returns only the most recent'), },
- src/tools/cards.ts:379-410 (registration)The registration of the 'get_cards_intervals' tool using server.tool(), including schema and handler.server.tool( 'get_cards_intervals', { cardIds: z.array(z.number()).describe('Array of card IDs to get intervals for'), complete: z .boolean() .optional() .describe('If true, returns all intervals; if false, returns only the most recent'), }, async ({ cardIds, complete = false }) => { try { const intervals = await ankiClient.card.getIntervals({ cards: cardIds, complete }); const result = cardIds.map((cardId, index) => ({ cardId, intervals: intervals[index], })); return { content: [ { type: 'text', text: `Intervals (${complete ? 'complete history' : 'most recent'}): ${JSON.stringify(result, null, 2)}`, }, ], }; } catch (error) { throw new Error( `Failed to get intervals: ${error instanceof Error ? error.message : String(error)}` ); } } );