This MCP (Model Context Protocol) server for Claude Desktop connects to Anki via AnkiConnect and retrieves leech-tagged cards. It helps you analyze problematic cards and improve your study strategy by providing comprehensive card data to Claude AI.
Clone the repository:
git clone https://github.com/yourusername/anki-mcp-server.git
cd anki-mcp-server
Install dependencies:
npm install
Build the project:
npm run build
Copy the example environment file to create your own configuration:
cp .env.example .env
Edit the .env
file with your preferred settings:
Environment Variable | Description | Default Value |
---|---|---|
ANKI_CONNECT_URL |
The URL of the Anki Connect API | http://localhost:8765 |
ANKI_CONNECT_VERSION |
The version of the Anki Connect API to use | 6 |
ANKI_MOCK_MODE |
Enable mock mode for testing (true/false) | false |
If connecting via localhost
doesn't work, use your computer's local IP address:
ifconfig
or ipconfig getifaddr en0
ipconfig
ip addr show
or hostname -I
Look for IPv4 addresses like 192.168.x.x
or 10.x.x.x
and update your .env
file:
ANKI_CONNECT_URL=http://YOUR_LOCAL_IP:8765
npm start
Open Claude Desktop
Edit the configuration file located at:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
Add this configuration to the mcpServers
section:
{
"mcpServers": {
"anki": {
"command": "node",
"args": ["path/to/anki-mcp-server/dist/index.js"]
}
}
}
Replace "path/to/anki-mcp-server"
with the actual path to your installation.
Once configured, you can ask Claude to analyze your Anki leech cards:
Could you analyze my Anki leech cards and suggest ways to improve my study?
Retrieves cards tagged as leeches from Anki.
Parameters:
detailed
(optional, boolean, default: true): Whether to return comprehensive card data or just IDscount
(optional, number): Number of random cards to return (defaults to all cards)Adds a date-stamped "reviewed" tag to specified cards.
Parameters:
card_ids
(required, array of numbers): Array of card IDs to tag as reviewedcustom_tag_prefix
(optional, string, default: "見直し"): Custom prefix for the tagThe tag format will be 見直し::YYYYMMDD
(or your custom prefix).
For testing without affecting Anki data:
ANKI_MOCK_MODE=true
in your .env
filenpm run start:test
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "anki" '{"command":"node","args":["path/to/anki-mcp-server/dist/index.js"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"anki": {
"command": "node",
"args": [
"path/to/anki-mcp-server/dist/index.js"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"anki": {
"command": "node",
"args": [
"path/to/anki-mcp-server/dist/index.js"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect