Skip to main content
Glama

connect_signal

Add signal connections between nodes in Godot .tscn scene files to enable event-driven communication and game logic.

Instructions

Add a new signal connection between nodes in a .tscn scene file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sceneYesPath to the .tscn file
sourceYesSource node name (emitter)
signalYesSignal name
targetYesTarget node name (receiver)
methodYesHandler method name on the target
flagsNoConnection flags (default: 0)
expectedHashNoExpected content hash for stale-edit prevention

Implementation Reference

  • The handler function for 'connect_signal' which validates the scene and nodes, checks for duplicates, and appends the new signal connection.
    handler: async (ctx) => {
      const {
        scene: scenePath,
        source: sourceNode,
        signal: signalName,
        target: targetNode,
        method,
        flags = 0,
        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 });
    
          // Validate source and target nodes exist (by node name in connections)
          let sourceExists = false;
          let targetExists = false;
          for (const [, node] of scene.nodes) {
            if (node.name === sourceNode || node.nodePath === sourceNode) sourceExists = true;
            if (node.name === targetNode || node.nodePath === targetNode || targetNode === ".")
              targetExists = true;
          }
    
          if (!sourceExists) {
            return makeTextResponse({
              error: `Source node not found: ${sourceNode}`,
              data: null,
            });
          }
          if (!targetExists) {
            return makeTextResponse({
              error: `Target node not found: ${targetNode}`,
              data: null,
            });
          }
    
          // Check for duplicate
          const duplicate = scene.signalConnections.find(
            (c) =>
              c.signalName === signalName &&
              c.sourceNode === sourceNode &&
              c.targetNode === targetNode &&
              c.targetMethod === method,
          );
          if (duplicate) {
            return makeTextResponse({
              error: "Connection already exists",
              data: null,
            });
          }
    
          scene.signalConnections.push({
            sourceScene: scenePath,
            sourceNode,
            signalName,
            targetNode,
            targetMethod: method,
            targetScript: null,
            targetMethodLine: null,
            connectionFlags: flags,
            rawSpan: null,
          });
    
          await writeAndEmit(scenePath, scene, eventBus, ctx.signal);
    
          return makeTextResponse({
            data: {
              signal: signalName,
              from: sourceNode,
              to: targetNode,
  • The schema defining the input arguments for 'connect_signal', including scene, source node, signal, target node, method, and flags.
    schema: {
      scene: z.string().describe("Path to the .tscn file"),
      source: z.string().describe("Source node name (emitter)"),
      signal: z.string().describe("Signal name"),
      target: z.string().describe("Target node name (receiver)"),
      method: z.string().describe("Handler method name on the target"),
      flags: z.number().optional().default(0).describe("Connection flags (default: 0)"),
      expectedHash: z
        .string()
        .optional()
        .describe("Expected content hash for stale-edit prevention"),
    },
  • The registration entry for the 'connect_signal' tool.
    {

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/woohq/godette-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server