anki-mcp
Anki MCP server that lets agents read, search, organize, and modify a local Anki collection through AnkiConnect, with safeguards around Yanki/Obsidian decks, duplicates, dry runs, and destructive operations.
List decks with counts and source (
anki/yanki/mixed).Search notes with Anki query syntax, paginate results, and fetch full note content by ID.
Find weak cards by lapses/ease, optionally limited to one deck.
Batch-add notes with validation, duplicate checks, dry-run preview, automatic
mcp-addedtagging, and optional pronunciation audio via Google or offline voices.Inspect deck formats and note types, and find semantically similar notes if the optional semantic index is enabled.
Save per-deck profiles for conventions such as note type, audio field/voice, field rules, tags, and rules.
Add or replace audio; update, delete, move, or convert notes; restyle/create note types; manage deck limits; create/export decks; suspend cards; and sync with AnkiWeb, with dry runs, backups, and Yanki protections where applicable.
Gives agents access to a local Anki collection through AnkiConnect: list decks with counts and source (Anki vs. Yanki-synced), search notes with Anki search syntax and paginated previews, fetch full note content by id, surface weak/forgotten cards (by lapses and ease, optionally per deck), and batch-add notes with validation, duplicate checks, dry-run mode, auto-tagging, and optional generated pronunciation audio. Refuses to modify decks owned by Yanki, keeping synced Obsidian-backed decks read-only from the agent side.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@anki-mcp show my most forgotten cards in the Spanish deck"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
anki-mcp
An MCP server that gives agents (Claude Code, Claude Desktop, …) access to your local Anki collection via AnkiConnect.
Blog post about building it: ikristina.github.io/blog/anki-mcp-server.
My other Anki project: anki-new-tab, a Chrome extension that turns every new tab into a quick review of due cards, with a Pomodoro timer. It also talks to Anki through AnkiConnect.
Tool | What it does |
| Decks with counts and |
| Works out a deck's format: note types, fields, audio field and its source, code values (e.g. WordType), templates, tag patterns, samples |
| Note types with fields in order and note counts; filter by name to also see template front/back fields. For empty decks or newly imported types |
| Anki search syntax, paginated compact previews |
| Finds notes by meaning ("cards about consensus", "cat" → el gato), from a text or an existing note id; catches near-duplicates exact search misses. Needs the optional semantic index |
| Full content for specific note ids; |
| Most-forgotten cards (lapses, then ease), optionally per deck |
| Your saved per-deck conventions (note type, audio field + voice, how to fill each field, tags, rules). Stored in a local JSON file, not in Anki |
| Adds pronunciation audio to existing notes that lack it; dry run by default, batches of ≤50, skips notes that already have audio. |
| Edits fields of existing notes, adds tags or appends a local |
| Permanently deletes notes by id (cards and history too); dry run by default, refuses Yanki notes. Only on the user's explicit request |
| Moves the cards matching an Anki search into another deck (history kept, normal sync); dry run by default with a count, the decks they come from and a sample; ≤200 cards per call, skips Yanki cards, refuses a Yanki target, keeps the semantic index's deck filter right |
| Changes the note type of existing notes (cards and review history kept) with a field map. High risk: Anki then requires a one-way full sync. Dry run by default; the real run needs the user's confirmation that every device is synced, backs up the affected decks to |
| Changes an existing note type's CSS and card template HTML by exact-match patch ( |
| Reads or sets a deck's new cards/day and reviews/day. The limits live in a preset that decks share, so changing a shared one needs |
| Creates a note type (fields, card templates, styling) from arguments or a JSON file, e.g. |
| Suspends (or unsuspends) the cards matching a search, e.g. |
| Creates an empty deck (and missing parents) so |
| Writes a deck (with subdecks and media) to an |
| Syncs desktop Anki with AnkiWeb (normal syncs only; refuses a full sync and says why), so notes added on a phone can be tidied and voiced remotely. See docs/remote-from-phone.md |
| Batch add with validation, |
Not sure what to ask for? docs/capabilities.md lists what's possible, what isn't yet, and what card-design terms mean.
Skills in .claude/skills/:
flashcardsroutes cards: technical topics become markdown in the Obsidian vault (synced by Yanki), and everything else goes straight to Anki.language-cards(/language-cards <words>) adds vocabulary with pronunciation audio to any language deck, following that deck's profile. If a deck has no profile yet, it works one out withdescribe_deckand asks you to confirm it. It also tidies cards you typed on your phone: fixes the text, adds audio and formats alternative answers.
Installation
Requirements
macOS (the offline voices and audio conversion use the built-in
sayandafconvert)uv (
brew install uv); it installs Python 3.11+ for you if neededAnki desktop
1. Anki + AnkiConnect
In Anki: Tools → Add-ons → Get Add-ons…, enter code
2055492159, and restart Anki.Keep Anki open whenever you use the server. AnkiConnect listens on
http://127.0.0.1:8765.
2. A Latin voice (if you study Latin)
Google's voices have no real Latin. eSpeak NG has a Latin voice, and at first it seemed like a good option even though it is VERY robotic. In practice turned out that its pronunciation is often wrong, so I trained my own Classical Latin voice with Piper instead. It sounds far more natural. It's not shared (the base model's license forbids redistribution), but you can build the same one: docs/building-a-tts-voice.md. Install it as piper:la_LA-vox-medium (see Audio voices).
eSpeak NG is still needed: Piper uses its Latin rules to turn text into phonemes.
brew install espeak-ngCheck it: espeak-ng --voices=la should list Latin.
3. The server
git clone <this repo> ~/Projects/anki-mcp # or copy the folder
cd ~/Projects/anki-mcp
uv sync
uv run python scripts/smoke.py # read-only check over stdio; Anki must be running4. Register with Claude Code
claude mcp add anki --scope user -- uv --directory /absolute/path/to/anki-mcp run anki-mcpThen start a new Claude Code session and run /mcp: anki should show as connected. --scope user makes the tools available in every project. The skills only load when Claude Code runs inside this folder, unless you copy .claude/skills/* to ~/.claude/skills/.
Other agents (Claude Desktop, Cursor, VS Code, Codex, Gemini CLI, …)
MCP is agent-agnostic, so any MCP client can run this server. No clone is needed: uvx builds it straight from GitHub. Steps 1–2 (Anki + AnkiConnect, Latin voice) still apply.
The command every client runs:
uvx --from git+https://github.com/ikristina/anki-mcp anki-mcpGUI apps often don't inherit your shell's PATH. If the server fails to start, replace uvx with its absolute path (which uvx, e.g. /Users/you/.local/bin/uvx).
Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json), Cursor (~/.cursor/mcp.json), Windsurf, Gemini CLI (~/.gemini/settings.json), and most other clients use the mcpServers format:
{
"mcpServers": {
"anki": {
"command": "uvx",
"args": ["--from", "git+https://github.com/ikristina/anki-mcp", "anki-mcp"]
}
}
}VS Code / GitHub Copilot (.vscode/mcp.json) uses servers:
{
"servers": {
"anki": {
"type": "stdio",
"command": "uvx",
"args": ["--from", "git+https://github.com/ikristina/anki-mcp", "anki-mcp"]
}
}
}OpenAI Codex CLI (~/.codex/config.toml):
[mcp_servers.anki]
command = "uvx"
args = ["--from", "git+https://github.com/ikristina/anki-mcp", "anki-mcp"]The tools work the same everywhere. The skills (.claude/skills/) are Claude Code's format; with other agents, copy the relevant SKILL.md body into that agent's rules/instructions file. Deck-specific conventions live in deck profiles (below), not in the skills, so the skills work with any collection.
Optional
ANKI_CONNECT_URL, if AnkiConnect isn't onhttp://127.0.0.1:8765(claude mcp add anki -e ANKI_CONNECT_URL=http://... -- ...).ANKI_MCP_BACKUP_DIR(default~/.config/anki-mcp/backups) andANKI_MCP_HISTORY(default~/.config/anki-mcp/convert_history.jsonl): whereconvert_noteswrites its pre-conversion backups and its log.ANKI_MCP_EXPORT_DIR: the folderexport_deckuses when no path is given (default~/Desktop), e.g. a synced Google Drive or Dropbox folder.
Semantic search index (optional)
An index of every note's meaning, which the find_similar_notes tool searches: "cards about consensus", or a near-duplicate that Anki's exact-match check misses. No other tool depends on it, and the server works the same without it (find_similar_notes then says how to set it up).
docker run -d --name anki-redis --restart unless-stopped -p 127.0.0.1:6379:6379 \
-v anki-redis-data:/data redis:8 redis-server --appendonly yes --save "60 1" --save "300 100"
uv sync --extra rag # fastembed (ONNX, no torch) + the Redis client
uv run --extra rag anki-mcp-index # Anki must be running; first run embeds everything (a few minutes)Embeddings come from a free local model (
paraphrase-multilingual-MiniLM-L12-v2, 384 dimensions, handles Spanish, French, Norwegian, Latin and English) and are stored in Redis 8 (vector search built in). The volume and AOF/RDB settings above keep them across restarts; the index is derived data, so it can always be rebuilt.Later runs re-embed only notes that changed since the last run and drop deleted ones.
--fullrebuilds from scratch,--limit Ncaps one run. Changing the model rebuilds automatically.A card moved to another deck keeps its old deck in the index until the next
--fullrun (Anki doesn't bump a note's modified time on a move).add_notesalso uses it: each valid note gets asimilarlist when an existing note has the same word (checked with Anki's own search, no index needed) or a similar meaning (similarity ≥ 0.8, from the index). Without the index,add_notesstill does the same-word check and sayssimilar_check: semantic check skipped.To use the tools from an agent, register the server with the extra:
claude mcp add anki --scope user -- uv --directory /absolute/path/to/anki-mcp run --extra rag anki-mcp. Re-runanki-mcp-indexnow and then (it takes seconds when little changed): notes added since the last run aren't found yet, andfind_similar_notesreportsindexed_at.After a reboot,
colima start(or start Docker) and the container comes back on its own (--restart unless-stopped). Ifdocker start anki-redissays No such container, the container was removed (adocker system prune, or a reset colima VM; its volume usually goes too): run thedocker runabove again, thenuv run --extra rag anki-mcp-index, a full rebuild that took about 2 minutes for 10.6k notes.A deck whose cards have no meaning to search by (an alphabet deck) can be left out with the deck profile option
semantic_index: false; the nextanki-mcp-indexrun removes it.ANKI_MCP_REDIS_URLpoints at a different Redis. If Redis is down, only these commands fail, with a message saying how to start it.How the model was chosen:
uv run --extra rag python scripts/rag_eval.py buildthenscore(recall@5 and MRR on query sets derived from your own collection; results stay in the gitignoredevals/retrieval/). Plan: ROADMAP.md, Phase 8.
Observability (optional): OpenTelemetry traces, metrics and logs
The server always logs to stderr (Claude Code keeps it in its MCP logs; ANKI_MCP_LOG_LEVEL=DEBUG for more). To export traces, metrics and logs over OTLP/HTTP, install the otel extra and point it at a collector. The quickest local backend is Grafana's all-in-one image, which stores all three signals and has a UI at http://localhost:3000:
docker run -d --name otel-lgtm -p 3000:3000 -p 4318:4318 grafana/otel-lgtm
claude mcp add anki --scope user -e OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 \
-- uv --directory /absolute/path/to/anki-mcp run --extra otel anki-mcpThe container has no volume, so telemetry is lost when it's removed. If docker start otel-lgtm says No such container, run the docker run above again.
To fill Grafana with data without using an agent, generate traffic. The script starts its own server with exporting on and makes random read-only calls, dry-run writes and a few deliberate mistakes. It never writes to the collection:
uv run --extra otel python scripts/otel_traffic.py # 60 scenarios, about 2 minutes
uv run --extra otel python scripts/otel_traffic.py --calls 300 # more data, for rate() and latency graphsAny OTLP backend works (Jaeger, Honeycomb, Grafana Cloud…); the standard OTEL_* variables apply (OTEL_EXPORTER_OTLP_HEADERS for API keys, OTEL_SERVICE_NAME, OTEL_SDK_DISABLED=true). Without an endpoint, nothing is exported.
Traces: one span per tool call (
tools/call add_notes, from the MCP SDK), with child spans per AnkiConnect request (ankiconnect findNotes) and per audio clip (tts google). Failed calls carry the error message the model saw.Metrics:
anki_mcp.tool.calls/anki_mcp.tool.duration(by tool and outcome),anki_mcp.ankiconnect.duration(by action),anki_mcp.tts.duration(by engine and voice; Google 429s show up here),anki_mcp.notes.written(by operation and deck). Exported every 10s (OTEL_METRIC_EXPORT_INTERVAL).Logs: writes (notes added, voiced, updated, synced) and tool errors.
Note contents are never recorded, but error messages can quote the word being voiced. Queries, troubleshooting, and how to add the same to your own MCP server: docs/observability.md.
Obsidian (optional, for Yanki decks)
This server never reads or writes Obsidian. It only spots Yanki decks (source: yanki) and refuses to add cards to them. To put new cards there, the agent has to write markdown into your vault by some other route: a separate Obsidian MCP server, or plain file access to the vault folder. Either works. A filesystem-based server such as obsidian-mcp (claude mcp add obsidian -- npx -y obsidian-mcp /path/to/vault) edits the files directly, so Obsidian doesn't need to be running. A server built on the Local REST API plugin needs Obsidian open but can also run commands. Either way, you still run Yanki: Sync in Obsidian to get the cards into Anki. Without either kind of access, the flashcards skill can still write cards for Anki-owned decks, but for Yanki decks it can only show you the markdown to paste in yourself.
Related MCP server: Anki MCP Server
Deck profiles
Some things describe_deck can't infer: which voice a deck uses, which field is spoken, "nouns include the article". Save them once as a deck profile, and every session and agent follows them:
File:
~/.config/anki-mcp/profiles.json(override withANKI_MCP_PROFILES=/path/to/file.json). It's plain JSON, so edit it by hand if you like. Nothing is written to your Anki collection.set_deck_profilechecks each profile against Anki before saving: the deck and note type must exist, the field names must belong to that note type, and the voice must work.Agents are told to save a profile only after you confirm it. The
language-cardsskill proposes one the first time you add to a deck that has none.examples/profiles.jsonholds my Spanish, French and Latin profiles. To start from them, copy the file to~/.config/anki-mcp/profiles.jsonand rename the decks to match yours.
Audio voices
add_notes takes audio: {"field": ..., "voice": ...}. All engines are free:
Voice string | Engine | Needs | Used for |
| Google Translate (gTTS) | internet | Spanish, French (the same voices HyperTTS's GoogleTranslate service uses) |
| eSpeak NG |
| Latin, but robotic and often mispronounced; I replaced it with the Piper voice below |
| macOS | macOS | natural offline voices |
| Microsoft Edge neural, via unofficial | internet; no key | natural online voices incl. male Spanish; unofficial endpoint, may break |
| any listed voices | as the voices | one voice per note, picked by a hash of the text (stable across re-runs) |
| Piper (neural) |
| natural offline voices, incl. a self-trained Latin one (how) |
Google files are MP3; the offline engines produce M4A (AAC). Anki plays both.
Listen before trusting a voice. Even a good one mispronounces rare words: Google en-US gets chimerical wrong where en-GB is right, and only macos:Samantha says kvetch correctly. To fix one card, clear its audio field in Anki and run add_audio on just that note with a different voice (or use replace=True).
Development
uv run pytest -q # unit tests: fake in-memory AnkiConnect, no Anki/network needed (runs in CI)
uv run python scripts/smoke.py # end-to-end over stdio against your real collection (read-only; Anki must be running)
uv run --extra rag python scripts/rag_eval.py build && uv run --extra rag python scripts/rag_eval.py score # embedding-model comparison on your collection (read-only, free)
uv run python evals/run.py --models haiku sonnet --repeats 5 # agent evals via `claude -p` against fakes (uses plan usage)Eval results and method: docs/evals.md. See LEARNINGS.md for design notes.
Example use

Available Tools
5 toolsadd_notesA
Add one or more notes. Every note gets tagged 'mcp-added' so the user can review them in Anki.
Only for decks with source='anki' (see list_decks); Yanki decks are rejected.
Each note is validated first (deck exists, note type exists, field names match, not a duplicate
of an existing first field in the same deck). Invalid notes are reported and skipped;
valid ones are still added. Prefer one batched call over many single-note calls.
Set audio on a note to generate pronunciation (needs internet; skipped in dry_run).
Inputs: notes (required), dry_run, allow_duplicates.
get_notesARead-only
Get the full content of specific notes (HTML stripped, not truncated). Get ids from search_notes.
Inputs: note_ids (required). Returns: result
get_weak_cardsARead-only
Find the cards the user struggles with most: highest lapse count (times forgotten), then lowest ease.
Good for 'quiz me on my weak spots' or deciding which topics need rewritten/extra cards. Suspended cards are excluded.
Inputs: deck, limit. Returns: result
list_decksARead-only
List all Anki decks with card counts (new / learning / due for review / own cards) and source.
source='yanki': generated from markdown in the user's Obsidian vault by the Yanki plugin. Read and quiz freely, but new cards must be written in Obsidian, not added here. source='anki': native deck, accepts add_notes. source='mixed': holds both kinds (or its subdecks do). add_notes works; prefer Obsidian for technical topics. Subdecks use '::' as the separator, e.g. 'DDIA::04_Transactions'. Counts include subdecks except 'own_cards'.
Inputs: no named parameters. Returns: result
search_notesARead-only
Search notes and return compact previews (HTML stripped, fields truncated).
Returns total match count so you can paginate with offset. Use get_notes for full field content.
Inputs: query (required), limit, offset.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a clearly distinct purpose: listing decks, searching note previews, retrieving full note content, finding weak cards, and adding notes. search_notes and get_notes are complementary rather than overlapping, and get_weak_cards is a specialized query with a clear scope.
All tool names follow a consistent snake_case verb_noun pattern: list_decks, search_notes, get_notes, get_weak_cards, add_notes. There is no mixing of conventions or vague naming.
Five tools are well-scoped for an Anki MCP focused on reviewing decks, searching notes, inspecting cards, finding weak spots, and adding notes. Each tool earns its place without unnecessary bloat.
The surface covers core read operations (list/search/get/weak cards) and note creation, which supports the stated quiz-and-add workflow. It lacks update/delete operations for existing notes and deck management, but these are minor gaps for the apparent review-focused purpose.
Maintenance
Related MCP Connectors
Turn text, files, URLs, or photos into Anki flashcard decks from your AI assistant.
Build and study spaced-repetition flashcards with your agent.
Language flashcards in your AI assistant: build decks, edit cards and review what's due in the chat.
Connects an AI assistant to your Lingard account (lingard.app), an app for learning languages with books, news and flashcards. Create topic word collections and add complete cards: translation, part of speech, pronunciation, synonyms, example sentences with translations, and images. Fill in missing fields on existing cards, rewrite example translations, and pause or resume collections, books and news in your daily study sessions. Every change can be previewed before it is saved, and saved words appear in the Lingard apps on iOS, Android and the web. Requires a Lingard account; sign-in uses OAuth.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables interaction with the Anki desktop flashcard application through the Anki-Connect plugin. Supports managing decks, cards, notes, and models, allowing AI assistants to create and query flashcards through natural language.7 npm1ISC
- 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 via AnkiConnect for creating, searching, and managing flashcards, decks, and note types.1MIT
- AlicenseAqualityCmaintenanceEnables AI assistants to interact with Anki flashcard collections through the AnkiConnect add-on, allowing creation, modification, searching, and management of flashcards and decks.3340 npm27MIT