Provides comprehensive CRUD access to Anki flashcard data via AnkiConnect, enabling management of cards, decks, tags, and reviews with tools for creating, updating, searching, and analyzing flashcard content and study metrics.
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 MCP Data Bridgeshow me my most difficult cards from 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 Data Bridge Setup & Integration Guide
Overview
This is a comprehensive MCP (Model Context Protocol) data bridge that provides full CRUD (Create, Read, Update, Delete) access to your Anki flashcard data via JSON-RPC over stdin/stdout. The server acts as a complete Anki management interface - Claude handles all analysis and decision-making.
π Quick Start
Install dependencies:
pip install -r requirements.txt(minimal - no AI libraries!)Install AnkiConnect add-on in Anki (code:
2055492159)Test the server:
./venv/bin/python test_server.pyConfigure Claude Desktop with the provided JSON config (no API keys needed!)
Ask Claude: "Analyze my Anki decks!" (Claude gets rich data and provides analysis)
Architecture
Key Principle: Server = Data Bridge, Claude = AI Analysis
β οΈ Important: This is a data-only server
No external AI dependencies - Claude handles all analysis
No API keys required - Just provides structured Anki data
Faster & more reliable - No external service calls
Communicates via stdin/stdout using MCP protocol
π What's New in This Version
β Architectural Improvements
Eliminated external AI dependencies - No more Gemini API calls or failures
Simplified configuration - No API keys or external service setup required
Enhanced reliability - No more "404 model not found" or quota errors
Improved performance - Direct data access without API round trips
β Enhanced Functionality
6 comprehensive data tools (upgraded from 4 analysis tools)
Richer data structures with detailed card statistics and metadata
Advanced search capabilities using full Anki search syntax
Better error handling with actionable troubleshooting information
β User Experience
Faster responses - No waiting for external AI processing
More detailed data - Access to all Anki card and deck information
Flexible analysis - Claude can perform any analysis you request
Zero maintenance - No API keys to manage or renew
Project Structure
Setup Instructions
1. Prerequisites
Python 3.8+ installed on your system
Anki application installed and running
Claude Desktop installed
AnkiConnect add-on installed in Anki
2. Clone and Install Dependencies
3. Install AnkiConnect Add-on
Open Anki
Go to Tools β Add-ons β Get Add-ons
Enter code:
2055492159Restart Anki
Verify it's working by keeping Anki running
4. Configure Environment (Optional)
Environment Variables:
Claude Desktop Configuration: Environment variables are set in the Claude Desktop config (shown in step 7 below):
Note: No API keys needed! The server only provides structured data - Claude handles all AI analysis.
5. Test the Server
Expected output:
Note: This is an MCP server - it doesn't run as a standalone HTTP server. It's launched by Claude Desktop when needed.
6. Configure Claude Desktop
Step 1: Find Your Claude Desktop Config File
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
Step 2: Add the MCP Server Configuration Create or edit the file with this content:
β οΈ Important Customizations:
Use absolute paths for everything: Use full paths for both
"command"and"args", not relative pathsUpdate all paths to match your actual project directory
No API keys needed: Server only provides data, Claude handles analysis
Step 3: Restart Claude Desktop Close Claude Desktop completely and reopen it.
Step 4: Verify Integration Ask Claude: "Can you help me analyze my Anki decks?"
Claude should now have access to 18 MCP tools for comprehensive Anki management (6 read + 12 write operations).
Available MCP Tools
Once configured, Claude Desktop will have access to these 18 comprehensive Anki management tools:
π Read Operations (6 tools)
Tool | Description | Example Usage |
| Retrieve detailed information about a specific card | "Get data for card ID 1234567890" |
| Get comprehensive deck statistics and metrics | "Give me an overview of my Spanish deck" |
| Retrieve all cards from a specified deck | "Get all cards from my Medical Terminology deck" |
| Get recently failed cards for review | "Show me cards I failed in the last week" |
| Search cards using Anki's search syntax | "Find all cards tagged 'difficult'" |
| List all available decks with basic information | "What decks do I have?" |
βοΈ Write Operations (12 tools)
Card Creation
Tool | Description | Example Usage |
| Create a single flashcard in a specified deck | "Create a card with 'bonjour' on front and 'hello' on back" |
| Create multiple cards efficiently in one operation | "Create 20 vocabulary cards from this list" |
Card Updates
Tool | Description | Example Usage |
| Update fields and tags of an existing card | "Update card 123 to fix the pronunciation" |
| Update multiple cards efficiently | "Add audio pronunciations to all Spanish cards" |
Card Management
Tool | Description | Example Usage |
| Suspend cards to remove them from review temporarily | "Suspend all cards I keep getting wrong" |
| Unsuspend previously suspended cards | "Unsuspend my anatomy cards for next week's exam" |
| Permanently delete cards (requires confirmation) | "Delete all duplicate cards in my German deck" |
Deck Management
Tool | Description | Example Usage |
| Create a new deck or subdeck | "Create a new deck called 'MCAT Biology'" |
| Move cards between decks | "Move difficult chemistry cards to a separate deck" |
| Delete a deck and optionally its cards | "Delete my old French deck and move cards to archive" |
Tag Management
Tool | Description | Example Usage |
| Add tags to multiple cards without replacing existing ones | "Tag all anatomy cards with 'medical' and 'memorize'" |
| Remove specific tags from multiple cards | "Remove 'easy' tag from cards I now find difficult" |
π Rich Data Structures
Each tool provides comprehensive, structured data that Claude can analyze. Here's what Claude receives:
Card Data Example (get_card_data)
Deck Overview Example (get_deck_overview)
This detailed data allows Claude to perform sophisticated analysis that was impossible with the old AI-dependent approach.
Example Conversations with Claude
Advanced Analysis & Action
Bulk Content Creation
Smart Deck Management
Alternative: Custom MCP Client Integration
For developers building custom MCP clients:
Note: This requires implementing your own MCP client. Claude Desktop handles this automatically.
Configuration Options
π§ Method 1: Configuration File (Recommended)
Copy the template:
cp config.template.json config.jsonCustomize :
{ "anki_connect": { "url": "http://localhost:8765", "timeout": 30 }, "server": { "name": "anki-mcp", "log_level": "INFO" }, "limits": { "max_cards_per_query": 50, "max_search_results": 100 }, "write_operations": { "enabled": true, "require_confirmation": ["delete_cards", "delete_deck"], "batch_size_limit": 100, "backup_before_delete": false } }
π§ Method 2: Environment Variables
Copy the template:
cp env.template .envCustomize :
# AnkiConnect URL (default: http://localhost:8765) ANKI_CONNECT_URL=http://localhost:8765 # Optional: Log level (DEBUG, INFO, WARNING, ERROR) LOG_LEVEL=INFO
π§ Method 3: Direct Environment (No Files)
Set environment variables directly:
βοΈ Configuration Priority
The server loads configuration in this order (later overrides earlier):
Built-in defaults
config.json file (if exists)
Environment variables (if set)
π οΈ Available Options
Setting | Default | Description |
|
| AnkiConnect endpoint URL |
|
| Request timeout in seconds |
|
| MCP server name |
|
| Logging level (DEBUG/INFO/WARNING/ERROR) |
|
| Maximum cards returned per query |
|
| Maximum search results |
|
| Enable/disable write operations |
|
| Operations requiring explicit confirmation |
|
| Maximum items per batch operation |
|
| Create backup before destructive operations |
Troubleshooting
Test MCP Server Connection
Expected output:
Common Issues
Claude Desktop can't find the server or script
spawn ./venv/bin/python ENOENT: Use absolute path for"command":"/path/to/your/anki-mcp-project/venv/bin/python"can't open file '//mcp_server.py': Use absolute path for"args":["/path/to/your/anki-mcp-project/mcp_server.py"]Use absolute paths for everything - Claude Desktop sometimes has issues with relative paths
Check the
cwdpath in your Claude config matches your project directoryVerify files exist:
ls -la venv/bin/pythonandls -la mcp_server.py
AnkiConnect not found
Make sure Anki is running
Verify AnkiConnect add-on is installed and enabled
Check AnkiConnect is listening on port 8765
Module not found errors
Ensure virtual environment is properly set up
Reinstall dependencies:
pip install -r requirements.txtCheck the Python path in Claude config
Data retrieval errors
Card not found: Verify the card ID exists in your Anki collection
Deck not found: Check deck name spelling and ensure deck exists
Permission errors: Verify AnkiConnect is properly configured and Anki is running
Large dataset timeouts: Use limit parameters for large deck queries
Server provides detailed error messages for troubleshooting
MCP Protocol errors
Restart Claude Desktop after config changes
Check Claude Desktop logs for specific error messages
Ensure no other processes are interfering
Usage Examples
With Claude Desktop
Once configured, you can ask Claude things like:
Claude will automatically use the MCP tools to:
Connect to your Anki via AnkiConnect
Retrieve structured data about your cards and decks
Analyze the data using its AI capabilities
Present you with actionable insights and recommendations
Features
π Comprehensive Card Data
Detailed card information including content, statistics, and scheduling data
Rich metadata with ease factors, intervals, lapses, and review counts
Field-by-field content with tags and model information
π Advanced Deck Analytics
Complete deck statistics with card distribution analysis
Performance metrics including average ease factors and intervals
Difficulty patterns and learning progress indicators
Sample card analysis for representative overview
π― Powerful Search & Filtering
Flexible card search using Anki's full search syntax
Lapsed card identification with detailed failure history
Deck-specific queries and cross-deck analysis
Customizable result limits for large datasets
β‘ Fast & Reliable Data Bridge
No external dependencies - pure Anki data access
High-performance queries with structured JSON responses
Robust error handling with detailed error messages
Real-time data directly from your Anki collection
Security Notes
β No network exposure - MCP server runs only when invoked by Claude Desktop
β Secure communication - All data exchange via stdin/stdout
β API key protection - Gemini API key stored in Claude Desktop config
β Local operation - AnkiConnect only accepts localhost connections
β No data persistence - Server doesn't store your Anki data
Development & Customization
Adding New Tools
Define the tool in
@server.list_tools()decorator:
Implement the handler in
@server.call_tool():
Test the changes:
Restart Claude Desktop to pick up changes
π― Quick Setup for GitHub Users
Clone and setup:
git clone <your-repo-url> anki-mcp cd anki-mcp python3 -m venv venv source venv/bin/activate # Linux/macOS # or: venv\Scripts\activate # Windows pip install -r requirements.txtConfigure (choose one):
# Option A: Use config file cp config.template.json config.json # Edit config.json with your settings # Option B: Use environment file cp env.template .env # Edit .env with your settingsUpdate Claude Desktop config with YOUR absolute paths:
{ "mcpServers": { "anki": { "command": "/YOUR/PATH/TO/anki-mcp/venv/bin/python", "args": ["/YOUR/PATH/TO/anki-mcp/mcp_server.py"], "cwd": "/YOUR/PATH/TO/anki-mcp" } } }
π§ Customizing the Server
The server is designed to be configurable without code changes:
Performance tuning: Adjust
max_cards_per_queryin config.jsonLogging control: Set
log_levelto DEBUG for troubleshootingNetwork settings: Change AnkiConnect URL/timeout for custom setups
Custom limits: Modify search result limits for your needs
For advanced customization, edit mcp_server.py to:
Add new MCP tools for additional Anki data access
Enhance data structures with additional fields
Implement custom error handling or logging
π Summary: Complete Anki Management Solution
π― What You Can Do Now
π Smart Analysis
Analyze deck performance and identify problem cards
Get detailed statistics and learning insights
Find patterns in your study habits
β‘ Intelligent Automation
Bulk create cards from lists or notes
Automatically reorganize decks by difficulty/subject
Batch update tags and content across multiple cards
π§ Powerful Management
Create and manage decks with subdecks
Move cards between decks intelligently
Suspend/unsuspend cards based on criteria
Clean up duplicate or outdated content
π‘οΈ Safe Operations
Confirmation required for destructive operations
Batch size limits prevent overwhelming Anki
Detailed error messages for troubleshooting
Atomic operations where possible
ποΈ Architecture Advantages
π§ Claude: Handles all analysis, decision-making, and user interaction
π MCP Server: Provides complete CRUD operations as a data bridge
π‘ AnkiConnect: Reliable protocol for Anki communication
πΎ Anki: Your flashcard database remains local and secure
π Key Benefits
π Complete Control: Full read/write access to your Anki data
π€ AI-Powered: Claude can analyze and act on your behalf
β‘ Efficient: Batch operations for large-scale changes
π‘οΈ Safe: Validation and confirmation for destructive operations
π Local: All data stays on your machine
π§ Configurable: Customize limits and safety features
π Rich Data: Access to all card metadata and statistics
This is the most comprehensive Anki automation solution available - combining the power of Claude's intelligence with complete control over your flashcard data.