Federico Mariani created CAMEL-25541:
----------------------------------------
Summary: camel-jbang-mcp - catalog tools return unbounded option
lists: 15-35 K for a component by default, up to 124 K from
camel_component_properties
Key: CAMEL-25541
URL: https://issues.apache.org/jira/browse/CAMEL-25541
Project: Camel
Issue Type: Improvement
Components: camel-jbang-mcp
Affects Versions: 4.22.1
Reporter: Federico Mariani
The catalog tools return the full option list of a component with no size
bound. For the components a migration typically needs, the default answer
(common options only) is 15-35 K characters, and {{camel_component_properties}}
returns 15-124 K. Agents ask these tools for one option name.
In an evaluation of coding agents (Claude Code and IBM Bob) on migration tasks
with camel-jbang-mcp 4.22.1, 121 of 192 sessions that used
{{camel_catalog_component_doc}}, {{camel_component_properties}} or
{{camel_catalog_language_doc}} got at least one result over 20 000 characters
(211 of 772 calls). Claude Code rejected 4 results outright and wrote 48 more
to a file instead of showing them to the model.
h3. Reproduction
Sizes of the recorded results (component name only; runtime main, camelVersion
4.22.1):
{noformat}
camel_catalog_component_doc activemq 32 959 chars
(includeOptions=all: 84 212, rejected by the client)
camel_catalog_component_doc file 31 423
camel_catalog_component_doc smtp 20 611
(includeOptions=all: 37 786)
camel_catalog_component_doc http / https 14 857 / 14 869
camel_component_properties activemq 123 893 "Error:
result (123,893 characters across 1 line) exceeds maximum allowed tokens"
camel_component_properties netty-http 76 218 rejected
the same way
camel_component_properties file / smtp / http 62 K / 61 K / 47 K
camel_component_properties platform-http 14 996
camel_catalog_language_doc simple about 70 K (152
functions with parameters; 7 options)
{noformat}
{{camel_component_properties platform-http}} was called 35 times (20 Claude
Code, 15 IBM Bob) to find the HTTP server port; each answer was 15 K of options
and none contained it (those are {{camel.server.*}}, see CAMEL-25533).
h3. Cause
* {{CatalogTools.toComponentDetailResult}} (4.22.1) and, on main where
{{camel_catalog_component_doc}} was folded into {{camel_catalog_doc}} by
CAMEL-24712, the component branch of {{CatalogDocs}} with {{putOptions}}
(camel-jbang-core, {{commands/ai/CatalogDocs.java}}) add every option the
{{OptionScope}} accepts. {{common}} only drops deprecated and advanced options:
on main activemq still has 88 common options (about 38 K of JSON), file 75 (35
K), smtp 76 (24 K), http 60 (19 K). CAMEL-23475 introduced the scopes with the
goal of a lean default (Kafka under 2K tokens); for these components the
default is still an order of magnitude larger. Nothing limits the count;
{{omittedOptions}} only reports what the scope dropped.
* {{ComponentPropertiesTools.camel_component_properties}} has no filter at all:
it returns every component option and every endpoint option, with descriptions,
javaType and enum lists. It is unchanged on main apart from the optional
arguments of #27511.
* {{CatalogTools.toLanguageDetailResult}} (4.22.1) returns all non-deprecated
functions of simple with their parameters. On main {{camel_catalog_doc}}
already returns the simple functions as names by group unless {{optionsFilter}}
is given, so this part is solved there; it is listed for the 4.22.x line only.
h3. Fix
* {{camel_catalog_doc}} (component, data format, language options): without
{{optionsFilter}}, return the required options plus the first N common options
(N around 25), and add {{truncated: true}} and the total count with a hint
("optionsFilter=<word> finds one; includeOptions=all with a limit pages the
rest"). Alternatively return option names only (name, type, default) when no
filter is given and keep descriptions for filtered calls.
* {{camel_component_properties}}: add {{filter}} and {{limit}} arguments with
the same default bound, and leave out the endpoint options unless asked
({{includeEndpointOptions}}), since only the component options are
{{camel.component.<scheme>.*}} keys. Or drop the tool and add the
component-level keys to {{camel_catalog_doc}} (for example
{{includeProperties=true}}).
* Optionally, a hard cap on any catalog tool result (for example 16 000
characters) with a truncation marker, so a client never rejects or silently
cuts the answer.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)