Skip to main content

Add your description here

Project description

anki-mcp

A Model Context Protocol (MCP) server for interacting with Anki flashcards via the AnkiConnect add-on. This server exposes AnkiConnect actions as MCP tools, organized into logical services.

Prerequisites

  • Anki desktop application
  • AnkiConnect add-on installed and configured in Anki
  • Python 3.8+
  • uv (for running and installing dependencies, optional but recommended)

Installation

# Clone the repository
git clone https://github.com/ujisati/anki-mcp.git
cd anki-mcp

# Install dependencies (using uv)
uv pip install -e .

Usage

To run the MCP server:

uv run anki-mcp

The server will start and listen for MCP requests, typically interfacing with AnkiConnect at http://127.0.0.1:8765.

Inspecting the Server

You can use the MCP Inspector to view the available tools:

npx @modelcontextprotocol/inspector uv run anki-mcp

Configuration for MCP Clients

If you're integrating this with an MCP client (like an AI assistant framework), you'll need to configure it to find this server. Here's an example configuration snippet:

{
    "mcpServers": {
        "anki": {
            "command": "uv",
            "args": [
                "run", // uv will find anki-mcp if run from project root
                "anki-mcp"
            ],
            // If running from outside the project directory, specify the path:
            // "args": [
            //     "--directory",
            //     "/ABSOLUTE/PATH/TO/anki-mcp", // Replace with actual path
            //     "run",
            //     "anki-mcp"
            // ]
        }
    }
}

Available MCP Tools

This MCP server provides access to Anki functionality through tools grouped by services. The tool names correspond directly to AnkiConnect actions.

Deck Service (deck.*)

  • deck.deckNamesAndIds: Gets the complete list of deck names and their respective IDs.
  • deck.getDeckConfig: Gets the configuration group object for a given deck name.
  • deck.deckNames: Gets the complete list of deck names for the current user.
  • deck.createDeck: Creates a new empty deck.
  • deck.deleteDecks: Deletes specified decks.
  • deck.changeDeck: Moves cards to a different deck.
  • deck.saveDeckConfig: Saves a deck configuration group.

Note Service (note.*)

  • note.findNotes: Returns note IDs for a given Anki search query.
  • note.notesInfo: Returns information for specified note IDs.
  • note.getNoteTags: Gets the tags for a specific note ID.
  • note.addNote: Creates a new note.
  • note.updateNoteFields: Modifies the fields of an existing note.
  • note.deleteNotes: Deletes specified notes.
  • note.addNotes: Creates multiple notes.
  • note.addTags: Adds tags to specified notes.
  • note.removeTags: Removes tags from specified notes.
  • note.updateNote: Modifies the fields and/or tags of an existing note.

Card Service (card.*)

  • card.findCards: Returns card IDs for a given Anki search query.
  • card.cardsInfo: Returns information for specified card IDs.
  • card.cardsToNotes: Returns note IDs for given card IDs.
  • card.areSuspended: Checks if specified cards are suspended.
  • card.cardsModTime: Returns modification time for specified card IDs.
  • card.suspended: Checks if a single card is suspended.
  • card.suspend: Suspends specified cards.
  • card.unsuspend: Unsuspends specified cards.
  • card.setSpecificValueOfCard: Sets specific values of a single card (use with caution).

Model Service (model.*) (Note Types)

  • model.modelNamesAndIds: Gets the complete list of model (note type) names and their IDs.
  • model.findModelsByName: Gets model definitions for provided model names.
  • model.modelFieldNames: Gets field names for a given model name.
  • model.modelTemplates: Gets template content for each card of a specified model.
  • model.modelStyling: Gets CSS styling for a given model name.
  • model.createModel: Creates a new model (note type).
  • model.updateModelTemplates: Modifies templates of an existing model.
  • model.updateModelStyling: Modifies CSS styling of an existing model.
  • model.modelFieldAdd: Adds a new field to an existing model.
  • model.modelFieldRemove: Removes a field from an existing model.

Media Service (media.*)

  • media.retrieveMediaFile: Retrieves the base64-encoded contents of a media file.
  • media.getMediaFilesNames: Gets names of media files matching a glob pattern.
  • media.storeMediaFile: Stores a media file (from base64, path, or URL).
  • media.deleteMediaFile: Deletes a specified media file.

Development

To set up for development:

uv sync
source .venv/bin/activate

uv pip install -e .

Running Tests

pytest

Todo

  • Finish adding all AnkiConnect tools

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iflow_mcp_ujisati_anki_mcp-0.1.0.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iflow_mcp_ujisati_anki_mcp-0.1.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file iflow_mcp_ujisati_anki_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: iflow_mcp_ujisati_anki_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_ujisati_anki_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8cfb40ff4cdc880f844d55631e631a6413ac25c9721b4e0f49a5d7428f7ca8e2
MD5 47bbab2eba36bb7cc8ecf05a9d883c13
BLAKE2b-256 9aff7a3d54b0e20febf3cf65172ed0770e2dd85801438490c7f2ea52d74ab78f

See more details on using hashes here.

File details

Details for the file iflow_mcp_ujisati_anki_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_ujisati_anki_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_ujisati_anki_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86f76b887a667c8fb41faa5239964b7456f998ba156bea24526703ceac385005
MD5 6e4251c638c35e8bfcac70c57490ffa9
BLAKE2b-256 baffd59356e86d60db863785edff18c997622bd18fe9edf234dc6f9bac94b9d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page