Scryfall API接口服务

一个与Scryfall API交互的MCP服务器,用于获取和显示详细的Magic: The Gathering卡牌数据。

  • by dbeltra
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 dbeltra/scryfall-mcp

使用说明

MCP服务器-Scryfall API接口

这是一个 主控程序 与连接的服务器 API公司 获取并显示详细的魔法:收集卡数据。它支持按名称、颜色、类型和文本内容搜索卡片。

特性

  • 通过Scryfall搜索MTG卡:
    • 卡片名称
    • 颜色
    • 型线
    • Oracle文本
  • 详细卡片数据输出:
    • Oracle文本、法力值、颜色
    • 类型、力量/韧性、稀有性
    • 设定名称
    • 价格(美元/欧元)(普通和箔纸)

项目设置

此项目使用 uv 用于Python环境和依赖关系管理。所有依赖关系都在中声明 pyproject.toml.

需求

  • Python 3.12+
  • 紫外线 (安装时 cargo install uv)

安装

uv venv
source .venv/bin/activate  # or `.venv/Scripts/activate` on Windows
uv pip install -r pyproject.toml

运行项目

用以下方式运行项目 uv run scryfall.py "Atraxa" 应在控制台中显示Atraxa卡的scryfall结果,但这是由MCP主机(如Claude Desktop)运行的。

与Claude Desktop集成

Claude Desktop可以运行MCP服务器与Scryfall API交互并使用结果。您需要安装或更新到最新版本 克劳德 版本并创建 claude_desktop_config.json 如果文件还不存在:

~/Library/Application\ Support/Claude/claude_desktop_config.json 在MacOS中 $env:AppData\Claude\claude_desktop_config.json 在Windows中

{
    "mcpServers": {
        "scryfall": {
            "command": "/ABSOLUTE/PATH/TO/BIN/uv",
            "args": [
                "--directory",
                "/ABSOLUTE/PATH/TO/mcp-server",
                "run",
                "scryfall.py"
            ]
        }
    }
}

测试

此项目使用 pytest 用于单元测试。测试位于 tests/ 目录。

运行测试

要运行完整的测试套件:

pytest

要运行特定测试,请执行以下操作:

pytest tests/test_scryfall.py::test_get_cards_no_query