Manage collection: sync, packages, media
manage_collectionRun Anki collection maintenance tasks: check version, manage profiles, sync with AnkiWeb, import/export .apkg packages, and list, store, retrieve, or delete media files.
Instructions
Collection maintenance for the Anki app: AnkiWeb sync, version check, .apkg import/export, profiles, and media files. Use this for maintenance tasks that are not about card content, decks, note types or reviews. To read a media file's contents (e.g. view an image), use get_media_file.
Operations:
version: read-only; AnkiConnect version (also a quick "is Anki running?" check).
get_profiles: read-only; profile names.
sync: syncs the collection with AnkiWeb (network; may upload or download changes).
export_deck: needs deckName and filePath (.apkg path to write); optional includeSched. Writes a file on disk.
import_package: needs filePath to an .apkg; adds its contents to the collection.
list_media: read-only; needs pattern (e.g. ".png", "").
retrieve_media: read-only; needs filename; reports whether it exists and its size.
store_media: needs filename plus mediaData (base64) or mediaUrl (downloaded by Anki). Overwrites a file with the same name.
delete_media: needs filename. Deletes the file from the media folder.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"operation": "<operation>"
},
"name": "manage_collection"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pattern | No | list_media: glob pattern, e.g. "*.png" or "*" | |
| deckName | No | export_deck: deck to export | |
| filePath | No | export_deck: .apkg path to write. import_package: .apkg path to read | |
| filename | No | store_media/retrieve_media/delete_media: media file name, e.g. "cat.png" | |
| mediaUrl | No | store_media: URL Anki downloads the file from (or use mediaData) | |
| mediaData | No | store_media: base64 file contents (or use mediaUrl) | |
| operation | Yes | Which operation to run; see the tool description for required parameters | |
| includeSched | No | export_deck: include review history and scheduling (default false) |