Add MCP runtime tools and camel ask AI assistant#23346
Conversation
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
I like the idea.. but I am not so sure about the implementation.. this is some kind of proxy between an LLM and a running camel application. The proxy idea is good, otherwise you should know a priori the endpoint of the running app, on the other hand:
|
|
This is a great feature ! |
|
Yeah this is a great step forward. Since the main instrucmention is dev consoles. I wonder if the description should be tied to that, it may say using dev consoles and other features. So its more open. Also the AI is good at analyzing the dev consoles, also via jbang cli use of them. But we may consider some kind of formal metadata contract that has more details. There are some dev consoles that have options to filter etc that are not documented. But the AI can scan the code and document them officially in the json metadat file. Currently it just have "console" as entry. But it could have "properties" to include these options. |
I rewrote it completely differently by embedding the java MCP server inside Camel. |
I see, but how do you picture the e2e flow? what if the camel app is running on another port? do you know if AI code assistant can load remote MCP server at runtime? |
orpiske
left a comment
There was a problem hiding this comment.
Claude Code on behalf of Otavio Rodolfo Piske
Review
Well-designed feature — the architecture follows established Camel patterns (@JdkService factory, ServiceSupport, StaticService) and the 24 tools mapped to DevConsole endpoints are a natural fit. The tests cover tool registry, prompt registry, and DevConsole handler well.
Issues
1. Duplicate camel.main.devConsoleEnabled in generated metadata (Bug)
The generated camel-main-configuration-metadata.json now has two entries for camel.main.devConsoleEnabled — one from DefaultConfigurationProperties (default false, description about developer console) and one from McpServerConfigurationProperties (default true, description about MCP tools). The other MCP properties (enabled, serverName, serverVersion, transport, includeTools, excludeTools) also appear under camel.main.* instead of camel.mcp.*. The main.adoc renders them this way too, which will confuse users.
2. Missing @since 4.21 Javadoc tags (Convention)
New public types in camel-main are missing @since 4.21:
MainMcpServerFactoryMcpServerConfigurationProperties
3. Security annotation missing on enabled property
The existing devConsoleEnabled in DefaultConfigurationProperties carries @Metadata(security = "insecure:dev") because DevConsole is development-only. The MCP server's enabled property exposes the same DevConsole data over a communication channel to external agents — arguably a larger attack surface. It should also carry security = "insecure:dev" so the security policy framework (camel.main.profile = prod) blocks it in production by default.
4. FQCN in McpServerService.createTransportProvider()
new JacksonMcpJsonMapper(new com.fasterxml.jackson.databind.ObjectMapper())Per project conventions, ObjectMapper should be imported rather than fully qualified.
5. Documented transports vs. implemented
McpServerConfigurationProperties.transport Javadoc says (stdio, uds, tcp) but McpServerService.createTransportProvider() throws IllegalArgumentException for anything non-stdio. The docs should reflect current reality or note these are planned.
6. CI failing
All 3 build jobs (JDK 17, 21, 25) are failing.
Suggestions (non-blocking)
serverVersiondefault of"1.0.0": consider using the CamelContext version dynamically so the MCP server version tracks the Camel version.McpToolRegistry.addToolWithCustomHandleris only used forcamel_top— could be unified withaddToolby adding a console ID mapper instead of a separate method.
|
Claude Code on behalf of Guillaume Nodet Good question. The current STDIO approach requires putting the route filename in the MCP config, which isn't user-friendly — you'd have to update the config and restart your agent every time the route changes. The plan is to take a different approach: a JBang command { "command": "jbang", "args": ["camel", "mcp"] }No URL, no route name, no port — ever. The command auto-discovers the running Camel instance (JBang already has all the process discovery logic). If multiple apps are running, you can pass This way:
The embedded Java MCP server stays useful for SSE transport later (native MCP endpoint on the HTTP server), but for the AI assistant use case, this is much cleaner. |
|
Claude Code on behalf of Guillaume Nodet Design Update: Runtime tools via JBang MCP ServerReworked the approach based on discussion. Instead of embedding an MCP server inside each Camel application (which required hardcoding the route filename or port in the MCP config), the runtime tools now live in the existing Key advantage: The MCP config is static and trivial: {"command": "jbang", "args": ["camel", "mcp"]}No route name, URL, or port — the server auto-discovers running Camel processes via Communication: Uses the existing file-based IPC protocol that 21 runtime tools added covering process discovery, context/route/health inspection, route control, message sending, tracing, expression evaluation, and endpoint browsing. |
I would also like for us to be able to include this MCP capability in the new camel tui, so end user can just run "one thing" such as camel tui --mcp (we can come up with a better name than tui). So you have that possibility as well. Then the TUI can visually show the human what happens and give easy access to all parts of Camel in a nice dashboard / system. While the AI / MCP can do its thing. But that can be done after this work. |
|
🧪 CI tested the following changed modules:
💡 Manual integration tests recommended:
All tested modules (8 modules)
|
|
there is a doc issue |
New:
|
|
f9e6cc1 to
34a645b
Compare
Inside the JLine shell, System.console() returns null, causing subcommands that read interactive input to silently fail. This moves the active terminal reference to EnvironmentHelper so all commands can detect and use the shell's terminal for input/output. Commands fixed: - debug: user input (step, quit) now works inside shell - infra run: "press ENTER to stop" now works inside shell - init: interactive template picker now works inside shell - watch commands: "press enter" to stop now works inside shell - confirmOperation: interactive confirmation now works inside shell Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add runtime inspection tools to the MCP server: context info, routes, health checks, endpoints, consumers, inflight/blocked exchanges, route source/dump/structure, trace control, and route lifecycle - Add route diagram tools for visualizing route structure - Update ExampleTools to use shared ExampleHelper - Add IPC actions in LocalCliConnector for runtime inspection - Update MCP documentation with new tool descriptions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add interactive AI assistant that can inspect running Camel apps, search the catalog, browse examples, and create/edit route files - Support Ollama (native /api/chat), OpenAI, and Anthropic APIs with auto-detection and Ollama model auto-selection for tool calling - Add streaming support for Ollama responses (progressive token output) - Add --verbose flag for debugging LLM requests and responses - Disable thinking mode on Ollama models (Qwen 3.5 etc.) via think:false - Refactor Explain command to share LlmClient with Ask - Add documentation for ask and explain commands Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4c8b11a to
0c30d5d
Compare
Summary
Two features adding AI-powered capabilities to Camel JBang: runtime MCP tools for live process inspection, and an interactive
camel askAI assistant with function calling.Depends on: #23479
MCP runtime tools
camel_runtime_*) for inspecting and interacting with live Camel applications via the file-based IPC protocolcamel_catalog_examples,camel_catalog_example_file) for browsing Camel JBang examplescamel-jbang-mcp.adoccamel ask— AI assistant with tool callingAn interactive AI assistant for Camel JBang that can inspect running applications, search the component catalog, browse examples, and create/edit route files — all through natural language.
LLM providers:
/api/chatAPI with NDJSON streaming, auto-model selectionAuto-detection: The client auto-detects which provider is available (checks
ANTHROPIC_API_KEY,OPENAI_API_KEY, then probes Ollama atlocalhost:11434). Can also usecamel infra run ollamato start an Ollama instance automatically.Ollama model auto-selection: When using Ollama, automatically queries
/api/tagsand picks the best model for tool calling from a ranked list:qwen3.5,qwen3,nemotron-3-nano,mistral-nemo,qwen2.5,granite4.1,llama3.1,llama3.3,mistral. Works particularly well with Qwen 3.5 which has excellent tool-calling support.25 function-calling tools:
get_context,get_routes,get_health,get_endpoints,get_inflight,get_blocked,get_consumers,get_properties,get_route_source,get_route_dump,get_route_structure,get_top_processorstrace_control,stop_route,start_route,suspend_route,resume_route,stop_applicationcatalog_components,catalog_component_doc,catalog_eips,list_examples,get_example_filelist_files,read_file,write_fileStreaming: Responses stream token-by-token to the terminal for immediate feedback.
Modes:
camel ask "what routes are running?"— answers and exitsShared
LlmClient: Extracted fromExplain.javainto a reusable client supporting all three providers, streaming, tool use, conversation history, and verbose debug logging.Test plan
mvn install -B -pl dsl/camel-jbang/camel-jbang-core,dsl/camel-jbang/camel-jbang-mcp -DskipTestscamel askwith Ollama + Qwen 3.5: tool calling, streaming, multi-turn conversation