Anki MCP Server

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Enables interaction with Anki flashcard software through AnkiConnect, providing tools for managing decks, creating various types of flashcards (Basic and Cloze), searching notes, and manipulating note types.

Anki MCP 服务器

模型上下文协议 (MCP) 服务器使 LLM 能够通过 AnkiConnect 与 Anki 抽认卡软件进行交互。

特征

工具

  • list_decks - 列出所有可用的 Anki 卡组
  • create_deck - 创建一个新的 Anki 卡组
  • create_note - 创建新笔记(基本或完形填空)
  • batch_create_notes - 一次创建多个笔记
  • search_notes - 使用 Anki 查询语法搜索笔记
  • get_note_info - 获取有关笔记的详细信息
  • update_note - 更新现有注释
  • delete_note删除注释
  • list_note_types - 列出所有可用的笔记类型
  • create_note_type - 创建新的笔记类型
  • get_note_type_info - 获取笔记类型的详细结构

资源

  • anki://decks/all - 可用卡组的完整列表
  • anki://note-types/all - 所有可用笔记类型的列表
  • anki://note-types/all-with-schemas - 所有笔记类型的详细结构信息
  • anki://note-types/{modelName} - 特定笔记类型的详细结构信息

先决条件

  1. 您的系统上安装了Anki
  2. AnkiConnect插件安装在 Anki 中

配置

与 Claude Desktop 一起使用

将服务器添加到您的 claude_desktop_config.json:

{ "mcpServers": { "anki": { "command": "npx", "args": ["--yes","anki-mcp-server"] } } }

Cline 的配置

将服务器添加到 VSCode 设置cline_mcp_settings.json中的 Cline MCP 设置文件中

{ "mcpServers": { "anki": { "command": "npx", "args": ["--yes","anki-mcp-server"] } } }

发展

设置

  1. 安装依赖项:
npm install
  1. 构建服务器:
npm run build
  1. 对于使用自动重建的开发:
npm run watch

测试

运行测试套件:

npm test

这将执行以下测试:

  • 服务器初始化
  • AnkiConnect 通信
  • 注释操作(创建/读取/更新/删除)
  • 甲板管理
  • 错误处理

调试

由于 MCP 服务器通过 stdio 进行通信,我们建议使用MCP Inspector

npm run inspector

这提供了一个基于浏览器的界面:

  • 监控 MCP 消息
  • 测试工具调用
  • 查看服务器日志
  • 调试通信问题

示例用法

  1. 创建新牌组:
Create a new Anki deck called "Programming"
  1. 添加基本卡:
Create an Anki card in the "Programming" deck with: Front: What is a closure in JavaScript? Back: A closure is the combination of a function and the lexical environment within which that function was declared.
  1. 添加完形填空卡片:
Create a cloze card in the "Programming" deck with: Text: In JavaScript, {{c1::const}} declares a block-scoped variable that cannot be {{c2::reassigned}}.

贡献

  1. 分叉存储库
  2. 创建你的功能分支
  3. 运行测试: npm test
  4. 提交拉取请求

致谢

图标由macOS Icons提供

执照

MIT 许可证 - 详情请参阅许可证文件

You must be authenticated.

A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

模型上下文协议服务器使 LLM 能够通过 AnkiConnect 与 Anki 抽认卡软件进行交互,从而允许创建和管理抽认卡、卡片组和笔记类型。

  1. Features
    1. Tools
    2. Resources
  2. Prerequisites
    1. Configuration
      1. Usage with Claude Desktop
      2. Configuration for Cline
    2. Development
      1. Setup
      2. Testing
      3. Debugging
    3. Example Usage
      1. Contributing
        1. Credits
          1. License
            ID: fpgag671vh