An AI-powered Magic: The Gathering deck analysis tool that provides detailed advice for improving your decks.
- Analyze decklists and get AI-powered suggestions
- Support for all major Magic formats
- Real-time progress updates during analysis
- Downloadable markdown reports
- Card suggestions based on deck strategy
- Python 3.8 or higher
- MongoDB database
- OpenAI (or compatible) API access
- Clone the repository:
git clone https://github.com/Ari-Zerner/mtg-ai.git
cd mtg-ai- Create and activate a virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows, use: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Create a
.envfile in the project root with the following variables:
API_KEY # API key for your LLM provider
API_BASE_URL # API base URL for your LLM provider
CHEAP_MODEL # Model for basic tasks
GOOD_MODEL # Model for complex analysis
# Optional configuration
MONGO_URI # MongoDB connection string, for caching Scryfall results
LOG_LEVEL # Logging level (default: INFO)
MAX_CARDS_PER_QUERY # Maximum number of cards to fetch per Scryfall query (default: 525)
MAX_CARDS_TO_CONSIDER # Maximum number of most-relevant potential additions to consider (default: 150)
MIN_RELEVANCE_SCORE # Minimum relevance score for suggestions (default: 50)
- Start the Flask development server:
python app.py- Open your web browser and navigate to:
http://localhost:5000
- Enter your decklist in the main text area
- Select the format from the dropdown (optional)
- Add any additional context or requirements (optional)
- Click "Get Advice" to start the analysis
- Wait for the analysis to complete
- View and optionally download the generated report
The key components of the application are:
app.py: Flask web application and job managementmtgai.py: Core deck analysis and AI interaction logictemplates/: HTML templates for the web interface