Labsco
letuanvu08 logo

Anki MCP

โ˜… 2

from letuanvu08

A Model Context Protocol (MCP) server that provides seamless integration with Anki, enabling AI assistants to interact with your flashcard collection. Create, read, update, and manage Anki cards programmatically through a standardized interface.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeQuick setup

Anki MCP Server

A Model Context Protocol (MCP) server that provides seamless integration with Anki, enabling AI assistants to interact with your flashcard collection. Create, read, update, and manage Anki cards programmatically through a standardized interface.

Features

  • ๐ŸŽด Card Management: Create, retrieve, and update flashcards with full field customization
  • ๐Ÿ” Smart Search: Query cards by ID, keywords, tags, decks, or any Anki search syntax
  • ๐Ÿ“Š Review Integration: Access due cards, new cards, and answer cards programmatically
  • ๐ŸŽต Media Support: Automatic handling of audio and images (local files, URLs, or existing media)
  • ๐Ÿ”„ Batch Operations: Create multiple cards efficiently in a single operation
  • ๐ŸŽฏ Generic Tools: Flexible tools that work with any deck, note type, and field configuration

Resources

  • anki://search/deckcurrent - All cards from current deck
  • anki://search/isdue - Cards due for review
  • anki://search/isnew - New unseen cards
  • Custom queries: anki://search/tag:vocabulary, anki://search/deck:Spanish, etc.

Tools

  • update_card - Update cards/notes (answer, update fields, update tags)
  • add_card - Create a new flashcard with custom deck, model, and fields
  • batch_add_card - Create multiple flashcards at once
  • get_due_cards - Get list of cards due for review
  • get_new_cards - Get list of new unseen cards
  • get_card - Retrieve detailed card information by ID or query

Development

Install dependencies:

npm install

Build the server:

npm run build

For development with auto-rebuild:

npm run watch

Media Files

How Media Files Are Handled

When you add cards with images or audio files, the server automatically handles different types of media sources:

  1. Local File Paths: If you provide an absolute path to a file on your computer (e.g., /Users/mycomputer/Documents/images/prune.jpg), the server will:

    • Read the file from your disk
    • Convert it to base64
    • Upload it to Anki's media collection using the storeMediaFile API
    • Reference it in the card by filename
  2. URLs: If you provide a URL (e.g., https://example.com/image.jpg), Anki-Connect will download the file automatically when the card is created.

  3. Existing Media: If you provide just a filename (e.g., prune.jpg), it assumes the file already exists in Anki's media folder.

Troubleshooting Image Issues

If images don't show up properly in Anki:

  1. Check the file path: Make sure the path to your image file is correct and the file exists
  2. File permissions: Ensure the file is readable by the application
  3. Supported formats: Anki supports common image formats (JPG, PNG, GIF, SVG, WebP)
  4. File size: Very large files might cause issues
  5. Special characters: Avoid special characters in filenames when possible

The server will now automatically handle local file paths, so you don't need to manually copy images to Anki's media folder anymore.