media.store
media_storeStore media files in Anki from base64 data, a local file path, or an HTTP(S) URL, with filename normalization and collision handling (rename, replace, or error).
Instructions
Acquire and store media using Anki filename normalization.
Reject traversal and path separators in filename. Validate strict base64 and source types before acquisition. Skip comparison is against incoming bytes and never deletes an existing file. Replacement is explicit and not collection-undoable.
Anki-Connect method media.store. Scope: collection. Effect: media. Completion: operation. Undo: none.
Long-running operation: by default the server waits for the final result (see waitForCompletion / timeoutSeconds).
Possible errors: collectionUnavailable, conflict, internalError, invalidParams, ioError, notFound, staleSession.
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": {
"filename": "<filename>",
"source": "<source>"
},
"name": "media_store"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source | Yes | Bytes to store: {"data": "<base64>"}, {"path": "<file on the machine running Anki>"} or {"url": "<http(s) URL>"}. Max 64 MiB; prefer path for large files. | |
| session | No | Optional. Collection session ID: the `session` field returned by `collection_get`. Usually omit it — the server then uses the session current at the time of the call. Pass it to make the call fail with `staleSession` instead of acting on a different profile/collection than the one your IDs, cursors and tokens came from. | |
| filename | Yes | Requested basename, e.g. `cat.jpg`. Anki may normalize or rename it — put the returned filename into note fields (`<img src="...">` or `[sound:...]`). | |
| collision | No | If the name exists: `rename` (default), `replace` or `error`. | rename |
| skipIfHash | No | Optional {algorithm: md5|sha256, digest}: skip storing if the incoming bytes have this hash. | |
| timeoutSeconds | No | MCP option (not sent to Anki): how long to wait for completion. A timeout does not cancel the work; the pending record is returned. | |
| waitForCompletion | No | MCP option (not sent to Anki): poll operations.get until the operation finishes and return its final record. If false, return the operation handle. |