Anki MCP Server
Enables interaction with Anki flashcard collections, providing tools to create, retrieve, update, and search for cards, manage decks and tags, and handle media files programmatically.
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 Server create a new flashcard for 'altruism' in my English 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 Server
A Model Context Protocol (MCP) server that provides seamless integration with Anki, enabling AI assistants to interact with your flashcard collection. Create, read, update, and manage Anki cards programmatically through a standardized interface.
Features
🎴 Card Management: Create, retrieve, and update flashcards with full field customization
🔍 Smart Search: Query cards by ID, keywords, tags, decks, or any Anki search syntax
📊 Review Integration: Access due cards, new cards, and answer cards programmatically
🎵 Media Support: Automatic handling of audio and images (local files, URLs, or existing media)
🔄 Batch Operations: Create multiple cards efficiently in a single operation
🎯 Generic Tools: Flexible tools that work with any deck, note type, and field configuration
Related MCP server: Anki MCP Server
Prerequisites
Anki Desktop App - Must be running during MCP server usage
AnkiConnect Add-on - Install from Anki: Tools → Add-ons → Get Add-ons → Code:
2055492159
⚠️ Important: Anki must be running with AnkiConnect enabled for this MCP server to function.
Resources
anki://search/deckcurrent- All cards from current deckanki://search/isdue- Cards due for reviewanki://search/isnew- New unseen cardsCustom queries:
anki://search/tag:vocabulary,anki://search/deck:Spanish, etc.
Tools
update_card- Update cards/notes (answer, update fields, update tags)add_card- Create a new flashcard with custom deck, model, and fieldsbatch_add_card- Create multiple flashcards at onceget_due_cards- Get list of cards due for reviewget_new_cards- Get list of new unseen cardsget_card- Retrieve detailed card information by ID or query
Development
Install dependencies:
npm installBuild the server:
npm run buildFor development with auto-rebuild:
npm run watchMedia Files
How Media Files Are Handled
When you add cards with images or audio files, the server automatically handles different types of media sources:
Local File Paths: If you provide an absolute path to a file on your computer (e.g.,
/Users/mycomputer/Documents/images/prune.jpg), the server will:Read the file from your disk
Convert it to base64
Upload it to Anki's media collection using the
storeMediaFileAPIReference it in the card by filename
URLs: If you provide a URL (e.g.,
https://example.com/image.jpg), Anki-Connect will download the file automatically when the card is created.Existing Media: If you provide just a filename (e.g.,
prune.jpg), it assumes the file already exists in Anki's media folder.
Troubleshooting Image Issues
If images don't show up properly in Anki:
Check the file path: Make sure the path to your image file is correct and the file exists
File permissions: Ensure the file is readable by the application
Supported formats: Anki supports common image formats (JPG, PNG, GIF, SVG, WebP)
File size: Very large files might cause issues
Special characters: Avoid special characters in filenames when possible
The server will now automatically handle local file paths, so you don't need to manually copy images to Anki's media folder anymore.
Installation & Configuration
Installation
Clone or download this repository
Install dependencies:
npm installBuild the server:
npm run build
Configuration with Claude Desktop
Add the server configuration to your Claude Desktop config file:
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"anki-mcp-server": {
"command": "/absolute/path/to/anki-mcp-server/build/index.js"
}
}
}💡 Tip: Replace
/absolute/path/to/anki-mcp-serverwith the actual full path to where you cloned this repository.
Configuration with Other MCP Clients
This server follows the standard MCP protocol and can be used with any MCP-compatible client. Configure it as a stdio-based server pointing to build/index.js.
Verification
After configuration:
Restart Claude Desktop (or your MCP client)
Ensure Anki is running with AnkiConnect installed
The server should appear in your available MCP servers
Test with a simple query like "Show me 5 due cards from Anki"
Debugging
Since MCP servers communicate over stdio, debugging can be challenging. We recommend using the MCP Inspector, which is available as a package script:
npm run inspectorThe Inspector will provide a URL to access debugging tools in your browser where you can:
Test tool calls interactively
View request/response logs
Debug connection issues
Validate tool schemas
Troubleshooting
Server not appearing in Claude Desktop:
Verify the path in config is absolute (not relative)
Check that
build/index.jsexists (runnpm run build)Restart Claude Desktop after config changes
"Connection refused" or timeout errors:
Ensure Anki is running
Verify AnkiConnect is installed (Tools → Add-ons)
Check AnkiConnect settings allow localhost connections (default)
Cards not updating/creating:
Close the Anki browser if you have it open (known AnkiConnect limitation)
Verify the deck and note type names match exactly (case-sensitive)
Check field names match your note type's field configuration
Contributing
Contributions are welcome! Whether you're fixing bugs, adding features, or improving documentation, your help is appreciated.
How to Contribute
Fork the repository on GitHub
Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/anki-mcp.git cd anki-mcpCreate a new branch for your feature or bugfix:
git checkout -b feature/your-feature-nameMake your changes and test thoroughly
Build and test your changes:
npm install npm run build npm run inspector # Test with MCP InspectorCommit your changes with clear, descriptive messages:
git commit -m "Add: description of your changes"Push to your fork:
git push origin feature/your-feature-nameOpen a Pull Request on GitHub with a clear description of your changes
Development Guidelines
Write clean, readable TypeScript code
Follow the existing code style and structure
Test your changes with the MCP Inspector
Update documentation if you're adding new features
Keep commits focused and atomic
Reporting Issues
Found a bug or have a feature request? Please open an issue on GitHub with:
A clear, descriptive title
Steps to reproduce (for bugs)
Expected vs actual behavior
Your environment (OS, Anki version, Node version)
Questions?
Feel free to open an issue for questions or join the discussion in existing issues.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Built on the Model Context Protocol by Anthropic
Uses AnkiConnect for Anki integration
Powered by yanki-connect npm package
Available Tools
6 toolsadd_cardA
Create a new flashcard in Anki. Requires: deckName (exact deck name), modelName (note type like 'Basic' or 'Cloze'), and fields object matching the note type's field names. Returns card ID on success. FORMATTING: Use HTML only (NO markdown) - for line breaks, for bold, for italic, / for lists. Media files (audio/picture) support URLs or local absolute paths.
Inputs: deckName (required), modelName (required), fields (required), tags, +2 more.
batch_add_cardA
Create multiple flashcards in one operation. Each card has same structure as add_card tool. Returns JSON with 'successful' (count), 'failed' (count), and 'errors' array (details of failures if any). More efficient than calling add_card multiple times. Use HTML formatting (not markdown). Processes cards sequentially; partial success possible (some cards created, some failed).
Inputs: cards (required).
get_cardA
Retrieve detailed card/note information. Provide EITHER cardId OR query (not both). Returns array of card objects with: cardId, deckName, modelName, question, answer, fields (object with all field values), due, interval, ease, reps, lapses, type, queue, noteId. Use this to find card/note IDs for update operations or to inspect card details.
Inputs: cardId, query.
get_due_cardsA
Retrieve cards that are due for review. Returns JSON object with 'count' (number of cards) and 'cards' array. Each card includes: cardId (number), question (HTML cleaned string), answer (HTML cleaned string), due (Unix timestamp). Ordered by due date (earliest first).
Inputs: num (required).
get_new_cardsA
Retrieve new unseen cards that haven't been studied yet. Returns JSON object with 'count' (number of cards) and 'cards' array. Each card includes: cardId (number), question (HTML cleaned string), answer (HTML cleaned string), due (Unix timestamp). Ordered by card position in new queue.
Inputs: num (required).
update_cardA
Update a card/note in Anki. Supports 4 operations: (1) 'answer': mark a card as reviewed with ease 1-4, (2) 'update_note': update note fields, tags, and media, (3) 'update_fields': update only fields and media, (4) 'update_tags': update only tags. Returns success message with operation details.
Inputs: operation (required), cardId, noteId, ease, +4 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a clearly distinct purpose with no overlap: add_card creates a single card, batch_add_card creates multiple, get_card retrieves specific card details, get_due_cards fetches cards due for review, get_new_cards fetches unseen cards, and update_card modifies existing cards. The descriptions clearly differentiate between creation, retrieval (by different criteria), and update operations.
All tool names follow a consistent verb_noun pattern: add_card, batch_add_card, get_card, get_due_cards, get_new_cards, update_card. The naming is uniform and predictable, using snake_case throughout with clear action prefixes (add, get, update) and descriptive nouns.
With 6 tools, this server is well-scoped for managing Anki flashcards. It covers core operations (create, retrieve, update) efficiently without being too sparse or bloated. The tools are focused and each serves a necessary function in the flashcard lifecycle.
The toolset provides strong coverage for flashcard management: creation (single and batch), retrieval (by ID, due status, or new status), and updates (including answering reviews). A minor gap is the lack of a delete_card tool, which could be useful for full CRUD operations, but agents can likely work around this by other means if needed.
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.
Spaced-repetition flashcards in Markdown: create cards, manage decks and study with FSRS.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables AI assistants to manage Anki flashcard decks and cards through natural language, supporting deck creation, card additions (basic and cloze types), and review queue management.66 npm2MIT
- 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.10 npm1ISC
- 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.3332 npm27MIT