Skip to main content
Glama

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)

Related MCP server: Anki MCP Server

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

Available Tools

40 tools
card_areSuspendedA

Returns an array indicating whether each given card is suspended. Each item is boolean or null if the card doesn't exist.

Inputs: cards (required).

card_cardsInfoC

Returns a list of objects containing information for each card ID provided.

Inputs: cards (required).

card_cardsModTimeB

Returns modification time for each card ID provided. Result is a list of objects with 'cardId' and 'modTime' (timestamp).

Inputs: cards (required).

card_cardsToNotesC

Returns an unordered array of note IDs for the given card IDs.

Inputs: cards (required).

card_findCardsB

Returns an array of card IDs for a given Anki search query.

Inputs: query (required).

card_setSpecificValueOfCardB

Sets specific values of a single card. Use with caution. Returns list of booleans indicating success for each key.

Inputs: card (required), keys (required), newValues (required), warning_check.

card_suspendC

Suspends the specified cards. Returns true on success.

Inputs: cards (required).

card_suspendedA

Checks if a single card is suspended by its ID. Returns true if suspended, false otherwise.

Inputs: card (required).

card_unsuspendB

Unsuspends the specified cards. Returns true on success.

Inputs: cards (required).

deck_changeDeckA

Moves cards with the given IDs to a different deck, creating the deck if it doesn't exist yet.

Inputs: cards (required), deck (required).

deck_createDeckA

Creates a new empty deck. Will not overwrite an existing deck with the same name. Returns the ID of the created deck.

Inputs: deck (required).

deck_deckNamesB

Gets the complete list of deck names for the current user. Returns a list of deck names.

Inputs: no named parameters.

deck_deckNamesAndIdsA

Gets the complete list of deck names and their respective IDs. Returns a dictionary mapping deck names to their IDs.

Inputs: no named parameters.

deck_deleteDecksC

Deletes decks with the given names. The 'cardsToo' argument must be specified and set to true.

Inputs: decks (required), cardsToo (required).

deck_getDeckConfigC

Gets the configuration group object for the given deck name. Returns the deck configuration object.

Inputs: deck (required).

deck_saveDeckConfigC

Saves the given configuration group. Returns true on success, false otherwise.

Inputs: config (required).

media_deleteMediaFileC

Deletes the specified file from Anki's media folder.

Inputs: filename (required).

media_getMediaFilesNamesB

Gets the names of media files matching the glob pattern. Returns a list of filenames.

Inputs: pattern (required).

media_retrieveMediaFileA

Retrieves the base64-encoded contents of the specified media file. Returns the base64 string or false if not found.

Inputs: filename (required).

media_storeMediaFileA

Stores a media file in Anki's media folder. Provide one of 'data' (base64), 'path', or 'url'. Returns the stored filename or false on error.

Inputs: filename (required), data, path, url, +1 more.

model_createModelB

Creates a new model (note type). Returns the created model object.

Inputs: modelName (required), inOrderFields (required), cardTemplates (required), css, +2 more.

model_findModelsByNameC

Gets a list of model definitions for the provided model names.

Inputs: modelNames (required).

model_modelFieldAddC

Adds a new field to an existing model.

Inputs: modelName (required), fieldName (required), index.

model_modelFieldNamesC

Gets the list of field names for the provided model name.

Inputs: modelName (required).

model_modelFieldRemoveC

Removes a field from an existing model.

Inputs: modelName (required), fieldName (required).

model_modelNamesAndIdsA

Gets the complete list of model (note type) names and their IDs. Returns a dictionary mapping model names to IDs.

Inputs: no named parameters.

model_modelStylingB

Gets the CSS styling for the provided model name. Returns an object containing the 'css' field.

Inputs: modelName (required).

model_modelTemplatesB

Returns an object indicating the template content for each card of the specified model.

Inputs: modelName (required).

model_updateModelStylingC

Modifies the CSS styling of an existing model by name.

Inputs: model (required).

model_updateModelTemplatesC

Modifies the templates of an existing model by name.

Inputs: model (required).

note_addNoteA

Creates a new note using the given deck, model, fields, and tags. Returns the ID of the created note or null if the note could not be created.

Inputs: note (required).

note_addNotesA

Creates multiple notes. See 'addNote' for the structure of each note object in the list. Returns a list of new note IDs, or null for notes that couldn't be created.

Inputs: notes (required).

note_addTagsC

Adds tags to the specified notes.

Inputs: notes (required), tags (required).

note_deleteNotesC

Deletes notes with the given IDs.

Inputs: notes (required).

note_findNotesB

Returns an array of note IDs for a given Anki search query.

Inputs: query (required).

note_getNoteTagsB

Gets the tags for a specific note ID. Returns a list of tags.

Inputs: note (required).

note_notesInfoC

Returns a list of objects containing information for each note ID provided.

Inputs: notes (required).

note_removeTagsC

Removes tags from the specified notes.

Inputs: notes (required), tags (required).

note_updateNoteC

Modifies the fields and/or tags of an existing note.

Inputs: note (required).

note_updateNoteFieldsC

Modifies the fields of an existing note.

Inputs: note (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 40 tools

    Disambiguation5/5

    Every tool has a clearly distinct purpose with no ambiguity, as they are organized by resource type (card, deck, media, model, note) and specific actions, making it easy for an agent to differentiate between them. For example, card_suspend and card_unsuspend are clearly opposites, and note_addNote and note_addNotes handle single vs. multiple notes without overlap.

    Naming Consistency5/5

    Tool names follow a highly consistent verb_noun pattern with a resource prefix (e.g., card_findCards, deck_createDeck, note_updateNote), all using snake_case throughout. This predictable structure makes the tool set easy to navigate and understand at a glance.

    Tool Count2/5

    With 40 tools, the count is excessive for the Anki domain, likely overwhelming for agents and indicating over-fragmentation of operations. A more streamlined set of 10-20 tools could cover the same functionality without sacrificing completeness, making this borderline heavy and inefficient.

    Completeness5/5

    The tool set provides comprehensive CRUD and lifecycle coverage for all key Anki resources (cards, decks, media, models, notes), with no obvious gaps. It includes creation, retrieval, updating, deletion, and specialized actions like suspension and tagging, ensuring agents can handle full workflows without dead ends.

    Related MCP Connectors

    Related MCP Servers

    Appeared in Searches