## Captures what the editor is currently showing — a scene, a layout, a ## rendering glitch. Saving and looking are separate steps on purpose: this ## writes the file, and read_file is what puts it in front of the model. class_name ClaudeGodotToolScreenshot extends ClaudeGodotTool const DEFAULT_PATH := "res://claude_godot_screenshot.png" func definition() -> Dictionary: return { "name": "screenshot", "description": "Capture the editor window to a PNG in the project and return its path and size. To actually look at it, call read_file on that path — it attaches images when the model accepts them.", "input_schema": { "type": "object", "properties": { "path": {"type": "string", "description": "Where to save it. Defaults to '%s'." % DEFAULT_PATH} } } } func execute(input: Dictionary) -> Dictionary: var path := resolve_path(input.get("path", DEFAULT_PATH)) if not path.to_lower().ends_with(".png"): path += ".png" var viewport := EditorInterface.get_base_control().get_viewport() if viewport == null: return {"is_error": true, "content": "No editor viewport to capture."} var texture := viewport.get_texture() if texture == null: return {"is_error": true, "content": "Editor viewport has no texture to capture."} var image := texture.get_image() if image == null or image.is_empty(): return {"is_error": true, "content": "Captured an empty image."} var err := image.save_png(path) if err != OK: return {"is_error": true, "content": "Could not write %s: %s" % [path, error_string(err)]} EditorInterface.get_resource_filesystem().update_file(path) return { "content": "Saved a %dx%d screenshot to %s. read_file it to look at it." % [image.get_width(), image.get_height(), path], "path": path, }