anki-mcp
Allows AI assistants to manage an Anki collection: list note types and decks, add/search/update/delete notes, and sync changes with AnkiWeb.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
anki-mcp
An MCP server that lets AI assistants such as Claude add, search, update and delete notes in your Anki collection, and syncs every change with AnkiWeb (or your own sync server).
A typical use: after a language class you send Claude a photo of your notes from your phone. Claude extracts the vocabulary and calls this server, and the new cards show up in Anki on all your devices.
Works with any note type, deck and fields
Uses the official
ankiPython library on its own copy of your collectionSync-safe: a normal sync runs before and after every change, and the server never does a full upload
Streamable HTTP transport, protected by a static bearer token
One
docker composeservice. Setup is one command.
How syncing works
The server keeps its own copy of your collection in data/. Every tool call does this:
lock → open collection → normal sync → change → normal sync → close → unlockIf the sync server asks for a full sync (for example because the collection was changed in a way that needs one), the call is aborted before anything is changed. You get a clear error. The server never overwrites AnkiWeb.
If the sync after a change fails, the error says that the change was only saved locally. All further calls stop at the first sync until you resolve the conflict.
The only full sync the server ever does is the one-time download during setup, and only into an empty local copy.
A lock prevents parallel access to the collection, including from CLI commands.
Before a change, the server makes an Anki backup in
data/backups/(at most every 30 minutes, rotated like in Anki desktop). If the backup fails, nothing is changed.
Related MCP server: Anki MCP Server
Quick start
You need Docker with Compose, a server reachable over HTTPS (see Reverse proxy), and an AnkiWeb account. Before you start, sync from the Anki desktop app once so AnkiWeb is up to date.
git clone https://github.com/antonleh04/anki-mcp.git && cd anki-mcp
mkdir -p data && cp .env.example .env # create both first, or Docker creates root-owned dirs
# edit .env: set MCP_PUBLIC_HOST (e.g. anki.example.com)
docker compose build
docker compose run --rm anki-mcp setup # generates the token, asks for your AnkiWeb login, downloads the collection
docker compose up -dsetup prints the bearer token at the end. It is also in .env as MCP_BEARER_TOKEN.
Your AnkiWeb password is only used once to get a sync token (ANKI_HKEY) and is never stored.
If your host user's UID/GID is not 1000, set UID and GID in .env before building.
Connect Claude
In claude.ai go to Settings → Connectors → Add custom connector:
URL |
|
Authentication | No sign-in |
Request headers |
|
If your account does not show Request headers (it is a beta feature), you can set
MCP_ALLOW_TOKEN_IN_PATH=true and use the URL https://anki.example.com/mcp/<MCP_BEARER_TOKEN>
instead. Only do this if you have to: the token is then part of the URL, and URLs end up in
proxy logs (Caddy logs them on errors, for example).
In Claude's connector settings, set update_note and delete_notes to require approval
(see Security).
Connectors you add on claude.ai are also available in the Claude mobile apps. Any other MCP client that supports Streamable HTTP and custom headers works too.
Note types
The server works with your existing note types. Claude can call list_note_types to see the
fields. Duplicates are detected on the first field of a note type, like Anki does.
To create a simple new note type: field 1 is the question, the other fields show on the
back. --reverse adds a second card that asks field 2.
docker compose run --rm anki-mcp create-note-type "Spanish Vocab" --fields "Spanish,English,Notes,Example" --reverseAdding a new note type normally syncs fine. If the sync server asks for a full sync anyway, the command stops and tells you how to recover. In that case create the note type in Anki desktop instead.
To restrict the tools to certain note types, set ANKI_ALLOWED_NOTE_TYPES in .env.
Tools
Tool | Description |
| Note types with their fields and card templates, plus all decks |
| Add one or more notes to a deck (created if missing) with tags. Skips duplicates and reports them. |
| Search with Anki's search syntax, newest first |
| Change some fields and/or replace the tags of a note |
| Delete notes (the assistant is told to ask for confirmation first) |
Field values are plain text. HTML is escaped on the way in and stripped on the way out. Every result includes the sync status.
Skills: tailoring it to your use case
The server is generic on purpose. Rules for a specific use case, such as which deck and note
type to use, how to format entries, or which tag to set, belong in a
skill (or custom instructions) for your assistant. examples/skills/spanisch-vokabeln
is an example (in German) for turning photos of Spanish class notes into flashcards.
To use it in Claude, zip the skill folder and upload it under Settings → Capabilities → Skills.
Reverse proxy
The container only listens on 127.0.0.1:8000. Put a TLS-terminating reverse proxy in
front of it, for example Caddy:
anki.example.com {
reverse_proxy 127.0.0.1:8000
}If your proxy runs in Docker on a shared network, create a docker-compose.override.yml
(it is gitignored) instead of publishing the port:
services:
anki-mcp:
ports: !reset []
networks: [web]
networks:
web:
external: trueThen point the proxy at anki-mcp:8000.
Configuration
All settings are environment variables in .env:
Variable | Description |
| Required. At least 24 characters. Generated by |
| Sync token. Set by |
| Public hostname. Enables the Host header check (DNS rebinding protection). |
| Optional comma-separated allow-list of note types |
| Optional self-hosted sync server URL |
| Also accept the token as |
| Build args for file ownership (default 1000) |
After changing .env, run docker compose up -d --force-recreate.
CLI
docker compose run --rm anki-mcp <command>
setup first-time setup (token, login, download); safe to re-run
login log in again, e.g. after changing your password
download [--redownload]
download the collection; --redownload backs up the local copy to data/backups/
create-note-type NAME --fields A,B,... [--reverse]
serve run the server (default)Recovering from a sync conflict
Open Anki desktop, sync, and resolve the conflict there.
Then replace the server's copy:
docker compose stop anki-mcp
docker compose run --rm anki-mcp download --redownload
docker compose up -dSecurity
Know what you are connecting before you run this:
The sync token (
ANKI_HKEY) is a powerful credential. Whoever has it can read your whole AnkiWeb collection and overwrite it. This server never uploads, but someone who steals the token could. It stays valid until you change your AnkiWeb password, so do that if you think the token or the server was compromised. Keep.envprivate (chmod 600).The bearer token protects everything.
setupgenerates a random 256-bit token. Use theAuthorizationheader, not the token-in-path fallback, and serve the endpoint over HTTPS only.Prompt injection. Your assistant reads untrusted content: photos, documents, web pages, and the notes themselves. Text in that content could trick it into changing or deleting notes, and those changes sync to all your devices. To limit the damage:
Set
update_noteanddelete_notesto require approval in your MCP client.Use
ANKI_ALLOWED_NOTE_TYPESso the tools only see the note types they need. Without it, the assistant can read your whole collection.Backups in
data/backups/(and Anki desktop's own backups) let you restore. A.colpkgbackup can be imported in Anki desktop via File → Import.
Data on the server.
data/holds a full copy of your collection. Treat the server like any device that has your Anki data on it.
Development
docker compose --profile test run --rm --build testThe tests run against temporary local collections in a container without network access. A
guard fails any test that tries to reach a real sync server. Without Docker, use
pip install ".[dev]" && pytest.
Limitations
Media files are not synced, and images cannot be added.
Field values are plain text, without formatting.
One collection (one AnkiWeb account) per server instance.
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Turn text, files, URLs, or photos into Anki flashcard decks from your AI assistant.
Lets Claude, ChatGPT, and Muse read and update your beckett tasks, notes, calendar, and lists.
Notes and actions in one app. Let Claude or ChatGPT read and update them.
Your own memory inside ChatGPT and Claude, with the source of every note.
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceEnables AI assistants like Claude to interact with Anki flashcard decks through AnkiConnect. Supports creating and managing decks, basic and cloze deletion cards, searching existing cards, and organizing content with tags.-
- AlicenseAqualityDmaintenanceEnables AI assistants to manage Anki flashcard collections by creating, searching, and updating cards through a standardized interface. It supports media handling, batch operations, and review scheduling via the AnkiConnect add-on.62MIT
- AlicenseNot gradedqualityDmaintenanceEnables LLMs to interact with Anki flashcard collections, including deck management, note search, viewing contents, and editing fields.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to create and manage Anki cards through AnkiConnect, including decks, card creation, search, updates, deletion, and mobile sync.MIT