anki-connect-mcp
Exposes every method of the Anki-Connect API v1 (95 methods) as individual MCP tools, enabling management of Anki flashcard collections: creating and modifying decks, notes, cards, models and media, querying and searching the collection, plus long-running operations such as collection sync and package import/export (with polling of operation handles until completion).
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., "@anki-connect-mcpCreate a deck called Japanese and add a note with the word こんにちは"
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.
PyAnkiConnectMCP
MCP Server for anki connect
The anki-connect-mcp package is an MCP server for the
Anki-Connect API v1
(JSON-RPC 2.0, POST http://127.0.0.1:8765/api/v1).
Each of the 95 API methods is exposed as a separate MCP tool: decks.create → decks_create,
advanced.cards.update → advanced_cards_update, and so on. Tool input schemas are generated
from the official machine-readable contract api-v1.schema.json (bundled with the package), so
parameters, required fields and constraints match the documentation exactly.
Requirements
Python 3.11+
Anki 26.08+ with the Anki-Connect add-on (a version providing API v1) installed and enabled
Related MCP server: Anki MCP Server
Installation
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -e .Connecting a client
The server speaks MCP over stdio. The examples below use /path/to/PyAnkiConnectMCP for the
directory you cloned the repository into. The executable is
.venv/bin/anki-connect-mcp on Linux/macOS and .venv\Scripts\anki-connect-mcp.exe on Windows;
python -m anki_connect_mcp from the virtual environment works as well.
Claude Code
claude mcp add anki -- /path/to/PyAnkiConnectMCP/.venv/bin/anki-connect-mcpClaude Desktop and other clients
Add the server to mcpServers in the client config:
{
"mcpServers": {
"anki": {
"command": "/path/to/PyAnkiConnectMCP/.venv/bin/anki-connect-mcp",
"env": { "ANKICONNECT_API_KEY": "" }
}
}
}LangGraph
LangChain agents are LangGraph graphs, and LangChain loads MCP tools through langchain.mcp
(langchain[mcp]>=1.4.0). Install it in your agent's environment:
pip install "langchain[mcp]" "langchain[anthropic]"Then connect the server and hand its tools to an agent:
import asyncio
from langchain.agents import create_agent
from langchain.mcp import MCPAdapter
CONFIG = {
"mcpServers": {
"anki": {
"command": "/path/to/PyAnkiConnectMCP/.venv/bin/anki-connect-mcp",
# Any CLI flag from the Configuration table can be passed here.
"args": ["--include", "decks.*,notes.*,cards.*"],
},
}
}
async def main():
async with MCPAdapter(CONFIG) as adapter:
tools = await adapter.list_tools()
agent = create_agent("claude-sonnet-5-5", tools)
result = await agent.ainvoke(
{"messages": [{"role": "user", "content": "Create a deck called Vocabulary."}]}
)
print(result["messages"][-1].content)
asyncio.run(main())Notes:
With a single server the tool names are unchanged (
decks_create); when the config lists several servers, LangChain prefixes them with the config key (anki_decks_create).langchain.mcpis in beta and emits aLangChainBetaWarningon import.The server process lives as long as the
async withblock; run the agent inside it.Pass the API key with
"args": ["--api-key", "..."]if Anki-Connect requires one.create_agentreturns a compiled LangGraph graph, so the agent can also be used as a node in your ownStateGraph.On LangChain versions before 1.4.0, use
MultiServerMCPClientfrom thelangchain-mcp-adapterspackage with{"anki": {"command": ..., "args": [...], "transport": "stdio"}}andawait client.get_tools()instead.
Configuration
Environment variable | Flag | Default | Purpose |
|
|
| API v1 endpoint |
|
| — |
|
|
|
| HTTP timeout per request, seconds |
|
| off | Expose only read methods (plus |
|
| all | Comma-separated method patterns, e.g. |
|
| — | Hide methods, e.g. |
| — |
| Log level (logs go to stderr) |
If your client struggles with a large number of tools, narrow the set with --include.
How it works
Errors. JSON-RPC errors are returned as a tool result with
isError: trueand the fieldscode,type(notFound,validationFailed,staleSession, …),messageanddata. HTTP rejections (401/403/405/413) and an unreachable Anki are also turned into clear errors.Long-running operations. Methods with
Completion: operation(collection.sync,packages.import,browser.open,api.execute, …) return a handle. The server pollsoperations.getitself and returns the final result. These tools accept two extra arguments that are not sent to Anki:waitForCompletion(defaulttrue) —falsereturns the handle immediately;timeoutSeconds(default300) — when it expires, the pending operation record is returned; the work in Anki is not cancelled.
Annotations.
readOnlyHintis set for methods witheffect: read, anddestructiveHintfor methods that delete or overwrite data. Clients use these hints to ask for confirmation.Write requests are never retried automatically (the documentation states explicitly that a request ID is not an idempotency key).
Updating the schema
When a new API version is released, replace src/anki_connect_mcp/api-v1.schema.json with
api-v1.schema.json from the Anki-Connect repository — new methods will appear automatically.
Tests
.\.venv\Scripts\python.exe -m pip install -e ".[test]"
.\.venv\Scripts\python.exe -m pytestThis server cannot be deployed
Maintenance
Related MCP Connectors
Read, write, and conversationally review open-source flashcards through split read/write MCP tools.
Your org's AI agents, tasks, runs, search, and brain files as MCP tools and resources.
Read-only search of 2,189 AI agent tools (MCP servers, x402 APIs) with daily automated trust scores.
Read and edit GA4, Search Console and Google Tag Manager from any MCP client. 29 tools.
Related MCP Servers
- FlicenseNot gradedqualityAmaintenanceExposes Anki flashcard collections to AI assistants via MCP, enabling AI-powered study sessions, card creation, deck management, and review workflows. Supports comprehensive collection operations including search, media management, and note type customization.94-
- FlicenseNot gradedqualityDmaintenanceProvides programmatic access to Anki flashcard operations through the AnkiConnect API, allowing users to list and create decks and cards. It enables seamless management of flashcards directly from MCP-compatible clients like Claude Desktop.-
- AlicenseNot gradedqualityCmaintenanceExposes Anki as a set of tools for LLM clients, enabling note creation, search, review, and deck management via AnkiConnect.17 npmMIT
- AlicenseBqualityCmaintenanceEnables AI assistants to manage Anki flashcards, decks, note types, tags, and media via AnkiConnect. Supports operations like adding, editing, finding, and syncing cards through a local MCP server.100MIT