Luigi De Masi created CAMEL-24679:
-------------------------------------

             Summary: Camel TUI: tui_run_example and tui_infra start fail for 
external MCP agents
                 Key: CAMEL-24679
                 URL: https://issues.apache.org/jira/browse/CAMEL-24679
             Project: Camel
          Issue Type: Bug
          Components: camel-jbang
    Affects Versions: 4.23.0
            Reporter: Luigi De Masi


{{TuiMcpServer}} builds its own {{TuiToolRegistry}} (TuiMcpServer.java:82), but 
nothing
ever calls {{setLaunchManager}} on it. The only wiring is
CamelMonitor.wireContextCallbacks() -> aiPanel.setLaunchManager(...) 
(CamelMonitor.java:499),
which reaches the AI panel's registry only (AiPanel.java:369).

The {{LaunchManager}} is the one piece of registry state not shared through the 
single
{{McpFacade}} instance, so two tools are dead for every external MCP client, 
including the
ACP coding agent added in CAMEL-24663 (it drives the TUI through this same MCP 
server):

* {{tui_run_example}} always returns
{code}
  {"error": "Launching examples is not available in this session"} 
{code}
(TuiToolRegistry.java:2332).
  There is no other way for an agent to start a bundled example.
* {{tui_infra}} with action {{start}}, {{run}} or {{restart}} returns
  {code}
Error: launching is not available
{code}
 (TuiToolRegistry.java:1060). {{list}}, {{log}} and
  {{stop}} work, since they go through the facade.

{{restart}} is the worst case: it stops the service and only then fails to 
start it, so an
agent asked to restart a broker just kills it (TuiToolRegistry.java:1046):

{code:java}
facade.stopInfra(info);
yield startInfra(info.alias).replace("Starting", "Restarting");
{code}

{{tui_infra}} is part of {{CORE_TOOLS}} and the documentation advertises
"start/stop/restart infra services" under what AI agents can do
(docs/user-manual/modules/ROOT/pages/camel-jbang-tui.adoc:1112).

h3. Steps to reproduce

# {{camel tui monitor --mcp}}
# From any MCP client (or an ACP agent in the F8 panel), call
  {{tui_list_examples}} - works - then {{tui_run_example}} with one of the 
returned names.
# Call {{tui_infra}} with {{action=start, alias=kafka}}.

Expected: the example / infra service starts, as it does from the F2 menu and 
from the
built-in F8 AI panel.
Actual: both calls return a "launching is not available" error.

h3. Proposed fix

Add a package-private {{setLaunchManager}} to {{TuiMcpServer}} that delegates 
to its registry,
and call it from {{CamelMonitor.wireMcpServer()}} (CamelMonitor.java:2983), 
which is on both
the startup path and the on-demand {{ensureMcpServer()}} path, and runs after
{{createActionsPopup()}} so the LaunchManager already exists.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to