Provides comprehensive tools for interacting with Anki desktop via AnkiConnect, allowing for the management of decks, creation and updating of notes, and retrieval of note types and field definitions.
Enables high-quality text-to-speech audio generation for flashcards using ElevenLabs voices.
Integrates Google Cloud Text-to-Speech API to generate natural-sounding pronunciation audio for flashcards, including support for HD Chirp voices.
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 Server with ElevenLabs SupportAdd 'Guten Tag' to my German deck with ElevenLabs audio"
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 with ElevenLabs Support
Based on
This version adds ElevenLabs TTS support via Pipecat while maintaining the original Google Cloud TTS functionality.
A FastMCP server for interacting with Anki through the Model Context Protocol (MCP). This server provides comprehensive tools for managing Anki decks, notes, and note types, with advanced features including AI-powered audio generation, bulk operations, and semantic similarity search.
External APIs Used
This project integrates with several external APIs to provide enhanced functionality:
Google Cloud Text-to-Speech API
Purpose: High-quality audio generation from text using Google's Chirp voices
Use Case: Generate pronunciation audio files for flashcards
Features: HD quality voices with natural pronunciation, especially excellent for Chinese
Setup: Requires
GOOGLE_CLOUD_API_KEYenvironment variable
AnkiConnect API (Local)
Purpose: Interface with Anki desktop application
Use Case: All Anki operations (create/read/update notes, manage decks, etc.)
Features: Complete Anki functionality via HTTP API
Setup: AnkiConnect add-on must be installed and Anki must be running
Setup
Install dependencies using uv:
uv syncMake sure Anki is running with the AnkiConnect add-on installed:
In Anki, go to Tools > Add-ons > Get Add-ons
Enter code:
2055492159Restart Anki
(Optional) Set up API key for audio generation:
# For audio generation with Google Cloud TTS export GOOGLE_CLOUD_API_KEY='your-google-cloud-api-key-here'Run the server:
uv run server.py
Claude Desktop Integration
To use this MCP server with Claude Desktop, add the following configuration to your claude_desktop_config.json file:
Configuration Location
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
Configuration Example
Setup Steps
Ensure dependencies are installed: Make sure you've run
uv syncin your anki-mcp directoryFind your config file at the location above (create it if it doesn't exist)
Update the path: Replace
/path/to/your/anki-mcp/with the actual path to your anki-mcp directoryAdd your API key:
Replace
your-google-cloud-api-key-herewith your actual Google Cloud API key (for audio generation)
Restart Claude Desktop for the changes to take effect
Important Notes
Make sure Anki is running with the AnkiConnect add-on before using the tools
The
uvcommand will automatically handle the Python environment and dependenciesMake sure
uvis installed on your system (curl -LsSf https://astral.sh/uv/install.sh | sh)
Alternative: Using Environment Variables
If you prefer to keep your API key in your shell environment, you can omit the env section:
Then set the environment variable in your shell:
Verification
Once configured, restart Claude Desktop and you should see the Anki MCP tools available in your conversations. You can verify by asking Claude to list your Anki decks or try any of the available tools.
Available Tools
list_decks
Lists all available Anki decks with count.
Parameters: None
Returns: Formatted string with all deck names and total count
get_deck_notes
Retrieves all notes/cards from a specific deck with detailed information.
Parameters:
deck_name(str): Name of the Anki deck to retrieve notes from
Returns: Detailed information about all notes including model name, tags, and field values
get_deck_sample
Gets a random sample of notes from a deck to understand typical note structure.
Parameters:
deck_name(str): Name of the Anki deck to sample notes fromsample_size(int, optional): Number of notes to sample (1-50, default: 5)
Returns: Detailed information about sampled notes
get_deck_note_types
Analyzes a deck to identify all note types (models) and their field definitions.
Parameters:
deck_name(str): Name of the Anki deck to analyze
Returns: All unique note types used in the deck with their field names
create_note
Creates a new note in the specified deck.
Parameters:
deck_name(str): Name of the Anki deck to add the note tomodel_name(str): Name of the note type/model to usefields(dict): Dictionary mapping field names to values (e.g.,{'Front': 'Question', 'Back': 'Answer'})tags(list, optional): Optional list of tags to add to the note
Returns: JSON object with noteId and success status or error message
update_note
Updates specific fields of an existing note while preserving other fields.
Parameters:
note_id(int): ID of the note to updatefields(dict): Dictionary mapping field names to new values (e.g.,{'Audio': '[sound:pronunciation.mp3]'})tags(list, optional): Optional list of tags to replace existing tags
Returns: JSON object with success status and updated field information
Use Case: Perfect for adding audio files to existing cards or updating specific content
create_deck_with_note_type
Creates a new deck and optionally a new note type with custom fields and templates.
Parameters:
deck_name(str): Name for the new Anki deckmodel_name(str): Name for the note type/modelfields(list): List of field names (e.g.,['Front', 'Back', 'Extra'])card_templates(list, optional): Optional list of card template definitions
Returns: JSON object with creation status and details
list_note_types
Lists all available note types (models) with comprehensive information.
Parameters: None
Returns: Information about all note types including fields, templates, and styling
generate_audio
Generates high-quality audio files from text using Google Cloud Text-to-Speech API with Chirp voices.
Parameters:
text(str): Text to convert to speechlanguage(str, optional): Language code (default: "cmn-cn" for Chinese)voice(str, optional): Voice name (default: "cmn-CN-Chirp3-HD-Achernar" for Chinese HD voice)
Returns: JSON object with base64-encoded MP3 audio data and metadata
Setup: Requires GOOGLE_CLOUD_API_KEY environment variable
Features: HD quality voices with natural pronunciation, especially excellent for Chinese language learning
save_media_file
Saves media data as a file in Anki's media collection for use in cards.
Parameters:
filename(str): Name of the file to save (e.g., 'audio.mp3', 'image.jpg')media_data(str): Base64 encoded file data OR a local file path (auto-detected)
Returns: JSON object with saved filename and success status
Use Case: Save generated audio, images, or other media files for use in Anki cards. Accepts either base64 data or a file path for convenience.
generate_and_save_audio
Generates audio from text and saves it directly to Anki's media collection in one operation.
Parameters:
text(str): Text to convert to speech and savefilename(str): Name for the audio file (e.g., 'pronunciation.mp3')language(str, optional): Language code (default: "cmn-cn" for Chinese)voice(str, optional): Voice name (default: "cmn-CN-Chirp3-HD-Achernar")
Returns: JSON object with filename and sound tag for use in card fields
Setup: Requires GOOGLE_CLOUD_API_KEY environment variable
Use Case: One-step audio generation and saving, returns [sound:filename.mp3] tag ready for card fields
create_notes_bulk
Creates multiple notes in a single batch operation for maximum efficiency. Handles duplicates gracefully by reporting which notes are duplicates while still creating non-duplicate notes.
Parameters:
deck_name(str): Name of the Anki deck to add notes tonotes_list(list): List of note dictionaries, each containing 'model_name', 'fields', and optionally 'tags'
Returns: JSON object with success/failed counts, successful notes array, and failed notes array with specific error details
Features:
Uses canAddNotesWithErrorDetail to pre-check which notes can be added
Only attempts to add valid notes, ensuring no batch failures
Provides detailed error reporting for each failed note (duplicates, validation errors, etc.)
Returns note IDs for successfully created notes for further processing
update_notes_bulk
Updates multiple notes in a single batch operation for maximum efficiency.
Parameters:
updates(list): List of update dictionaries, each containing 'note_id', 'fields' dict, and optionally 'tags' list
Returns: JSON object with success/failure counts and detailed update results
Use Case: Perfect for batch updates like adding audio files to multiple cards at once
find_similar_notes
Find notes containing any of the search terms. Returns results grouped by term, with subdeck info.
Parameters:
deck_name(str): Name of the Anki deck to search in (used as a filter)search_terms(list[str]): List of terms to search for as substrings in any fieldcase_sensitive(bool, optional): Whether the search should be case sensitive (default: false)max_results_per_term(int, optional): Maximum number of matching notes to return per search term (default: 20)
Returns: Results grouped by search term. The top-level deck_name is the input filter; each match includes deck_names (list) showing all decks the note's cards belong to.
Features:
Bulk search: check multiple terms in a single call
Returns all deck names per match (useful for filtered decks and nested hierarchies)
Fast substring matching across all note fields
Case-sensitive or case-insensitive search options
Shows exactly which fields matched the search criteria
Uses only local AnkiConnect (no external APIs)
Note: Tags are not returned (uses cardsInfo API for subdeck support).
Technical Details
Framework: FastMCP (built on FastAPI)
Server Name: "anki-mcp"
AnkiConnect URL: http://localhost:8765
Dependencies: fastapi, fastmcp, requests, uvicorn
External APIs:
Google Cloud Text-to-Speech API (for audio generation)
Audio Format: MP3 with base64 encoding
Features
HD Audio Generation: Premium quality TTS using Google Cloud Chirp voices, optimized for Chinese pronunciation
Note Updates: Update existing notes with new content like audio files while preserving other fields
Media Management: Direct integration with Anki's media collection for seamless file handling
Bulk Operations: Efficient batch note creation and updates for large datasets
Fast Text Search: Simple substring matching for finding notes containing specific text
Comprehensive Error Handling: Robust error handling for all API failures and edge cases
Smart Data Formatting: Content truncation and formatting for optimal readability
Random Sampling: Efficient sampling for large datasets without memory issues
Custom Templates: Full support for custom card templates and CSS styling
Type Safety: Complete parameter validation using Pydantic
Secure API Key Handling: Environment variable-based API key management
Robust Error Handling: Pre-validation of notes with detailed error reporting for duplicates and other issues
Cross-Language Support: Optimized for Chinese language learning but supports multiple languages