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

# Start MCP server with Puma
# This script handles the streaming connection issues with proper signal handling

require "bundler/setup"

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

puts "🤖 Starting ActionMCP server with Puma on port #{port}..."
puts "⚠️  Note: Use Ctrl+C to stop (signal handling enabled)"
puts "🚀 For better streaming performance, consider using bin/sfalcon instead"
puts ""

# Execute Puma with the MCP Rack application
exec("bundle", "exec", "puma", "-p", port.to_s, "-C", File.expand_path("../config/puma.rb", __dir__),
     File.expand_path("../mcp.ru", __dir__))
