mcp-server-anki
Enables AI tools to manage Anki flashcards, including deck management, card search, creation, editing, deletion, and statistics.
README
MCP Server Anki
<div align="center"> <img src="./src/public/icons8-anki-480.png" alt="Anki Logo" width="120" height="120">
中文文档 | English </div>
A Model Context Protocol (MCP) server that bridges Anki with AI tools, enabling intelligent flashcard management and learning assistance.
💡 Compatibility: This server works with any MCP-compatible AI tool including Claude Code, Cline, Zed AI, and more. We use Claude Code as an example in this documentation, but the setup process is similar for other tools.
🌟 Features
- 📚 Deck Management: Get deck lists, view deck statistics
- 🔍 Card Search: Search cards using Anki's advanced query syntax
- ➕ Smart Creation: Create and manage Anki cards with AI assistance
- ✏️ Card Editing: Update existing card fields and content
- 🗑️ Card Deletion: Delete unwanted cards and notes
- 📊 Data Analysis: Get learning statistics and progress information
- 🔧 Template Management: View and use different note types
📋 Prerequisites
- Anki Desktop - Download Anki
- AnkiConnect Plugin - Install in Anki (Code:
2055492159) - Node.js - Version 16 or higher
- MCP-compatible AI Tool - Such as:
- Claude Code
- Cline
- Zed AI
- Any other tool supporting MCP
🚀 Quick Start
1. Install AnkiConnect
In Anki:
- Tools → Add-ons → Get Add-ons
- Enter code:
2055492159 - Restart Anki
2. Configure Your MCP Client
The following examples use Claude Code, but the configuration is similar for other MCP-compatible tools.
Option A: Using Command Line
# For Claude Code
claude mcp add anki -- npx mcp-server-anki
# For other tools, consult their documentation for the equivalent command
Option B: Manual Configuration
Add the server to your MCP client's configuration file:
{
"mcp": {
"servers": {
"anki": {
"command": "npx",
"args": ["mcp-server-anki"]
}
}
}
}
📖 Usage Guide
Basic Workflow
- Start Anki - Ensure Anki is running with AnkiConnect enabled
- Start MCP Server - Automatically started by Claude Code
- Use AI Tools - Interact with Anki through Claude Code
Example Conversations
User: Show me the learning progress for my "English Vocabulary" deck
Claude: I'll check the statistics for your "English Vocabulary" deck...
[Calls get_deck_stats tool]
User: Create a new English word card for "ephemeral"
Claude: I'll create this word card for you...
[Calls add_note tool]
🛠️ Available Tools
| Tool Name | Description | Parameters |
|---|---|---|
get_deck_names |
Get all deck names | None |
get_cards_in_deck |
Get cards from a specific deck | deckName |
get_deck_stats |
Get deck statistics | deckName |
search_cards |
Search cards | query |
add_note |
Add new note | deckName, modelName, fields, tags |
update_note |
Update existing note fields | noteId, fields |
get_note_info |
Get detailed note information | noteId |
delete_notes |
Delete one or more notes | noteIds |
get_models |
Get all note types | None |
get_model_fields |
Get note type fields | modelName |
🏗️ Project Structure
mcp-server-anki/
├── src/
│ ├── index.ts # MCP server entry point
│ ├── ankiConnect.ts # AnkiConnect API client
│ └── tools/ # MCP tool definitions
│ ├── deckTools.ts # Deck-related tools
│ ├── cardTools.ts # Card-related tools
│ └── noteTools.ts # Note-related tools
├── dist/ # Compiled JavaScript
├── package.json
├── tsconfig.json
└── README.md
🔧 Development
Build Commands
# Development mode (watch for changes)
npm run dev
# Production build
npm run build
Architecture
Claude Code (MCP Client) ←→ Anki MCP Server ←→ AnkiConnect ←→ Anki Desktop
📝 API Documentation
get_deck_names
Get a list of all deck names.
Returns:
["Default", "English Vocabulary", "Programming"]
search_cards(query)
Search cards using Anki query syntax.
Parameters:
query: Anki query string (e.g.,deck:English is:due)
Query Syntax Examples:
deck:DeckName- Specific decktag:TagName- By tagis:due- Due cardsis:new- New cardsadded:7- Cards added in last 7 days
add_note
Add a new note to Anki.
Parameters:
deckName: Target deck namemodelName: Note type (e.g., "Basic", "Cloze")fields: Field content objecttags: Tag array (optional)
Example:
{
"deckName": "English Vocabulary",
"modelName": "Basic",
"fields": {
"Front": "ephemeral",
"Back": "lasting for a very short time"
},
"tags": ["vocabulary", "adjective"]
}
update_note
Update fields of an existing note.
Parameters:
noteId: The ID of the note to updatefields: Object with field names and new values
Example:
{
"noteId": 1234567890,
"fields": {
"Back": "lasting for an extremely short time"
}
}
get_note_info
Get detailed information about a specific note.
Parameters:
noteId: The ID of the note to query
Returns:
{
"noteId": 1234567890,
"modelName": "Basic",
"fields": {
"Front": "ephemeral",
"Back": "lasting for a very short time"
},
"tags": ["vocabulary", "adjective"]
}
delete_notes
Delete one or more notes.
Parameters:
noteIds: Array of note IDs to delete
Example:
{
"noteIds": [1234567890, 9876543210]
}
🔧 Building from Source
If you want to contribute or customize the server:
# Clone the repository
git clone https://github.com/here-tunan/mcp-server-anki.git
cd mcp-server-anki
# Install dependencies
npm install
# Build TypeScript
npm run build
To use your local build with Claude Code, configure it with:
{
"mcp": {
"servers": {
"anki": {
"command": "node",
"args": ["/path/to/mcp-server-anki/dist/index.js"]
}
}
}
}
🤝 Contributing
Issues and Pull Requests are welcome!
📄 License
Apache License
🔗 Links
❓ FAQ
Q: AnkiConnect connection failed?
A: Ensure Anki is running and AnkiConnect plugin is installed and enabled. Default port is 8765.
Q: How to customize note types?
A: After creating custom note types in Anki, use get_models and get_model_fields tools to view available fields.
Q: Mobile support?
A: Currently only supports desktop Anki due to AnkiConnect dependency.
Made with ❤️ for Anki learners and AI enthusiasts
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。