AnkiMCP Server
Enables AI assistants to interact with Anki flashcard collections, providing tools for deck and note management, card reviews, note type configuration, media file handling, and GUI operations within the Anki application.
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., "@AnkiMCP Servershow me cards due for review today"
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.
AnkiMCP Server (Addon)
An Anki addon that exposes your collection to AI assistants via the Model Context Protocol (MCP).
What is this?
AnkiMCP Server runs a local MCP server inside Anki, allowing AI assistants like Claude to interact with your flashcard collection. This enables AI-powered study sessions, card creation, and collection management.
Part of the ankimcp.ai project.
Related MCP server: Anki MCP Server
Note on First Run
On first run, this addon downloads pydantic_core (~2MB) from PyPI. This is required because pydantic_core contains platform-specific binaries (Windows/macOS/Linux) that cannot be bundled in a single addon file.
Features
Local HTTP server - Runs on
http://127.0.0.1:3141/by defaultRemote tunnel - Access your collection from anywhere via a public HTTPS URL
MCP protocol - Compatible with any MCP client (Claude Desktop, etc.)
Auto-start - HTTP server starts automatically when Anki opens
Tunnel-friendly - Works with Cloudflare Tunnel, ngrok, or the built-in tunnel
Toolbar indicator - A
● AnkiMCPitem in the top toolbar shows tunnel connection state at a glance (opt out viashow_toolbar_indicator)Cross-platform - Works on macOS, Windows, and Linux (x64 and ARM)
Installation
From AnkiWeb (recommended)
Open Anki and go to Tools → Add-ons → Get Add-ons...
Enter code:
124672614Restart Anki
From GitHub Releases
Download
anki_mcp_server.ankiaddonfrom ReleasesDouble-click to install, or use Tools → Add-ons → Install from file...
Restart Anki
NixOS
With flakes (recommended)
Add the flake input and use the pre-built package:
# flake.nix
{
inputs.anki-mcp.url = "github:ankimcp/anki-mcp-server-addon";
outputs = { nixpkgs, anki-mcp, ... }: {
# Option A: Standalone — Anki with the addon pre-installed
environment.systemPackages = [
anki-mcp.packages.${system}.default
];
# Option B: Composable with other addons via overlay
nixpkgs.overlays = [ anki-mcp.overlays.default ];
environment.systemPackages = [
(pkgs.anki.withAddons [ pkgs.ankiAddons.anki-mcp-server ])
];
};
}Without flakes
# configuration.nix
{ pkgs, ... }:
let
python3 = pkgs.python3;
ankiMcpPythonDeps = python3.withPackages (ps: with ps; [
mcp pydantic pydantic-settings starlette uvicorn anyio httpx websockets
]);
anki-mcp-server = pkgs.anki-utils.buildAnkiAddon (finalAttrs: {
pname = "anki-mcp-server";
version = "0.20.0";
src = pkgs.fetchFromGitHub {
owner = "ankimcp";
repo = "anki-mcp-server-addon";
rev = "v${finalAttrs.version}";
hash = ""; # nix will tell you the correct hash on first build
};
sourceRoot = "${finalAttrs.src.name}/anki_mcp_server";
});
ankiWithMcp = pkgs.anki.withAddons [ anki-mcp-server ];
ankiWrapped = pkgs.symlinkJoin {
name = "anki-with-mcp";
paths = [ ankiWithMcp ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/anki \
--prefix PYTHONPATH ':' "${ankiMcpPythonDeps}/${python3.sitePackages}"
'';
};
in
{
environment.systemPackages = [ ankiWrapped ];
}Usage
The server starts automatically when you open Anki. Check status via Tools → AnkiMCP Server Settings...
Connect with Claude Desktop
Requires Node.js installed. Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"anki": {
"command": "npx",
"args": ["mcp-remote", "http://127.0.0.1:3141"]
}
}
}Note: Claude Desktop doesn't natively support HTTP servers in its JSON config —
mcp-remotebridges the connection via stdio.
Connect with Claude Code
claude mcp add anki --transport http http://127.0.0.1:3141/Tunnel (Remote Access)
The built-in tunnel gives your Anki collection a public HTTPS URL, so AI assistants can reach it from anywhere — no port forwarding or reverse proxy needed. The collection is relayed through a WebSocket tunnel server (wss://tunnel.ankimcp.ai by default). Requires an ankimcp.ai account to log in.
How to connect:
Open Tools -> AnkiMCP Server Settings...
Click Connect Tunnel
If not logged in, a login dialog appears — it shows a one-time code; click Open Browser and enter that code at the verification URL (OAuth 2.0 device flow)
Once connected, a public tunnel URL is displayed (e.g.,
https://tunnel.ankimcp.ai/e3439277-9d1e-47a1-b961-d193a4590da0)Use this URL in your AI client instead of
http://127.0.0.1:3141
Using with Claude Desktop:
Replace the localhost URL with your tunnel URL in the Claude Desktop config:
{
"mcpServers": {
"anki": {
"command": "npx",
"args": ["mcp-remote", "https://tunnel.ankimcp.ai/<your-tunnel-id>"]
}
}
}Using with Claude Code:
claude mcp add anki --transport http https://tunnel.ankimcp.ai/<your-tunnel-id>Disconnect vs. Logout:
Disconnect closes the tunnel connection. Credentials stay on disk — next Connect reconnects without re-login.
Logout deletes credentials. Next Connect triggers the login dialog again.
Tunnel config fields (for advanced users / self-hosters):
tunnel_server_url— WebSocket URL of the tunnel relay server (default:wss://tunnel.ankimcp.ai)tunnel_client_id— OAuth client identifier (default:ankimcp-cli)
Credentials are stored in the addon's own user_files/credentials.json (preserved across addon updates). They are not shared with the AnkiMCP CLI — the CLI keeps its own credentials under ~/.ankimcp/, so you log in to the addon and the CLI independently. The on-disk format is identical between the two.
Configuration
Edit via Anki's Tools → Add-ons → AnkiMCP Server → Config:
{
"http_enabled": true,
"http_port": 3141,
"http_host": "127.0.0.1",
"http_path": "",
"cors_origins": [],
"cors_expose_headers": ["mcp-protocol-version"],
"disabled_tools": [],
"enabled_destructive_tools": [],
"max_notes_per_batch": 100,
"tunnel_server_url": "wss://tunnel.ankimcp.ai",
"tunnel_client_id": "ankimcp-cli",
"media_import_dir": "",
"media_allowed_types": [],
"media_allowed_hosts": [],
"show_toolbar_indicator": true
}HTTP Server Toggle
The http_enabled setting controls whether the local HTTP server runs. When set to false, the HTTP server won't start — only the tunnel transport is available. Default is true.
{
"http_enabled": false
}This is useful if you only use the tunnel and don't want a local HTTP server listening.
Toolbar Status Indicator
A persistent ● AnkiMCP item in Anki's top toolbar shows tunnel connection state (grey = off, amber = connecting, green = connected); clicking it opens the settings dialog. It's shown by default. Set show_toolbar_indicator to false to hide it (takes effect after an Anki restart).
{
"show_toolbar_indicator": false
}Disabling Tools
Hide specific tools or actions from AI clients to reduce token usage:
{
"disabled_tools": [
"sync",
"card_management:bury",
"card_management:unbury"
]
}"tool_name"— disables the entire tool"tool_name:action"— disables a specific action within a multi-action tool
Disabled tools are removed from the MCP schema entirely — AI clients never see them. Typos in tool/action names will produce console warnings.
Destructive Tools (Opt-In)
Tools or actions classified as destructive (high-risk operations) are hidden from AI clients by default. To expose them, add them to the enabled_destructive_tools allow-list:
{
"enabled_destructive_tools": [
"some_destructive_tool",
"some_tool:destructive_action"
]
}"tool_name"— opts in an entire destructive tool"tool_name:action"— opts in a destructive action within a multi-action tool (a whole-tool entry does not implicitly opt in its destructive actions)disabled_toolsstill applies on top — an opted-in tool can still be disabledEntries that don't match anything, or match a non-destructive tool/action, produce console warnings
This is server-side enforcement: until opted in, destructive tools are absent from the MCP schema, so even a misbehaving client cannot call them. No currently shipped tool is destructive — this mechanism exists for future high-risk tools (e.g., deck deletion).
Custom Path
Set http_path to serve the MCP endpoint under a custom path. Useful when exposing Anki via a tunnel (Cloudflare, ngrok) to avoid a fully open endpoint:
{
"http_path": "my-secret-path"
}The server will be accessible at http://localhost:3141/my-secret-path/ instead of the root. Leave empty for default behavior.
CORS Configuration
To allow browser-based MCP clients (like web-hosted MCP Inspector), add allowed origins:
{
"cors_origins": ["https://inspector.example.com", "http://localhost:5173"]
}Use ["*"] to allow all origins (not recommended for production).
The cors_expose_headers setting controls which response headers browsers can read. The default (mcp-protocol-version) lets browser-based MCP clients negotiate the protocol version. Since v0.16.0 the server runs in stateless mode, so mcp-session-id is no longer emitted and no longer needs to be exposed.
Media Security
Thanks to Hideaki Takahashi (Columbia University) for responsibly disclosing the media path traversal vulnerability.
The store_media_file tool validates all inputs to prevent path traversal and SSRF attacks:
File paths are restricted to media files only (images, audio, video) via MIME type checking
URLs must use
http://orhttps://and cannot target private/internal networksFilenames are sanitized to remove path traversal sequences
Optional hardening via config:
{
"media_import_dir": "/Users/me/anki-media",
"media_allowed_types": ["application/pdf"],
"media_allowed_hosts": ["192.168.1.50", "my-nas.local"]
}media_import_dir— restrict file path imports to this directory tree (empty = no restriction)media_allowed_types— allow additional MIME types beyond image/audio/videomedia_allowed_hosts— allow specific hosts to bypass private network blocking
Available Tools
Essential Tools
Tool | Description |
| Synchronize collection with AnkiWeb |
| List all decks in the collection |
| Create a new deck |
| Search for notes using Anki's search syntax |
| Get detailed information about notes |
| Add a new note to a deck |
| Batch-add up to |
| Manage cards with 9 actions: |
| Manage tags with 5 actions: |
| Filtered deck lifecycle: |
| Update fields of existing notes |
| Batch-update fields of multiple notes in one atomic undo step (single backend call). Validates every entry first; supports partial success up to |
| Delete notes from the collection |
| Get next due card for review (supports |
| Get card content for review |
| Rate a card after review (Again/Hard/Good/Easy) |
| List available note types |
| Get field names and descriptions for a note type |
| Get CSS styling for a note type |
| Update CSS styling for a note type |
| Read the Front/Back HTML templates for each card type in a note type |
| Update Front/Back template HTML. Rejects unrecognized keys (case-sensitive) and unknown template names up front, applying all edits atomically — a failed call leaves the model unchanged |
| Create a new note type |
| Store a media file (image/audio) via base64, file path, or URL. File paths are validated against a media-type allowlist; URLs are checked for SSRF |
| List media files matching a pattern |
| Move a media file to Anki's trash (recoverable via Check Media) |
FSRS Tools
Tool | Description |
| Get FSRS scheduler parameters for deck presets |
| Update FSRS parameters (weights, desired retention, max interval) |
| Get FSRS memory state (stability, difficulty, retrievability) for cards |
| Run FSRS parameter optimization using Anki's built-in optimizer |
GUI Tools
These tools interact with Anki's user interface:
Tool | Description |
| Open the card browser with a search query |
| Open the Add Cards dialog |
| Open the note editor for a specific note |
| Get info about the currently displayed card |
| Show the question side of current card |
| Show the answer side of current card |
| Select a specific card in the reviewer |
| Navigate to deck browser |
| Undo the last operation |
Resources
Resource | URI | Description |
|
| Anki version, profile, and scheduler info |
|
| Anki search query syntax reference |
|
| Data model documentation (entities, fields, relationships) |
|
| Today's study statistics |
|
| 30-day review forecast |
|
| Overall collection statistics |
|
| FSRS configuration summary and parameters |
Prompts
Prompt | Description |
| Guided review session workflow (interactive, quick, or voice mode) |
Requirements
Anki 25.07 or later (ships Python 3.13)
Anki 25.02 and earlier ship Python 3.9, which is not supported — the MCP SDK requires Python 3.10+ (#8)
Architecture
The addon runs an MCP server in a background thread with two independent transports: local HTTP (FastMCP + uvicorn) and remote tunnel (WebSocket relay with in-memory transport). Both share the same FastMCP server instance. All Anki operations are bridged to the main Qt thread via a queue system, following the same proven pattern as AnkiConnect.
For details, see Anki Add-on Development Documentation.
Development
Running E2E Tests
E2E tests run against a real Anki instance in Docker using headless-anki.
# Install test dependencies
python -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txt
# Build the addon
./package.sh
# Start Anki container
cd .docker && docker compose up -d && cd ..
# Run tests (waits for server automatically)
pytest tests/e2e/ -v
# Stop container
cd .docker && docker compose downOr use the Makefile shortcuts:
make e2e # Build, start container, run tests, stop
make e2e-up # Just start container
make e2e-test # Just run tests
make e2e-down # Just stop containerCI
E2E tests run automatically on push to any branch and on PRs to main. See .github/workflows/e2e.yml.
License
AGPL-3.0-or-later
Links
ankimcp.ai - Project homepage
MCP Protocol - Model Context Protocol specification
Anki Add-on Docs - Official Anki addon development documentation
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ankimcp/anki-mcp-server-addon'
If you have feedback or need assistance with the MCP directory API, please join our Discord server