disconnect_signal
Remove signal connections from Godot scene files to manage event handling and clean up node interactions in game development projects.
Instructions
Remove a signal connection from a .tscn scene file.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scene | Yes | Path to the .tscn file | |
| source | Yes | Source node name | |
| signal | Yes | Signal name | |
| target | Yes | Target node name | |
| method | Yes | Handler method name | |
| expectedHash | No | Expected content hash for stale-edit prevention |
Implementation Reference
- src/tools/scene-edit-tools.ts:470-536 (handler)The implementation of the disconnect_signal tool, which includes schema definition, parsing, logic to find and remove a signal connection from a Godot .tscn file, and error handling.
{ name: "disconnect_signal", description: "Remove a signal connection from a .tscn scene file.", schema: { scene: z.string().describe("Path to the .tscn file"), source: z.string().describe("Source node name"), signal: z.string().describe("Signal name"), target: z.string().describe("Target node name"), method: z.string().describe("Handler method name"), expectedHash: z .string() .optional() .describe("Expected content hash for stale-edit prevention"), }, handler: async (ctx) => { const { scene: scenePath, source: sourceNode, signal: signalName, target: targetNode, method, expectedHash, } = ctx.args; validatePath(scenePath); return withFileLock(scenePath, async () => { try { const { source, scene } = await readAndParse(scenePath); const hashErr = hashCheck(source, expectedHash); if (hashErr) return makeTextResponse({ error: hashErr, data: null }); const idx = scene.signalConnections.findIndex( (c) => c.signalName === signalName && c.sourceNode === sourceNode && c.targetNode === targetNode && c.targetMethod === method, ); if (idx === -1) { return makeTextResponse({ error: `Connection not found: ${signalName} from ${sourceNode} to ${targetNode}::${method}`, data: null, }); } scene.signalConnections.splice(idx, 1); await writeAndEmit(scenePath, scene, eventBus, ctx.signal); return makeTextResponse({ data: { removed: { signal: signalName, from: sourceNode, to: targetNode, method, }, }, metadata: { source: "index" }, }); } catch (err) { return makeTextResponse({ error: `Failed to disconnect signal: ${(err as Error).message}`, data: null, }); }