magic-wand

magic-wand

Enables AI agents to interactively remove image backgrounds using a Paint.NET-style magic wand tool with live visual feedback and precision helpers.

Category
访问服务器

README

Magic Wand 🪄

A Paint.NET-style magic wand that an AI can use. Point Claude (or any MCP-capable agent) at an image, and it removes the background the way a careful human would: click, look at the result, adjust tolerance, zoom in, fix mistakes, verify, save — with a live window on your desktop showing every step as it happens. You can grab the mouse and click alongside it.

demo

Why this exists

Fully automatic background removers fail on hard images (white flowers on white paper, thin stems, soft watercolor edges) and give you no way to fix the result. A human with a magic wand tool gets it right because they can see what each click did. This gives an AI agent the same loop: every tool call returns a rendered view of the canvas, so the model inspects its own work before deciding the next step.

Features

  • Wand selection — tolerance-based flood fill, contiguous or global, add/subtract ops, rect-scoped clicks, live tolerance re-run
  • Multiple canvases — parallel agents each get their own image and their own live viewer window (auto-tiled on screen)
  • Vision-first API — every mutation returns the updated view plus a +/- px delta and changed-region bbox
  • Precision helpers — probe (is this pixel paper or pale paint?), inspect (pixel-accurate zoom with a coordinate grid and a "matches background" highlight), sweep_paper (grab every trapped background pocket in one call, with size caps and exclusion rects), peel_paper (iteratively remove every leftover a viewer would actually see), unselect_region
  • Built-in QA — qa_check audits the result against the pristine original: leftover background and possible artwork loss, with per-region visibility verdicts; save_png re-runs the audit on save
  • Human-friendly windows — mouse wheel zoom, right-drag pan, manual clicks, slider, undo; everything you do is visible to the agent too
  • Undo everything — selections and deletes alike, with labeled history

Install

git clone https://github.com/nathandstory/magic-wand
cd magic-wand
pip install -r requirements.txt

Requires Python 3.10+ with tkinter (included in the standard Windows/macOS Python installers).

Use with Claude Code

claude mcp add magic-wand -- python /path/to/magic-wand/main.py

or add it to your MCP config manually:

"magic-wand": {
  "type": "stdio",
  "command": "python",
  "args": ["/path/to/magic-wand/main.py"]
}

Then ask Claude: "open flower.png with the magic wand and remove the background". The viewer window opens automatically; watch, or intervene with your own clicks (the agent sees your edits on its next look).

Use as a plain GUI app

python main.py image.png

No MCP client required — it's a small standalone wand editor.

Tool reference

Tool What it does
open_image load a file onto a named canvas + open its window
wand flood-fill select at (x,y); tolerance, contiguous/global, add/subtract, within rect, region-size cap
set_tolerance re-runs the last click live at a new tolerance (add/subtract included)
sweep_paper select every trapped background-colored pocket ≤ N px, with paint-safety guards
peel_paper post-delete: iteratively remove every leftover a viewer would see
probe color, selection state, and distance-from-background for one pixel
inspect zoomed crop with original-coordinate grid + match highlighting
grow_selection / invert_selection / clear_selection / unselect_region selection algebra
delete_selection selected pixels → transparency (antialiased), then auto-clear
qa_check audit vs the original: leftover background, artwork loss, visibility verdicts
save_png save with transparency (+trim), includes a QA audit
undo undo anything, with a label of what was reverted
list_canvases / close_canvas / show_window canvas management

How it works

One WandModel per canvas holds the image, selection mask, and history; the MCP server (FastMCP over stdio) mutates models and returns rendered views; a Tk viewer polls each model ~12×/s so the window always shows the truth. The GUI never owns state — agent calls and your manual clicks go through the same model, which is why you can co-edit with the AI.

Selection semantics follow Paint.NET: tolerance is a normalized RGBA distance, flood fill is 8-connected, deletes are antialiased with a ~1px soft edge. The QA layer compares against a pristine copy of the original and estimates the background color from the image border — see magicwand/core.py for the details; it's readable.

Tests

python tests/test_core.py        # headless algorithm tests
python tests/drive_mcp.py ...    # end-to-end MCP stdio driver

License

MIT — see LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选