magic-the-gathering-mcp

AImaginationLab/magic-the-gathering-mcp

3.2

If you are the rightful owner of magic-the-gathering-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A fast, local MCP server and CLI for Magic: The Gathering, offering card search, artwork browsing, price checking, deck validation, and AI-powered deck building assistance.

Tools
5
Resources
0
Prompts
0

Magic: The Gathering MCP Server

A fast, local MCP server and CLI for Magic: The Gathering. Search 33,000+ cards, browse artwork, check prices, validate decks, and get AI-powered deck building assistance—all powered by offline SQLite databases.

Quick Start

# Install
git clone git@github.com:aimaginationlab/magic-the-gathering-mcp.git
cd magic-the-gathering-mcp
uv sync

# Download AllPrintings.sqlite from https://mtgjson.com/downloads/all-files/
# Place in resources/ directory

# Run the CLI
uv run mtg repl

Two Ways to Use

1. Interactive CLI

A themed REPL for quick card lookups, artwork browsing, and deck analysis.

uv run mtg repl

    ╔╦╗╔═╗╔═╗╦╔═╗  ┌┬┐┬ ┬┌─┐
    ║║║╠═╣║ ╦║║     │ ├─┤├┤
    ╩ ╩╩ ╩╚═╝╩╚═╝   ┴ ┴ ┴└─┘
  ╔═╗╔═╗╔╦╗╦ ╦╔═╗╦═╗╦╔╗╔╔═╗
  ║ ╦╠═╣ ║ ╠═╣║╣ ╠╦╝║║║║║ ╦
  ╚═╝╩ ╩ ╩ ╩ ╩╚═╝╩╚═╩╝╚╝╚═╝

"Every planeswalker was once a beginner."

Tapping mana sources...


Library loaded! 33,044 cards across 839 sets
Type a card name to look it up, or ? for help

⚡ Sol Ring
⚡ art Lightning Bolt
⚡ set final fantasy
⚡ search dragon

Features:

  • Just type a card name to look it up
  • art <card> — Browse all unique artworks, pick one to display
  • set <name> — Find sets by name or code
  • search, rulings, legal, price, random
  • Card images display directly in iTerm2, Kitty, or any true-color terminal

2. MCP Server

Integrate with Claude Desktop or any MCP-compatible client for AI-powered assistance.

uv run mtg-mcp

Add to Claude Desktop config (default OSX: ~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "mtg": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/magic-the-gathering-mcp", "mtg-mcp"]
    }
  }
}

Then ask Claude things like:

  • "Build me a budget Mono-Red Commander deck under $50"
  • "What are the best counterspells in Modern?"
  • "Compare Lightning Bolt vs Chain Lightning"
  • "Is this deck legal in Pioneer?" (paste your decklist)

Tools

Card Lookup

ToolDescription
search_cardsFilter by name, colors, type, CMC, keywords, format, rarity, set
get_cardFull card details with images and prices
get_card_rulingsOfficial rulings from Gatherer
get_card_legalitiesFormat legality (Standard, Modern, Commander, etc.)
get_random_cardDiscover something new

Images & Prices

ToolDescription
get_card_imageImage URLs in multiple sizes
get_card_printingsEvery printing with artwork and prices
get_card_priceCurrent USD/EUR prices
search_by_priceFind cards in a price range

Deck Analysis

ToolDescription
validate_deckCheck format legality, deck size, copy limits
analyze_mana_curveCMC distribution and average
analyze_colorsColor balance and recommended land ratios
analyze_deck_compositionCreature/spell/land breakdown
analyze_deck_priceTotal cost and expensive cards

Sets

ToolDescription
get_setsList and search all sets
get_setSet details (release date, card count, type)
get_database_statsDatabase version and statistics

CLI Commands

# Card commands
mtg card search -n "Lightning" -c R           # Search red cards with "Lightning"
mtg card get "Sol Ring"                       # Card details
mtg card rulings "Doubling Season"            # Rulings
mtg card price "Black Lotus"                  # Prices

# Set commands
mtg set list --type expansion                 # List expansion sets
mtg set get DOM                               # Dominaria details

# Deck commands
mtg deck validate deck.txt -f modern          # Validate Modern deck
mtg deck curve deck.txt                       # Mana curve analysis
mtg deck price deck.txt                       # Price breakdown

# Database stats
mtg stats

Data Sources

DatabaseSourceContents
AllPrintings.sqliteMTGJsonCards, rules, legalities (required)
scryfall.sqliteScryfallImages, prices, purchase links (optional)

Place databases in resources/ or set paths via environment variables:

MTG_DB_PATH=resources/AllPrintings.sqlite
SCRYFALL_DB_PATH=resources/scryfall.sqlite

Development

uv sync --all-extras    # Install dev dependencies
uv run pytest           # Run tests
uv run ruff check src/  # Lint
uv run mypy src/        # Type check

Copyright

All rights to Magic: The Gathering belong to Wizards of the Coast, a subsidiary of Hasbro, Inc.