Skip to main content
Glama

🧠 Anki MCP

NPM 包 yanki-connect 许可证:MIT

用人工智能改变你的 Anki 抽认卡体验!这款MCP(模型上下文协议)服务器将你的 Anki 抽认卡集与 Claude 等人工智能助手连接起来,让你能够自然地讨论你的学习资料。

🚀你能做什么?

想象一下,有一位 AI 导师了解你的全部抽认卡,并且可以:

📚互动学习

  • “考考我三天没见过的日语词汇”

  • “用我医疗卡组中的挑战卡来测试我”

  • “给我看看我最近遇到困难的卡片”

✨智能内容创作

  • “用图表制作关于光合作用的抽认卡”

  • “将此 PDF 章节转换为间隔重复卡片”

  • “从我的课堂笔记中生成完形填空卡”

🔍强大的分析功能

  • “我最难理解的是哪些主题?”

  • “显示我上个月的学习模式”

  • “不同类型的卡的留存率是多少?”

🎯批量操作

  • “给我所有的化学卡片都贴上‘备考’的标签”

  • “将留存率低的卡片移至密集复习卡组”

  • “查找并修复我牌组中的重复卡牌”

Related MCP server: Anki MCP Server

🎯 功能

  • 完全 Anki 集成:通过所有 115 种 AnkiConnect API 方法完全访问卡片组、卡片、笔记和统计数据

  • 对话界面:通过人工智能助手发出自然语言命令

  • 批量操作:同时高效管理数千张卡

  • 实时统计:了解您的学习进度

  • 媒体支持:处理卡片中的图像、音频和其他媒体

  • 高级查询:使用复杂的搜索条件查找卡片

  • 类型安全:具有全面错误处理的全类型 API

🛠 技术栈

  • Node.js :运行环境(要求 18+)

  • TypeScript :类型安全和开发者体验

  • MCP SDK :模型上下文协议实现

  • yanki-connect :🙏全类型、同构的 AnkiConnect API 客户端

  • tsup :快速 TypeScript 打包器

  • PNPM :高效的包管理器

特别感谢yanki-connect库提供强大的 AnkiConnect 接口来支持此集成!

📋 先决条件

1.安装Anki

如果尚未下载并安装Anki ,请下载并安装。

2.安装AnkiConnect插件

  1. 打开 Anki

  2. 转到工具→附加组件

  3. 单击获取附加组件...

  4. 输入代码: 2055492159

  5. 重启 Anki

**📋 版本要求:**本服务器需要 AnkiConnect 25.2.25.0 或更新版本(发布于 2025-02-25)才能完全兼容。大多数功能可在旧版本中使用,但我们建议您更新以获得最佳体验。

3.配置 AnkiConnect(可选)

AnkiConnect 开箱即用,但您可以自定义设置:

  1. 转到工具→附加组件

  2. 选择AnkiConnect并点击配置

  3. 默认设置应该适合大多数用户

🚀 快速入门

选项 1:与 Claude Desktop 一起使用(推荐)

  1. 安装包

    npm install -g @arielbk/anki-mcp
  2. 配置 Claude 桌面

    编辑您的 Claude Desktop 配置文件:

    macOS : ~/Library/Application Support/Claude/claude_desktop_config.jsonWindows : %APPDATA%\Claude\claude_desktop_config.json

    添加此配置:

    {
      "mcpServers": {
        "anki": {
          "command": "anki-mcp",
          "args": []
        }
      }
    }
  3. 重启Claude桌面

  4. 开始使用它!

    • 确保 Anki 正在运行并且启用了 AnkiConnect

    • 询问 Claude: “给我看看我的 Anki 卡组”或“用 5 张卡牌测试我”

**💡 专业提示:您可以通过向 Claude 询问一些简单的问题来测试您的设置,例如“我有多少个 Anki 牌组?”或“我最大的牌组里有什么?”

选项 2:开发设置

  1. 克隆存储库

    git clone https://github.com/arielbk/anki-mcp.git
    cd anki-mcp
  2. 安装依赖项

    pnpm install
  3. 构建项目

    pnpm build
  4. 测试服务器

    # Use the MCP inspector to test functionality
    pnpm inspect

选项 3:与其他 MCP 客户端一起使用

此服务器可与任何兼容 MCP 的客户端配合使用。您还可以将其用于:

  • MCP Inspector :交互式调试工具

  • Cline :用于 AI 编码的 VS Code 扩展

  • 自定义 MCP 客户端:使用MCP SDK构建您自己的客户端

对于 stdio 传输,运行:

node dist/index.js

🎮 使用示例

一旦配置了 Claude Desktop,您就可以进行自然的对话,例如:

📖 学习课程

You: "I have a Japanese exam tomorrow. Can you quiz me on Hiragana cards I haven't reviewed in a week?"

Claude: I'll find your Hiragana cards that need review and start a quiz session...

📝 内容创作

You: "Create flashcards for the major battles of World War II with dates and significance"

Claude: I'll create comprehensive flashcards covering the key WWII battles...

📊 学习分析

You: "How am I doing with my medical terminology deck? Show me my weak areas."

Claude: Let me analyze your performance on the medical terminology deck...

🏷️ 组织

You: "Tag all cards about cardiovascular system with 'cardiology' and move them to my MCAT prep deck"

Claude: I'll help you organize those cards...

🔧 可用的工具和资源

该 MCP 服务器通过以下功能提供对您的 Anki 集合的全面访问:

📚牌组管理

  • 列出所有带有统计数据的卡组

  • 创建新牌组

  • 重命名和删除卡组

  • 获取甲板配置

🗂️卡片操作

  • 按搜索条件查找卡片

  • 答题卡(模拟复习)

  • 获取卡信息和统计数据

  • 暂停/取消暂停卡

  • 批量卡操作

📝笔记管理

  • 使用自定义字段添加新注释

  • 更新现有笔记

  • 删除笔记

  • 通过搜索查询查找笔记

  • 批量票据操作

📊统计与分析

  • 牌组统计数据和性能指标

  • 卡片难易度和间隔数据

  • 回顾历史和模式

  • 学习进度洞察

🎨媒体与模特

  • 访问注释类型和字段定义

  • 媒体文件管理

  • 模板定制支持

🔍高级功能

  • 使用 Anki 搜索语法的复杂搜索查询

  • 批量操作以提高效率

  • 与Anki实时同步

  • 错误处理和验证

  • 按功能分组的组织 API 方法(卡片、卡组、注释、模型、统计数据、媒体等)

  • 直接访问所有 115 个 AnkiConnect API 方法,并具有完全类型安全性

🛠 开发

# Run in development mode with auto-reloading
pnpm dev

# Lint the code
pnpm lint

# Format the code
pnpm format

# Test with MCP inspector
pnpm inspect

🔧 配置

AnkiConnect 设置

服务器默认连接到localhost:8765上的 AnkiConnect。如果你自定义了 AnkiConnect 配置,则可能需要调整连接设置。

重要提示:使用 MCP 服务器前,请确保 Anki 已运行且 AnkiConnect 已安装。如果 AnkiConnect 无法访问,服务器将无法连接。

**💡 注意:**底层 yanki-connect 库支持在 macOS 上自动启动 Anki,但此功能目前尚未在 MCP 服务器配置中公开。您需要手动启动 Anki。

Claude Desktop高级配置

对于高级用户,您可以传递额外的参数:

{
  "mcpServers": {
    "anki": {
      "command": "anki-mcp",
      "args": ["--verbose"],
      "env": {
        "ANKI_CONNECT_HOST": "localhost",
        "ANKI_CONNECT_PORT": "8765"
      }
    }
  }
}

故障排除

常见问题:

  • “无法连接到 AnkiConnect” :确保 Anki 正在运行并且 AnkiConnect 插件已安装

  • “未找到牌组” :请确保 Anki 中至少有一个牌组

  • Claude 没有响应:配置更改后重新启动 Claude Desktop

  • 权限错误:检查全局 npm install 是否与npm list -g @arielbk/anki-mcp正确运行

🤝 贡献

欢迎投稿!请:

  1. 分叉存储库

  2. 创建功能分支

  3. 进行更改

  4. 如果适用,添加测试

  5. 提交拉取请求

📜 许可证

MIT——详情请参阅LICENSE文件。

🙏 致谢


利用 AI 对话改变你的抽认卡体验!🚀

Available Tools

8 tools
anki_guiControl the Anki app UIA
Destructive

Drive the Anki desktop application's user interface: open windows and dialogs (Card Browser, Add Cards, Edit Note, deck overview, import), run an on-screen review session, and read what the user currently has selected or on screen. Use this when the user wants to see or act on something inside the Anki app itself; use manage_flashcards (and the other non-GUI tools) for headless reads and writes, which are faster and do not disturb the user's windows.

Side effects: every operation except current_card and selected_notes changes what is shown in Anki. answer_card records a review and reschedules the card. undo reverts the user's last action in Anki. exit_anki quits the Anki application (and AnkiConnect with it), so only use it when the user explicitly asks. add_cards, edit_note and import_file only open pre-filled dialogs; nothing is saved until the user confirms in Anki.

Operations and the parameters they use:

  • add_cards: open Add Cards pre-filled (deckName, modelName, fields, tags?); returns the note ID it would create.

  • browse: open the Card Browser with a search (query, reorderCards?); returns matching card IDs.

  • select_card: select a card in an open Card Browser (cardId).

  • select_note: legacy alias that also selects by card ID in the Card Browser (noteId, treated as a card ID by AnkiConnect).

  • selected_notes: read-only; note IDs selected in the Card Browser.

  • edit_note: open the Edit dialog for a note (noteId).

  • deck_browser: show the main deck list.

  • deck_overview: show a deck's overview screen (deckName).

  • deck_review: start reviewing a deck (deckName).

  • current_card: read-only; the card currently shown in the reviewer, or none.

  • show_question / show_answer: flip the current review card.

  • start_card_timer: restart the answer timer for the current card.

  • answer_card: grade the current card (ease 1-4); the answer must be showing.

  • undo: undo the last action in Anki.

  • check_database: start Tools > Check Database (returns before it finishes).

  • import_file: open the Import dialog for a file (filePath, forward slashes on Windows; Anki 2.1.52+).

  • exit_anki: gracefully close Anki.

Requires Anki to be running with the AnkiConnect add-on.

Inputs: operation (required), ease, tags, query, +7 more.

anki_operationsAnki utilities: sync, packages, mediaA
Destructive

Utility operations for the Anki app: AnkiWeb sync, version check, .apkg import/export, profiles, and media files. Use this for maintenance tasks that are not about card content, decks, note types or reviews. To read a media file's contents (e.g. view an image), use get_media_file.

Operations:

  • version: read-only; AnkiConnect version (also a quick "is Anki running?" check).

  • get_profiles: read-only; profile names.

  • sync: syncs the collection with AnkiWeb (network; may upload or download changes).

  • export_deck: needs deckName and filePath (.apkg path to write); optional includeSched. Writes a file on disk.

  • import_package: needs filePath to an .apkg; adds its contents to the collection.

  • list_media: read-only; needs pattern (e.g. ".png", "").

  • retrieve_media: read-only; needs filename; reports whether it exists and its size.

  • store_media: needs filename plus mediaData (base64) or mediaUrl (downloaded by Anki). Overwrites a file with the same name.

  • delete_media: needs filename. Deletes the file from the media folder.

Inputs: operation (required), pattern, deckName, filePath, +4 more.

get_analyticsStudy analyticsA
Read-onlyIdempotent

Read-only study statistics and review history from the local Anki collection, aggregated server-side into compact JSON or one line per row. Use this for reporting and diagnosing progress; it never changes data. To act on the findings, use study_session or manage_flashcards.

Scopes (set scope, then the listed parameters). deckName always includes subdecks; where optional, omitting it means the whole collection:

  • deck_overview: needs deckName; optional days (default 30), limit (top tags, default 10). One-call answer to "how am I doing on this deck": new/learning/review/suspended and seen/unseen counts, the preset's new/day and reviews/day limits, the date the unseen cards run out at the new/day limit, reviews, correct % and retention over the window, and top tags by Again count.

  • collection_stats: optional deckName, days (forecast length, default 14). Studied today (cards, minutes, again, correct %), card counts (new/learning/young/mature/suspended; mature = interval >= 21d), correct % by card type over the last 30 days, due-review forecast per day before limits (overdue backlog separate from today), shownToday (what Anki's deck list shows today after daily limits: new/learning/review for each top-level deck, or the deck and its direct subdecks), average/longest interval.

  • reviews_by_day: optional deckName, days (default 30) or since (YYYY-MM-DD). One "YYYY-MM-DD: n" line per day (zero days included) plus a total.

  • trouble_cards: optional deckName, days (default 7), limit (default 10). Cards answered Again in the window, grouped by tag, plus the worst cards (cardId, front text, again count, lapses).

  • deck_stats: needs deckName; Anki's new/learning/review counts for the deck.

  • reviews_today: number of reviews today across all decks.

  • card_reviews: needs deckName and startTimestamp (epoch ms); raw review log for that deck (not subdecks), one line per review. Over limit (default 300) rows it returns a summary and how to narrow.

  • card_details: needs cardIds; ease factor and current interval per card.

For "what am I failing", trouble_cards gives the aggregate; to get the cards themselves use manage_flashcards find with Anki search syntax, e.g. "rated:2:1" (answered Again in the last 2 days), "deck:Spanish rated:7:1", "prop:lapses>3" or "is:due".

Inputs: scope (required), days, limit, since, +4 more.

get_media_fileGet media file contentsA
Read-onlyIdempotent

Read one file from Anki's media folder and return it as base64; images are also returned as image content the model can look at. Read-only. Use this when you need a referenced image/audio file's actual contents; use anki_operations list_media to find file names and store_media/delete_media to change files. Pass the bare filename as it appears in the card (e.g. "diagram.png"); paths and ".." are rejected. Returns an error object if the file doesn't exist.

Inputs: filename (required).

manage_decksManage decksA
Destructive

Create, list, inspect, configure, rename and delete Anki decks, and move cards between them. Use this for deck organization and per-deck daily limits; use manage_flashcards for card content. To suspend/unsuspend cards (e.g. pause a deck), use study_session.

Operations:

  • list: read-only; all deck names and IDs.

  • create: needs deckName (use "Parent::Child" for subdecks). Optional newPerDay and/or reviewsPerDay give the new deck its own daily limits (see set_limits). Does nothing if the deck already exists.

  • set_limits: needs deckName plus newPerDay and/or reviewsPerDay. Changes daily limits for this deck only: if the deck uses a shared options preset (e.g. "Default"), the preset is cloned into a new preset named after the deck, assigned to the deck, and only the clone is changed. Other decks are never affected. Cloned presets stay in Anki; deleting one later (in Anki's Deck Options) forces a full sync.

  • get_stats: read-only; deckName (one deck) or deckNames (array). One line per deck: total cards and today's new/learning/review due counts. Unknown names are reported, never created. For counts by tag or state within a deck, use manage_flashcards find with groupBy.

  • get_config: read-only; needs deckName. Readable summary of the deck's options preset: name/ID and which other decks share it, daily limits, learning/relearning steps, leeches, burying, max interval, FSRS desired retention, and display order as named values. raw: true returns the full preset JSON instead (FSRS parameters included).

  • set_display_order: needs deckName plus any of newGatherOrder (deck, deck_then_random_notes, ascending_position, descending_position, random_notes, random_cards), newSortOrder (card_type_then_gathered, gathered, card_type_then_random, random_note_then_card_type, random), reviewOrder (due_date_then_random, due_date_then_deck, deck_then_due_date, ascending/descending_intervals, ascending/descending_ease, ascending/descending_retrievability, relative_overdueness, random, order_added, reverse_order_added), newReviewMix and interdayLearningMix (mix_with_reviews, after_reviews, before_reviews). Same shared-preset safety as set_limits; reports each change as old → new. For random new cards, set newGatherOrder random_notes (newSortOrder random only shuffles the cards already gathered). Anki uses the display order of the deck you study, not its subdecks'.

  • set_config: needs deckNames and configId; assigns an existing options preset to the decks.

  • rename: needs deckName and newName. Subdecks follow; cards keep their scheduling and each deck keeps its options preset. Refuses if newName already exists with cards. Anki's "studied today" counters start fresh for the renamed deck.

  • move_cards: needs targetDeck plus cardIds OR query (Anki search, e.g. 'deck:"Old" tag:x'; any number of cards). Reports the count and source decks. dryRun: true reports what would move without moving (only move_cards takes dryRun).

  • delete: needs deckNames. Permanently deletes the decks AND all their cards (deleteCards must not be false; AnkiConnect always deletes cards) and reports how many cards each held. Deleting a filtered deck returns its cards to their home decks instead. requireEmpty: true refuses if any deck has cards that would be deleted. Cannot be undone.

Inputs: operation (required), raw, query, dryRun, +15 more.

manage_flashcardsManage flashcardsA
Destructive

Create, search, inspect, edit, tag and delete Anki notes (flashcards) in the local collection via AnkiConnect. Use this for card content; use manage_decks for deck structure/limits, manage_models for note-type fields and templates, and study_session for review state (to suspend/unsuspend cards, use study_session). For guidance on writing effective cards, use the "writing_good_flashcards" prompt.

Operations (set operation, then the listed parameters):

  • create: add one note. Needs deckName, modelName, fields; optional tags, allowDuplicate, duplicateScope. Writes immediately.

  • create_batch: add many notes. Give notes inline OR filePath to a .json (array of notes), .csv or .tsv file (header row = field names; optional tags, deck, model columns). Top-level deckName/modelName act as defaults that each note can override; top-level tags are added to every note. Notes are validated first (note type exists, field names match, duplicates, empty first field: each failure gets a reason), then sent sequentially in chunks of chunkSize (default 10). The result maps every note (#n plus the first ~40 chars of its first field) to its new note ID or failure reason. If Anki stops responding partway, it stops and lists which notes were saved and which to resend. Use dryRun: true to validate without writing. Prefer filePath for large imports: it keeps card text out of the conversation.

  • update: change fields and/or replace tags of one note. Needs noteId plus fields and/or tags.

  • delete: permanently delete notes and all their cards. Needs noteIds. Cannot be undone.

  • find: read-only search with Anki query syntax. Needs query. Output is compact: a header with the total match count and next offset, then one line per note. Optional:

    • include: what each note carries. Default ["fields"] (field text, HTML stripped, each field cut to maxFieldChars, default 120; 0 = no limit). Add "tags", "deck", "model", "cards" (card IDs) or "state" (per card: new/learning/review/relearning/suspended/buried, interval, due date, reps, lapses, ease). [] returns IDs only. includeDetails: true = all of them.

    • groupBy: "tag" | "deck" | "model" returns {notes, cards, new, seen} per group, and "state" returns card/note counts per queue, over ALL matches (ignores limit). Use this for "how many cards per topic" or "how much of this deck have I seen" instead of listing.

    • limit (default 50), offset, format ("lines" default, or "json" for single-line JSON). Listings are capped at ~20k chars: past that you get the first notes that fit plus a hint to use groupBy, include or a narrower query/limit. Search power-ups: deck:"Interview prep", tag:verbs, is:new, is:due, is:suspended, rated:2:1 (answered Again in the last 2 days; the go-to for "what am I failing"), rated:7 (reviewed in the last 7 days), prop:ivl>=21 (mature), prop:lapses>=3 (leeches), added:7, "front:word". Combine with spaces (AND), "or", and "-" for NOT.

  • get_info: read-only card details. Needs cardIds (max 50).

  • add_tags / remove_tags: needs tags plus noteIds OR query (Anki search; the server finds the notes, any number). dryRun: true reports the match count and sample IDs without writing.

  • clear_empty: deletes every note with empty cards in the whole collection.

Fails with a clear message if Anki isn't running.

Inputs: operation (required), tags, limit, notes, +18 more.

manage_modelsManage note typesA
Destructive

List and modify Anki note types (models): fields, card templates and CSS. Use list before creating notes to find a note type's exact field names (e.g. "Front"/"Back"); use manage_flashcards for note content.

Operations:

  • list: read-only; every note type with its ID and ordered field names.

  • create: needs modelName, fields (ordered names) and templates ([{ Front, Back }]); optional css, isCloze.

  • add_field: needs modelName, fieldName, fieldIndex.

  • remove_field: needs modelName, fieldName. Deletes that field's content from every note of this type (destructive).

  • rename_field: needs modelName, fieldName, newFieldName.

  • add_template: needs modelName, template ({ Front, Back }). Generates new cards for existing notes.

  • remove_template: needs modelName, templateName. Deletes the cards generated by that template (destructive).

  • update_styling: needs modelName, css. Replaces the note type's CSS.

All operations except list change the collection immediately and affect every note of that type.

Inputs: operation (required), css, fields, isCloze, +7 more.

study_sessionStudy session and schedulingA
Destructive

Find due cards and change review state (answer, suspend, unsuspend, reset, relearn) in the local Anki collection. Use this to run a quiz or adjust scheduling; use manage_flashcards to edit card content and get_analytics for history and statistics.

Operations:

  • find_due: read-only. Needs query (Anki search syntax, e.g. "deck:Spanish"); returns which matching cards are due now.

  • check_status: read-only. Needs cardIds; returns due/suspended flags per card.

  • answer: records reviews, as if answered in Anki. Needs answers: [{ cardId, ease }] where ease 1=Again, 2=Hard, 3=Good, 4=Easy. Affects future scheduling.

  • suspend / unsuspend: needs cardIds OR query. Suspended cards are excluded from reviews until unsuspended (e.g. pause a whole deck: query 'deck:"Spanish"').

  • forget: needs cardIds OR query. Resets cards to new, discarding their review progress (destructive).

  • relearn: needs cardIds OR query. Puts cards back into relearning. With query (Anki search syntax), the server finds the cards and applies the change in chunks, so thousands of cards take one call; it returns the count. dryRun: true returns the match count and sample IDs without writing. A query matching nothing changes nothing.

All writes apply immediately and are not undoable through this tool.

Inputs: operation (required), query, dryRun, answers, +1 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.6/5.0

    Scored across 8 tools

    Disambiguation4/5

    Each tool owns a clear domain (card content, deck structure, note types, review state, analytics, GUI, app maintenance), and descriptions explicitly cross-reference boundaries (e.g. 'use study_session to suspend'). However, several read paths overlap heavily — manage_flashcards find with state/groupBy, study_session find_due, manage_decks get_stats, and get_analytics scopes can all answer 'what's due / how am I doing', which risks misselection despite the guidance.

    Naming Consistency3/5

    The manage_flashcards / manage_decks / manage_models trio follows a clean verb_noun pattern, and get_analytics/get_media_file fit it. But study_session, anki_operations, and anki_gui are noun-phrase names that break the convention, and the aggregate 'anki_operations' bucket is vague about its scope.

    Tool Count5/5

    Eight tools is well-scoped for an Anki integration, and each aggregates a coherent area via an operation parameter rather than exploding into dozens of single-action tools. Every tool earns its place in the surface.

    Completeness5/5

    Coverage is broad and lifecycle-complete: note CRUD plus batch import, deck CRUD and limits/config, note-type fields/templates/CSS, review answering/suspend/forget/relearn, analytics, media files, sync/import/export, and even GUI driving. Only niche gaps (e.g. tag renaming, own-write undo) remain.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      An MCP server that enables AI assistants like Claude to interact with Anki flashcard decks, allowing users to create, manage, and update flashcards through natural language conversations.
      9
      45
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      An MCP server that enables AI assistants to interact with the Anki flashcard application for studying, deck management, and note creation. It supports natural language interaction for reviewing cards, searching content, and managing media files across local and remote environments.
      993 npm
      582
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that enables AI assistants to seamlessly manage Anki flashcards, decks, and templates through the AnkiConnect API. It supports intelligent querying, batch note creation, and detailed study progress analysis using natural language.
      4
      MIT