Skip to content

Add an opt-in MCP server backed by the scripting API - #4653

Open
varnholt wants to merge 6 commits into
mapeditor:masterfrom
varnholt:feature/integrated-mcp
Open

varnholt wants to merge 6 commits into
mapeditor:masterfrom
varnholt:feature/integrated-mcp

Conversation

@varnholt

@varnholt varnholt commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Add an optional MCP server inside the editor, following the suggestion in #4505 (comment) to use the existing scripting API and interact with a running Tiled instance.

Edit > MCP Server starts a loopback-only Streamable HTTP endpoint and copies client connection settings. One execute_script tool runs synchronous JavaScript against the existing script engine, so callers operate on live documents and use the existing editing and Undo APIs. The tiled://scripting-api resource serves the existing TypeScript API reference.

The endpoint starts disabled, requires a generated bearer token, rejects browser origins and unexpected Host headers, and revokes its credentials when disabled. Script errors reach the client; preceding edits are not automatically rolled back. The script-engine reset blocker and a reentrancy guard protect calls that enter nested event loops.

Qt HTTP Server is an optional build dependency (Qt 6.4+). Packaging includes the module and its WebSockets dependency where available; the Qt 6.2 macOS build remains supported without MCP. Qt HTTP Server's GPLv3 license is included and the corresponding package metadata is updated.

Snap builds run independently. Arm64 CI installs the official Qt SDK revision 52 used by the preceding successful upstream build, then declares the KF6 SDK explicitly so the KDE extension uses the installed Qt SDK without querying its unavailable channel. All architecture targets are preserved.

Validation:

  • Built with MSVC 2022 and Qt 6.10.1 without precompiled headers; all 25 native MCP tests pass.
  • Official Python MCP SDK 2.3.0 passed initialization and automatic negotiation, tool/resource discovery, API reads, live document edits, Undo, and error propagation.
  • Ubuntu CI with Qt 6.4 passes the full build and all 25 MCP tests. Linux AppImage, both Snap architectures, Windows packaging, both macOS package variants, and documentation pass in https://github.com/mapeditor/tiled/actions/runs/42390666447. The arm64 log confirms MCP support was compiled and the Snap artifact uploaded.
  • The committed C++ files pass Qt Creator's formatter configuration, matching the contribution guidelines' style reference.
  • The unchanged scripting suite passed 6/7 tests on Windows. Its file round-trip fixture fails with Access is denied; all 7 pass in a temporary copy using a directory-backed fixture instead of an open QTemporaryFile. That unrelated workaround is not included here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant