Skip to main content
Glama

Anki MCP 服务器

Claude Desktop 的 MCP(模型上下文协议)服务器通过 AnkiConnect 连接到 Anki 并检索带有水蛭标记的卡片。

特征

  • 通过 AnkiConnect API 连接到 Anki

  • 检索带有“leech”标签的卡片

  • 在卡片上添加带有日期戳的评论标签

  • 提供全面的卡片数据供 Claude 分析

  • 可与 Claude Desktop 一起使用

Related MCP server: Anki MCP

先决条件

安装

  1. 克隆此存储库:

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

    npm install
  3. 构建项目:

    npm run build

配置

可以使用环境变量配置服务器。复制提供的示例文件以创建您自己的配置:

cp .env.example .env

然后编辑.env文件以自定义您的设置:

环境变量

描述

默认值

ANKI_CONNECT_URL

Anki Connect API 的 URL

http://localhost:8765

ANKI_CONNECT_VERSION

要使用的 Anki Connect API 版本

6

ANKI_MOCK_MODE

启用模拟模式进行测试(真/假)

false

如果未设置环境变量,服务器将使用默认值。

查找 AnkiConnect 的本地 IP 地址

如果连接到localhost不起作用,则需要使用计算机的本地 IP 地址。使用以下命令配置.env文件:

ANKI_CONNECT_URL=http://YOUR_LOCAL_IP:8765

要查找您的本地 IP 地址:

  • macOS :打开终端并运行ifconfig或ipconfig getifaddr en0 (适用于 WiFi)

  • Windows :打开命令提示符并运行ipconfig

  • Linux :打开终端并运行ip addr show或hostname -I

在输出中查找 IPv4 地址,例如192.168.xx或10.xxx 。

测试配置

为了测试,提供了一个单独的配置文件.env.test :

cp .env.example .env.test

编辑.env.test以设置特定于测试的值:

ANKI_CONNECT_URL=http://localhost:8765
ANKI_CONNECT_VERSION=6
ANKI_MOCK_MODE=true

要在测试模式下运行:

npm run start:test

用法

  1. 确保 Anki 正在运行并且安装了 AnkiConnect

  2. 运行 MCP 服务器:

    npm start

配置 Claude 桌面

要将此 MCP 服务器与 Claude Desktop 一起使用:

  1. 打开 Claude 桌面

  2. 编辑位于以下位置的 Claude Desktop 配置文件:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

    • Windows: %APPDATA%\Claude\claude_desktop_config.json

    • Linux: ~/.config/Claude/claude_desktop_config.json

  3. 将以下配置添加到mcpServers部分:

{
  "mcpServers": {
    "anki": {
      "command": "node",
      "args": ["path/to/anki-mcp-server/dist/index.js"]
    }
  }
}

将"path/to/anki-mcp-server"替换为您克隆此存储库的实际路径。

MCP 工具使用

配置完成后,您可以在 Claude 中使用以下工具:

示例用法

Could you analyze my Anki leech cards and suggest ways to improve my study?

克劳德将使用 MCP 服务器检索您的吸血卡并对其进行分析。

可用工具

获取借贷卡

从 Anki 中检索标记为水蛭的卡片。

参数:

  • detailed (可选,布尔值,默认值:true):是否返回综合卡数据或仅返回 ID

  • count (可选,数字):返回的随机卡片数量(默认为所有卡片)

标签_已审阅_卡片

为指定卡片添加带有日期标记的“已审阅”标签。这样您就可以追踪哪些卡片已由 Claude 审阅过。

参数:

  • card_ids (必需,数字数组):要标记为已审核的卡片 ID 数组

  • custom_tag_prefix (可选,字符串,默认:“见直し”):标签的自定义前缀

标签的格式为見直し_YYYYMMDD (或您的自定义前缀,如果指定)。

Claude 中的用法示例:

I've reviewed these cards, please tag them as reviewed: [1234567890, 1234567891]

故障排除

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

  • “未找到吸血鬼卡片” ——你在 Anki 中没有任何标记为“吸血鬼”的卡片

  • localhost 的连接问题- 如果您无法使用localhost进行连接:

    1. 按照配置部分中的说明查找本地 IP 地址

    2. 更新您的.env文件以使用ANKI_CONNECT_URL=http://YOUR_LOCAL_IP:8765

    3. 确保 AnkiConnect 配置为允许来自您的 IP 地址的连接

    4. 完成这些更改后重新启动 MCP 服务器

  • 标签未出现- 确保您向tag_reviewed_cards工具提供了有效的卡片 ID

测试模式

为了在不影响实际 Anki 数据的情况下进行测试,您可以使用模拟模式:

  1. 在您的.env文件中设置ANKI_MOCK_MODE=true或使用提供的.env.test文件

  2. 使用npm run start:test运行服务器

在模拟模式下,服务器将模拟所有 Anki 操作,而无需实际连接 Anki。这对于测试 Claude 集成非常有用,并且不会影响数据更改的风险。

发展

要使用热重载以开发模式运行服务器:

npm run dev

对于启用模拟模式的开发:

npm run dev:test

执照

麻省理工学院

Available Tools

2 tools
get_leech_cardsB

Retrieve cards tagged as leeches from Anki

ParametersJSON Schema
NameRequiredDescriptionDefault
detailedNoWhether to return detailed card information or just IDs
countNoNumber of random cards to return (defaults to all)

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. While 'Retrieve' implies a read operation, it doesn't specify whether this requires authentication, how results are returned (format, pagination), error conditions, or performance characteristics. The description is minimal and lacks behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with zero wasted words. It's appropriately sized for a simple retrieval tool and front-loads the essential information. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a retrieval tool with 2 parameters and 100% schema coverage but no annotations or output schema, the description provides basic purpose but lacks behavioral context and usage guidance. It's minimally adequate but has clear gaps in explaining how the tool behaves and when to use it.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds no parameter-specific information beyond what's in the schema. Baseline 3 is appropriate when the schema does the heavy lifting, though no additional semantic context is provided.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Retrieve') and target resource ('cards tagged as leeches from Anki'), making the purpose immediately understandable. It doesn't explicitly differentiate from its sibling tool 'tag_reviewed_cards', but the distinction is implied through the different operations (retrieval vs tagging).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives or in what context. The description only states what the tool does, without mentioning prerequisites, timing considerations, or relationship to the sibling tool beyond their different names.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

tag_reviewed_cardsC

Add a 'reviewed on date' tag to specified cards

ParametersJSON Schema
NameRequiredDescriptionDefault
card_idsYesArray of card IDs to tag as reviewed
custom_tag_prefixNoCustom prefix for the tag (default: '見直し')

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It implies a mutation ('Add'), but doesn't clarify if this is destructive (e.g., overwrites existing tags), requires authentication, has side effects, or includes error handling. The description is minimal and lacks critical behavioral details for a write operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core action and resource, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's mutation nature (adding tags), no annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like permissions, side effects, or return values, leaving significant gaps for an AI agent to understand how to use it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents both parameters (card_ids and custom_tag_prefix). The description adds no additional parameter semantics beyond implying the tag format ('reviewed on date'), which is already suggested by the schema's default value for custom_tag_prefix. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Add') and target resource ('tag to specified cards'), with the specific tag content 'reviewed on date' mentioned. However, it doesn't differentiate from the sibling tool 'get_leech_cards' (which presumably retrieves rather than modifies cards), so it doesn't fully distinguish from alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention the sibling tool 'get_leech_cards' or any other context for selection, nor does it specify prerequisites like required permissions or system states.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 2 tool updates
    • First observedget_leech_cards
    • First observedtag_reviewed_cards

TDQS

B3.1/5.0

Scored across 2 tools

Disambiguation5/5

The two tools have completely distinct purposes: one retrieves cards with a specific tag, while the other adds a tag to cards. There is no overlap in functionality or ambiguity between them.

Naming Consistency5/5

Both tools follow a consistent verb_noun pattern (get_leech_cards, tag_reviewed_cards) with clear actions and objects, making them predictable and easy to understand.

Tool Count2/5

With only 2 tools, the server feels thin for an Anki integration, lacking basic operations like creating cards, reviewing cards, or managing decks. This minimal set limits agent workflows significantly.

Completeness2/5

The toolset is severely incomplete for an Anki server, missing core CRUD operations for cards, decks, and reviews. Agents cannot perform essential tasks like adding new cards or scheduling reviews, leading to dead ends.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers