anki-mcp
A Model Context Protocol server that enables interaction with Anki flashcards through AnkiConnect, providing organized tools for managing decks, notes, cards, models, and media files.
Tools
deck_deleteDecks
Deletes decks with the given names. The 'cardsToo' argument must be specified and set to true.
deck_changeDeck
Moves cards with the given IDs to a different deck, creating the deck if it doesn't exist yet.
deck_saveDeckConfig
Saves the given configuration group. Returns true on success, false otherwise.
note_updateNote
Modifies the fields and/or tags of an existing note.
card_suspend
Suspends the specified cards. Returns true on success.
model_modelFieldAdd
Adds a new field to an existing model.
media_retrieveMediaFile
Retrieves the base64-encoded contents of the specified media file. Returns the base64 string or false if not found.
media_getMediaFilesNames
Gets the names of media files matching the glob pattern. Returns a list of filenames.
deck_createDeck
Creates a new empty deck. Will not overwrite an existing deck with the same name. Returns the ID of the created deck.
deck_deckNamesAndIds
Gets the complete list of deck names and their respective IDs. Returns a dictionary mapping deck names to their IDs.
deck_getDeckConfig
Gets the configuration group object for the given deck name. Returns the deck configuration object.
deck_deckNames
Gets the complete list of deck names for the current user. Returns a list of deck names.
note_findNotes
Returns an array of note IDs for a given Anki search query.
note_notesInfo
Returns a list of objects containing information for each note ID provided.
note_getNoteTags
Gets the tags for a specific note ID. Returns a list of tags.
note_addNote
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.
note_updateNoteFields
Modifies the fields of an existing note.
media_storeMediaFile
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.
note_deleteNotes
Deletes notes with the given IDs.
note_addNotes
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.
note_addTags
Adds tags to the specified notes.
note_removeTags
Removes tags from the specified notes.
card_findCards
Returns an array of card IDs for a given Anki search query.
card_cardsInfo
Returns a list of objects containing information for each card ID provided.
card_cardsToNotes
Returns an unordered array of note IDs for the given card IDs.
card_areSuspended
Returns an array indicating whether each given card is suspended. Each item is boolean or null if the card doesn't exist.
card_cardsModTime
Returns modification time for each card ID provided. Result is a list of objects with 'cardId' and 'modTime' (timestamp).
card_suspended
Checks if a single card is suspended by its ID. Returns true if suspended, false otherwise.
card_unsuspend
Unsuspends the specified cards. Returns true on success.
card_setSpecificValueOfCard
Sets specific values of a single card. Use with caution. Returns list of booleans indicating success for each key.
model_modelNamesAndIds
Gets the complete list of model (note type) names and their IDs. Returns a dictionary mapping model names to IDs.
model_findModelsByName
Gets a list of model definitions for the provided model names.
model_modelFieldNames
Gets the list of field names for the provided model name.
model_modelTemplates
Returns an object indicating the template content for each card of the specified model.
model_modelStyling
Gets the CSS styling for the provided model name. Returns an object containing the 'css' field.
model_createModel
Creates a new model (note type). Returns the created model object.
model_updateModelTemplates
Modifies the templates of an existing model by name.
model_updateModelStyling
Modifies the CSS styling of an existing model by name.
model_modelFieldRemove
Removes a field from an existing model.
media_deleteMediaFile
Deletes the specified file from Anki's media folder.
README
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.
<a href="https://glama.ai/mcp/servers/@ujisati/anki-mcp"> <img width="380" height="200" src="https://glama.ai/mcp/servers/@ujisati/anki-mcp/badge" alt="anki-mcp MCP server" /> </a>
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
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。