import_package
Import package files into Anki MCP by specifying the file path, enabling efficient integration and management of learning resources.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Path to the package file to import |
Implementation Reference
- src/tools/miscellaneous.ts:108-130 (registration)Full registration of the 'import_package' MCP tool, including inline schema validation and execution handler that calls the underlying AnkiConnect importPackage method.server.tool( 'import_package', { filePath: z.string().describe('Path to the package file to import'), }, async ({ filePath }) => { try { const result = await ankiClient.miscellaneous.importPackage({ path: filePath }); return { content: [ { type: 'text', text: `Successfully imported package from ${filePath}. Result: ${result}`, }, ], }; } catch (error) { throw new Error( `Failed to import package: ${error instanceof Error ? error.message : String(error)}` ); } } );
- src/tools/miscellaneous.ts:113-129 (handler)Core handler function for the import_package tool: validates input implicitly via schema, invokes ankiClient.miscellaneous.importPackage(path: filePath), and formats MCP response.async ({ filePath }) => { try { const result = await ankiClient.miscellaneous.importPackage({ path: filePath }); return { content: [ { type: 'text', text: `Successfully imported package from ${filePath}. Result: ${result}`, }, ], }; } catch (error) { throw new Error( `Failed to import package: ${error instanceof Error ? error.message : String(error)}` ); } }
- src/tools/miscellaneous.ts:110-112 (schema)Input schema using Zod: requires a single 'filePath' parameter as string with description.{ filePath: z.string().describe('Path to the package file to import'), },
- src/tools/consolidated.ts:1052-1065 (handler)Secondary handler implementation as a case within the larger 'anki_operations' consolidated tool, providing similar import functionality.case 'import_package': { if (!filePath) { throw new Error('import_package requires filePath'); } await ankiClient.miscellaneous.importPackage({ path: filePath }); return { content: [ { type: 'text', text: `✓ Imported package from ${filePath}`, }, ], }; }