s

samefarrar

@samefarrar/mcp-ankiconnect
Hosted
0 Stars 351 次浏览 samefarrar 更新于 2026-08-23

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "mcp-ankiconnect": {
      "args": [
        "run",
        "--with",
        "mcp-ankiconnect",
        "mcp-ankiconnect"
      ],
      "command": "uv"
    }
  }
}

可用工具 (6 个)

该服务在 MCP 协议中暴露的工具,AI 可按需调用

num_cards_due_today

Get the number of cards due exactly today, with an optional deck filter.

该工具无需必填参数,直接调用即可

list_decks_and_notes

Get all decks (excluding specified patterns) and note types with their fields.

该工具无需必填参数,直接调用即可

get_examples

Get example notes from Anki to guide your flashcard making. Limit the number of examples returned and provide a sampling technique: - random: Randomly sample notes - recent: Notes added in the last week - most_reviewed: Notes with more than 10 reviews - best_performance: Notes with less than 3 lapses - mature: Notes with interval greater than 21 days - young: Notes with interval less than 7 daysArgs: deck: Optional[str] - Filter by specific deck (use exact name). limit: int - Maximum number of examples to return (default 5). sample: str - Sampling technique (random, recent, most_reviewed, best_performance, mature, young).

该工具无需必填参数,直接调用即可

fetch_due_cards_for_review

Fetch cards due for review, formatted for an LLM to present.Args: deck: Optional[str] - Filter by specific deck name. limit: int - Maximum number of cards to fetch (default 5). today_only: bool - If true, only fetch cards due today. If false, fetch cards due up to MAX_FUTURE_DAYS ahead (currently {MAX_FUTURE_DAYS}).

该工具无需必填参数,直接调用即可

submit_reviews

Submit multiple card reviews to Anki using ratings ( wrong , hard , good , easy ).Args: reviews: List of review dictionaries, each with: - card_id (int): The ID of the card reviewed. - rating (str): wrong , hard , good , or easy .

该工具无需必填参数,直接调用即可

add_note

Add a flashcard to Anki. Ensure you have looked at examples before you do this, and that you have got approval from the user to add the flashcard.For code examples, use u003ccodeu003e tags to format your code.e.g. u003ccodeu003edef fibonacci(n):if n u003c= 1: return nreturn fibonacci(n-1) + fibonacci(n-2)u003c/codeu003eFor MathJax, use the u003cmathu003e tag to format your math equations. This will automatically render the math equations in Anki.# e.g. u003cmathu003efrac{d}{dx}[3sin(5x)] = 15cos(5x)u003c/mathu003eArgs: deckName: str - The target deck name. modelName: str - The note type (model) name. fields: dict - Dictionary of field names and their string content. tags: List[str] - Optional list of tags.

该工具无需必填参数,直接调用即可

服务介绍

mcp-ankiconnect MCP 服务器

通过 MCP 将 Claude 对话与 AnkiConnect 连接起来,使间隔重复变得像“让我们复习今天的闪卡”或“为这个内容制作闪卡”一样简单。

组件

工具

服务器实现了三个工具:

  • num_cards_due_today: 获取今天到期的卡片数量

    • 可选的 deck 参数用于按特定牌组过滤
    • 返回所有牌组或指定牌组中到期卡片的数量
  • get_due_cards: 获取需要复习的卡片

    • 可选的 limit 参数(默认值:5)用于控制卡片数量
    • 可选的 deck 参数用于按特定牌组过滤
    • 可选的 today_only 参数(默认值:true)仅显示今天的卡片
    • 以 XML 格式返回带有问题和答案的卡片
  • submit_reviews: 提交已复习卡片的答案

    • 接受包含 card_idratingreviews 列表
    • 评分选项:"wrong", "hard", "good", "easy"
    • 返回提交复习的确认信息

配置

前提条件

  • 必须安装并运行 AnkiConnect 插件(插件 ID 2055492159)
    由于 AppSleep 功能,AnkiConnect 在 Mac 上可能会很慢,因此需要为 Anki 禁用它。在终端中运行以下命令:
    bash
    defaults write net.ankiweb.dtop NSAppSleepDisabled -bool true
    defaults write net.ichi2.anki NSAppSleepDisabled -bool true
    defaults write org.qt-project.Qt.QtWebEngineCore NSAppSleepDisabled -bool true

安装

快速开始

  1. 在 Anki 中安装 AnkiConnect 插件:

    • 工具 > 插件 > 获取插件...
    • 输入代码:2055492159
    • 重启 Anki
  2. 配置 Claude Desktop:

    在 MacOS 上:~/Library/Application Support/Claude/claude_desktop_config.json
    在 Windows 上:%APPDATA%/Claude/claude_desktop_config.json

    添加以下配置:
    json
    {
    "mcpServers": {
    "mcp-ankiconnect": {
    "command": "uv",
    "args": ["run", "--with", "mcp-ankiconnect", "mcp-ankiconnect"]
    }
    }
    }

  3. 重启 Anki 和 Claude 桌面应用

调试

由于 MCP 服务器通过标准输入输出运行,调试可能会比较困难。为了获得最佳调试体验,我们强烈建议使用 MCP Inspector
首先,克隆仓库并安装依赖项:

bash
git clone https://github.com/samefarrar/mcp-ankiconnect.git
cd mcp-ankiconnect
uv sync

你可以通过 mcp CLI 启动 MCP Inspector:

bash
uv run mcp dev mcp_ankiconnect/server.py

启动后,Inspector 会显示一个 URL,你可以在浏览器中访问该 URL 开始调试。

相关 MCP 服务