Scryfall MCP Server
A comprehensive Model Context Protocol server that integrates with the Scryfall API to provide Magic: The Gathering card data to AI assistants like Claude.
README
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
-
Clone the repository
git clone https://github.com/bmurdock/scryfall-mcp.git cd scryfall-mcp -
Install dependencies
npm install -
Configure environment (optional)
cp .env.example .env # Edit .env with your preferences -
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- Colortype:creature- Type lineset:dom- Set codecmc:3- Converted mana costpower>=4- Power/toughness comparisonslegal:modern- Format legality
Advanced Operators
is:commander- Card propertiesyear:2023- Release yearrarity:mythic- Rarityartist:"john avon"- Artist nameflavor:"text"- Flavor text search
Boolean Logic
red OR blue- Either conditioncreature AND red- Both conditionsNOT 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
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- 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
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。