Automatically creates and imports flashcards into Anki via AnkiConnect, enabling real-time flashcard generation and deck management
Extracts content from Notion pages, specifically recognizing toggle blocks as question-answer pairs for flashcard generation
Uses OpenAI's API to refine and improve the quality of generated flashcards from extracted content
Notion-Anki MCP Server
A Model Context Protocol (MCP) server that automatically generates Anki flashcards from Notion pages. This tool extracts questions and answers from Notion toggle blocks and converts them into structured Anki cards using OpenAI's API, with real-time import via AnkiConnect.
Use Cases
Students: Convert study notes from Notion into flashcards for spaced repetition
Professionals: Transform training materials and documentation into memorable cards
Educators: Quickly create quiz content from lesson plans
Researchers: Convert paper summaries and key concepts into study materials
Features
Notion Integration: Extracts content from Notion pages via official API
Smart Parsing: Recognizes toggle blocks as question-answer pairs
AI Enhancement: Uses OpenAI to refine and improve flashcard quality
Real-time Import: Automatically adds cards to Anki via AnkiConnect
MCP Protocol: Works with MCP-compatible clients like Claude Desktop
Prerequisites
Before setting up this project, ensure you have:
Notion API Access
Create a Notion integration
Get your API key from the integration settings
OpenAI API Access
Sign up for OpenAI API
Create an API key with sufficient credits
Anki Setup
Install Anki desktop application
Install AnkiConnect add-on
Keep Anki running during flashcard generation
Python Environment
Python 3.8 or higher
pip package manager
Quick Start
1. Clone the Repository
2. Install Dependencies
3. Environment Configuration
Edit .env
with your API keys:
4. Start the MCP Server
How to Structure Your Notion Pages
For the tool to work effectively, structure your Notion pages as follows:
Toggle Block Format
Create toggle blocks where:
Toggle title = Your question
Toggle content = The answer/explanation
Example structure:
Supported Content Types
Within toggle blocks, the tool supports:
Plain text paragraphs
Bulleted lists
Numbered lists
Basic formatting (bold, italic, etc.)
Usage
Via MCP Client (Recommended)
Configure your MCP client to connect to this server
Use the available tools:
search_page
: Find a Notion page by nameextract_page_content
: Extract questions and answers from a pagegenerate_flashcards
: Create and import Anki cards
Direct Python Usage
API Reference
MCP Tools
search_page
Searches for a Notion page by name.
Parameters:
page_name
(string): The title of the Notion page to search for
Returns:
extract_page_content
Extracts questions and answers from a Notion page.
Parameters:
page_id
(string): The UUID of the Notion page
Returns:
generate_flashcards
Creates Anki flashcards from extracted content.
Parameters:
page_name
(string): Name for the Anki decktopics
(array): List of topics/headings from the pagecontent
(object): Question-answer pairs
Returns:
Troubleshooting
Common Issues
"Page not found" Error
Ensure the page name matches exactly (case-sensitive)
Verify your Notion integration has access to the page
Check that the page is in a shared workspace
"AnkiConnect not responding" Error
Make sure Anki desktop is running
Verify AnkiConnect add-on is installed and enabled
Check that Anki isn't in review mode or showing a dialog
"OpenAI API Error" Error
Verify your OpenAI API key is correct and active
Check your API usage limits and billing
Ensure you have access to the GPT-4 models
Empty flashcards generated
Check that your Notion page uses the toggle block format
Ensure toggle blocks contain text content
Verify the page has actual content, not just headers
Debug Mode
Enable debug logging by modifying server.py
:
Contributing
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature
)Commit your changes (
git commit -m 'Add amazing feature'
)Push to the branch (
git push origin feature/amazing-feature
)Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Notion API for excellent documentation
AnkiConnect for Anki integration
Model Context Protocol for the MCP standard
OpenAI for powerful language models
Made with ❤️ for better learning and knowledge retention
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Automatically generates Anki flashcards from Notion pages by extracting questions and answers from toggle blocks. Uses OpenAI to enhance card quality and imports them directly into Anki via AnkiConnect for spaced repetition learning.
Related MCP Servers
- AsecurityFlicenseAqualityA Model Context Protocol server that enables LLMs to interact with Anki flashcard software through AnkiConnect, allowing for creation and management of flashcards, decks, and note types.Last updated -47130
- AsecurityAlicenseAqualityA TypeScript-based server that integrates with Anki via the AnkiConnect plugin, allowing you to manage flashcard decks, note models, and create Anki notes using natural language.Last updated -3073MIT License
- -securityAlicense-qualityA Model Context Protocol server that allows LLMs to interact with Anki flashcard software, enabling functions like creating decks, adding notes, searching cards, and managing flashcard content through natural language.Last updated -471MIT License