Anki记忆服务
一个服务器实现,它可以连接到本地运行的Anki,通过模型上下文协议实现卡片的复习和创建。
可用工具 (4 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
update_cards 1 个参数
After the user answers cards you've quizzed them on, use this tool to mark them answered and update their ease
该工具无需必填参数,直接调用即可
add_card 2 个参数 需填 2 项
Create a new flashcard in Anki for the user. Must use HTML formatting only. IMPORTANT FORMATTING RULES: 1. Must use HTML tags for ALL formatting - NO markdown 2. Use <br> for ALL line breaks 3. For code blocks, use <pre> with inline CSS styling 4. Example formatting: - Line breaks: <br> - Code: <pre style="background-color: transparent; padding: 10px; border-radius: 5px;"> - Lists: <ol> and <li> tags - Bold: <strong> - Italic: <em>
必填参数:front、back
get_due_cards 1 个参数 需填 1 项
Returns a given number (num) of cards due for review.
必填参数:num
get_new_cards 1 个参数 需填 1 项
Returns a given number (num) of new and unseen cards.
必填参数:num
服务介绍
Anki MCP 服务器
这是一个连接到本地运行的 Anki 的 MCP 服务器实现,提供卡片复习和创建功能。
此服务器设计用于与 Anki 桌面应用程序 和 Anki-Connect 插件一起工作。
在使用前请确保已安装插件。
资源
- anki://search/deckcurrent
- 返回当前牌组中的所有卡片
- 等同于 Anki 中的
deck:current
- anki://search/isdue
- 返回等待学习的复习和学习中的卡片
- 等同于 Anki 中的
is:due
- anki://search/isnew
- 返回所有未见过的卡片
- 等同于 Anki 中的
is:new
工具
-
update_cards
- 标记给定卡片 ID 的卡片为已回答,并给予它们一个介于 1(再次)和 4(容易)之间的难度分数
- 输入:
answers(数组): 包含cardId(数字) 和ease(数字) 字段的对象数组
-
add_card
- 在默认的 Anki 牌组中创建一张新卡片
- 输入:
front(字符串): 卡片正面back(字符串): 卡片背面
-
get_due_cards
- 返回目前需要复习的 n 张卡片
- 输入:
num(数字): 卡片数量
-
get_new_cards
- 从新卡片中返回 n 张
- 输入:
num(数字): 卡片数量
开发
安装依赖项:
npm install
构建服务器:
npm run build
开发时自动重建:
npm run watch
配置
要与 Claude Desktop 一起使用,请添加服务器配置:
在 MacOS 上: ~/Library/Application Support/Claude/claude_desktop_config.json
在 Windows 上: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"anki-mcp-server": {
"command": "/path/to/anki-mcp-server/build/index.js"
}
}
}
调试
由于 MCP 服务器通过 stdio 进行通信,调试可能会比较困难。我们建议使用 MCP Inspector,它作为包脚本提供:
npm run inspector
Inspector 将提供一个 URL 以便您在浏览器中访问调试工具。