export_package
Export Anki flashcards from a specified deck to a file, including optional scheduling information, for backup or sharing purposes.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deckName | Yes | Name of the deck to export | |
| filePath | Yes | Path where to save the exported package | |
| includeSched | No | Whether to include scheduling information |
Implementation Reference
- src/tools/miscellaneous.ts:40-67 (registration)Registers the 'export_package' MCP tool, including schema and handler function.server.tool( 'export_package', { deckName: z.string().describe('Name of the deck to export'), filePath: z.string().describe('Path where to save the exported package'), includeSched: z.boolean().optional().describe('Whether to include scheduling information'), }, async ({ deckName, filePath, includeSched }) => { try { const params: any = { deck: deckName, path: filePath }; if (includeSched !== undefined) params.includeSched = includeSched; const result = await ankiClient.miscellaneous.exportPackage(params); return { content: [ { type: 'text', text: `Successfully exported deck "${deckName}" to ${filePath}. Result: ${result}`, }, ], }; } catch (error) { throw new Error( `Failed to export package: ${error instanceof Error ? error.message : String(error)}` ); } } );
- src/tools/miscellaneous.ts:47-66 (handler)The handler function for the 'export_package' tool. Prepares parameters and calls the underlying ankiClient.exportPackage method, returning a success message or throwing an error.async ({ deckName, filePath, includeSched }) => { try { const params: any = { deck: deckName, path: filePath }; if (includeSched !== undefined) params.includeSched = includeSched; const result = await ankiClient.miscellaneous.exportPackage(params); return { content: [ { type: 'text', text: `Successfully exported deck "${deckName}" to ${filePath}. Result: ${result}`, }, ], }; } catch (error) { throw new Error( `Failed to export package: ${error instanceof Error ? error.message : String(error)}` ); } }
- src/tools/miscellaneous.ts:42-46 (schema)Zod schema defining input parameters for the 'export_package' tool: deckName (required), filePath (required), includeSched (optional boolean).{ deckName: z.string().describe('Name of the deck to export'), filePath: z.string().describe('Path where to save the exported package'), includeSched: z.boolean().optional().describe('Whether to include scheduling information'), },
- src/tools/consolidated.ts:1035-1050 (helper)The 'anki_operations' consolidated tool uses the same underlying exportPackage functionality in its 'export_deck' operation.case 'export_deck': { if (!deckName || !filePath) { throw new Error('export_deck requires deckName and filePath'); } const params: any = { deck: deckName, path: filePath }; if (includeSched !== undefined) params.includeSched = includeSched; await ankiClient.miscellaneous.exportPackage(params); return { content: [ { type: 'text', text: `✓ Exported deck "${deckName}" to ${filePath}`, }, ], }; }