Sponsored by Deepsite.site

Scryfall MCP Server

Created By
bmurdock6 months ago
MCP Server for Scryfall
Content

Scryfall MCP Server

A comprehensive Model Context Protocol (MCP) server that integrates with the Scryfall API to provide Magic: The Gathering card data and functionality to AI assistants like Claude.

Features

🔧 MCP Tools

  • search_cards: Search for cards using Scryfall's powerful search syntax
  • get_card: Get detailed information about specific cards
  • get_card_prices: Retrieve current price data for cards
  • random_card: Get random cards with optional filters
  • search_sets: Search and filter Magic sets

📚 MCP Resources

  • card-database://bulk: Complete Scryfall bulk card database with daily updates
  • set-database://all: All Magic sets with metadata and icons

💡 MCP Prompts

  • analyze_card: Generate comprehensive card analysis including competitive viability, synergies, and meta positioning
  • build_deck: Create deck building guides centered around specific cards

⚡ Performance Features

  • Rate Limiting: Respects Scryfall's API limits with 75ms minimum intervals
  • Intelligent Caching: Reduces API calls by >70% with configurable TTL
  • Error Handling: Graceful handling of all API error conditions
  • Circuit Breaker: Prevents cascading failures during API outages

Installation

Prerequisites

  • Node.js 18+
  • npm or yarn

Setup

  1. Clone the repository

    git clone https://github.com/bmurdock/scryfall-mcp.git
    cd scryfall-mcp
    
  2. Install dependencies

    npm install
    
  3. Configure environment (optional)

    cp .env.example .env
    # Edit .env with your preferences
    
  4. Build the project

    npm run build
    

Usage

Development Mode

npm run dev

Production Mode

npm start

Testing

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with UI
npm run test:ui

MCP Inspector

npm run inspector

Claude Desktop Integration

Add the following to your Claude Desktop configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "scryfall": {
      "command": "node",
      "args": ["/absolute/path/to/scryfall-mcp/dist/index.js"]
    }
  }
}

Replace /absolute/path/to/scryfall-mcp with the actual path to your installation.

Tool Usage Examples

Search Cards

// Basic search
{
  "query": "lightning bolt"
}

// Advanced search with Scryfall syntax
{
  "query": "c:red type:instant cmc:1",
  "limit": 10,
  "format": "json"
}

// Format-specific search
{
  "query": "legal:modern type:creature power>=4",
  "order": "cmc"
}

Get Card Details

// By name
{
  "identifier": "Lightning Bolt"
}

// By set and collector number
{
  "identifier": "dom/123"
}

// By Scryfall ID
{
  "identifier": "f7a99cc1-2b73-4c9c-8de2-9b6c4c1d8f2a"
}

// With specific set
{
  "identifier": "Lightning Bolt",
  "set": "m21"
}

Get Card Prices

{
  "card_id": "f7a99cc1-2b73-4c9c-8de2-9b6c4c1d8f2a",
  "currency": "usd"
}

Random Card

// Completely random
{}

// Filtered random card
{
  "query": "type:creature",
  "format": "modern"
}

Search Sets

// All sets
{}

// Filter by type and date
{
  "type": "expansion",
  "released_after": "2020-01-01"
}

Scryfall Search Syntax

The server supports Scryfall's full search syntax:

Basic Operators

  • c:red - Color
  • type:creature - Type line
  • set:dom - Set code
  • cmc:3 - Converted mana cost
  • power>=4 - Power/toughness comparisons
  • legal:modern - Format legality

Advanced Operators

  • is:commander - Card properties
  • year:2023 - Release year
  • rarity:mythic - Rarity
  • artist:"john avon" - Artist name
  • flavor:"text" - Flavor text search

Boolean Logic

  • red OR blue - Either condition
  • creature AND red - Both conditions
  • NOT black - Exclude condition
  • (red OR blue) type:instant - Grouping

Error Handling

The server provides detailed error messages for common issues:

  • 404: Card/resource not found
  • 422: Invalid search syntax
  • 429: Rate limit exceeded (automatic retry)
  • Validation errors: Parameter validation failures

Performance Monitoring

Cache Statistics

// Get cache performance
server.getCacheStats()

Rate Limiter Status

// Check rate limiting status
server.getRateLimiterStatus()

Health Check

// Overall system health
server.healthCheck()

Configuration

Environment Variables

SCRYFALL_USER_AGENT=ScryfallMCPServer/1.0
CACHE_TTL_HOURS=24
RATE_LIMIT_MS=75
LOG_LEVEL=info
NODE_ENV=development

Cache Durations

  • Card Search: 30 minutes
  • Card Details: 24 hours
  • Card Prices: 6 hours
  • Set Data: 1 week
  • Bulk Data: 24 hours

Troubleshooting

Common Issues

"Rate limit exceeded"

  • The server automatically handles rate limiting
  • Wait a moment and try again
  • Check if you're making too many concurrent requests

"Network error: Unexpected token" or gzip-related errors

  • This was fixed in v1.0.2 by disabling gzip compression
  • Make sure you're using the latest build: npm run build
  • Restart Claude Desktop after rebuilding
  • The server now requests uncompressed responses to avoid parsing issues

"Card not found"

  • Verify card name spelling
  • Try using set code + collector number format
  • Check if the card exists in Scryfall

"Invalid search syntax"

  • Review Scryfall search syntax documentation
  • Check for unmatched parentheses
  • Avoid starting queries with boolean operators

Claude Desktop integration not working

  • Verify the absolute path in configuration
  • Ensure the server builds successfully
  • Check Claude Desktop logs for errors

Debug Mode

LOG_LEVEL=debug npm run dev

Clear Cache

# Programmatically
server.clearCaches()

# Or restart the server

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Submit a pull request

Development Guidelines

  • Follow TypeScript best practices
  • Maintain >80% test coverage
  • Use conventional commit messages
  • Update documentation for new features

API Rate Limiting & Compliance

This server fully complies with Scryfall's API guidelines:

  • Rate Limiting: 100ms minimum between requests (10 requests/second max)
  • Required Headers: Proper User-Agent and Accept headers
  • Caching: 24+ hour caching for card data, 6 hours for prices
  • Bulk Data: Uses daily bulk downloads that don't count against limits
  • Error Handling: Respects 429 responses with exponential backoff
  • Circuit Breaker: Prevents overloading during API issues

See SCRYFALL_COMPLIANCE.md for complete compliance details.

License

MIT License - see LICENSE file for details.

Acknowledgments

  • Scryfall for providing the excellent Magic: The Gathering API
  • Model Context Protocol for the MCP specification
  • The Magic: The Gathering community for inspiration and feedback
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Playwright McpPlaywright MCP server
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
ChatWiseThe second fastest AI chatbot™
Tavily Mcp
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
DeepChatYour AI Partner on Desktop
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
CursorThe AI Code Editor
Amap Maps高德地图官方 MCP Server
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Serper MCP ServerA Serper MCP Server
WindsurfThe new purpose-built IDE to harness magic
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"