import bpy
scene=bpy.context.scene
# Build the compositor using the Blender 5 compositor node-tree API.
try:
    comp_tree=bpy.data.node_groups.get('Lantern Compositor') or bpy.data.node_groups.new('Lantern Compositor','CompositorNodeTree')
    comp_tree.nodes.clear()
    rl=comp_tree.nodes.new('CompositorNodeRLayers'); rl.location=(-300,0)
    gl=comp_tree.nodes.new('CompositorNodeGlare'); gl.glare_type='FOG_GLOW'; gl.quality='HIGH'; gl.threshold=1.1; gl.size=7; gl.mix=-0.86; gl.location=(-20,0)
    comp=comp_tree.nodes.new('CompositorNodeComposite'); comp.location=(260,0)
    comp_tree.links.new(rl.outputs['Image'],gl.inputs['Image']); comp_tree.links.new(gl.outputs['Image'],comp.inputs['Image'])
    scene.compositing_node_group=comp_tree
    scene.render.use_compositing=True
    comp_status='enabled'
except Exception as e:
    comp_status='failed: '+repr(e)
    scene.render.use_compositing=False

# Final preview settings (temporarily Eevee for an immediate check).
scene.render.engine='BLENDER_EEVEE'
scene.render.resolution_x=720; scene.render.resolution_y=720; scene.render.resolution_percentage=100
scene.render.image_settings.file_format='PNG'; scene.render.image_settings.color_mode='RGBA'; scene.render.film_transparent=False
scene.render.filepath='/tmp/camping_lantern_preview.png'
try: scene.view_settings.look='AgX - Medium High Contrast'
except:
    try: scene.view_settings.look='Medium High Contrast'
    except: pass
scene.view_settings.exposure=0.0
# World, if the build inherited the default, is made very dark for the studio sweep.
if scene.world:
    scene.world.use_nodes=True
    wb=scene.world.node_tree.nodes.get('Background')
    if wb:
        wb.inputs['Color'].default_value=(0.0025,0.006,0.014,1); wb.inputs['Strength'].default_value=0.035
# Render a validation image.
bpy.ops.render.render(write_still=True)
# Save native-fidelity settings as the final deliverable.
scene.render.engine='CYCLES'
scene.render.resolution_x=1536; scene.render.resolution_y=1536; scene.render.resolution_percentage=100
scene.render.filepath='/tmp/camping_lantern_final.png'
scene.cycles.samples=64
try: scene.cycles.use_denoising=True
except: pass
scene.cycles.max_bounces=8; scene.cycles.diffuse_bounces=3; scene.cycles.glossy_bounces=4; scene.cycles.transmission_bounces=8; scene.cycles.transparent_max_bounces=8
try: scene.cycles.device='GPU'
except: pass
scene['hero_prop']='Classic camping lantern with emissive mantle, glass chimney, protective brass frame, and bail handle'
scene['lighting_note']='Warm point source inside glass plus cool studio softboxes and a subtle ground pool'
for obj in bpy.data.objects: obj.select_set(False)
hero=bpy.data.objects.get('Glowing mantle')
if hero: hero.select_set(True); bpy.context.view_layer.objects.active=hero
bpy.ops.wm.save_as_mainfile(filepath='/tmp/camping_lantern.blend')
result={'objects':len(bpy.data.objects),'materials':len(bpy.data.materials),'camera':scene.camera.name if scene.camera else None,'engine':scene.render.engine,'preview':'/tmp/camping_lantern_preview.png','file':'/tmp/camping_lantern.blend','compositor':comp_status}


Traceback (most recent call last):
  File "<repo>\.runner\blender-mcp-v1.0.0\addon\mcp_to_blender_server.py", line 230, in _execute_code
    exec(code, namespace)
    ~~~~^^^^^^^^^^^^^^^^^
  File "<string>", line 51, in <module>
RuntimeError: Error: Cannot open file <repo>\apps\console\tmp\camping_lantern.blend@ for writing: No such file or directory