Anki Connect MCP Server

Anki Connect MCP Server

Enables AI assistants to interact with Anki flashcard collections through the AnkiConnect add-on, allowing creation, modification, searching, and management of flashcards and decks.

Category
访问服务器

README

Anki Connect MCP Server

A Model Context Protocol (MCP) server that provides seamless integration with Anki through the AnkiConnect add-on. This server enables AI assistants and other MCP clients to interact with your Anki flashcard collection programmatically.

Project

What is Anki Connect?

AnkiConnect is a powerful Anki add-on that exposes Anki's functionality through a REST API. It allows external applications to:

  • Create, modify, and delete flashcards
  • Manage decks and their configurations
  • Control Anki's GUI programmatically
  • Search and retrieve card information
  • Manage tags and note types
  • Perform bulk operations on cards and notes

What is MCP (Model Context Protocol)?

The Model Context Protocol is a standardized way for AI assistants to connect to external data sources and tools. This MCP server acts as a bridge between MCP clients (like Claude Desktop) and AnkiConnect, allowing AI assistants to help you manage your Anki flashcards naturally through conversation.

Features

This MCP server provides comprehensive access to AnkiConnect functionality through the following tools:

Flashcard Management

  • create_flashcard() - Create new flashcards with front and back content
  • add_note() - Add notes with custom fields and tags
  • add_notes() - Bulk add multiple notes
  • update_note_fields() - Update existing note fields
  • find_notes() - Search for notes using Anki's query syntax

Deck Management

  • deck_names() - Get all deck names
  • deck_names_and_ids() - Get deck names with their IDs
  • change_deck() - Move cards between decks
  • delete_decks() - Delete decks and optionally their cards
  • get_deck_config() - Retrieve deck configuration settings

Card Operations

  • find_cards() - Search for cards
  • cards_info() - Get detailed card information
  • suspend() / unsuspend() - Suspend/unsuspend cards
  • are_suspended() / are_due() - Check card status

GUI Control

  • gui_deck_browser() - Open deck browser
  • gui_deck_review() - Start deck review
  • gui_browse() - Open card browser with search
  • gui_add_cards() - Open add cards dialog

Utility Tools

  • version() - Get AnkiConnect version
  • get_tags() - Retrieve all tags
  • multi() - Execute multiple AnkiConnect requests in batch

Prerequisites

1. Install AnkiConnect Add-on

  1. Open Anki
  2. Go to Tools → Add-ons
  3. Click Get Add-ons...
  4. Enter the code: 2055492159
  5. Click OK and restart Anki

2. Configure AnkiConnect (Optional)

AnkiConnect works out of the box, but you can customize its settings:

  1. Go to Tools → Add-ons
  2. Select AnkiConnect and click Config
  3. Modify settings if needed (default port is 8765)
  4. Restart Anki after making changes

Installation

  1. Clone this repository:
git clone https://github.com/spacholski1225/anki-connect-mcp.git
cd anki-connect-mcp
  1. Install dependencies:
npm install
  1. Build the project:
npm run build

MCP Client Configuration

Claude Desktop

To use this MCP server with Claude Desktop, add the following configuration to your MCP settings file:

Location of MCP configuration file:

  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

Configuration Options:

Option 1: Using Node.js (Local Installation)

{
  "mcpServers": {
    "anki-connect-mcp": {
      "command": "node",
      "args": [
        "dist/index.js"
      ],
      "env": {},
      "disabled": false,
      "alwaysAllow": [
        "deck_names",
        "cards_info",
        "deck_names_and_ids",
        "gui_deck_browser"
      ]
    }
  }
}

Option 2: Using npx (NPM Package)

Then configure your MCP client:

{
  "mcpServers": {
    "anki-connect": {
      "command": "npx",
      "args": [
        "@spacholski1225/anki-connect-mcp"
      ],
      "env": {},
      "disabled": false,
      "alwaysAllow": [
        "deck_names",
        "cards_info",
        "deck_names_and_ids",
        "gui_deck_browser"
      ]
    }
  }
}

Option 3: Using Docker

{
  "mcpServers": {
    "anki-connect": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "--network=host",
        "-e", "ANKI_CONNECT_URL=http://host.docker.internal:8765",
        "spacholski/anki-connect-mcp:latest"
      ],
      "env": {},
      "disabled": false,
      "alwaysAllow": [
        "deck_names",
        "cards_info",
        "deck_names_and_ids",
        "gui_deck_browser"
      ]
    }
  }
}

Docker-Specific AnkiConnect Configuration:

When using the Docker option, you must configure AnkiConnect with specific settings to allow Docker container access:

  1. Go to Tools → Add-ons in Anki
  2. Select AnkiConnect and click Config
  3. Update the configuration with the following settings:
{
    "apiKey": null,
    "apiLogPath": null,
    "ignoreOriginList": [],
    "webBindAddress": "0.0.0.0",
    "webBindPort": 8765,
    "webCorsOriginList": [
        "http://localhost",
        "http://host.docker.internal",
        "http://host.docker.internal:3000"
    ]
}

Key Docker Configuration Points:

  • webBindAddress: "0.0.0.0" - Allows AnkiConnect to accept connections from any IP address (required for Docker containers)
  • webCorsOriginList - Must include "http://host.docker.internal" and related origins to allow cross-origin requests from Docker containers
  • Restart Anki after making these configuration changes

Important Notes:

  • For Node.js option: Replace the path in args with the actual path to your built index.js file
  • For npx option: Uses the published NPM package @spacholski1225/anki-connect-mcp - no local installation required
  • For Docker option: Uses the pre-built Docker image spacholski/anki-connect-mcp:latest
  • The alwaysAllow array contains tools that won't require confirmation each time
  • Make sure Anki is running with AnkiConnect enabled before using the MCP server
  • For Docker option, the --network=host flag allows the container to access AnkiConnect on the host machine

Usage Examples

Once configured with an MCP client like Claude Desktop, you can interact with your Anki collection naturally:

  • "Create a flashcard about the capital of France"
  • "Show me all my deck names"
  • "Find all cards tagged with 'vocabulary'"
  • "Suspend all cards in the 'Difficult Words' deck"
  • "Open the deck browser in Anki"

Troubleshooting

Common Issues

  1. Connection refused: Make sure Anki is running and AnkiConnect is installed
  2. Port conflicts: Check if port 8765 is available or configure AnkiConnect to use a different port
  3. Permission errors: Ensure the MCP server has proper file system permissions
  4. Tool not found: Verify the MCP client configuration and restart the client

Contributing

Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.

License

ISC License

References

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选