Skip to main content

A Model Context Protocol server for creating Anki flashcards via AnkiConnect

Project description

Anki MCP Connector

A Model Context Protocol (MCP) server that enables AI assistants to create Anki flashcards programmatically via AnkiConnect.

Overview

Anki MCP Connector provides a set of tools that allow MCP clients (like Claude Desktop) to interact with Anki, enabling automated flashcard creation and deck management. This makes it easy to create study materials directly from your conversations with AI assistants.

Features

  • 📚 List all Anki decks - Get all available decks in your Anki collection
  • 🎴 Get note type models - Discover available card templates (Basic, Cloze, etc.)
  • 🔍 Inspect model fields - See what fields are available for each note type
  • Create flashcards - Add notes with custom fields, tags, and content
  • 🏷️ Automatic tagging - All created cards are tagged with "Automatic" for easy filtering

Prerequisites

  1. Anki - Download and install from ankiweb.net
  2. AnkiConnect - Install the AnkiConnect add-on for Anki:
    • Open Anki
    • Go to Tools → Add-ons → Get Add-ons
    • Enter code: 2055492159
    • Restart Anki

AnkiConnect will run automatically whenever Anki is open, listening on http://127.0.0.1:8765.

Installation

pip install anki-mcp-connector

Usage

With Claude Desktop

Add this to your Claude Desktop configuration file:

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

Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "anki": {
      "command": "anki-mcp-connector"
    }
  }
}

Then restart Claude Desktop. With Anki running, you can now ask Claude to create flashcards!

Example Conversations

You: "Create a flashcard with 'What is MCP?' on the front and 'Model Context Protocol' on the back in my 'Programming' deck"

You: "Add 5 vocabulary cards for common Spanish greetings to my Spanish deck"

You: "Create a cloze deletion card about Python list comprehensions"

Available Tools

The MCP server exposes the following tools:

get_deck_list()

Returns a list of all deck names in your Anki collection.

get_model_names()

Returns available note type models (e.g., "Basic", "Basic (and reversed card)", "Cloze").

get_model_field_names(modelName: str)

Returns the field names for a specific model.

Example: For "Basic" model, returns ["Front", "Back"]

add_note(deckName: str, modelName: str, fields: dict, tags: list = None)

Creates a new flashcard in the specified deck.

Parameters:

  • deckName: Target deck name
  • modelName: Note type to use
  • fields: Dictionary mapping field names to content
  • tags: Optional list of tags (always includes "Automatic")

Example:

add_note(
    deckName="Japanese",
    modelName="Basic",
    fields={"Front": "こんにちは", "Back": "Hello"},
    tags=["greetings", "basic"]
)

Development

Setup

# Clone the repository
git clone https://github.com/yourusername/anki-mcp-connector.git
cd anki-mcp-connector

# Install in development mode
pip install -e .

Building

# Install build tools
pip install build twine

# Build the package
python -m build

# Upload to PyPI (requires credentials)
python -m twine upload dist/*

Troubleshooting

"Connection refused" errors

  • Make sure Anki is running
  • Verify AnkiConnect is installed (Tools → Add-ons)
  • Check that AnkiConnect is listening on port 8765

"Deck not found" errors

  • Use get_deck_list() to see exact deck names (case-sensitive)
  • Create the deck in Anki first if it doesn't exist

Duplicate cards

The server prevents duplicates by default. If a card with the same content exists, you'll get an error.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details.

Links


Note: This package requires Anki to be running with the AnkiConnect add-on installed. It communicates locally and does not send any data over the internet.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anki_mcp_connector-0.1.3.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anki_mcp_connector-0.1.3-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file anki_mcp_connector-0.1.3.tar.gz.

File metadata

  • Download URL: anki_mcp_connector-0.1.3.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for anki_mcp_connector-0.1.3.tar.gz
Algorithm Hash digest
SHA256 237bec02e4fe02d32bbce3b7cec16c7087ac18e106de430b175a0bd565fb21a9
MD5 a5bf1b3afaed76a7dc0303219e0c67c2
BLAKE2b-256 3f646edd15aa46767eb5c104f8cff7c2264e4427f1d694e20a54abe04b13a495

See more details on using hashes here.

File details

Details for the file anki_mcp_connector-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for anki_mcp_connector-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 12e56cf035bc8e0eaf8d37be1d8982db709ae64b505e1b07cb7153d5eed723ea
MD5 499ff9d3091b0aa9239b367bdff12f4c
BLAKE2b-256 b06e7abd690342d0e47768c0da3d97c9c3da032d55e8e65bcc102bcd3f8a6b7f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page