#!/usr/bin/env python3
"""
Godot MCP Server

This MCP server provides tools for interacting with the Godot game engine.
It enables AI assistants to launch the Godot editor, run Godot projects,
capture debug output, and control project execution.

Tool Naming Convention: domain_action (e.g., scene_create, node_add)
Domains: godot, project, editor, scene, node, script, signal, resource, tilemap, input, animation, collision, physics, camera, audio, ui, autoload, timer, canvas_layer, particle, light, viewport

Architecture:
    - core.py: GodotServer class and utility functions
    - tools/: Tool implementations organized by domain
        - godot.py: Godot version info
        - editor.py: Editor launch
        - project.py: Project management
        - scene.py: Scene operations
        - node.py: Node operations
        - script.py: Script management
        - signal.py: Signal connections
        - resource.py: Resource management
        - tilemap.py: TileMap operations
        - input.py: Input map configuration
        - animation.py: Animation management
        - collision.py: Collision shape management
        - physics.py: Physics body properties
        - camera.py: Camera management
        - audio.py: Audio system
        - ui.py: UI controls and layout
        - autoload.py: Autoload singletons
        - timer.py: Timer nodes
        - canvas_layer.py: Canvas layer management
        - particle.py: Particle systems
        - light.py: Light sources and environment
        - viewport.py: Viewport management
"""

# Re-export core utilities for backward compatibility
from godot_mcp.core import (
    DEBUG_MODE,
    GODOT_DEBUG_MODE,
    GodotServer,
    create_error_response,
    extract_json_from_output,
    godot_server,
    mcp,
    validate_path,
)

# Import all tools to register them with the MCP server
# This triggers the @mcp.tool() decorators in each module
from godot_mcp.tools import *  # noqa: F401, F403

# Re-export all tools for backward compatibility with tests
from godot_mcp.tools.godot import godot_get_version
from godot_mcp.tools.editor import editor_launch
from godot_mcp.tools.project import (
    project_export,
    project_get_debug_output,
    project_get_info,
    project_list,
    project_list_export_presets,
    project_run,
    project_setting_get,
    project_setting_set,
    project_stop,
    project_update_uids,
)
from godot_mcp.tools.scene import (
    scene_create,
    scene_get_tree,
    scene_instantiate,
    scene_list,
    scene_save,
)
from godot_mcp.tools.node import (
    node_add,
    node_add_to_group,
    node_delete,
    node_duplicate,
    node_get_properties,
    node_load_sprite_texture,
    node_rename,
    node_reparent,
    node_set_property,
)
from godot_mcp.tools.script import (
    script_attach,
    script_create,
    script_detach,
    script_list,
)
from godot_mcp.tools.signal import (
    signal_connect,
    signal_disconnect,
    signal_list_connections,
    signal_list_node_signals,
)
from godot_mcp.tools.resource import (
    resource_create_material,
    resource_export_mesh_library,
    resource_get_material_properties,
    resource_get_uid,
    resource_list,
)
from godot_mcp.tools.tilemap import (
    tilemap_get_cell,
    tilemap_set_cell,
)
from godot_mcp.tools.input import (
    input_list_actions,
    input_setup_action,
)
from godot_mcp.tools.animation import (
    animation_create,
    animation_add_track,
    animation_set_keyframe,
    animation_get_info,
    animation_list,
)
from godot_mcp.tools.collision import (
    collision_add_shape,
    collision_set_shape_properties,
    collision_set_layers,
)
from godot_mcp.tools.physics import (
    physics_set_body_properties,
)
from godot_mcp.tools.camera import (
    camera_add,
    camera_set_current,
    camera_set_properties,
    camera_get_info,
)
from godot_mcp.tools.audio import (
    audio_add_stream_player,
    audio_set_stream,
    audio_configure_bus,
)
from godot_mcp.tools.ui import (
    ui_add_control,
    ui_set_layout,
    ui_add_container,
)
from godot_mcp.tools.autoload import (
    autoload_add,
    autoload_remove,
    autoload_list,
)
from godot_mcp.tools.timer import (
    timer_add,
    timer_configure,
)
from godot_mcp.tools.canvas_layer import (
    canvas_layer_add,
    canvas_layer_set_order,
    canvas_layer_configure,
)
from godot_mcp.tools.particle import (
    particle_add_system,
    particle_set_properties,
    particle_start_emitting,
)
from godot_mcp.tools.light import (
    light_add,
    light_set_properties,
    light_set_shadow,
    environment_setup,
)
from godot_mcp.tools.viewport import (
    viewport_add,
    viewport_set_size,
    viewport_configure,
)
from godot_mcp.tools.navigation import (
    navigation_add_region,
    navigation_set_navmesh,
    navigation_add_obstacle,
    navigation_add_agent,
)

# Export all public symbols
__all__ = [
    # Core
    "DEBUG_MODE",
    "GODOT_DEBUG_MODE",
    "GodotServer",
    "create_error_response",
    "extract_json_from_output",
    "godot_server",
    "mcp",
    "validate_path",
    # Godot tools
    "godot_get_version",
    # Editor tools
    "editor_launch",
    # Project tools
    "project_export",
    "project_get_debug_output",
    "project_get_info",
    "project_list",
    "project_list_export_presets",
    "project_run",
    "project_setting_get",
    "project_setting_set",
    "project_stop",
    "project_update_uids",
    # Scene tools
    "scene_create",
    "scene_get_tree",
    "scene_instantiate",
    "scene_list",
    "scene_save",
    # Node tools
    "node_add",
    "node_add_to_group",
    "node_delete",
    "node_duplicate",
    "node_get_properties",
    "node_load_sprite_texture",
    "node_rename",
    "node_reparent",
    "node_set_property",
    # Script tools
    "script_attach",
    "script_create",
    "script_detach",
    "script_list",
    # Signal tools
    "signal_connect",
    "signal_disconnect",
    "signal_list_connections",
    "signal_list_node_signals",
    # Resource tools
    "resource_create_material",
    "resource_export_mesh_library",
    "resource_get_material_properties",
    "resource_get_uid",
    "resource_list",
    # TileMap tools
    "tilemap_get_cell",
    "tilemap_set_cell",
    # Input tools
    "input_list_actions",
    "input_setup_action",
    # Animation tools
    "animation_create",
    "animation_add_track",
    "animation_set_keyframe",
    "animation_get_info",
    "animation_list",
    # Collision tools
    "collision_add_shape",
    "collision_set_shape_properties",
    "collision_set_layers",
    # Physics tools
    "physics_set_body_properties",
    # Camera tools
    "camera_add",
    "camera_set_current",
    "camera_set_properties",
    "camera_get_info",
    # Audio tools
    "audio_add_stream_player",
    "audio_set_stream",
    "audio_configure_bus",
    # UI tools
    "ui_add_control",
    "ui_set_layout",
    "ui_add_container",
    # Autoload tools
    "autoload_add",
    "autoload_remove",
    "autoload_list",
    # Timer tools
    "timer_add",
    "timer_configure",
    # CanvasLayer tools
    "canvas_layer_add",
    "canvas_layer_set_order",
    "canvas_layer_configure",
    # Particle tools
    "particle_add_system",
    "particle_set_properties",
    "particle_start_emitting",
    # Light tools
    "light_add",
    "light_set_properties",
    "light_set_shadow",
    "environment_setup",
    # Viewport tools
    "viewport_add",
    "viewport_set_size",
    "viewport_configure",
    # Navigation tools
    "navigation_add_region",
    "navigation_set_navmesh",
    "navigation_add_obstacle",
    "navigation_add_agent",
]


def main() -> None:
    """Run the MCP server."""
    mcp.run()


if __name__ == "__main__":
    main()
