Anki Model Context Protocol (MCP) Server
Provides tools for managing Anki flashcards, decks, notetypes, tags, media, and searches, including batch card creation, deck hierarchy management, note retrieval and updates, tag operations, and deck export.
Click on "Install 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 Model Context Protocol (MCP) ServerCreate a deck called 'Spanish Vocabulary' and add the batch of cards from /tmp/spanish_cards.json"
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 Model Context Protocol (MCP) Server
A high-performance Model Context Protocol (MCP) server enabling AI assistants (Claude Desktop, Claude Code, Antigravity, Codex, Cursor, etc.) to directly manage Anki flashcards, decks, notetypes, tags, media, and searches.
⚡ Universal File-Based I/O Architecture
Modern flashcards (especially with HTML markup, syntax-highlighted code blocks, and LaTeX math formulas) are large payloads. Streaming these through JSON-RPC tool parameters or returning full card content directly to the model causes token exhaustion, truncated outputs, and context window saturation.
This server implements Universal File-Based Input and Output (File-Based I/O):
Zero In-Band Token Bloat: Flashcard mutations, queries, searches, and schema introspections accept input JSON file paths and write full structured output to disk.
Compact Telemetry Responses: Every tool call returns bounded metadata summaries ($< 150$ tokens) with status, IDs, affected counts, and the resolved
output_filepath.Atomic Batch Ingestion: Hundreds of cards can be written to a single JSON payload and ingested in an atomic SQLite transaction in milliseconds.
Cross-Platform Temp Storage: Outputs default to the OS temporary directory (
%TEMP%\anki_mcpon Windows,/tmp/anki_mcpon Linux/macOS) and can be overridden viaANKI_MCP_OUTPUT_DIR.
Features
⚡ Fast Direct Bridge: Interacts directly with Anki's collection database (
collection.anki2) via the officialankiPython engine with zero HTTP overhead.🔒 Non-Blocking Connection Lifecycle: Uses per-request open/close context management (~2.7ms) so database locks are immediately released and Anki Desktop is not locked out.
🪟 Cross-Platform: Native support for Windows, macOS, and Linux, with automatic collection discovery in standard OS locations.
🗂️ Hierarchical Decks: Full support for nested deck creation (e.g.
Computer Science::Algorithms::Trees).📝 Rich Card Formats: Supports Standard/Basic cards, Cloze deletions (
{{c1::...}}), custom fields, and LaTeX math formulas ($...$and$$...$$).🔍 Query Engine: Full support for Anki's search syntax (
deck:Languages tag:grammar,is:due,added:7,"Recursion").🏷️ Tag Management: Hierarchical tagging and bulk tag additions/removals.
📦 Batch Creation: High-throughput batch card addition in single atomic operations via JSON payloads.
💾 Deck Export: Native packaging to
.apkg,.colpkg, and.json.💡 MCP Prompts & Resources: Built-in resources (
anki://decks,anki://stats) and structured card generation prompt (flashcard_generator).
Installation & Setup
This project uses uv for fast, reproducible Python environment management.
Clone and Install
git clone https://github.com/debnath-d/anki-mcp-server.git
cd anki-mcp-server
uv syncRun Server
uv run anki-mcp-serverClient Configurations
1. Claude Desktop
Add the server to your Claude Desktop configuration file:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
Windows Configuration
{
"mcpServers": {
"anki": {
"command": "uv",
"args": [
"--directory",
"C:\\path\\to\\anki-mcp-server",
"run",
"anki-mcp-server"
]
}
}
}macOS / Linux Configuration
{
"mcpServers": {
"anki": {
"command": "uv",
"args": [
"--directory",
"/path/to/anki-mcp-server",
"run",
"anki-mcp-server"
]
}
}
}2. Google Antigravity
Add to your Antigravity MCP configuration (~/.gemini/config/mcp_config.json):
{
"mcpServers": {
"anki": {
"command": "uv",
"args": [
"--directory",
"/path/to/anki-mcp-server",
"run",
"anki-mcp-server"
]
}
}
}3. Claude Code / Codex / CLI Clients
Start Claude Code with the MCP server:
claude --mcp-server "uv --directory '/path/to/anki-mcp-server' run anki-mcp-server"Available MCP Tools
1. Deck Management
Tool | Parameters | Description |
|
| Lists all decks with names, IDs, and card counts. Writes hierarchy to disk and returns summary. |
|
| Creates a new deck or subdeck (e.g. |
|
| Renames an existing deck and updates all nested subdeck prefixes. |
|
| Deletes a deck and its cards. |
|
| Moves cards across decks by IDs, query, or input file. |
2. Notetypes (Models)
Tool | Parameters | Description |
|
| Lists all available notetypes (e.g. |
|
| Returns detailed schema, fields, and templates for a notetype to disk. |
3. Flashcard & Note Management (File-Based)
Tool | Parameters | Description |
|
| Creates a standard note from a JSON file payload ( |
|
| Creates a Cloze deletion card from a JSON file payload ( |
|
| Adds multiple flashcards in a single atomic batch from a JSON array file. |
|
| Fetches a note by ID with fields, tags, notetype, and cards to disk. |
|
| Updates fields or tags on an existing note from a JSON payload. |
|
| Deletes notes and their cards by ID list or JSON file. |
4. Media, State Control & Export
Tool | Parameters | Description |
|
| Copies an image/diagram directly from disk into Anki's media storage and returns embed tags. |
|
| Suspends cards from active review queues by IDs, query, or file. |
|
| Restores suspended cards to active review queues by IDs, query, or file. |
|
| Exports a deck to |
5. Search & Discovery
Tool | Parameters | Description |
|
| Searches notes using Anki search syntax ( |
|
| Searches cards and returns review queue, intervals, and due dates to disk. |
6. Tag Management & Stats
Tool | Parameters | Description |
|
| Lists all unique tags across the collection to disk. |
|
| Adds tags in bulk to specified notes. |
|
| Removes tags in bulk from specified notes. |
|
| Returns summary statistics (total notes, cards, new/due cards, deck breakdown). |
Testing
Run the automated test suite and linter:
ruff check .
uv run python -m unittest discover -s testsImportant Notes & Troubleshooting
SQLite Database Lock: Anki uses exclusive file locks. The Anki desktop GUI application must be closed while the MCP server executes write operations to prevent
anki.errors.DBErrorlocks.Collection Path Auto-Discovery:
Windows: Automatically detected in
%APPDATA%\Anki2\<Profile>\collection.anki2or%LOCALAPPDATA%\Anki2\<Profile>\collection.anki2.macOS: Automatically detected in
~/Library/Application Support/Anki2/<Profile>/collection.anki2.Linux: Automatically detected in
~/.local/share/Anki2/<Profile>/collection.anki2.To use a custom location, set the
ANKI_COLLECTION_PATHenvironment variable.
Output Cache: Tool outputs are stored in your OS temporary directory (
%TEMP%\anki_mcpor/tmp/anki_mcp) by default. SetANKI_MCP_OUTPUT_DIRto use a custom directory.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
AI access to your aNotepad online notes: read, search, write, and organize via 22 tools.
Free: turn your AI chats into spaced-repetition vocabulary. 13 tools, reads and writes.
AI-powered YouTube to flashcards with spaced repetition and Anki export
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/debnath-d/anki-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server