#!/usr/bin/env ruby
# frozen_string_literal: true

# Start MCP server with Falcon (recommended for streaming)
# Falcon handles SSE and async I/O much better than Puma

require "bundler/setup"

# Set the port
port = ARGV[0] || 62_770

puts "🦅 Starting ActionMCP server with Falcon on port #{port}..."
puts "✨ Falcon is optimized for streaming and async I/O"
puts "🔄 SSE connections and real-time features work best with Falcon"
puts "⭐ Recommended for production MCP servers"
puts ""

# Execute Falcon with the MCP Rack application
exec("bundle", "exec", "falcon", "serve", "--bind", "http://0.0.0.0:#{port}", "--config",
     File.expand_path("../mcp.ru", __dir__))
