Class: ActionMCP::Dev::Runner
- Inherits:
-
Object
- Object
- ActionMCP::Dev::Runner
- 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
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#initialize(root:, argv: [], env: ENV, out: $stdout) ⇒ Runner
constructor
A new instance of Runner.
-
#plan ⇒ Array<Spec>
The set of child processes this invocation would start.
- #run ⇒ Object
-
#run_views? ⇒ Boolean
Whether the vite view-builder should run: opt-in tier is present and the user did not disable it.
Constructor Details
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
25 26 27 |
# File 'lib/action_mcp/dev/runner.rb', line 25 def @options end |
#root ⇒ Object (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
#plan ⇒ Array<Spec>
The set of child processes this invocation would start. Pure — no spawning — so the wiring is unit-testable.
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 |
#run ⇒ Object
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 (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.
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 |