mcp-server-anki

here-tunan/mcp-server-anki

3.3

If you are the rightful owner of mcp-server-anki and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The MCP Server Anki bridges Anki with AI tools, enhancing flashcard management and learning assistance through the Model Context Protocol.

Tools
7
Resources
0
Prompts
0

MCP Server Anki

Anki Logo

MCP TypeScript AnkiConnect

| English

A Model Context Protocol (MCP) server that bridges Anki with AI tools, enabling intelligent flashcard management and learning assistance.

šŸ’” Compatibility: This server works with any MCP-compatible AI tool including Claude Code, Cline, Zed AI, and more. We use Claude Code as an example in this documentation, but the setup process is similar for other tools.

🌟 Features

  • šŸ“š Deck Management: Get deck lists, view deck statistics
  • šŸ” Card Search: Search cards using Anki's advanced query syntax
  • āž• Smart Creation: Create and manage Anki cards with AI assistance
  • āœļø Card Editing: Update existing card fields and content
  • šŸ—‘ļø Card Deletion: Delete unwanted cards and notes
  • šŸ“Š Data Analysis: Get learning statistics and progress information
  • šŸ”§ Template Management: View and use different note types

šŸ“‹ Prerequisites

  1. Anki Desktop - Download Anki
  2. AnkiConnect Plugin - Install in Anki (Code: 2055492159)
  3. Node.js - Version 16 or higher
  4. MCP-compatible AI Tool - Such as:

šŸš€ Quick Start

1. Install AnkiConnect

In Anki:

  1. Tools → Add-ons → Get Add-ons
  2. Enter code: 2055492159
  3. Restart Anki

2. Configure Your MCP Client

The following examples use Claude Code, but the configuration is similar for other MCP-compatible tools.

Option A: Using Command Line
# For Claude Code
claude mcp add anki -- npx mcp-server-anki

# For other tools, consult their documentation for the equivalent command
Option B: Manual Configuration

Add the server to your MCP client's configuration file:

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

šŸ“– Usage Guide

Basic Workflow

  1. Start Anki - Ensure Anki is running with AnkiConnect enabled
  2. Start MCP Server - Automatically started by Claude Code
  3. Use AI Tools - Interact with Anki through Claude Code

Example Conversations

User: Show me the learning progress for my "English Vocabulary" deck

Claude: I'll check the statistics for your "English Vocabulary" deck...
[Calls get_deck_stats tool]

User: Create a new English word card for "ephemeral"

Claude: I'll create this word card for you...
[Calls add_note tool]

šŸ› ļø Available Tools

Tool NameDescriptionParameters
get_deck_namesGet all deck namesNone
get_cards_in_deckGet cards from a specific deckdeckName
get_deck_statsGet deck statisticsdeckName
search_cardsSearch cardsquery
add_noteAdd new notedeckName, modelName, fields, tags
update_noteUpdate existing note fieldsnoteId, fields
get_note_infoGet detailed note informationnoteId
delete_notesDelete one or more notesnoteIds
get_modelsGet all note typesNone
get_model_fieldsGet note type fieldsmodelName

šŸ—ļø Project Structure

mcp-server-anki/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ index.ts           # MCP server entry point
│   ā”œā”€ā”€ ankiConnect.ts      # AnkiConnect API client
│   └── tools/              # MCP tool definitions
│       ā”œā”€ā”€ deckTools.ts    # Deck-related tools
│       ā”œā”€ā”€ cardTools.ts    # Card-related tools
│       └── noteTools.ts    # Note-related tools
ā”œā”€ā”€ dist/                   # Compiled JavaScript
ā”œā”€ā”€ package.json
ā”œā”€ā”€ tsconfig.json
└── README.md

šŸ”§ Development

Build Commands

# Development mode (watch for changes)
npm run dev

# Production build
npm run build

Architecture

Claude Code (MCP Client) ←→ Anki MCP Server ←→ AnkiConnect ←→ Anki Desktop

šŸ“ API Documentation

get_deck_names

Get a list of all deck names.

Returns:

["Default", "English Vocabulary", "Programming"]

search_cards(query)

Search cards using Anki query syntax.

Parameters:

  • query: Anki query string (e.g., deck:English is:due)

Query Syntax Examples:

  • deck:DeckName - Specific deck
  • tag:TagName - By tag
  • is:due - Due cards
  • is:new - New cards
  • added:7 - Cards added in last 7 days

add_note

Add a new note to Anki.

Parameters:

  • deckName: Target deck name
  • modelName: Note type (e.g., "Basic", "Cloze")
  • fields: Field content object
  • tags: Tag array (optional)

Example:

{
  "deckName": "English Vocabulary",
  "modelName": "Basic",
  "fields": {
    "Front": "ephemeral",
    "Back": "lasting for a very short time"
  },
  "tags": ["vocabulary", "adjective"]
}

update_note

Update fields of an existing note.

Parameters:

  • noteId: The ID of the note to update
  • fields: Object with field names and new values

Example:

{
  "noteId": 1234567890,
  "fields": {
    "Back": "lasting for an extremely short time"
  }
}

get_note_info

Get detailed information about a specific note.

Parameters:

  • noteId: The ID of the note to query

Returns:

{
  "noteId": 1234567890,
  "modelName": "Basic",
  "fields": {
    "Front": "ephemeral",
    "Back": "lasting for a very short time"
  },
  "tags": ["vocabulary", "adjective"]
}

delete_notes

Delete one or more notes.

Parameters:

  • noteIds: Array of note IDs to delete

Example:

{
  "noteIds": [1234567890, 9876543210]
}

šŸ”§ Building from Source

If you want to contribute or customize the server:

# Clone the repository
git clone https://github.com/here-tunan/mcp-server-anki.git
cd mcp-server-anki

# Install dependencies
npm install

# Build TypeScript
npm run build

To use your local build with Claude Code, configure it with:

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

šŸ¤ Contributing

Issues and Pull Requests are welcome!

šŸ“„ License

Apache License

šŸ”— Links

ā“ FAQ

Q: AnkiConnect connection failed?

A: Ensure Anki is running and AnkiConnect plugin is installed and enabled. Default port is 8765.

Q: How to customize note types?

A: After creating custom note types in Anki, use get_models and get_model_fields tools to view available fields.

Q: Mobile support?

A: Currently only supports desktop Anki due to AnkiConnect dependency.


Made with ā¤ļø for Anki learners and AI enthusiasts