anki-mcp-server

AndrewGEvans95/anki-mcp-server

3.2

If you are the rightful owner of anki-mcp-server 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.

Anki MCP Server is a Model Context Protocol server that facilitates the creation and management of Anki flashcards through the AnkiConnect add-on.

Tools
  1. create_anki_note

    Create a new Anki flashcard.

  2. create_cloze_note

    Create a cloze deletion card.

  3. bulk_create_notes

    Create multiple notes at once.

  4. create_anki_deck

    Create a new deck.

  5. list_anki_decks

    List all available decks.

  6. list_anki_models

    List all available note types/models.

  7. get_anki_model_fields

    Get field names for a specific model.

Anki MCP Server

A Model Context Protocol (MCP) server that enables AI assistants to create and manage Anki flashcards through the AnkiConnect add-on.

Features

  • βœ… Create individual Anki notes/flashcards
  • βœ… Create cloze deletion cards
  • βœ… Bulk create multiple notes at once
  • βœ… Create new decks
  • βœ… List available decks and note types
  • βœ… Get model field information
  • βœ… Support for tags and duplicate handling

Prerequisites

  1. Anki - Download and install from ankiweb.net
  2. AnkiConnect Add-on - Install the AnkiConnect add-on (code: 2055492159)
    • In Anki: Tools β†’ Add-ons β†’ Get Add-ons β†’ Enter code 2055492159
    • Restart Anki after installation

Installation

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

Usage

Running the Server

Start the MCP server:

npm start

Or for development:

npm run dev

Available Tools

create_anki_note

Create a new Anki flashcard.

Parameters:

  • deckName (string, required): Name of the deck
  • modelName (string, optional): Note type (default: "Basic")
  • fields (object, required): Field values (e.g., {"Front": "Question", "Back": "Answer"})
  • tags (array, optional): Tags to add
  • allowDuplicate (boolean, optional): Allow duplicate cards

Example:

{
  "deckName": "Spanish Vocabulary",
  "fields": {
    "Front": "ΒΏCΓ³mo estΓ‘s?",
    "Back": "How are you?"
  },
  "tags": ["spanish", "greetings"]
}
create_cloze_note

Create a cloze deletion card.

Parameters:

  • deckName (string, required): Name of the deck
  • text (string, required): Text with cloze deletions (e.g., "{{c1::Paris}} is the capital of France")
  • extra (string, optional): Additional information
  • tags (array, optional): Tags to add

Example:

{
  "deckName": "Geography",
  "text": "{{c1::Paris}} is the capital of {{c2::France}}",
  "tags": ["geography", "capitals"]
}
bulk_create_notes

Create multiple notes at once.

Parameters:

  • notes (array, required): Array of note objects

Example:

{
  "notes": [
    {
      "deckName": "Math",
      "fields": {"Front": "2 + 2", "Back": "4"}
    },
    {
      "deckName": "Math", 
      "fields": {"Front": "3 Γ— 3", "Back": "9"}
    }
  ]
}
create_anki_deck

Create a new deck.

Parameters:

  • deckName (string, required): Name of the new deck
list_anki_decks

List all available decks.

list_anki_models

List all available note types/models.

get_anki_model_fields

Get field names for a specific model.

Parameters:

  • modelName (string, required): Name of the model

Integration with AI Assistants

This MCP server can be integrated with AI assistants that support the Model Context Protocol. The assistant can then:

  • Create flashcards from study materials
  • Generate cloze deletion cards from text
  • Convert questions and answers into Anki cards
  • Organize cards into appropriate decks
  • Bulk import flashcard sets

Configuration

The server connects to AnkiConnect on http://localhost:8765 by default. Make sure:

  1. Anki is running
  2. AnkiConnect add-on is installed and enabled
  3. No firewall is blocking the connection

Troubleshooting

"Failed to connect to AnkiConnect"

  • Ensure Anki is running
  • Verify AnkiConnect add-on is installed (code: 2055492159)
  • Check that AnkiConnect is listening on port 8765

"AnkiConnect error: deck was not found"

  • The specified deck doesn't exist
  • Use create_anki_deck first or list_anki_decks to see available decks

"AnkiConnect error: model was not found"

  • The specified note type doesn't exist
  • Use list_anki_models to see available note types
  • Common types: "Basic", "Basic (and reversed card)", "Cloze"

Development

Project Structure

anki-mcp-server/
β”œβ”€β”€ src/
β”‚   └── index.ts          # Main server code
β”œβ”€β”€ dist/                 # Compiled JavaScript
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
└── README.md

Building

npm run build

Development Mode

npm run dev

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Related Projects