## Makes the editor pick up changes on disk. ## ## Scripts are reloaded by the editor on its own, but a scene already open ## keeps the version it loaded, and some changes — a new class_name, an ## addon's own code — are only fully picked up by restarting. ## ## A restart is deferred to the end of the turn for the same reason ## resume_session is: it tears down the dock, and the MCP server the dock ## hosts, in the middle of the call asking for it. class_name ClaudeGodotToolReload extends ClaudeGodotTool func definition() -> Dictionary: return { "name": "reload", "description": "Reload after changing files. scope 'filesystem' rescans res:// so new files appear (cheap, immediate). 'scene' reloads one open scene from disk. 'editor' restarts the whole editor — it ends this conversation's turn and closes the dock, so only ask for it when something genuinely needs a restart, and tell the user first.", "input_schema": { "type": "object", "properties": { "scope": {"type": "string", "description": "'filesystem' (default), 'scene' or 'editor'."}, "path": {"type": "string", "description": "For scope 'scene': the .tscn to reload."} } } } func execute(input: Dictionary) -> Dictionary: match str(input.get("scope", "filesystem")).to_lower(): "scene": var path := resolve_path(input.get("path", "")) if path == "" or not FileAccess.file_exists(path): return {"is_error": true, "content": "scope 'scene' needs the path of a scene that exists; got %s." % path} EditorInterface.reload_scene_from_path(path) return {"content": "Reloaded %s from disk." % path} "editor": # Not done here: the restart has to outlive this call. return { "content": "The editor will restart once this turn finishes, saving first. The dock and its MCP server go down with it and this conversation ends — it is saved and will be in the session list when the editor comes back.", "restart_editor": true, } _: EditorInterface.get_resource_filesystem().scan() return {"content": "Rescanning res:// — files written outside the editor will show up once it finishes."}