Anki MCP server

Integrates with Anki flashcard decks via AnkiConnect to enable automated creation, retrieval, and management of study materials.
Back to servers
Setup instructions
Provider
Camden Clark
Release date
Dec 02, 2024
Language
TypeScript
Stats
60 stars

This MCP server integrates with Anki through the AnkiConnect plugin, allowing you to manage Anki decks and notes programmatically. The server provides access to Anki resources and tools that let you create and manage flashcards from external applications.

Installation Requirements

Before using the MCP server, ensure you have:

  1. Anki installed
  2. AnkiConnect plugin installed in Anki
  3. Node.js installed on your system

Setting Up the Server

First, clone or download the repository, then install the necessary dependencies:

npm install

Build the server by running:

npm run build

Configuration

To use the server with Claude Desktop, you need to add the server configuration to Claude's config file:

On MacOS:

Edit the file at ~/Library/Application Support/Claude/claude_desktop_config.json

On Windows:

Edit the file at %APPDATA%/Claude/claude_desktop_config.json

Add the following configuration (adjust the path to match your installation):

{
  "mcpServers": {
    "anki-mcp": {
      "command": "node",
      "args": ["path/to/anki-mcp-server/build/index.js"]
    }
  }
}

Available Features

Resource Access

The server provides access to Anki resources through URI patterns:

  • Decks: anki://decks/{id} - Access specific Anki decks
  • Note Models: anki://models/{id} - Access specific note models

Tools and Functions

The server provides several tools for interacting with Anki:

Listing Resources

  • listDecks - Retrieves names of all available Anki decks
  • listModels - Retrieves names of all available note models

Getting Model Details

  • getModel - Retrieves detailed information about a specific note model

Creating Notes

  • addNote - Creates a single note with specified parameters:

    • Deck name
    • Model name
    • Fields content
    • Tags (optional)
  • addNotes - Creates multiple notes in bulk

Using the Debugging Tools

If you need to debug the server, you can use the MCP Inspector tool:

npm run inspector

This will provide a URL to access debugging tools in your browser, which helps monitor the communication between the MCP client and server.

Example Usage

To create a new flashcard in Anki:

  1. Ensure Anki is running with AnkiConnect installed
  2. Use the addNote tool with the necessary parameters:
    • The deck where the card should be added
    • The note model to use
    • Content for each field required by the note model
    • Any tags you want to apply

The server will communicate with Anki via AnkiConnect to create the note in your specified deck.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "anki-mcp" '{"command":"node","args":["path/to/anki-mcp-server/build/index.js"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

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.

Adding an MCP server to Cursor globally

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-mcp": {
            "command": "node",
            "args": [
                "path/to/anki-mcp-server/build/index.js"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "anki-mcp": {
            "command": "node",
            "args": [
                "path/to/anki-mcp-server/build/index.js"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later