Claus Ibsen created CAMEL-26932:
-----------------------------------

             Summary: camel-jbang-mcp - runtime tools act on another 
integration when given name, camel_version_list always fails, and 
camel_get_files returns files of any size
                 Key: CAMEL-26932
                 URL: https://issues.apache.org/jira/browse/CAMEL-26932
             Project: Camel
          Issue Type: Bug
          Components: camel-jbang
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found by a scan of the Camel CLI on 2026-11-13, with the unpacked 
4.24.0-SNAPSHOT camel-launcher on macOS (JDK 25). *(exp)* means reproduced by 
experiment, *(read)* means traced in the code. Paths are relative to 
{{dsl/camel-jbang/}}, and line numbers are from main at that time. Earlier 
findings of this kind: CAMEL-26901, CAMEL-26911 to CAMEL-26914.

Driven over stdio with JSON-RPC against the runner jar built from main. No 
security issue was found: the file tools refuse paths outside their directory.

h3. 1. A runtime tool given name instead of nameOrPid acts on the only running 
integration (exp, high)

The {{camel_runtime_*}} tools take {{nameOrPid}} ({{RuntimeTools.java:95-97}} 
-> {{RuntimeService.findSingleProcess}}), while {{camel_run}}, 
{{camel_get_log}}, {{camel_get_errors}}, {{camel_control}} and 
{{camel_eval_expression}} take {{name}}. {{ToolArgumentAliases}} (46-52) has no 
{{name -> nameOrPid}}, so the argument is only noted as ignored and the tool 
picks the one integration that runs:

{noformat}
camel_runtime_routes {"name":"nosuch"}
{"argumentNote":"ignored: name; camel_runtime_routes takes 
nameOrPid","routes":[{"routeId":"ra",...
{noformat}

The same path serves route control, send, receive, SQL, HTTP requests and 
chaos, so an agent that carries {{name}} over can change another app, including 
the user's own. In {{camel_runtime_heap_dump}} {{name}} is the dump's file 
name. Add the alias, rename the heap dump argument to {{file}}, and do not 
auto-select when a selector-like argument was ignored.

h3. 2. camel_get_files returns a file of any size (exp, high)

{{ai/AuthoringTools.java:2334}} puts the whole file in the answer: a 3.6 MB 
file gave a 4.5 MB answer (about 1M tokens). {{camel_validate_source}} reads an 
existing file the same way. Cap the content, add offset/limit in lines, and say 
when it was cut.

h3. 3. camel_version_list always fails with a NullPointerException (exp, high)

{{VersionTools.java:57-67}} creates {{new VersionList(main)}}; since the aesh 
port its {{@Mixin MavenResolverMixin mavenResolver}} stays null, and 
{{VersionList.java:197}} throws. There is no test, and the tool declares 
{{openWorldHint=false}} although it reaches Maven Central.

h3. 4. camel_render_route_diagram (exp)

{{ActionBaseCommand.dumpRoutesFromSource}} (265-298) uses 
{{.camel-jbang/route-diagram-source-<pid>}}, the same for every call in the 
server, deletes it at the start, and boots a short camel run in the server JVM:
* Three calls at once: one ok, one timed out after 17 s, one 
{{NoSuchFileException}}. Clients call tools in parallel.
* 6.1-6.6 s per call even warm (3.2 s boot plus a fixed 1 s wait).
* The short Camel turns on the CLI connector, so the MCP server shows up in 
{{~/.camel}} for 2.5 s per diagram; {{camel ps}}, the TUI and other sessions 
see it, and their "only one running" auto-selection breaks.
* A temp file is left per call, the PNG answer says "Diagram saved to" twice, a 
relative {{sourceFile}} is resolved against the server's working directory, and 
{{.camel-jbang/}} is created in the user's project.

h3. 5. Source lines come back with escaped quotes (exp)

The dev consoles escape each code line with {{Jsoner.escape}} before putting it 
in JSON ({{RouteDumpDevConsole.java:228,279,281}}, {{ConsoleHelper.java:74}}, 
{{RouteStructureDevConsole.java:277}}, {{MessageHistoryDevConsole.java:138}}, 
{{DebugDevConsole.java:380,419}}). The CLI undoes it 
({{CamelRouteDumpAction.java:185}}, {{CamelSourceAction.java:135}}); 
route_source, route_dump, route_structure, routes, processor_detail, 
config_drift and history do not, so the agent sees {{\"}} that is not in the 
file. {{camel_edit_file}} works around it (CAMEL-24909).

h3. 6. camel_edit_file with a whitespace replace deletes text (exp)

{{camel-jbang-mcp/.../AuthoringTools.java:591-595}} drops blank strings from 
the arguments, so {{replace:"\n"}} or {{replace:"  "}} becomes "" and the text 
is deleted, reported as "edited". In YAML whitespace is structure. 
{{camel_write_file}} refuses empty content, so an agent cannot empty a file. 
Drop only null values.

h3. 7. camel ask history grows until every question fails (read)

{{Ask.java:243-302}} keeps every tool call and result for the session, results 
are not cut ({{AskTools.executeTool}}; {{cli_exec}} returns up to 32 KB of 
stdout plus 32 KB of stderr), and {{LlmClient}} does not trim. Once the history 
is larger than the model's context every later question fails, and the failed 
turn stays in the history.

h3. 8. Outside the launcher the server runs the camel on PATH, and camel mcp 
needs jbang (exp)

{{camel_run}} and {{camel_control restart}} start 
{{LauncherHelper.getCamelCommand()}} ({{ai/IntegrationLauncher.java:98,158}}), 
which in the runner jar is the {{camel}} on PATH, although 
{{camel-jbang-mcp.adoc:70-83}} says {{java -jar}} needs no JBang; it may also 
be another Camel version. {{camel mcp}} from the launcher without jbang exits 
70 with a 23-line trace ({{McpCommand.java:56-67}} always runs jbang).

h3. 9. A catalog lookup that finds nothing is a success (exp)

{{ai/CatalogDocs.java:576,1955-1961}} answers {{{"error":...}}} as data 
({{isError=false}}), with no near-spelling suggestion ({{kafak}}), and 
{{callDeterministic}} counts it as answered: the third identical call says "Go 
on with the options the earlier answer gave".

h3. 10. Smaller

* Answers name camel ask tools the server does not have ({{list_processes}}, 
{{list_examples}}, {{select_process}}: {{ai/AuthoringTools.java:2895}}, 
{{ai/ToolContext.java:269,292}}, {{ai/IntegrationLauncher.java:250,499}}, 
{{ai/ToolRegistry.java:156,1747}}). Add a test that every tool name in an 
answer exists.
* A camelVersion that cannot be loaded silently answers from the built-in 
catalog and is retried on every call ({{CatalogService.java:146-156}}); 
validate says "valid" with no hint.
* 98 tools are 97 KB, about 24k tokens per session, with no tool groups. 
Argument names differ ({{nameOrPid}}/{{name}}, {{term}}/{{filter}}/{{query}}, 
{{limit}}/{{maxRows}}); some numbers and booleans are strings (memory_leak, 
heap_dump); several tools overlap.
* Large answers without a limit: security_advisories 71 KB, thread_dump 13 KB 
for 2 routes, catalog_examples 40 KB.
* {{camel_runtime_processes}} returns one text item per process and nothing 
when none runs; its name is the file name.
* Empty answers without a reason: metrics without micrometer, browse on 
{{direct:}}, services.
* No tools for export, test run or infra.

h3. Latency (warm)

catalog and validate 2-25 ms; runtime tools from the status file 4-34 ms, 
through an action 100-210 ms; route diagram 6 s; camel_run 3.6 s.

_Claude Code on behalf of Claus Ibsen_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to