qupath-mcp¶
Drive QuPath's GUI from an AI agent. A QuPath 0.7 extension runs an MCP server inside QuPath, which Claude Code or any other MCP client connects to.
Install¶
- In QuPath, open Extensions ▸ Manage extensions ▸ Manage extension catalogs, add
https://github.com/earthmover-support/qupath-mcp, then install QuPath MCP from the extension manager. -
Register the server with your agent:
claude mcp add -s user --transport http qupath http://127.0.0.1:51515/mcp-s usermakes the server available in every project; without it, only in the current one. Claude Code MCP docsIn
~/.cursor/mcp.json, or.cursor/mcp.jsonin a project:{ "mcpServers": { "qupath": { "url": "http://127.0.0.1:51515/mcp" } } }In
.vscode/mcp.json, or your user configuration (MCP: Open User Configuration). The top-level key isservers:{ "servers": { "qupath": { "type": "http", "url": "http://127.0.0.1:51515/mcp" } } }In
~/.gemini/settings.json. UsehttpUrl; Gemini CLI readsurlas the older SSE transport:{ "mcpServers": { "qupath": { "httpUrl": "http://127.0.0.1:51515/mcp" } } }Claude Desktop can't connect to this server directly: its config file takes only local commands, and its custom connectors need a server reachable from the internet. A bridge such as the third-party
mcp-remotepackage can run as a local command and forward to the URL; this is untested. -
Have QuPath open when the client connects.
Details, including building from source, are in Install.
Warning
The MCP server lets the connected agent run any code in QuPath, as you, with access to your files. Give it only as much trust as you give your coding agent. It is on whenever the jar is installed and any program on this computer can reach it; turn it off with Extensions ▸ MCP server ▸ Enabled. See Security.
Why¶
QuPath's own scripting reaches the data model: images, objects, measurements. An agent also needs the GUI: open menus, read and answer dialogs, see the screen. These tools do that without deadlocking on modal dialogs, which block the window behind them until closed.
The jar is the qupath-gui-driver extension. The server speaks MCP over HTTP on 127.0.0.1.
What the tools handle for you¶
qupath_describereturns a dialog's buttons, text fields, tables and labels as text, so the agent can read a dialog without a screenshot.- Tools that act on the GUI, such as
qupath_menuandqupath_click, return without waiting for the handler. A handler that opens a modal dialog would otherwise block the call until the dialog closes or the 60 s timeout expires. - qupath-mcp marks each control the agent acts on and lists its recent actions in the corner of QuPath's window, so the person at the screen can follow along. A paced mode slows the agent down for recordings; see Watching the agent.
- qupath-mcp keeps a record of every action the agent takes, one JSON line each, so a session can be checked or redone afterwards; see Action log.
Example session¶
The loop an agent runs against a QuPath dialog, here the file-path prompt:
qupath_menu("File>Open URI...")fires the menu item and returns the open windows, one per line, then the outline of the dialog it opened.qupath_describe("Choose path")returns the dialog's controls as a text outline.qupath_set("/path/to/image.tif", "#0", "Choose path")fills in the text field the outline tagged#0.qupath_click("OK", "Choose path")presses a button named in that outline and returns the open windows again.qupath_screenshot("Choose path")returns a screenshot of that window as an image when the text outline is not enough.
To open an image without a dialog, qupath_open does it in one call. A failing call returns an error result with the message, so the agent sees an error instead of a silent no-op.
Where to go next¶
- Tools: every tool and when to use it.
- Security: what the server exposes.
- Contributing: building, releasing and source layout.