Class: ActionMCP::Dev::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/action_mcp/dev/runner.rb

Overview

A single command that boots the ActionMCP dev loop: the standalone MCP server plus, when a compiled-views tier is present, the vite view builder in watch mode, plus an optional public tunnel.

Note on the reload model: MCP Apps views are delivered to hosts as inlined resource text inside a sandboxed iframe, so there is no websocket channel for classic in-browser HMR. The dev loop is watch-and-rebuild: editing a view triggers a vite rebuild of its bundle + manifest, and the next tool invocation in the MCP client renders the fresh view.

Usage from the generated binstub:

ActionMCP::Dev::Runner.new(root: Dir.pwd, argv: ARGV).run

Defined Under Namespace

Classes: Spec

Constant Summary collapse

DEFAULT_PORT =
62_770
VIEWS_SUBDIR =
"app/mcp/views"
BUILD_BIN =
"action-mcp-build-views"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root:, argv: [], env: ENV, out: $stdout) ⇒ Runner

Returns a new instance of Runner.



27
28
29
30
31
32
33
# File 'lib/action_mcp/dev/runner.rb', line 27

def initialize(root:, argv: [], env: ENV, out: $stdout)
  @root = File.expand_path(root)
  @env = env
  @out = out
  @options = parse(argv)
  @pids = {}
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



25
26
27
# File 'lib/action_mcp/dev/runner.rb', line 25

def options
  @options
end

#rootObject (readonly)

Returns the value of attribute root.



25
26
27
# File 'lib/action_mcp/dev/runner.rb', line 25

def root
  @root
end

Instance Method Details

#planArray<Spec>

The set of child processes this invocation would start. Pure — no spawning — so the wiring is unit-testable.

Returns:



39
40
41
42
43
44
# File 'lib/action_mcp/dev/runner.rb', line 39

def plan
  specs = [ server_spec ]
  specs << views_spec if run_views?
  specs << tunnel_spec if @options[:tunnel]
  specs
end

#runObject



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/action_mcp/dev/runner.rb', line 52

def run
  if @options[:help]
    @out.puts usage
    return 0
  end

  specs = plan
  print_banner(specs)

  specs.each { |spec| spawn(spec) }
  install_signal_traps
  supervise
end

#run_views?Boolean

Whether the vite view-builder should run: opt-in tier is present and the user did not disable it.

Returns:

  • (Boolean)


48
49
50
# File 'lib/action_mcp/dev/runner.rb', line 48

def run_views?
  @options[:views] && File.directory?(File.join(@root, VIEWS_SUBDIR))
end