Clanki
Clanki is an MCP server that lets AI assistants manage Anki flashcards through AnkiConnect.
Create decks, including nested decks via
::in the nameCreate basic flashcards with HTML-formatted front/back, tags, and embedded images/audio from URLs
Create cloze cards with
{{c1::text}}deletions, extra back content, tags, and mediaBulk-create many basic or cloze notes in one request, with automatic duplicate and cloze-syntax handling
Update existing notes and cloze cards (content and tags)
Search notes using Anki's query syntax and get IDs, note types, tags, and excerpts
Permanently delete notes by explicit ID, with a required confirmation flag
Read an entire deck's notes through the
anki://deck/<name>resource
Enables interaction with Anki flashcard decks through AnkiConnect, allowing creation and management of decks, creation of basic and cloze deletion cards, updating existing cards, adding tags, and viewing deck contents.
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., "@Clanki create a flashcard in my Spanish deck with 'hola' on the front and 'hello' on the back"
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.
Clanki - Claude's Anki Integration
An MCP server that enables AI assistants like Claude to interact with Anki flashcard decks through the Model Context Protocol (MCP).
Features
Create and manage Anki decks
Create basic notes with front/back content
Create cloze notes
Create many notes at once in a single request
Attach images and audio from URLs - automatically downloaded and embedded
HTML formatting support in note fields
Update existing notes and cloze deletions
Add and manage tags
Search for notes with Anki's query syntax
Delete notes permanently
View deck contents and note information
Full integration with AnkiConnect
Related MCP server: Anki MCP Server
Prerequisites
Anki installed and running
AnkiConnect plugin installed in Anki
Node.js 16 or higher
Installation
Clone this repository:
git clone https://github.com/yourusername/clanki.git
cd clankiInstall dependencies:
npm installBuild the project:
npm run buildSetup
Make sure Anki is running and the AnkiConnect plugin is installed and enabled.
Note the absolute path to
build/index.jsin your clanki checkout. Every client below needs it, and none of them accept a relative path — they do not run from your project directory, so./build/index.jswill not resolve.# from the clanki directory node -e "console.log(require('path').resolve('build/index.js'))"On Windows this prints backslashes. They are fine as-is for the two CLI commands below, but must be doubled or swapped for forward slashes if you paste the path into a JSON config — see the Claude Desktop note.
Register the server with your client, using one of the sections below.
Verify the server can reach Anki. With Anki running:
curl -X POST http://127.0.0.1:8765 -d "{\"action\":\"version\",\"version\":6}"A working setup replies {"result": 6, "error": null}. If it does not, see
docs/troubleshooting.md — connection failures are by
far the most common problem, and AnkiConnect's default configuration needs no
changes.
Claude Desktop
Edit claude_desktop_config.json:
Platform | Location |
macOS |
|
Windows |
|
Linux |
|
{
"mcpServers": {
"clanki": {
"command": "node",
"args": ["/absolute/path/to/clanki/build/index.js"]
}
}
}Replace /absolute/path/to/clanki with the actual path to your clanki
installation. On Windows, write the path with either forward slashes or escaped
backslashes (C:\\Users\\you\\clanki\\build\\index.js) — a single backslash is
an escape character in JSON and will not parse.
Restart Claude Desktop afterwards; it reads the config only at startup.
Claude Code
claude mcp add clanki -- node /absolute/path/to/clanki/build/index.jsThe -- is required. It marks the end of claude mcp add's own options, so
everything after it is treated as the command to launch. Without it the
arguments are parsed as options to claude mcp add itself and you get a broken
entry rather than an error.
By default this registers the server for you in the current project only
(--scope local). Two other scopes are available:
Scope | What it does |
| You, in this project only. The default. |
| You, in every project on this machine. |
| Written to |
Check it worked:
claude mcp listclanki should be listed as connected. If it is listed as failed to connect,
claude mcp get clanki shows the error.
You can also write .mcp.json by hand instead, using the same shape as the
Claude Desktop config above. Claude Code reads it at session start, so restart
the session after editing it.
Codex
codex mcp add clanki -- node /absolute/path/to/clanki/build/index.jsAs with Claude Code, the -- separates Codex's own options from the command
that launches the server, and is required.
This writes to ~/.codex/config.toml. Codex uses TOML rather than JSON, so if
you prefer to edit the file directly the entry looks like this:
[mcp_servers.clanki]
command = "node"
args = ["/absolute/path/to/clanki/build/index.js"]Note that the TOML table is mcp_servers with an underscore, not mcpServers
as in the JSON configs above.
List the configured servers with:
codex mcp listConfiguration
Clanki needs no configuration in a normal setup. Every variable below is optional.
Using Anki in a language other than English
Clanki works with translated collections (e.g. German Einfach instead of
Basic) with no setup. If your collection has several look-alike note types,
you name the one to use with the CLANKI_BASIC_NOTE_TYPE,
CLANKI_CLOZE_NOTE_TYPE, CLANKI_BASIC_FIELDS and CLANKI_CLOZE_FIELDS
variables — see docs/non-english-anki.md.
Connecting to AnkiConnect elsewhere
Variable | Default |
|
|
Set this only if you changed AnkiConnect's port or reach Anki on another machine.
Where the variables go depends on your client.
In the JSON configs (Claude Desktop, and .mcp.json for Claude Code), they go
in an env block alongside command and args:
{
"mcpServers": {
"clanki": {
"command": "node",
"args": ["/path/to/clanki/build/index.js"],
"env": {
"CLANKI_BASIC_NOTE_TYPE": "Einfach"
}
}
}
}In ~/.codex/config.toml, they go in an env sub-table under the server:
[mcp_servers.clanki]
command = "node"
args = ["/path/to/clanki/build/index.js"]
[mcp_servers.clanki.env]
CLANKI_BASIC_NOTE_TYPE = "Einfach"Both CLIs can set them when you register the server, with --env repeated once
per variable:
claude mcp add clanki --env CLANKI_BASIC_NOTE_TYPE=Einfach -- node /path/to/clanki/build/index.jscodex mcp add clanki --env CLANKI_BASIC_NOTE_TYPE=Einfach -- node /path/to/clanki/build/index.jsRestart the server after changing them.
Available Tools
create-deck
Creates a new Anki deck
Parameters:
name: Name for the new deck
create-card
Creates a new note in a specified deck. Supports HTML formatting and media attachments.
Parameters:
deckName: Name of the deck to add the note tofront: Front side content of the note (supports HTML)back: Back side content of the note (supports HTML)tags: (Optional) Array of tags for the notefrontImages: (Optional) Array of image URLs for the frontbackImages: (Optional) Array of image URLs for the backfrontAudio: (Optional) Array of audio URLs for the frontbackAudio: (Optional) Array of audio URLs for the back
create-cloze-card
Creates a new cloze note in a specified deck. Supports HTML formatting and media attachments.
Parameters:
deckName: Name of the deck to add the note totext: Text containing cloze deletions using {{c1::text}} syntax (supports HTML)backExtra: (Optional) Extra information to show on the back of the card (supports HTML)tags: (Optional) Array of tags for the notetextImages: (Optional) Array of image URLs for the text fieldbackImages: (Optional) Array of image URLs for the back extra fieldtextAudio: (Optional) Array of audio URLs for the text fieldbackAudio: (Optional) Array of audio URLs for the back extra field
create-cards-bulk
Creates many basic notes in one request. Prefer this over repeated create-card
calls for a batch: it sends a single request to Anki regardless of size. Does
not support media — use create-card for notes that need images or audio.
Parameters:
deckName: Name of the deck to add the notes tocards: Array of{ front, back, tags? }objects (at least one)
Anki's addNotes is all-or-nothing — a single duplicate would otherwise fail
the whole batch — so the tool asks which notes are addable first and sends only
those. The response reports how many were added, and the input position and
Anki's own reason for each note skipped, so you can correct and resend just
those.
create-cloze-cards-bulk
Creates many cloze notes in one request. Same trade-offs as
create-cards-bulk; use create-cloze-card when you need media.
Parameters:
deckName: Name of the deck to add the notes tocards: Array of{ text, backExtra?, tags? }objects (at least one)
Cloze syntax is validated for the whole batch before anything is sent, so a malformed entry fails the call rather than leaving a partial batch in the deck.
update-card
Updates an existing note
Parameters:
noteId: ID of the note to updatefront: (Optional) New front side contentback: (Optional) New back side contenttags: (Optional) New tags for the note
update-cloze-card
Updates an existing cloze note
Parameters:
noteId: ID of the note to updatetext: (Optional) New text with cloze deletionsbackExtra: (Optional) New extra information for the backtags: (Optional) New tags for the note
find-cards
Searches for notes with Anki's query syntax and returns their note IDs, note
type, tags, and a short excerpt of each field. Use it to obtain the noteId
that update-card, update-cloze-card and delete-card need.
Field content is truncated and the number of results is capped, so narrow the query if the note you want is not listed — the reply always reports how many notes matched in total.
Parameters:
query: Anki search query, e.g.deck:Spanish,tag:vocab,deck:Spanish tag:verbs
delete-card
Permanently deletes notes. This cannot be undone — there is no trash to recover them from, and every card generated from a deleted note goes with it.
Note IDs must be listed explicitly; there is no delete-by-query. Use
find-cards first to obtain them and to check you have the right notes. The
reply reports which IDs were actually deleted and which did not exist, because
Anki reports success either way.
Parameters:
noteIds: IDs of the notes to delete, at most 50 per callconfirm: Must betrue
Resources
Besides the tools above, decks are exposed as a readable resource.
anki://deck/<name>
Reads one deck and returns every note in it — note ID, front, back and tags.
Unlike find-cards, the content is returned in full rather than truncated.
Usage Examples
Basic card with text only
"Create a flashcard in my Spanish deck with 'Hola' on the front and 'Hello' on the back"
Card with images
"Create a flashcard about the Eiffel Tower with an image from https://example.com/eiffel.jpg on the front"
Card with audio
"Create a pronunciation card with audio from https://example.com/pronunciation.mp3"
Card with multiple media
"Create a card with images on both sides and audio on the back for studying animals"
Cloze card with media
"Create a cloze card: 'The capital of {{c1::France}} is {{c2::Paris}}' with an image of the Eiffel Tower"
Note: Media files are automatically downloaded from URLs and embedded into the cards. Ensure URLs are accessible and point to valid media files. A URL that cannot be used is reported back in the tool's response; the note is still created without that attachment.
Media placement: Attachments are appended to the end of the field they belong to, after any text. You cannot position an image inline with HTML, because the filename is generated at upload time and is not known in advance. HTML formatting and media attachments therefore do not compose: use HTML to format your text, and the media parameters to attach files after it.
Development
To modify or extend the server:
Make changes to
src/index.tsRebuild with
npm run buildDebug with
npx @modelcontextprotocol/inspector node build/index.js
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgments
Built with the Model Context Protocol SDK
Integrates with Anki via AnkiConnect
Available Tools
9 toolscreate-cardB
Create a new note in a specified deck. Supports HTML formatting in text fields. You can attach multiple images and audio files from URLs - they will be automatically downloaded and embedded in the note.
Inputs: back (required), front (required), deckName (required), tags, +4 more.
create-cards-bulkA
Create multiple basic notes in a single call. Use this instead of calling create-card repeatedly — it sends one request to Anki regardless of how many notes are in the batch. Does not support images or audio: use create-card for notes that need media.
Inputs: cards (required), deckName (required).
create-cloze-cardB
Create a new cloze note in a specified deck. Use {{c1::text}} syntax for cloze deletions (e.g., {{c1::Paris}} is the capital of France). Supports HTML formatting and can attach multiple images and audio files from URLs - they will be automatically downloaded and embedded.
Inputs: text (required), deckName (required), tags, backAudio, +4 more.
create-cloze-cards-bulkA
Create multiple cloze notes in a single call. Use this instead of calling create-cloze-card repeatedly — it sends one request to Anki regardless of how many notes are in the batch. Does not support images or audio: use create-cloze-card for notes that need media.
Inputs: cards (required), deckName (required).
create-deckA
Create a new Anki deck
Inputs: name (required).
delete-cardA
PERMANENTLY deletes notes. This cannot be undone and there is no trash to recover them from — the notes and every card generated from them are gone. Only delete notes the user has asked you to delete. Use find-cards first to obtain the note IDs and to confirm you have the right notes; there is no delete-by-query, and IDs must be listed explicitly. Deleting one cloze note removes every card generated from it.
Inputs: confirm (required), noteIds (required).
find-cardsA
Search for notes using Anki's search syntax and return their note IDs, note type, tags, and a short excerpt of each field. Use this to get the noteId needed by update-card, update-cloze-card or delete-card. Field content is truncated and the number of results is capped, so narrow the query if the note you want is not listed. Examples: 'deck:Spanish', 'tag:vocab', 'front:hello', 'deck:Spanish tag:verbs'.
Inputs: query (required).
update-cardC
Update an existing note
Inputs: noteId (required), back, tags, front.
update-cloze-cardC
Update an existing cloze note
Inputs: noteId (required), tags, text, backExtra.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Each tool targets a distinct action and note type: deck creation, card creation/update for basic and cloze types, bulk variants, search, and deletion. The bulk tools are explicitly separated from single-card tools, and find-cards is clearly the retrieval path. No two tools appear to do the same thing.
All tool names follow a consistent hyphenated lowercase verb-noun pattern: create-deck, create-card, update-card, create-cloze-card, update-cloze-card, create-cards-bulk, create-cloze-cards-bulk, find-cards, delete-card. The pattern is uniform and predictable.
With 9 tools, the server is well-scoped for Anki card management. It covers core lifecycle operations (create, update, find, delete) with separate handling for basic vs. cloze notes and bulk operations, without excessive redundancy.
The card lifecycle is well covered: create (single/bulk, basic/cloze), update, find, delete. Deck management is limited to creation only, with no update or delete deck tools, but this is a minor gap since decks are simple containers and find-cards can search by deck name.
Maintenance
Related MCP Connectors
Cloud-hosted MCP server for durable AI memory
MCP server for AI dialogue using various LLM models via AceDataCloud
Driflyte MCP server which lets AI assistants query topic-specific knowledge from web and GitHub.
An MCP server that integrates with Discord to provide AI-powered features.
Related MCP Servers
- AlicenseAqualityCmaintenanceAn MCP server that integrates Claude with Anki flashcards, allowing users to review due cards and create new flashcards directly through conversation.1422 PyPI13MIT
- AlicenseNot gradedqualityAmaintenanceAn MCP server that enables AI assistants to interact with the Anki flashcard application for studying, deck management, and note creation. It supports natural language interaction for reviewing cards, searching content, and managing media files across local and remote environments.1,222 npm570MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables AI assistants to seamlessly manage Anki flashcards, decks, and templates through the AnkiConnect API. It supports intelligent querying, batch note creation, and detailed study progress analysis using natural language.4MIT
- FlicenseAqualityDmaintenanceAn MCP server that enables Claude Code to create, manage, and search Anki flashcards directly from the terminal. It supports batch card creation, deck statistics retrieval, and synchronization with AnkiWeb for cross-platform review.8-