A command-line tool that analyzes Magic: The Gathering decklists using the Scryfall API.
- Mana curve breakdown with ASCII bar chart
- Color and card type distribution
- Average CMC (excluding lands)
- Format legality check
- Estimated deck price (USD and EUR)
- Local card cache to avoid redundant API calls
Python 3.10+ and the requests library:
pip install requests
python main.py <decklist> # basic analysis
python main.py <decklist> --format modern # include legality check
python main.py <decklist> --no-price # skip price data
python main.py <decklist> --output json # output as JSON
python main.py <decklist> --clear-cache # wipe cache, then analyze
python main.py --clear-cache # wipe cache and exit
Supported --format values: standard, pioneer, modern, legacy, vintage, commander
Plain .txt file, one card per line. All of these are supported:
4 Lightning Bolt
4x Lightning Bolt
4X Lightning Bolt
Lightning Bolt x4
Lightning Bolt # no quantity — assumes 1
// this is a comment
Creatures # section headers are ignored
mtg-deck-analyzer/
├── main.py # entry point, argparse
├── parser.py # decklist file parsing
├── scryfall.py # Scryfall API client
├── cache.py # local JSON card cache
├── analyzer.py # deck statistics
├── display.py # terminal output formatting
└── cache/ # auto-created, stores cached card data
python -m unittest discover -p "test_*.py" -v
105 tests across test_parser.py, test_analyzer.py, test_cache.py, and test_scryfall.py.
- Basic lands (Forest, Mountain, etc.) have no price data on Scryfall and are excluded from price totals
- Single-word card names without a quantity (e.g.
Brainstorm) will be skipped — add a quantity to include them - Card data is cached in
cache/cards.jsonafter the first fetch; use--clear-cacheto refresh it