@@ -477,9 +477,10 @@ func create_camera(params: Dictionary) -> Dictionary:
477477 "Invalid camera type '%s '. Valid: %s " % [type_str , ", " .join (_VALID_TYPES .keys ())]
478478 )
479479
480- var scene_root := EditorInterface .get_edited_scene_root ()
481- if scene_root == null :
482- return McpErrorCodes .make (McpErrorCodes .EDITOR_NOT_READY , "No scene open" )
480+ var _scene_check := McpNodeValidator .require_scene_or_error ()
481+ if _scene_check .has ("error" ):
482+ return _scene_check
483+ var scene_root : Node = _scene_check .scene_root
483484
484485 var parent : Node = scene_root
485486 if not parent_path .is_empty ():
@@ -869,9 +870,10 @@ func follow_2d(params: Dictionary) -> Dictionary:
869870# ============================================================================
870871
871872func get_camera (params : Dictionary ) -> Dictionary :
872- var scene_root := EditorInterface .get_edited_scene_root ()
873- if scene_root == null :
874- return McpErrorCodes .make (McpErrorCodes .EDITOR_NOT_READY , "No scene open" )
873+ var _scene_check := McpNodeValidator .require_scene_or_error ()
874+ if _scene_check .has ("error" ):
875+ return _scene_check
876+ var scene_root : Node = _scene_check .scene_root
875877
876878 var camera_path : String = params .get ("camera_path" , "" )
877879 var node : Node = null
@@ -952,9 +954,10 @@ func get_camera(params: Dictionary) -> Dictionary:
952954# ============================================================================
953955
954956func list_cameras (_params : Dictionary ) -> Dictionary :
955- var scene_root := EditorInterface .get_edited_scene_root ()
956- if scene_root == null :
957- return McpErrorCodes .make (McpErrorCodes .EDITOR_NOT_READY , "No scene open" )
957+ var _scene_check := McpNodeValidator .require_scene_or_error ()
958+ if _scene_check .has ("error" ):
959+ return _scene_check
960+ var scene_root : Node = _scene_check .scene_root
958961
959962 var cams := _list_cameras_in_scene (scene_root , "" )
960963 var out : Array [Dictionary ] = []
@@ -999,9 +1002,10 @@ func apply_preset(params: Dictionary) -> Dictionary:
9991002 "Invalid camera type '%s '. Valid: %s " % [type_str , ", " .join (_VALID_TYPES .keys ())]
10001003 )
10011004
1002- var scene_root := EditorInterface .get_edited_scene_root ()
1003- if scene_root == null :
1004- return McpErrorCodes .make (McpErrorCodes .EDITOR_NOT_READY , "No scene open" )
1005+ var _scene_check := McpNodeValidator .require_scene_or_error ()
1006+ if _scene_check .has ("error" ):
1007+ return _scene_check
1008+ var scene_root : Node = _scene_check .scene_root
10051009
10061010 var parent : Node = scene_root
10071011 if not parent_path .is_empty ():
@@ -1088,15 +1092,14 @@ static func _camera_type_str(node: Node) -> String:
10881092
10891093
10901094func _resolve_camera (params : Dictionary ) -> Dictionary :
1091- var node_path : String = params .get ("camera_path" , "" )
1092- if node_path .is_empty ():
1093- return McpErrorCodes .make (McpErrorCodes .MISSING_REQUIRED_PARAM , "Missing required param: camera_path" )
1094- var scene_root := EditorInterface .get_edited_scene_root ()
1095- if scene_root == null :
1096- return McpErrorCodes .make (McpErrorCodes .EDITOR_NOT_READY , "No scene open" )
1097- var node := McpScenePath .resolve (node_path , scene_root )
1098- if node == null :
1099- return McpErrorCodes .make (McpErrorCodes .NODE_NOT_FOUND , McpScenePath .format_node_error (node_path , scene_root ))
1095+ var resolved := McpNodeValidator .resolve_or_error (
1096+ params .get ("camera_path" , "" ), "camera_path" ,
1097+ )
1098+ if resolved .has ("error" ):
1099+ return resolved
1100+ var node : Node = resolved .node
1101+ var node_path : String = resolved .path
1102+ var scene_root : Node = resolved .scene_root
11001103 if not _is_camera (node ):
11011104 return McpErrorCodes .make (
11021105 McpErrorCodes .WRONG_TYPE ,
0 commit comments