
Anki MCP Server
โ 8from dhkim0124
Create Anki flashcards using natural language by connecting to the AnkiConnect add-on.
โ labsco summary โ our analysis, not the vendor's
What it is โ An MCP server that connects Claude to Anki via the AnkiConnect add-on, letting you build and manage flashcard decks in natural language.
What you get โ
- Deck tools:
list_decks(with new/due/learning stats),create_deck(nested::decks),delete_deck(confirmation required) - Card tools:
create_card,create_card_batch, andcreate_card_customfor custom note types - Rich prompts like "Create a Python deck with Code style and add 10 cards about decorators" or "upload this image and attach it to a new card in my Biology deck"
- A guided flow that asks clarifying questions and confirms before destructive operations
Requirements โ Python 3.9+, Anki 2.1.x+, the AnkiConnect add-on (code 2055492159) running at localhost:8765, and an MCP client. env is empty โ no keys.
Cost snapshot โ Free and open source (MIT); everything runs locally against your Anki, no paid service.
Setup effort โ Install AnkiConnect, clone and set up a venv with pip install -r requirements.txt, then add a python block pointing at anki_server.py.
Our take โ A delightful, safe-by-default way to generate cards from Claude; the practical caveat is the dependency chain โ Anki must be running with AnkiConnect installed, and it is a clone-and-venv setup rather than a one-liner.
Source: the project README โ summarized 2026-07-08.
โ readme from github โ mirrored (latest on GitHub โ)
anki-mcp-server
Read this in other languages: English, ํ๊ตญ์ด
A Model Context Protocol (MCP) server that connects Claude and Anki, allowing you to create, manage, and enrich flashcard decks through natural language โ without ever opening the Anki UI.
Available Tools
Deck Management
| Tool | Description |
|---|---|
list_decks | List all decks with stats (total, new, due, learning cards) |
create_deck | Create a new deck (supports nested decks with ::) |
delete_deck | Delete a deck โ requires explicit confirmation |
Card Operations
| Tool | Description |
|---|---|
create_card | Create a single Basic card (front/back) |
create_card_batch | Create multiple cards in one call |
create_card_custom | Create a card using a custom note type, with optional audio/image attachments |
search_cards | Search using Anki's query syntax (tags, text, deck filters) |
update_card | Edit fields and tags of an existing card |
delete_cards | Delete one or more cards โ requires explicit confirmation |
Note Types & Styling
| Tool | Description |
|---|---|
create_note_type | Create a custom note type with chosen fields, CSS style, and HTML templates |
get_note_types | List all available note types and their fields |
update_note_type_style | Update the CSS of an existing note type |
update_note_type_template | Update the HTML templates of an existing note type |
Media & Sync
| Tool | Description |
|---|---|
add_media | Upload an image or audio file (base64) to Anki's media folder |
sync_anki | Sync your local collection with AnkiWeb |
Style Templates
Four built-in styles are available via the style parameter in create_note_type:
| Style | Key | Best for |
|---|---|---|
| Default | "default" | General use |
| Duolingo | "duolingo" | Language learning, gamified feel |
| Dark Mode | "dark" | Night studying, reduced eye strain |
| Code | "code" | Programming, algorithms |
| Custom | "custom" | Full control โ you provide the CSS |
For custom style, describe what you want in natural language and Claude generates the CSS:
"Dark blue background, mint green accents, smooth fade-in animation"
All custom CSS is validated to block javascript: URLs, <script> tags, and inline event handlers before being sent to Anki.
Project Structure
anki-mcp-server/
โโโ anki_server.py # MCP tool definitions and AnkiConnect client
โโโ config.py # Constants: URL, API version, media limits
โโโ instructions.py # LLM system instructions for conversational behavior
โโโ templates.py # Built-in CSS themes, CSS validation, HTML generators
โโโ tests/
โโโ test_anki_server.py # Tests for all tools (mocked AnkiConnect)
โโโ test_templates.py # Tests for template logic and CSS validation{
"mcpServers": {
"anki-mcp": {
"command": "python",
"args": ["/absolute/path/to/anki_server.py"]
}
}
}Requirements
- Python 3.9 or higher
- Anki 2.1.x or higher
- AnkiConnect add-on
- Claude Desktop (or any MCP-compatible client)
Installation
1. Set up Anki and AnkiConnect
- Install Anki.
- Install the AnkiConnect add-on:
- In Anki, go to
Tools > Add-ons > Get Add-ons - Enter code
2055492159and click OK - Restart Anki
- In Anki, go to
- Verify it works by visiting
http://localhost:8765โ you should seeAnkiConnect v.6.
2. Install anki-mcp-server
git clone https://github.com/dhkim0124/anki-mcp-server.git
cd anki-mcp-server
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt3. Configure Claude Desktop
Edit your Claude Desktop config file:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"anki-mcp": {
"command": "python",
"args": ["/absolute/path/to/anki_server.py"]
}
}
}Usage
With Anki running in the background, you can ask Claude things like:
- "Create a Python deck with Code style and add 10 cards about decorators"
- "Show me my decks and their stats"
- "Search for cards tagged 'sql' and update the one about indexes"
- "Create a custom dark-mode deck with fields: Word, Definition, Example, Audio"
- "Upload this image and attach it to a new card in my Biology deck"
- "Sync my collection with AnkiWeb"
The server guides the conversation โ it asks clarifying questions about deck, style, and card type before creating anything, and always asks for confirmation before destructive operations.
Running Tests
pip install pytest pytest-asyncio
pytest tests/ -vAll tests mock AnkiConnect via httpx โ no running Anki instance required.
Troubleshooting
- Anki must be open: The MCP server requires Anki to be running.
- AnkiConnect not responding: Visit
http://localhost:8765to confirm it's active. - Windows firewall: You may need to allow Anki through the firewall for AnkiConnect to work.
- Restart everything: If issues persist, restart Anki, Claude Desktop, and re-check the config file path.
Licensed under MITโ you can use, modify, and redistribute it under that license's terms.
License
MIT License โ see LICENSE for details.