Skip to content

MCP: Fix scene_action connect not persisting signal connections - #1367

Closed
MichaelFisher1997 wants to merge 1 commit into
Redot-Engine:masterfrom
MichaelFisher1997:fix/mcp-connect-persist
Closed

MichaelFisher1997 wants to merge 1 commit into
Redot-Engine:masterfrom
MichaelFisher1997:fix/mcp-connect-persist

Conversation

@MichaelFisher1997

Copy link
Copy Markdown
Contributor

Problem

The scene_action tool's connect action reported success ("Connected signal…") but never persisted the connection: no [connection] entry was written to the .tscn file (verified by grepping both existing and freshly created scenes). The connection existed only in memory for the running session, so AI agents wiring up signals got a misleading success message plus a generated callback stub while the actual wire-up silently vanished on save/reload.

Root cause

MCPTools::tool_scene_action() connected signals with default flags:

source->connect(sig, Callable(target, method));

PackedScene::pack()SceneState::_parse_connections() skips every connection without CONNECT_PERSIST (scene/resources/packed_scene.cpp:1086), so the packed scene dropped it. The editor's Connections dialog sets this flag (editor/scene/connections_dialog.cpp:950); the MCP tool did not.

Fix

  • Pass CONNECT_PERSIST when connecting (modules/mcp/mcp_tools.cpp).
  • Check connect()'s return value and surface an error instead of a success message on failure.

Verification

Ran the editor binary headless as an MCP server and drove it over stdio JSON-RPC:

  1. initialize handshake
  2. scene_action create → fresh res://test.tscn (Node2D root)
  3. scene_action add → Button child
  4. scene_action connectpressedon_pressed

Before: .tscn contained no [connection] section.
After:

[connection signal="pressed" from="MyButton" to="." method="on_pressed"]

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants