get_collection_stats_html
Generate HTML-formatted statistics for Anki decks. Use this tool to analyze study progress by retrieving detailed metrics for either specific decks or the entire collection.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| wholeCollection | Yes | Whether to get stats for the whole collection |
Implementation Reference
- src/tools/statistic.ts:45-65 (handler)The main execution logic of the 'get_collection_stats_html' tool. It takes a boolean 'wholeCollection' parameter, fetches the HTML statistics from the Anki client, and returns an MCP-formatted response containing a description and the raw HTML.async ({ wholeCollection }) => { try { const statsHTML = await ankiClient.statistic.getCollectionStatsHTML({ wholeCollection }); return { content: [ { type: 'text', text: `Collection statistics retrieved (${wholeCollection ? 'whole collection' : 'current deck'})`, }, { type: 'text', text: statsHTML, }, ], }; } catch (error) { throw new Error( `Failed to get collection statistics: ${error instanceof Error ? error.message : String(error)}` ); } }
- src/tools/statistic.ts:42-44 (schema)Input schema defined using Zod, specifying a single boolean parameter 'wholeCollection' to indicate if stats should cover the entire collection.{ wholeCollection: z.boolean().describe('Whether to get stats for the whole collection'), },
- src/tools/statistic.ts:40-66 (registration)Registers the 'get_collection_stats_html' tool on the MCP server, providing the tool name, input schema, and handler function.server.tool( 'get_collection_stats_html', { wholeCollection: z.boolean().describe('Whether to get stats for the whole collection'), }, async ({ wholeCollection }) => { try { const statsHTML = await ankiClient.statistic.getCollectionStatsHTML({ wholeCollection }); return { content: [ { type: 'text', text: `Collection statistics retrieved (${wholeCollection ? 'whole collection' : 'current deck'})`, }, { type: 'text', text: statsHTML, }, ], }; } catch (error) { throw new Error( `Failed to get collection statistics: ${error instanceof Error ? error.message : String(error)}` ); } } );