Anki MCP

by ankimcp

Not rated
GitHub

About

A MCP server that enables AI assistants to interact with Anki, the spaced repetition flashcard application.

Details

Author
ankimcp
Categories
Productivity, Other, AI

Setup

Install Anki MCP in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/ankimcp/anki-mcp-server

Follow the installation instructions in the repository README, then restart your MCP client.

-

Review due cards— Ask your assistant to sync with AnkiWeb (sync), fetch due cards (get_due_cards), present each card (present_card), and record your rating (rate_card).

Create and batch-add notes— Have the assistant list note types (modelNames), create custom models with RTL styling (createModel+updateModelStyling), then batch-create up to 100 notes (addNotes).

Search and update notes— Use Anki query syntax (findNotes) to locate notes, inspect their fields and tags (notesInfo), and update content with HTML support (updateNoteFields).

Manage media files— Upload images or audio from a file path, URL, or base64 (storeMediaFile), retrieve media as base64 (retrieveMediaFile), or list and delete files incollection.media.

Drive the Anki GUI— Open the Card Browser (guiBrowse), select cards (guiSelectCard), get selected note IDs (guiSelectedNotes), and edit notes via the desktop interface (guiEditNote).

Analyze study statistics— Get collection-wide card-state counts (collection_stats) and review history with retention metrics and streaks (review_stats).

Seamlessly integrateAnkiwith AI assistants through theModel Context Protocol

Beta- This project is in active development. APIs and features may change.

A Model Context Protocol (MCP) server that enables AI assistants to interact with Anki, the spaced repetition flashcard application.

Transform your Anki experience with natural language interaction - like having a private tutor. The AI assistant doesn't just present questions and answers; it can explain concepts, make the learning process more engaging and human-like, provide context, and adapt to your learning style. It can create and edit notes on the fly, turning your study sessions into dynamic conversations. More features coming soon!

For comprehensive guides, real-world examples, and step-by-step tutorials on using this MCP server with Claude Desktop, visit:

ankimcp.ai- Complete documentation with practical examples and use cases

Seedocs/for supplementary documentation, including thereviewer setup guideand the sample Anki deck.

Three representative prompts showing the tool flows this server enables:
-

"Help me review my Spanish deck."— The assistant syncs with AnkiWeb (sync), fetches due cards (get_due_cardswith deck filter), presents each card (present_card), and records your rating (rate_card). Natural study conversation with explanations tailored to you.

"Create 10 Arabic vocab cards with RTL styling."— The assistant lists note types (modelNames), creates a custom RTL model if needed (createModel+updateModelStylingfor right-to-left CSS), then batch-creates the cards (addNotes).

"Import this image from my Downloads folder into the front of the selected note."— The assistant uploads the local file (storeMediaFilewith a file path), reads the currently-selected note from the browser (guiSelectedNotes+notesInfo), and updates the front field with an`tag (updateNoteFields).

The server exposes42 MCP tools— 31 essential tools for everyday Anki operations and 11 GUI tools that drive the Anki desktop interface for note editing/creation workflows.

- sync- Sync with AnkiWeb to pull latest data and push changes
-
get_due_cards- Get cards that are due for review, optionally filtered by deck
-
get_cards- Get cards with flexible filtering by state (due, new, learning, suspended, buried) and deck
-
present_card- Show a card for review with its question/front side
-
rate_card- Rate card performance (Again, Hard, Good, Easy) and schedule the next review

Note:Cardfront/backcontent is rendered per card from its own template (as Anki shows it), so reversed and cloze cards display the correct direction. Static text added by your card templates appears in the output as well.

- listDecks- List all decks, optionally with per-deck study-queue statistics
-
deckStats- Get comprehensive statistics for a single deck (study queue, true card-state counts, ease/interval distributions)
-
createDeck- Create a new empty deck (supportsParent::Child, max 2 levels)
-
changeDeck- Move cards to a different deck (created if it doesn't exist)

Note:Deck statistics come in two flavours. Thecountsblock (and everythinglistDecksreports) mirrors Anki's deck browser: cardsdue today, capped by each deck'sdaily new/review limits, with suspended and buried cards excluded — soreviewis not "mature cards" and theotherbucket is just the arithmetic remainder (mostly review cards not due today plus new cards over the daily limit). For true per-state totals use thestatesblock ondeckStats/collection_stats, which countsnew,learning,review,suspendedandburiedvia Anki searches, ignoring due dates and daily limits.

- addNote- Create a single note with specified fields and tags
-
addNotes- Batch-create up to 100 notes sharing a deck and model (partial success supported)
-
findNotes- Search for notes using Anki query syntax (deck:,tag:,is:due, etc.)
-
notesInfo- Get detailed information about notes (fields, tags, CSS styling)
-
updateNoteFields- Update existing note fields (CSS-aware, supports HTML content)
-
deleteNotes- Delete notes and all associated cards (destructive, requires confirmation)

- getTags- Get all tags in the collection (use first to avoid duplication)
-
addTags- Add space-separated tags to specified notes
-
removeTags- Remove space-separated tags from specified notes
-
replaceTags- Rename a tag across specified notes
-
clearUnusedTags- Remove orphaned tags not used by any notes (destructive)

- getMediaFilesNames- List media files incollection.media, optionally filtered by pattern
-
retrieveMediaFile- Download a media file as base64 content
-
storeMediaFile- Upload media from base64 data, an absolute file path, or a URL
-
deleteMediaFile- Remove a media file fromcollection.media(destructive)

- ✅Use file paths(e.g.,/Users/you/image.png) - Fast and efficient
- ✅Use URLs(e.g.,
https://example.com/image.jpg) - Direct download
- ❌Avoid base64- Extremely slow and token-inefficient

Just tell Claude where the image is, and it will handle the upload automatically using the most efficient method.

- modelNames- List all available note types/models
-
modelFieldNames- Get field names for a specific note type
-
modelStyling- Get CSS styling information for a note type
-
modelTemplates- Get the card templates (Front and Back HTML) for a note type
-
createModel- Create a new note type with custom fields, card templates, and CSS (e.g., RTL models)
-
updateModelStyling- Update the CSS styling for an existing note type (applies to all its cards)
-
updateModelTemplates- Update the card templates (Front and Back HTML) for an existing note type (applies to all its cards)
-
addModelField- Add a new field to an existing note type (appended at the end or inserted at a specific position)
-
removeModelField- Remove a field from an existing note type (deletes its content from all notes; requires explicit confirmation)
-
renameModelField- Rename a field in an existing note type (card templates referencing the old name must be updated separately)
-
repositionModelField- Change the position of a field within an existing note type

- collection_stats- Aggregated statistics across all decks with per-deck breakdown and collection-wide card-state counts
-
review_stats- Review history analysis (temporal patterns, retention metrics, study streaks)

Tools that drive the Anki desktop interface. Intended for note editing/creation and deck-management workflows,notfor review sessions.

- guiBrowse- Open the Card Browser and search for cards
-
guiSelectCard- Select a specific card in the Card Browser
-
guiSelectedNotes- Get IDs of notes currently selected in the Card Browser
-
guiAddCards- Open the Add Cards dialog with preset note details
-
guiEditNote- Open the note editor for a specific note
-
guiDeckOverview- Open the Deck Overview dialog for a specific deck
-
guiDeckBrowser- Open the Deck Browser dialog
-
guiCurrentCard- Get info about the current card in review mode
-
guiShowQuestion- Show the question side of the current card
-
guiShowAnswer- Show the answer side of the current card
-
guiUndo- Undo the last action in Anki

- AnkiwithAnkiConnectplugin installed
- Node.js 22.12.0+

There are a few ways to get the server onto your machine. Once it's installed, head toConnecting an AI Clientto wire it up to your AI assistant — locally or remotely.

The general-purpose way to install the server, suitable for any MCP client that launches it directly.

Install it globally for clients that run theankimcpcommand:

Or run it on demand with no install required:

MCPB Bundle (Recommended for Claude Desktop)

The easiest way to install this MCP server for Claude Desktop:
- Download the latest
.mcpbbundle from the
Releasespage
- In Claude Desktop, install the extension:

- Method 1: Go to Settings → Extensions, then drag and drop the.mcpbfile
- Method 2: Go to Settings → Developer → Extensions → Install Extension, then select the
.mcpbfile

That's it! The bundle includes everything needed to run the server locally.

For Anthropic MCP Directory reviewers:a zero-to-integration walkthrough with a pre-populated sample deck lives indocs/reviewer-setup.md.

There are two ways an AI assistant can reach this server, depending on where the assistant runs:

- Local— the server runs on the same machine as the AI client (Claude Desktop, Cursor, Cline, Zed, or a local browser session). UseSTDIOfor desktop MCP clients,HTTPfor local web-based tools.
-
Remote— a hosted/remote AI (e.g. ChatGPT or Claude.ai in the cloud) needs to reach the Anki running on your local machine. Use the managedTunnel(✅ recommended — authenticated) or, as a lighter-weight unauthenticated alternative,ngrok.

The server runs on the same computer as your AI client and talks to AnkiConnect onlocalhost.

STDIO is the standard transport for local desktop MCP clients —Claude Desktop,Cursor IDE,Cline,Zed Editor, and others. The client launches the server as a subprocess and communicates over standard input/output.

- Claude Desktop
-
Cursor IDE- AI-powered code editor
-
Cline- VS Code extension for AI assistance
-
Zed Editor- Fast, modern code editor
- Other MCP clients that support STDIO transport

For Claude Desktop, theMCPB bundleis the easiest path. For other clients, configure the npm package with the--stdioflag.

Method 1: Using npx (recommended - no installation needed)

{ "mcpServers": { "anki-mcp": { "command": "npx", "args": ["-y", "@ankimcp/anki-mcp-server", "--stdio"], "env": { "ANKI_CONNECT_URL": "http://localhost:8765" } } } }
{ "mcpServers": { "anki-mcp": { "command": "ankimcp", "args": ["--stdio"], "env": { "ANKI_CONNECT_URL": "http://localhost:8765" } } } }

- Cursor IDE:~/.cursor/mcp.json(macOS/Linux) or%USERPROFILE%\.cursor\mcp.json(Windows)
- Cline: Accessible via settings UI in VS Code
- Zed Editor: Install as MCP extension through extension marketplace

For client-specific features and troubleshooting, consult your MCP client's documentation. See alsoConnect to Claude Desktopfor a config that points directly at a builtdist/main-stdio.js.

HTTP mode runs the server as a local web server speaking the MCP Streamable HTTP protocol. It's the transport a web-based AI tool talks to when pointed at your machine, and it's also what theRemoteoptions expose to the outside world. On its own, HTTP mode binds tolocalhostonly.

Binding beyond localhost?If you pass--host 0.0.0.0(or run behind a reverse proxy/public domain), the server only accepts loopbackHostheaders by default for DNS-rebinding protection — setALLOWED_HOSTSto the hostname(s) clients use. SeeHTTP Mode Configuration.

Method 1: Using npx (recommended - no installation needed)

# Quick start npx @ankimcp/anki-mcp-server # With custom options npx @ankimcp/anki-mcp-server --port 8080 --host 0.0.0.0 npx @ankimcp/anki-mcp-server --anki-connect http://localhost:8765
# Install once npm install -g @ankimcp/anki-mcp-server # Run the server ankimcp # With custom options ankimcp --port 8080 --host 0.0.0.0 ankimcp --anki-connect http://localhost:8765

Method 3: Install from source (for development)

npm install npm run build npm run start:prod:http

To make a local HTTP server reachable by a cloud-hosted AI, use one of theRemoteoptions below.

A hosted/remote AI (such as ChatGPT or Claude.ai running in the cloud) can't reachlocalhostdirectly. These options expose yourlocalAnki to the internet so a remote assistant can talk to it.

Recommended remote path — authenticated & secure.Unlike a raw public port, tunnel mode requires you to log in (OAuth 2.0 device flow), so the endpoint isn't open to anyone who guesses the URL.

Tunnel mode lets web-based AI assistants reach yourlocalAnki without running your own tunnel. The server connects out to the managed AnkiMCP tunnel service (wss://tunnel.ankimcp.ai) over a WebSocket and is assigned a public URL. Authentication is built in — no ngrok account or separate tunnel process required, and you log in once.

Tunnel mode uses the OAuth 2.0 Device Authorization Grant. Logging in opens your browser automatically to an approval page with the code already embedded in the URL — nothing to type, just approve. (If the browser can't open, the terminal prints a verification URL and code to enter manually as a fallback.) On success, credentials are saved to~/.ankimcp/credentials.json(file permissions0600).

# Pre-authenticate (optional — --tunnel will trigger this automatically if needed) ankimcp --login npx @ankimcp/anki-mcp-server --login # Clear saved credentials ankimcp --logout
# Connect to the managed tunnel service (wss://tunnel.ankimcp.ai) ankimcp --tunnel npx @ankimcp/anki-mcp-server --tunnel # Override the tunnel server URL (must be ws:// or wss://) — e.g. for self-hosting ankimcp --tunnel wss://my-tunnel.example.com

If no credentials exist,--tunnelautomatically starts the login flow first, then continues to the tunnel. This auto-login requires an interactive terminal — when stdout is not a TTY (systemd, headless Docker, CI), the server fast-fails and asks you to runankimcp --loginfirst. Once connected, the public tunnel URL is printed; press Ctrl+C to disconnect. Share that URL with your AI assistant.

The device-flow auth endpoints (/auth/device,/auth/token) are derived fromTUNNEL_SERVER_URL, so pointing--tunnel(orTUNNEL_SERVER_URL) at a different host also moves authentication to that host.

How it works:Tunnel mode runs the MCP server in-process behind an in-memory transport (TunnelTransport). That transport owns the MCP server and turns each relayed request body into a response, andTunnelClientbridges it to the remote tunnel service over a WebSocket — relaying MCP requests in and responses out. AnkiConnect is still only ever reached on your local machine.

Protocol revisions:Because the tunnel connects the MCP server in-process, tunnel mode serves the 2025 revision of the MCP protocol only, while STDIO and HTTP modes serve both 2025 and the newer 2026-07-28 revision. Every tool behaves the same either way — but a client that speaks only 2026-07-28 is turned away over the tunnel with a protocol-version error; runSTDIOorHTTPmode for that client.

If you'd rather exposelocal HTTP modepublicly without an account on the managed tunnel, the built-in--ngrokflag launches anngroksubprocess (src/services/ngrok.service.ts) and prints the public URL in the startup banner:

# One-time ngrok setup, then: ankimcp --ngrok

This route isunauthenticated— anyone with the URL can reach your Anki, so it's less secure thanTunnel. Prefer Tunnel unless you have a specific reason to manage your own ngrok endpoint. (Requires a global ngrok install and authtoken.)

The--ngrokflag launches ngrok with--host-header=rewrite, so ngrok rewrites the upstreamHosttolocalhostbefore forwarding. That keeps requests within the loopback Host allowlist (seeDNS-rebinding protection) without you having to add the public*.ngrokdomain toALLOWED_HOSTS. If you instead run ngrok manually, use the same flag —ngrok http --host-header=rewrite 3000— otherwise ngrok forwards the public ngrok hostname asHostand the server rejects it with403.

ankimcp [options] Options: --stdio Run in STDIO mode (for MCP clients) --tunnel [url] Connect via the managed tunnel (authenticated) --login Authenticate for tunnel mode (OAuth device flow) --logout Clear saved tunnel credentials -p, --port <port> Port to listen on (HTTP mode, default: 3000) -h, --host <host> Host to bind to (HTTP mode, default: 127.0.0.1) -a, --anki-connect <url> AnkiConnect URL (default: http://localhost:8765) --ngrok Start ngrok tunnel (requires global ngrok installation) --read-only Run in read-only mode (blocks all write operations) --help Show help message Usage with npx (no installation needed): npx @ankimcp/anki-mcp-server # HTTP mode npx @ankimcp/anki-mcp-server --port 8080 # Custom port npx @ankimcp/anki-mcp-server --stdio # STDIO mode npx @ankimcp/anki-mcp-server --tunnel # Managed tunnel mode npx @ankimcp/anki-mcp-server --ngrok # HTTP mode with ngrok tunnel npx @ankimcp/anki-mcp-server --read-only # Read-only mode Usage with global installation: npm install -g @ankimcp/anki-mcp-server # Install once ankimcp # HTTP mode ankimcp --port 8080 # Custom port ankimcp --stdio # STDIO mode ankimcp --tunnel # Managed tunnel mode ankimcp --ngrok # HTTP mode with ngrok tunnel ankimcp --read-only # Read-only mode

The--read-onlyflag prevents any modifications to your Anki collection. When enabled:

- All read operations work normally (browsing decks, viewing cards, searching notes)
- Review operations are allowed (sync, answerCards, suspend/unsuspend)
- Content modifications are blocked (addNote, deleteNotes, createDeck, updateNoteFields, etc.)
- Useful for safely exploring Anki data without risk of accidental changes

# HTTP mode with read-only ankimcp --read-only # STDIO mode with read-only ankimcp --stdio --read-only # Can combine with other flags ankimcp --ngrok --read-only`

You can also enable read-only mode via environment variable:

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.