Skip to main content

A Model Context Protocol (MCP) server that provides access to the Scryfall API for Magic: The Gathering card data.

Project description

Scryfall MCP Server

License Python PyPI

A Model Context Protocol (MCP) server that provides access to the Scryfall API for Magic: The Gathering card data. This server enables AI assistants and other MCP clients to search for cards, retrieve card information, download high-resolution images, and access comprehensive MTG data through a standardized interface.

Features

  • Card Search: Search for Magic: The Gathering cards using Scryfall's powerful search syntax
  • Card Details: Retrieve detailed information about specific cards including prices, legality, and metadata
  • Image Downloads: Download high-resolution card images and art crops
  • Database Operations: Manage local card databases with integrity verification
  • Set Information: Access information about MTG sets and expansions
  • Artwork Access: Get high-quality card artwork and images in multiple formats
  • Advanced Filtering: Use Scryfall's advanced search operators for precise queries

Installation

Install the package from PyPI:

pip install scryfall-mcp

Or install from source:

git clone https://github.com/kaminaduck/scryfall-mcp.git
cd scryfall-mcp
pip install -e .

Quick Start

Running the Server

Start the MCP server:

python -m mcp

Or run directly:

from scryfall_mcp import main
main()

Basic Usage

The server provides several tools that can be used by MCP clients:

Search for Cards

# Search for Lightning Bolt cards
result = mcp_search_cards("lightning bolt")

# Search for red creatures with converted mana cost 3
result = mcp_search_cards("t:creature c:red cmc:3")

# Search for cards in a specific set
result = mcp_search_cards("set:znr")

Download Card Images

# Download a specific card image
result = mcp_download_card("Lightning Bolt")

# Download from a specific set
result = mcp_download_card("Lightning Bolt", set_code="m10", collector_number="146")

# Force re-download
result = mcp_download_card("Lightning Bolt", force_download=True)

Download Art Crops

# Download art crop for a card
result = mcp_download_art_crop("Lightning Bolt")

# Download art crop from specific printing
result = mcp_download_art_crop("Lightning Bolt", set_code="m10", collector_number="146")

Available Tools

Search Tools

  • mcp_search_cards(query): Search for cards using Scryfall syntax
  • mcp_get_card_artwork(card_id): Get artwork URLs for a specific card

Download Tools

  • mcp_download_card(card_name, set_code?, collector_number?, force_download?): Download high-resolution card images
  • mcp_download_art_crop(card_name, set_code?, collector_number?, force_download?): Download art crop images

Database Tools

  • mcp_verify_database(): Verify database integrity
  • mcp_scan_directory(directory, update_db?): Scan directories for image files
  • mcp_clean_database(execute?): Clean database of missing file references
  • mcp_database_report(): Generate comprehensive database report

Available Resources

Card Resources

  • resource://card/{card_id}: Get detailed card information by Scryfall ID
  • resource://card/name/{card_name}: Get detailed card information by name
  • resource://random_card: Get a random Magic: The Gathering card

Database Resources

  • resource://database/stats: Get database statistics and information

Search Syntax

The server supports Scryfall's powerful search syntax. Here are some examples:

Query Description
lightning bolt Cards with "lightning bolt" in the name
t:creature All creature cards
c:red All red cards
cmc:3 Cards with converted mana cost 3
set:znr Cards from Zendikar Rising
r:mythic Mythic rare cards
pow>=4 Creatures with power 4 or greater
o:"draw a card" Cards with "draw a card" in rules text
is:commander Cards that can be commanders
year:2023 Cards printed in 2023
Advanced Search Examples
# Find all red creatures with power 4 or greater from recent sets
mcp_search_cards("t:creature c:red pow>=4 year>=2020")

# Find all planeswalkers that cost 3 mana
mcp_search_cards("t:planeswalker cmc:3")

# Find all cards with "flying" and "vigilance"
mcp_search_cards("o:flying o:vigilance")

# Find all legendary creatures that can be commanders
mcp_search_cards("t:legendary t:creature is:commander")

# Find all cards illustrated by a specific artist
mcp_search_cards("a:\"Rebecca Guay\"")

Configuration

The server uses the following default directories:

  • Card Images: .local/scryfall_card_images/
  • Art Crops: .local/scryfall_images/
  • Database: Local SQLite database for tracking downloads

Error Handling

All tools return structured responses with status indicators:

{
    "status": "success" | "error",
    "message": "Description of result or error",
    "data": {...}  # Additional response data
}

Requirements

  • Python 3.12+
  • httpx >= 0.28.1
  • mcp[cli] >= 1.8.0

Development

Setting up Development Environment

git clone https://github.com/kaminaduck/scryfall-mcp.git
cd scryfall-mcp
pip install -e ".[dev]"

Running Tests

pytest

Code Style

This project follows PEP 8 style guidelines and includes comprehensive docstrings following the project's documentation standards.

API Reference

Tool Signatures

def mcp_search_cards(query: str) -> Dict[str, Any]
def mcp_download_card(card_name: str, set_code: Optional[str] = None, 
                     collector_number: Optional[str] = None, 
                     force_download: bool = False) -> Dict[str, Any]
def mcp_download_art_crop(card_name: str, set_code: Optional[str] = None,
                         collector_number: Optional[str] = None,
                         force_download: bool = False) -> Dict[str, Any]
def mcp_get_card_artwork(card_id: str) -> Dict[str, Any]
def mcp_verify_database() -> Dict[str, Any]
def mcp_scan_directory(directory: str, update_db: bool = False) -> Dict[str, Any]
def mcp_clean_database(execute: bool = False) -> Dict[str, Any]
def mcp_database_report() -> Dict[str, Any]

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Acknowledgments

  • Scryfall for providing the comprehensive Magic: The Gathering API
  • Model Context Protocol for the standardized interface
  • The Magic: The Gathering community for their continued support

Support

If you encounter any issues or have questions:

  1. Check the Issues page
  2. Create a new issue with detailed information about your problem
  3. Include relevant error messages and system information

Note: This is an unofficial tool and is not affiliated with Wizards of the Coast or Scryfall. Magic: The Gathering is a trademark of Wizards of the Coast LLC.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scryfall_mcp-0.0.1.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scryfall_mcp-0.0.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file scryfall_mcp-0.0.1.tar.gz.

File metadata

  • Download URL: scryfall_mcp-0.0.1.tar.gz
  • Upload date:
  • Size: 24.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for scryfall_mcp-0.0.1.tar.gz
Algorithm Hash digest
SHA256 aabde18b58a7721bfe38b4f6b2ed04af95b0628f9f873fdf80ac8b0f0eed66bd
MD5 98066cf4db0733745a873e6185c3a253
BLAKE2b-256 c8eeb9a35e81364da6b563a2c2c24d992840f94977ebd7971a7c7c12ae917a8b

See more details on using hashes here.

File details

Details for the file scryfall_mcp-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: scryfall_mcp-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for scryfall_mcp-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4399a2dfe3da1845c27c66d6bdc11465677216394ba46fdaf54f31f0c03b95e6
MD5 97bf6b2ce909d944175b4795b827dcc6
BLAKE2b-256 4d2100ae2ce05e930784e7e5fc5dee21ffd0aaa141e538b6cd6b206cd8faf6bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page