card_reviews
Fetch card reviews from a specified deck in Anki MCP, starting from a given Unix time, to track and manage learning progress efficiently.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deck | Yes | Name of the deck to get reviews for | |
| startID | Yes | Latest unix time not included in the result |
Implementation Reference
- src/tools/statistic.ts:11-37 (registration)Registers the 'card_reviews' MCP tool, including input schema (deck name and start timestamp) and handler function that fetches reviews via ankiClient.statistic.cardReviews and returns formatted text content with JSON data.'card_reviews', { deck: z.string().describe('Name of the deck to get reviews for'), startID: z.number().describe('Latest unix time not included in the result'), }, async ({ deck, startID }) => { try { const reviews = await ankiClient.statistic.cardReviews({ deck, startID }); return { content: [ { type: 'text', text: `Found ${reviews.length} card reviews for deck "${deck}" after timestamp ${startID}`, }, { type: 'text', text: JSON.stringify(reviews, null, 2), }, ], }; } catch (error) { throw new Error( `Failed to get card reviews for deck "${deck}": ${error instanceof Error ? error.message : String(error)}` ); } } );
- src/tools/statistic.ts:16-36 (handler)The core handler function for the 'card_reviews' tool. It calls the Anki statistic API to retrieve card reviews for the specified deck after the given start timestamp and formats the response as MCP content.async ({ deck, startID }) => { try { const reviews = await ankiClient.statistic.cardReviews({ deck, startID }); return { content: [ { type: 'text', text: `Found ${reviews.length} card reviews for deck "${deck}" after timestamp ${startID}`, }, { type: 'text', text: JSON.stringify(reviews, null, 2), }, ], }; } catch (error) { throw new Error( `Failed to get card reviews for deck "${deck}": ${error instanceof Error ? error.message : String(error)}` ); } }
- src/tools/statistic.ts:12-15 (schema)Input schema for the 'card_reviews' tool using Zod: requires 'deck' (string) and 'startID' (number, unix timestamp).{ deck: z.string().describe('Name of the deck to get reviews for'), startID: z.number().describe('Latest unix time not included in the result'), },
- src/resources/statistic.ts:57-98 (helper)Related MCP resource 'card_reviews' that provides card reviews data via URI template, using the same underlying ankiClient.statistic.cardReviews method.server.resource( 'card_reviews', new ResourceTemplate('anki:///statistics/decks/{deckName}/reviews/{startID}', { list: undefined, }), async (uri, { deckName, startID }) => { const deckNameString = Array.isArray(deckName) ? deckName[0] : deckName; const startIDString = Array.isArray(startID) ? startID[0] : startID; if (!deckNameString) { throw new Error('Deck name is required'); } if (!startIDString) { throw new Error('Start ID is required'); } const startIDNumber = parseInt(startIDString, 10); if (isNaN(startIDNumber)) { throw new Error(`Invalid start ID: ${startIDString}`); } try { const reviews = await ankiClient.statistic.cardReviews({ deck: deckNameString, startID: startIDNumber, }); return { contents: [ { uri: uri.href, mimeType: 'application/json', text: JSON.stringify(reviews, null, 2), }, ], }; } catch (error) { throw new Error( `Failed to get card reviews for deck "${deckNameString}": ${error instanceof Error ? error.message : String(error)}` ); } }