
An MCP server for connecting LLMs with Anki Flashcards.
An MCP server for connecting LLMs with Anki Flashcards.
·
An MCP server that enables AI assistants like Claude to interact with Anki flashcard decks through the Model Context Protocol (MCP).
git clone https://github.com/yourusername/clanki.git
cd clankinpm installnpm run buildMake sure Anki is running and the AnkiConnect plugin is installed and enabled.
Note the absolute path to build/index.js in 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.js will 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.
Edit claude_desktop_config.json:
| Platform | Location |
|---|---|
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
| Linux | ~/.config/Claude/claude_desktop_config.json |
{
"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 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 |
|---|---|
--scope local | You, in this project only. The default. |
--scope user | You, in every project on this machine. |
--scope project | Written to .mcp.json in the repo root, for committing so teammates get it too. |
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 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 listClanki needs no configuration in a normal setup. Every variable below is optional.
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.
| Variable | Default |
|---|---|
CLANKI_ANKI_CONNECT_URL | http://127.0.0.1:8765 |
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.
Creates a new Anki deck
name: Name for the new deckCreates a new note in a specified deck. Supports HTML formatting and media attachments.
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 backCreates a new cloze note in a specified deck. Supports HTML formatting and media attachments.
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 fieldCreates 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.
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.
Creates many cloze notes in one request. Same trade-offs as
create-cards-bulk; use create-cloze-card when you need media.
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.
Updates an existing note
noteId: ID of the note to updatefront: (Optional) New front side contentback: (Optional) New back side contenttags: (Optional) New tags for the noteUpdates an existing cloze note
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 noteSearches 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.
query: Anki search query, e.g. deck:Spanish, tag:vocab,
deck:Spanish tag:verbsPermanently 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.
noteIds: IDs of the notes to delete, at most 50 per callconfirm: Must be trueBesides the tools above, decks are exposed as a readable resource.
<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.
"Create a flashcard in my Spanish deck with 'Hola' on the front and 'Hello' on the back"
"Create a flashcard about the Eiffel Tower with an image from https://example.com/eiffel.jpg on the front"
"Create a pronunciation card with audio from https://example.com/pronunciation.mp3"
"Create a card with images on both sides and audio on the back for studying animals"
"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.
To modify or extend the server:
src/index.tsnpm run buildnpx @modelcontextprotocol/inspector node build/index.jsThis project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
Pick your client and paste the snippet. Each one is the same server, written the way that client expects it.
claude mcp add clanki -- node /absolute/path/to/clanki/build/index.js{
"mcpServers": {
"clanki": {
"args": [
"/absolute/path/to/clanki/build/index.js"
],
"command": "node"
}
}
}code --add-mcp '{"name":"clanki","args":["/absolute/path/to/clanki/build/index.js"],"command":"node"}'[mcp_servers.clanki]
command = "node"
args = ["/absolute/path/to/clanki/build/index.js"]Runs locally on your device. Your client starts the server itself, so nothing has to be hosted.
Paste this prompt into your agent. It reads this page and does the setup for you.
Read https://aiagentslisting.com/mcp/clanki-claudes-anki-integration to learn what the "Clanki - Claude's Anki Integration" MCP server does and how to install it. Add it to my coding agent's MCP configuration as documented on that page, then confirm the server connects and list the tools it exposes.Agents can also browse this directory over MCP at https://aiagentslisting.com/api/mcp
claude mcp add clanki -- node /absolute/path/to/clanki/build/index.js
claude mcp add clanki --env CLANKI_BASIC_NOTE_TYPE=Einfach -- node /path/to/clanki/build/index.jsThis server runs locally, so we can't read its tool list over the web yet.
We could not run this server: it ships no npx package for our sandbox and no public endpoint. The four checks that need a live server are left out, and the grade tops out at B until one exists.
Maintain this server? Claiming proves you own the listing and earns the last 4 points.
Claim this listingPaste this line near the top of your repository's README. The badge always renders the current score.
[](https://aiagentslisting.com/mcp/clanki-claudes-anki-integration)Nothing comparable is listed yet.
No tagged releases on record.
Connect to the AI Agents Listing MCP server at https://aiagentslisting.com/api/mcp using the HTTP transport and complete the sign-in when it asks. Then call the submit_review tool for the listing "clanki-claudes-anki-integration" with a rating from 1 to 5 and a short note on what worked and what did not.No reviews yet
Be the first to share your experience with this tool.
One email a week. New agents, MCP servers and skills, and what is actually getting traction.