Files
Moeblack-ComfyUI-AnimaTool/MCP_SETUP.md
T
Nakano Kenji f7fd0c07d9 feat: add environment variable configuration and improve error handling
Configuration improvements:

- Support COMFYUI_URL environment variable for remote/Docker ComfyUI

- Add ANIMATOOL_TIMEOUT, ANIMATOOL_DOWNLOAD_IMAGES, etc.

- Can configure via MCP env block without modifying code

Error handling improvements:

- Add check_comfyui_health() for friendly connection error messages

- Better error messages when ComfyUI is not running

- Detect and report ComfyUI execution errors

Documentation:

- Add environment variable reference table to README

- Add remote/Docker ComfyUI configuration guide

- Expand troubleshooting section with common issues

- Add system requirements section
2026-02-03 21:29:28 +08:00

3.3 KiB
Raw Blame History

Anima Tool MCP Server 配置指南

让 Cursor/Claude 原生显示生成的图片(不需要 Read 工具)。

快速配置

1. 安装 MCP 依赖

# 使用 ComfyUI 的 Python 环境
pip install mcp

2. 配置 Cursor

在你的项目根目录创建 .cursor/mcp.json:

{
  "mcpServers": {
    "anima-tool": {
      "command": "<PATH_TO_PYTHON>",
      "args": ["<PATH_TO>/ComfyUI-AnimaTool/servers/mcp_server.py"]
    }
  }
}

路径说明:

  • <PATH_TO_PYTHON>:ComfyUI 使用的 Python 解释器路径
  • <PATH_TO>:ComfyUI custom_nodes 目录路径

Windows 示例

{
  "mcpServers": {
    "anima-tool": {
      "command": "C:\\ComfyUI\\.venv\\Scripts\\python.exe",
      "args": ["C:\\ComfyUI\\custom_nodes\\ComfyUI-AnimaTool\\servers\\mcp_server.py"]
    }
  }
}

macOS/Linux 示例

{
  "mcpServers": {
    "anima-tool": {
      "command": "/path/to/ComfyUI/.venv/bin/python",
      "args": ["/path/to/ComfyUI/custom_nodes/ComfyUI-AnimaTool/servers/mcp_server.py"]
    }
  }
}

3. 重启 Cursor

重启 Cursor 以加载 MCP Server 配置。

使用

  1. 确保 ComfyUI 运行(默认 http://127.0.0.1:8188)
  2. 直接让 AI 生成图片:

用 @fkey, @jima 画师风格,画一个穿白裙的少女,竖屏 9:16,safe

图片会原生显示在聊天窗口中。

验证 MCP Server

检查状态

Cursor Settings → MCP → 查看 anima-tool 状态

手动测试

# Windows
python "<PATH_TO>/ComfyUI-AnimaTool/servers/mcp_server.py"

# macOS/Linux
python /path/to/ComfyUI/custom_nodes/ComfyUI-AnimaTool/servers/mcp_server.py

如果正常启动,不会有任何输出(MCP 使用 stdio 通信)。

故障排除

MCP Server 没加载?

  1. 检查 Cursor Settings → MCP → anima-tool 状态
  2. 查看输出日志(点击 "Show Output")
  3. 确认 Python 路径正确(使用绝对路径)
  4. 确认已安装 mcp 库

"Connection closed" 错误?

  1. 确认 mcp 库已安装到正确的 Python 环境
  2. 检查路径是否使用正确的转义(Windows 使用 \\\\ 或 /)

生成失败?

  1. 确认 ComfyUI 正在运行
  2. 确认 Anima 模型文件存在
  3. 检查 ComfyUI 控制台的错误信息

高级配置

环境变量配置(推荐)

无需修改代码,通过环境变量配置:

环境变量 默认值 说明
COMFYUI_URL http://127.0.0.1:8188 ComfyUI 服务地址
ANIMATOOL_TIMEOUT 600 生成超时(秒)
ANIMATOOL_DOWNLOAD_IMAGES true 是否保存图片到本地

在 MCP 配置中设置环境变量

{
  "mcpServers": {
    "anima-tool": {
      "command": "C:\\ComfyUI\\.venv\\Scripts\\python.exe",
      "args": ["C:\\ComfyUI\\custom_nodes\\ComfyUI-AnimaTool\\servers\\mcp_server.py"],
      "env": {
        "COMFYUI_URL": "http://192.168.1.100:8188",
        "ANIMATOOL_TIMEOUT": "300"
      }
    }
  }
}

远程 ComfyUI 配置

如果 ComfyUI 运行在其他机器/Docker:

局域网:

"env": { "COMFYUI_URL": "http://192.168.1.100:8188" }

Docker 访问宿主机:

"env": { "COMFYUI_URL": "http://host.docker.internal:8188" }

禁用图片保存

"env": { "ANIMATOOL_DOWNLOAD_IMAGES": "false" }