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.2.tar.gz (52.0 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.2-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for scryfall_mcp-0.0.2.tar.gz
Algorithm Hash digest
SHA256 1ba01d35312196e77c1f0f65829ff5bf8f99608040af51c7d3869a7676e95d06
MD5 4735f00d24544d255f1ae91033ecdc1a
BLAKE2b-256 ffccb0619fb1492c3a5563c978bd0aba3d7ced06143ccffdd389d590c6647c1f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for scryfall_mcp-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 87b15330db17d2f5dcc611a27665250ae58eebdc687c055058f199399b379004
MD5 ea010cc3d42707b43e65bb0d022bc47e
BLAKE2b-256 615964ed9614afb91372296c290da47c1e3c796b61bffcb957d1ed7199a93cd1

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