justinfriesen/anki-mcp-server
If you are the rightful owner of anki-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The Anki MCP Server is a Model Context Protocol server that integrates AI assistants with Anki flashcard functionality via AnkiConnect.
Anki MCP Server
A Model Context Protocol (MCP) server that provides AI assistants with access to Anki flashcard functionality through AnkiConnect.
Prerequisites
- Anki - The desktop application must be running
- AnkiConnect - Install from Anki's add-on menu (code: 2055492159)
- Python 3.6+ - Required to run the server
Features
Resources
- Browse and read deck information
- View note model (card type) details
- Access individual note contents
Tools
listDecks- List all available deckslistModels- List all note modelsgetDeckInfo- Get statistics for a specific deckcreateDeck- Create a new deckaddNote- Create a single flashcardaddNotesBatch- Create multiple flashcards in one efficient operation ⭐canAddNotes- Validate notes before batch creation (check for duplicates/errors)findNotes- Search for notes using Anki's query syntaxupdateNoteFields- Update existing note contentaddTags- Add tags to notesdeleteNotes- Delete notesguiCurrentCard- Get the card currently being reviewed in Anki
Installation
Prerequisites
- Anki Desktop - Must be running when using the MCP server
- AnkiConnect Add-on - Install in Anki via Tools → Add-ons → Get Add-ons → Code:
2055492159 - Python 3.6+ - Required to run the server
- Claude Desktop - Download from claude.ai
Minimal Installation (Easiest)
-
Download just the server file:
curl -O https://raw.githubusercontent.com/justinfriesen/anki-mcp-server/main/anki_mcp_server.pyOr manually download
anki_mcp_server.pyfrom the repository. -
Configure Claude Desktop:
Edit
~/Library/Application Support/Claude/claude_desktop_config.json(macOS) or%APPDATA%\Claude\claude_desktop_config.json(Windows):{ "mcpServers": { "anki": { "command": "python3", "args": ["/path/to/anki_mcp_server.py"] } } } -
Restart Claude Desktop - That's it! 🎉
Full Setup (Recommended for developers)
-
Clone this repository:
git clone https://github.com/justinfriesen/anki-mcp-server.git cd anki-mcp-server -
Install dependencies (optional):
pip install -r requirements.txt # Only if you want requests library -
Configure Claude Desktop:
Edit
~/Library/Application Support/Claude/claude_desktop_config.json(macOS) or%APPDATA%\Claude\claude_desktop_config.json(Windows):{ "mcpServers": { "anki": { "command": "python3", "args": ["/absolute/path/to/anki_mcp_server.py"] } } }Replace
/absolute/path/to/with your actual path to the cloned repository. -
Restart Claude Desktop
-
Test the connection:
- Open Anki
- Open Claude Desktop
- Ask Claude: "What Anki decks do I have?"
Usage
With Claude Desktop
See installation instructions above for configuring Claude Desktop.
With Other MCP Clients
The server communicates via stdio (standard input/output) using JSON-RPC 2.0 messages.
Testing
Run the test scripts to verify everything is working:
python3 tests/test_anki_connection.py # Test AnkiConnect
python3 tests/test_mcp_server.py # Test MCP server
Example Usage
Once connected, an AI assistant can:
-
Create a new deck: "Create an Anki deck called 'Spanish Vocabulary'"
-
Add flashcards efficiently: "Create 10 Spanish vocabulary flashcards for common greetings" (uses batch upload)
-
Search and update: "Find all notes tagged 'verb' and add the tag 'conjugation'"
-
Get deck statistics: "How many cards are due for review in my Default deck?"
-
Help with the card you're reviewing: "What's the card I'm looking at?" (shows current card) "Can you explain this concept in more detail?" (Claude sees your card and provides explanation) "Give me a mnemonic to remember this answer"
Protocol Details
This server implements MCP protocol version 2025-06-18 with:
- Full resources support (list and read)
- Tools with JSON Schema validation
- Proper error handling and logging
- Stdio transport
Troubleshooting
- Connection Error: Make sure Anki is running and AnkiConnect is installed
- Port Issues: AnkiConnect uses port 8765 by default
- Permission Errors: Some Anki operations may require specific permissions in AnkiConnect settings
License
MIT License - See LICENSE file for details