Manage Anki Flashcards Programmatically
MCP server for Anki via AnkiConnect - create and update flashcards and note types, generate TTS audio, review due cards, and manage decks.
Why it matters
Automate the creation, updating, and review of Anki flashcards and decks through a programmatic interface. Integrate with AnkiConnect and leverage Azure TTS for audio generation to streamline your learning and teaching processes.
Outcomes
What it gets done
Create and update Anki cards with HTML content and optional audio.
Manage Anki decks, note types, and card review processes.
Bulk update multiple Anki notes efficiently.
Generate audio for flashcards using Azure Text-to-Speech.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-anki | bash Capabilities
Tools your agent gets
Mark cards as answered and update their ease factor after answering questions
Create a new flashcard in Anki with HTML content
Create a new flashcard with automatically generated audio via Azure TTS
Update an existing card — generate audio from a field and add to the audio field
Get a specified number of cards due for review
Get a specified number of new, not yet reviewed cards
Get a list of all Anki deck names
Find cards using raw Anki search query with detailed information
Overview
Anki MCP Server
An MCP server that lets an AI assistant manage Anki through AnkiConnect: creating and bulk-updating flashcards, reviewing due and new cards, editing note types and templates, and generating Azure text-to-speech audio for cards. Use it for AI-assisted flashcard creation and review, bulk card operations, and note-type editing. It needs Anki running locally with AnkiConnect installed, and Azure TTS credentials for audio generation.
What it does
An MCP server that gives an AI assistant direct control over Anki through the AnkiConnect plugin - creating, updating, and reviewing flashcards, editing note types, and generating spoken-word audio for cards, all as tool calls instead of manual clicking inside Anki. Cards can be added individually or in bulk, existing notes updated field by field or in a single bulk operation, and reviews marked with an ease rating the same way answering a card in Anki would record it. Because AnkiConnect only works locally, the server is designed to run on the same machine as the Anki desktop app.
When to use - and when NOT to
Use it to let an assistant build a deck from source material, quiz a user and record the results, bulk-edit hundreds of existing notes at once, or restructure a note type's fields and templates - all faster than doing it by hand in Anki's UI. The tool descriptions are explicit about add versus update: add_card and add_bulk only create new cards and will error on an existing one, while update_note_fields and bulk_update_notes require an existing noteId; using the wrong one for the situation is the most common mistake the tool guards against. Audio generation needs an Azure Speech API key and the path to Anki's collection.media folder configured up front - without both, add_card_with_audio and update_card_with_audio will not work. It has only been tested on Windows, so behavior on macOS or Linux, while the paths are documented, is less proven.
Capabilities
Review and lookup: get_due_cards, get_new_cards, get_deck_names, find_cards (raw Anki search syntax), update_cards (submit ease ratings after a quiz). Card creation and editing: add_card, add_bulk (bulk creation, recommended for multiple cards), update_note_fields, bulk_update_notes (bulk updates, recommended over one-by-one), create_deck. Audio: add_card_with_audio and update_card_with_audio generate Azure TTS speech from a source field into an audio field, in any of 27 supported language codes including English, Spanish, Japanese, and Mandarin. Note-type management: get_model_names, get_model_details, get_deck_model_info, create_model, add_note_type_field, remove_note_type_field, rename_note_type_field, reposition_note_type_field, update_note_type_templates, and update_note_type_styling.
How to install
Requires Node.js, npm, and the AnkiConnect plugin running in Anki.
npx -y github:nietus/anki-mcp
For Claude Desktop, the recommended path is building an .mcpb extension bundle:
npm install
npm run build
npm run pack:mcpb
then dragging the resulting dist/anki-mcp.mcpb into Claude Desktop's Settings, Extensions panel, and providing the Azure API key and Anki media directory when prompted.
Who it's for
Anki users who want an AI assistant to generate flashcards from study material, quiz them and log results, bulk-edit large decks, or add pronunciation audio to language-learning cards.
Source README
anki-mcp
MCP server for Anki. This server allows interaction with Anki through the Model Context Protocol (MCP). It enables users to manage flashcards, decks, and review processes programmatically.
Prerequisites
- Node.js and npm installed.
- AnkiConnect plugin installed and running in Anki.
- For audio features: Azure API key (set in
.envfile asAZURE_API_KEY) and Anki Media Directory (set asANKI_MEDIA_DIR).
Setup and Execution
Highly recommended to run locally, since AnkiConnect only works locally.
Was only tested on windows.
Running locally via npx
If you only wish to use the tool and not develop the tool,
you may launch an MCP STDIO server locally using npx:
npx -y github:nietus/anki-mcp
This can be used in Desktop MCP clients such as Msty Studio or others.
Running locally via source code
Alternatively, you can run locally via source code using these instructions:
Clone the repository:
git clone https://github.com/nietus/anki-mcpInstall dependencies:
npm installBuild the project
npm run buildSetup for Audio Features (If you want to use audio tools):
Create a .env file in the root directory with your Azure API key and Anki media directory:
AZURE_API_KEY=your_azure_api_key_here ANKI_MEDIA_DIR=path/to/your/anki/media/directoryFor Anki media directory, use the path to your Anki collection.media folder. This is where audio files will be stored. If you have trouble, paste it directly into the code.
- Windows example:
C:\Users\username\AppData\Roaming\Anki2\User 1\collection.media - macOS example:
/Users/username/Library/Application Support/Anki2/User 1/collection.media - Linux example:
/home/username/.local/share/Anki2/User 1/collection.media
Note: The ANKI_MEDIA_DIR is required for audio generation to work properly as Anki needs to find the audio files in its media collection.
- Windows example:
Integrate with Cursor settings (for local execution):
To run your local build of anki-mcp with Cursor, you need to tell Cursor how to start the server. Below are example configurations which you can access on cursor settings. Replace YOUR_USERNAME and adjust the path if you cloned anki-mcp to a different location than Downloads.
Windows:
"anki": { "command": "cmd", "args": [ "/c", "node", "c:/Users/YOUR_USERNAME/Downloads/anki-mcp/build/client.js" ] }Integrate with Claude Desktop using an
.mcpbbundle:The recommended way to use this server with Claude Desktop is to install it as an MCP extension bundle (
.mcpbfile).Build and package the extension:
npm install npm run build npm run pack:mcpbThis will produce a file at
dist/anki-mcp.mcpb.Install the bundle in Claude Desktop:
- Open Claude Desktop.
- Go to Settings → Extensions.
- Drag and drop the
dist/anki-mcp.mcpbfile into the Extensions panel.
Claude will handle launching the server automatically when needed.
Configure environment variables:
When prompted during installation, provide your
AZURE_API_KEYandANKI_MEDIA_DIR(the path to your Ankicollection.mediafolder). These are required for audio features and media file handling.
That’s it! No manual configuration is needed-Claude Desktop will manage the server for you once the
.mcpbbundle is installed.
macOS / Linux:
"anki": {
"command": "bash",
"args": [
"-c",
"node /Users/YOUR_USERNAME/Downloads/anki-mcp/build/client.js"
]
}
Create a Claude Desktop extension bundle (.mcpb)
If you want one-click installation inside Claude Desktop, you can package this server as an MCP bundle:
Install dependencies and build the project:
npm install npm run buildGenerate the
.mcpbbundle (requires the@anthropic-ai/mcpbCLI, which expects Node.js 18+):npm run pack:mcpb
The script stages the compiled server (build/), copies runtime dependencies, and produces dist/anki-mcp.mcpb. Drag that file into Claude Desktop's Settings → Extensions panel to install. When prompted, provide the Azure Speech API key and Anki media directory so audio tools can save files in your collection.media folder.
Available Tools
To debug the tools, use
npm run inspector
The server provides the following tools for interacting with Anki:
update_cards:- Description: After the user answers cards you've quizzed them on, use this tool to mark them answered and update their ease.
- Input: An array of answers, each with
cardId(number) andease(number, 1-4).
add_card:- Description: Create a NEW flashcard in Anki. Use ONLY for creating new cards, NOT for updating existing ones (will throw an error if the card already exists). For updating existing cards, use
update_note_fieldswith the noteId instead. Note content uses HTML.- Line breaks:
<br> - Code:
<pre style="background-color: transparent; padding: 10px; border-radius: 5px;"> - Lists:
<ol>and<li> - Bold:
<strong> - Italic:
<em>
- Line breaks:
- Input:
fields: (object) An object where keys are field names (e.g., "Hanzi", "Pinyin") and values are their HTML content.modelName: (string) The name of the Anki note type (model) to use.deckName: (optional string) The name of the deck to add the card to. Defaults to the current deck or 'Default'.tags: (optional array of strings) A list of tags to add to the note.
- Description: Create a NEW flashcard in Anki. Use ONLY for creating new cards, NOT for updating existing ones (will throw an error if the card already exists). For updating existing cards, use
add_card_with_audio:- Description: Create a NEW flashcard in Anki with automatically generated audio from Azure TTS. Use ONLY for creating new cards, NOT for updating existing ones (will throw an error if the card already exists). For updating audio on existing cards, use
update_card_with_audiowith the noteId instead. - Input:
fields,modelName,deckName,tags: Same asadd_card.sourceField: (string) Field name containing the text to generate audio from.audioField: (string) Field name where the generated audio will be stored.language: (optional string) Language code for TTS (e.g., 'en', 'es', 'fr'). Defaults to 'en'.
- Supported languages: en, es, fr, de, it, ja, ko, pt, ru, zh, ar, nl, hi, tr, pl, sv, fi, da, no, cs, hu, el, he, th, vi, id, ms, ro.
- Description: Create a NEW flashcard in Anki with automatically generated audio from Azure TTS. Use ONLY for creating new cards, NOT for updating existing ones (will throw an error if the card already exists). For updating audio on existing cards, use
update_card_with_audio:- Description: Update an EXISTING card by generating audio from a specified field and adding it to an audio field. Use ONLY for cards that already exist (you must have the noteId). For creating new cards with audio, use
add_card_with_audioinstead. - Input:
noteId: (number) The ID of the Anki note to update.sourceField: (string) Field name containing the text to generate audio from.audioField: (string) Field name where the generated audio will be stored.language: (optional string) Language code for TTS. Defaults to 'en'.
- Description: Update an EXISTING card by generating audio from a specified field and adding it to an audio field. Use ONLY for cards that already exist (you must have the noteId). For creating new cards with audio, use
get_due_cards:- Description: Returns a given number of cards due for review.
- Input:
num(number).
get_new_cards:- Description: Returns a given number of new and unseen cards.
- Input:
num(number).
get_deck_names:- Description: Get a list of all Anki deck names.
- Input: None.
find_cards:- Description: Find cards using a raw Anki search query. Returns detailed card information including fields.
- Input:
query(string, e.g.,'deck:Default -tag:test', or'"deck:My Deck" tag:important'). To filter for empty fields, use'-FieldName:_*'(e.g.,'-Hanzi:_*').
update_note_fields:- Description: Update specific fields of an EXISTING Anki note. Use ONLY when you already have the noteId of an existing card. For creating new cards, use
add_cardinstead. - Input:
noteId(number),fields(object, e.g.,{"Front": "New Q", "Back": "New A"}).
- Description: Update specific fields of an EXISTING Anki note. Use ONLY when you already have the noteId of an existing card. For creating new cards, use
create_deck:- Description: Create a new Anki deck.
- Input:
deckName(string).
bulk_update_notes:- Description: RECOMMENDED FOR MULTIPLE CARDS: Update specific fields for multiple EXISTING Anki notes in a single operation. Much more efficient than updating cards one by one. Use ONLY when you have noteIds for cards that already exist. For creating new cards in bulk, use
add_bulkinstead. Always complete all updates in a single operation whenever possible. - Input: An array of
notes, where each note hasnoteId(number) andfields(object).
- Description: RECOMMENDED FOR MULTIPLE CARDS: Update specific fields for multiple EXISTING Anki notes in a single operation. Much more efficient than updating cards one by one. Use ONLY when you have noteIds for cards that already exist. For creating new cards in bulk, use
get_model_names:- Description: Lists all available Anki note type/model names.
- Input: None.
get_model_details:- Description: Retrieves the fields, card templates, and CSS styling for a specified note type.
- Input:
modelName(string).
get_deck_model_info:- Description: Retrieves information about the note types (models) used within a specified deck. Helps determine if a single model is used, multiple, or if the deck is empty or non-existent.
- Input:
deckName(string). - Output: An object with
deckName,status(e.g., "single_model_found", "multiple_models_found", "no_notes_found", "deck_not_found"), and conditionallymodelName(string) ormodelNames(array of strings).
add_note_type_field:- Description: Adds a new field to a note type.
- Input:
modelName(string),fieldName(string).
remove_note_type_field:- Description: Removes an existing field from a note type.
- Input:
modelName(string),fieldName(string).
rename_note_type_field:- Description: Renames a field in a note type.
- Input:
modelName(string),oldFieldName(string),newFieldName(string).
reposition_note_type_field:- Description: Changes the order (index) of a field in a note type.
- Input:
modelName(string),fieldName(string),index(number).
update_note_type_templates:- Description: Updates the HTML templates (e.g., front and back) for the cards of a note type.
- Input:
modelName(string),templates(object, e.g.,{"Card 1": {"Front": "html", "Back": "html"}}).
update_note_type_styling:- Description: Updates the CSS styling for a note type.
- Input:
modelName(string),css(string).
create_model:- Description: Creates a new Anki note type (model).
- Input:
modelName(string),fieldNames(array of strings),cardTemplates(array of objects, each withName,Front,BackHTML strings),css(optional string),isCloze(optional boolean, defaults to false),modelType(optional string, defaults to 'Standard').
add_bulk:- Description: RECOMMENDED FOR MULTIPLE CARDS: Adds multiple NEW flashcards to Anki in a single operation. Much more efficient than adding cards one by one. Use ONLY for creating new cards, NOT for updating existing ones (will throw errors for any cards that already exist). For updating existing cards, use
bulk_update_noteswith noteIds instead. Always complete all additions in a single operation whenever possible. Must use HTML formatting for card content. - Input: An array of
notes, where each note object has:fields: (object) An object where keys are field names and values are their HTML content.modelName: (string) The name of the Anki note type (model) to use for this note.deckName: (optional string) The name of the deck for this note. Defaults to 'Default'.tags: (optional array of strings) A list of tags for this note.
- Description: RECOMMENDED FOR MULTIPLE CARDS: Adds multiple NEW flashcards to Anki in a single operation. Much more efficient than adding cards one by one. Use ONLY for creating new cards, NOT for updating existing ones (will throw errors for any cards that already exist). For updating existing cards, use
More information can be found here Anki Integration | Smithery
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.