This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch feature/CAMEL-23852-mcp-cli in repository https://gitbox.apache.org/repos/asf/camel.git
commit 06332a54802ca1649505cdbd2c5315e5836f45aa Author: Claus Ibsen <[email protected]> AuthorDate: Mon Jun 29 12:21:26 2026 +0200 CAMEL-23852: Add camel mcp CLI command Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../modules/ROOT/pages/camel-jbang-mcp.adoc | 392 +++++++++++++-------- .../camel/dsl/jbang/core/common/PluginType.java | 1 + .../{ => camel-jbang-plugin-mcp}/pom.xml | 44 ++- .../camel-jbang-plugin/camel-jbang-plugin-mcp | 2 + .../dsl/jbang/core/commands/mcp/McpCommand.java | 76 ++++ .../dsl/jbang/core/commands/mcp/McpPlugin.java | 31 ++ dsl/camel-jbang/camel-launcher/pom.xml | 5 + dsl/camel-jbang/pom.xml | 1 + 8 files changed, 373 insertions(+), 179 deletions(-) diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang-mcp.adoc b/docs/user-manual/modules/ROOT/pages/camel-jbang-mcp.adoc index 74a885006a48..613624b8afe7 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-jbang-mcp.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-jbang-mcp.adoc @@ -1,21 +1,251 @@ = Camel MCP Server -The Camel MCP Server exposes the Apache Camel Catalog and runtime introspection tools through the -https://modelcontextprotocol.io/[Model Context Protocol (MCP)]. AI coding assistants (Claude Code, OpenAI Codex, -GitHub Copilot, JetBrains AI) can query catalog data, validate endpoints, analyze routes, and inspect running applications. +The Camel MCP Server gives AI coding assistants deep knowledge of Apache Camel. +It exposes the full Camel Catalog — components, EIPs, data formats, Kamelets, examples — plus +runtime introspection tools for live Camel applications, all through the +https://modelcontextprotocol.io/[Model Context Protocol (MCP)]. -Built on https://quarkus.io/[Quarkus] with the https://docs.quarkiverse.io/quarkus-mcp-server/dev/index.html[quarkus-mcp-server] extension, launched via https://www.jbang.dev/[JBang]. +With the MCP server running, your AI assistant can look up component documentation, validate +endpoints and routes, generate test scaffolds, diagnose errors from stack traces, check +dependencies, plan migrations, review routes for security concerns, and interact with running +Camel applications — without you having to copy-paste anything. -NOTE: This module is in *Preview* status as of Camel 4.18. +Built on https://quarkus.io/[Quarkus] with the +https://docs.quarkiverse.io/quarkus-mcp-server/dev/index.html[quarkus-mcp-server] extension. + +NOTE: This module is in *Preview* status since Camel 4.18. + +== Getting Started + +The quickest way to get started: + +1. Install https://www.jbang.dev/[JBang] (one-time) +2. Run `camel mcp` (or `jbang org.apache.camel:camel-jbang-mcp:LATEST:runner`) +3. Connect your AI assistant (see <<Setup>> below) + +That's it — the MCP server starts with STDIO transport and your AI assistant can immediately +query the Camel Catalog, validate routes, and more. + +== Running the MCP Server + +There are three ways to run the MCP server. + +=== Using the Camel CLI (recommended) + +The `camel mcp` command launches the MCP server as a first-class CLI command: + +[source,bash] +---- +camel mcp +---- + +This starts the MCP server with STDIO transport (the default). To enable HTTP transport: + +[source,bash] +---- +camel mcp --http +camel mcp --http --port 9090 +---- + +See <<Options>> for all available flags. + +=== Using JBang directly + +If you have https://www.jbang.dev/[JBang] installed: + +[source,bash] +---- +# STDIO transport (default) +jbang org.apache.camel:camel-jbang-mcp:LATEST:runner + +# HTTP transport +jbang -Dquarkus.http.host-enabled=true -Dquarkus.http.port=8080 org.apache.camel:camel-jbang-mcp:LATEST:runner +---- + +=== Using java -jar (no JBang needed) + +Download the MCP server uber-JAR from Maven Central and run it directly: + +[source,bash] +---- +# Download (replace VERSION with the desired Camel version, e.g., 4.21.0) +curl -O https://repo1.maven.org/maven2/org/apache/camel/camel-jbang-mcp/VERSION/camel-jbang-mcp-VERSION-runner.jar + +# Run with STDIO transport +java -jar camel-jbang-mcp-VERSION-runner.jar + +# Run with HTTP transport +java -Dquarkus.http.host-enabled=true -Dquarkus.http.port=8080 -jar camel-jbang-mcp-VERSION-runner.jar +---- == Transport * **STDIO** (default) -- communicates over stdin/stdout. Logging goes to stderr. -* **HTTP/SSE** -- for web-based clients and remote/shared access. Enable with `quarkus.http.host-enabled=true`. +* **HTTP/SSE** -- for web-based clients and remote/shared access. Enable with `--http` flag or `-Dquarkus.http.host-enabled=true`. Supports two variants: SSE (`/mcp/sse`, protocol `2024-11-05`) and Streamable HTTP (`/mcp`, protocol `2025-03-26`, recommended for new integrations). IMPORTANT: The MCP server does **not** expose REST endpoints — all communication uses JSON-RPC over the MCP protocol. +[[Setup]] +== Setup + +=== Claude Code (plugin install, recommended) + +[source,bash] +---- +claude plugin marketplace add apache/camel +claude plugin install camel-mcp@camel-marketplace +---- + +=== Manual configuration (all AI tools) + +Add the server to your MCP configuration file. The JSON is the same for all tools — only the file location differs: + +[cols="1,2",options="header"] +|=== +| Tool | Configuration file + +| Claude Code | `.mcp.json` (project) or `~/.claude/mcp.json` (global) +| OpenAI Codex | MCP configuration file +| VS Code / Copilot | `.vscode/mcp.json` (use `"servers"` instead of `"mcpServers"` as the top-level key) +| JetBrains IDEs (2025.1+) | Settings > Tools > AI Assistant > MCP Servers, or `.junie/mcp.json` +|=== + +[source,json] +---- +{ + "mcpServers": { + "camel": { + "command": "jbang", + "args": [ + "-Dquarkus.log.level=WARN", + "org.apache.camel:camel-jbang-mcp:LATEST:runner" + ] + } + } +} +---- + +NOTE: For VS Code, the top-level key is `"servers"` instead of `"mcpServers"`. + +=== Inspecting with MCP Inspector + +Start the server with HTTP enabled, then: + +[source,bash] +---- +npx @modelcontextprotocol/inspector +---- + +Open http://localhost:6274/, set Transport Type to `SSE`, URL to `http://localhost:8080/mcp/sse`, Connection to `Via Proxy`. + +[[Options]] +== `camel mcp` Options + +[cols="1,1,3",options="header"] +|=== +| Option | Default | Description + +| `--http` +| `false` +| Enable HTTP transport (Streamable HTTP and SSE). Without this flag, the server uses STDIO transport. + +| `--port` +| `8080` +| HTTP server port (only used with `--http`). + +| `--log-level` +| `WARN` +| Log level: `ERROR`, `WARN`, `INFO`, `DEBUG`, `TRACE`. + +| `--version` +| _(current Camel version)_ +| Camel MCP server version to use. Defaults to the version of the Camel CLI. +|=== + +== Examples + +Here are example prompts you can give your AI assistant. The assistant automatically selects the right MCP tools. + +=== Catalog exploration + +* _"List all Camel components in the messaging category"_ — uses `camel_catalog_components` +* _"Show me the Kafka component documentation with all options"_ — uses `camel_catalog_component_doc` +* _"Show me all AWS source kamelets"_ — uses `camel_catalog_kamelets` +* _"What options does aws-s3-source accept?"_ — uses `camel_catalog_kamelet_doc` +* _"Show me beginner REST examples"_ — uses `camel_catalog_examples` + +=== Building routes + +Ask the assistant to build a route from requirements: + +---- +Build me a Camel route that generates a message every 5 seconds with a random number, +logs it, and sends it to a SEDA queue called "numbers". +---- + +The assistant discovers components, looks up documentation, builds a YAML route, and validates it with `camel_validate_yaml_dsl`. Use the `camel_build_integration` prompt for a structured multi-step workflow. + +=== Validation + +* _"Validate this endpoint: `kafka:myTopic?brkers=localhost:9092`"_ — detects the typo and suggests `brokers` +* _"Validate this YAML route"_ — checks against the YAML DSL JSON schema, reports invalid elements + +=== Understanding, security, and testing + +* _"Explain what this route does"_ — uses `camel_route_context` for catalog-enriched analysis +* _"Analyze this route for security concerns"_ — uses `camel_route_harden_context` to detect hardcoded credentials, plain-text protocols, etc. +* _"Generate a JUnit 5 test for this route"_ — uses `camel_route_test_scaffold` to produce test class with mock endpoints and test-infra stubs + +=== Error diagnosis + +Paste a stack trace: + +---- +org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> To[kafka:myTopic] <<< +Caused by: org.apache.camel.NoSuchEndpointException: No endpoint could be found for: kafka:myTopic +---- + +The assistant uses `camel_error_diagnose` to identify the exception chain, extract components, and suggest fixes (e.g., missing `camel-kafka` dependency). + +=== Dependencies and versions + +* _"Check my pom.xml for missing or outdated dependencies"_ — uses `camel_dependency_check` +* _"What are the latest LTS versions for Spring Boot?"_ — uses `camel_version_list` + +=== Migration + +* _"Migrate my project to the latest version (here's my pom.xml)"_ — uses `camel_migration_analyze` → `camel_migration_compatibility` → `camel_migration_recipes` +* _"What changed with direct-vm in Camel 4?"_ — uses `camel_migration_guide_search` +* _"Migrate from WildFly to Quarkus"_ — uses `camel_migration_wildfly_karaf` for archetype commands and steps +* Use the `camel_migrate_project` prompt for an orchestrated multi-step workflow + +=== OpenAPI contract-first + +* _"Validate this OpenAPI spec for Camel compatibility"_ — uses `camel_openapi_validate` +* _"Generate a Camel YAML scaffold with mock mode"_ — uses `camel_openapi_scaffold` +* _"Show me the mock directory structure"_ — uses `camel_openapi_mock_guidance` + +Combine all three for a complete prototyping workflow: validate, scaffold, then implement routes one at a time while Camel mocks the rest. + +=== Runtime introspection + +Start a route with `camel run my-route.yaml`, then ask: + +* _"Show me running Camel processes and route statistics"_ — uses `camel_runtime_processes` and `camel_runtime_routes` +* _"Enable tracing and show me the traced messages"_ — uses `camel_runtime_trace` +* _"Send a test message to direct:start"_ — uses `camel_runtime_send` +* _"Which processors are the slowest?"_ — uses `camel_runtime_top` +* _"Browse messages in seda:numbers"_ — uses `camel_runtime_browse` + +=== Prompts (structured workflows) + +MCP clients that support prompts expose these as selectable workflows: + +* `camel_build_integration` — 7-step guided workflow: discover components → select EIPs → build → validate → security review +* `camel_migrate_project` — 6-step migration: analyze → compatibility → recipes → guide search → summary +* `camel_security_review` — 3-step audit: analyze vulnerabilities → understand data flow → produce checklist + == Available Tools The server exposes catalog tools for exploring components, validating routes, and assisting with migration, @@ -435,153 +665,3 @@ instructions and executes each step by calling the referenced tools. produce an actionable audit checklist organized into critical issues, warnings, positive findings, recommendations, and compliance notes. |=== - -== Setup - -The MCP server requires https://www.jbang.dev/[JBang] installed and on your PATH. - -=== Claude Code (plugin install, recommended) - -[source,bash] ----- -claude plugin marketplace add apache/camel -claude plugin install camel-mcp@camel-marketplace ----- - -=== Manual configuration (all AI tools) - -Add the server to your MCP configuration file. The JSON is the same for all tools — only the file location differs: - -[cols="1,2",options="header"] -|=== -| Tool | Configuration file - -| Claude Code | `.mcp.json` (project) or `~/.claude/mcp.json` (global) -| OpenAI Codex | MCP configuration file -| VS Code / Copilot | `.vscode/mcp.json` (use `"servers"` instead of `"mcpServers"` as the top-level key) -| JetBrains IDEs (2025.1+) | Settings > Tools > AI Assistant > MCP Servers, or `.junie/mcp.json` -|=== - -[source,json] ----- -{ - "mcpServers": { - "camel": { - "command": "jbang", - "args": [ - "-Dquarkus.log.level=WARN", - "org.apache.camel:camel-jbang-mcp:LATEST:runner" - ] - } - } -} ----- - -NOTE: For VS Code, the top-level key is `"servers"` instead of `"mcpServers"`. - -=== Generic STDIO or HTTP/SSE - -[source,bash] ----- -# STDIO (any MCP client) -jbang org.apache.camel:camel-jbang-mcp:LATEST:runner - -# HTTP/SSE transport -jbang -Dquarkus.http.host-enabled=true -Dquarkus.http.port=8080 org.apache.camel:camel-jbang-mcp:LATEST:runner ----- - -HTTP endpoints: `/mcp/sse` (SSE, legacy) and `/mcp` (Streamable HTTP, recommended). - -=== Inspecting with MCP Inspector - -Start the server with HTTP enabled, then: - -[source,bash] ----- -npx @modelcontextprotocol/inspector ----- - -Open http://localhost:6274/, set Transport Type to `SSE`, URL to `http://localhost:8080/mcp/sse`, Connection to `Via Proxy`. - -== Examples - -Here are example prompts you can give your AI assistant. The assistant automatically selects the right MCP tools. - -=== Catalog exploration - -* _"List all Camel components in the messaging category"_ — uses `camel_catalog_components` -* _"Show me the Kafka component documentation with all options"_ — uses `camel_catalog_component_doc` -* _"Show me all AWS source kamelets"_ — uses `camel_catalog_kamelets` -* _"What options does aws-s3-source accept?"_ — uses `camel_catalog_kamelet_doc` -* _"Show me beginner REST examples"_ — uses `camel_catalog_examples` - -=== Building routes - -Ask the assistant to build a route from requirements: - ----- -Build me a Camel route that generates a message every 5 seconds with a random number, -logs it, and sends it to a SEDA queue called "numbers". ----- - -The assistant discovers components, looks up documentation, builds a YAML route, and validates it with `camel_validate_yaml_dsl`. Use the `camel_build_integration` prompt for a structured multi-step workflow. - -=== Validation - -* _"Validate this endpoint: `kafka:myTopic?brkers=localhost:9092`"_ — detects the typo and suggests `brokers` -* _"Validate this YAML route"_ — checks against the YAML DSL JSON schema, reports invalid elements - -=== Understanding, security, and testing - -* _"Explain what this route does"_ — uses `camel_route_context` for catalog-enriched analysis -* _"Analyze this route for security concerns"_ — uses `camel_route_harden_context` to detect hardcoded credentials, plain-text protocols, etc. -* _"Generate a JUnit 5 test for this route"_ — uses `camel_route_test_scaffold` to produce test class with mock endpoints and test-infra stubs - -=== Error diagnosis - -Paste a stack trace: - ----- -org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> To[kafka:myTopic] <<< -Caused by: org.apache.camel.NoSuchEndpointException: No endpoint could be found for: kafka:myTopic ----- - -The assistant uses `camel_error_diagnose` to identify the exception chain, extract components, and suggest fixes (e.g., missing `camel-kafka` dependency). - -=== Dependencies and versions - -* _"Check my pom.xml for missing or outdated dependencies"_ — uses `camel_dependency_check` -* _"What are the latest LTS versions for Spring Boot?"_ — uses `camel_version_list` - -=== Migration - -* _"Migrate my project to the latest version (here's my pom.xml)"_ — uses `camel_migration_analyze` → `camel_migration_compatibility` → `camel_migration_recipes` -* _"What changed with direct-vm in Camel 4?"_ — uses `camel_migration_guide_search` -* _"Migrate from WildFly to Quarkus"_ — uses `camel_migration_wildfly_karaf` for archetype commands and steps -* Use the `camel_migrate_project` prompt for an orchestrated multi-step workflow - -=== OpenAPI contract-first - -* _"Validate this OpenAPI spec for Camel compatibility"_ — uses `camel_openapi_validate` -* _"Generate a Camel YAML scaffold with mock mode"_ — uses `camel_openapi_scaffold` -* _"Show me the mock directory structure"_ — uses `camel_openapi_mock_guidance` - -Combine all three for a complete prototyping workflow: validate, scaffold, then implement routes one at a time while Camel mocks the rest. - -=== Runtime introspection - -Start a route with `camel run my-route.yaml`, then ask: - -* _"Show me running Camel processes and route statistics"_ — uses `camel_runtime_processes` and `camel_runtime_routes` -* _"Enable tracing and show me the traced messages"_ — uses `camel_runtime_trace` -* _"Send a test message to direct:start"_ — uses `camel_runtime_send` -* _"Which processors are the slowest?"_ — uses `camel_runtime_top` -* _"Browse messages in seda:numbers"_ — uses `camel_runtime_browse` - -=== Prompts (structured workflows) - -MCP clients that support prompts expose these as selectable workflows: - -* `camel_build_integration` — 7-step guided workflow: discover components → select EIPs → build → validate → security review -* `camel_migrate_project` — 6-step migration: analyze → compatibility → recipes → guide search → summary -* `camel_security_review` — 3-step audit: analyze vulnerabilities → understand data flow → produce checklist diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/PluginType.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/PluginType.java index 32ab80632d44..997214bd8841 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/PluginType.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/PluginType.java @@ -30,6 +30,7 @@ public enum PluginType { TEST("test", "test", "Manage tests for Camel applications", "4.14.0", null, "ASF"), ROUTE_PARSER("route-parser", "route-parser", "Parses Java route and dumps route structure", "4.17.0", null, "ASF"), VALIDATE("validate", "validate", "Validate Camel routes", "4.18.0", null, "ASF"), + MCP("mcp", "mcp", "MCP server for AI coding assistants", "4.21.0", null, "ASF"), TUI("tui", "tui", "Camel Dashboard", "4.20.0", null, "ASF"); private final String name; diff --git a/dsl/camel-jbang/pom.xml b/dsl/camel-jbang/camel-jbang-plugin-mcp/pom.xml similarity index 58% copy from dsl/camel-jbang/pom.xml copy to dsl/camel-jbang/camel-jbang-plugin-mcp/pom.xml index d6a6cf2b6d2b..fd3b00f5eb7f 100644 --- a/dsl/camel-jbang/pom.xml +++ b/dsl/camel-jbang/camel-jbang-plugin-mcp/pom.xml @@ -18,35 +18,33 @@ --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.camel</groupId> - <artifactId>dsl</artifactId> + <artifactId>camel-jbang-parent</artifactId> <version>4.21.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> - <artifactId>camel-jbang-parent</artifactId> - <packaging>pom</packaging> - - <name>Camel :: JBang :: Parent</name> - <description>Camel CLI Modules (parent)</description> - - <modules> - <module>camel-jbang-console</module> - <module>camel-jbang-core</module> - <module>camel-jbang-main</module> - <module>camel-jbang-mcp</module> - <module>camel-jbang-plugin-generate</module> - <module>camel-jbang-plugin-edit</module> - <module>camel-jbang-plugin-kubernetes</module> - <module>camel-jbang-plugin-route-parser</module> - <module>camel-jbang-plugin-test</module> - <module>camel-jbang-plugin-tui</module> - <module>camel-jbang-plugin-validate</module> - <module>camel-jbang-it</module> - <module>camel-launcher</module> - <module>camel-launcher-container</module> - </modules> + <artifactId>camel-jbang-plugin-mcp</artifactId> + + <name>Camel :: JBang :: Plugin :: MCP</name> + <description>Camel CLI MCP Plugin - Launches the Camel MCP server for AI coding assistants</description> + + <properties> + <firstVersion>4.21.0</firstVersion> + <label>jbang,mcp,ai</label> + <supportLevel>Preview</supportLevel> + <camel-prepare-component>false</camel-prepare-component> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-jbang-core</artifactId> + </dependency> + </dependencies> + </project> diff --git a/dsl/camel-jbang/camel-jbang-plugin-mcp/src/generated/resources/META-INF/services/org/apache/camel/camel-jbang-plugin/camel-jbang-plugin-mcp b/dsl/camel-jbang/camel-jbang-plugin-mcp/src/generated/resources/META-INF/services/org/apache/camel/camel-jbang-plugin/camel-jbang-plugin-mcp new file mode 100644 index 000000000000..d57b288500ea --- /dev/null +++ b/dsl/camel-jbang/camel-jbang-plugin-mcp/src/generated/resources/META-INF/services/org/apache/camel/camel-jbang-plugin/camel-jbang-plugin-mcp @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.dsl.jbang.core.commands.mcp.McpPlugin diff --git a/dsl/camel-jbang/camel-jbang-plugin-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/McpCommand.java b/dsl/camel-jbang/camel-jbang-plugin-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/McpCommand.java new file mode 100644 index 000000000000..81fa9fb318c0 --- /dev/null +++ b/dsl/camel-jbang/camel-jbang-plugin-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/McpCommand.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.dsl.jbang.core.commands.mcp; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.camel.dsl.jbang.core.commands.CamelCommand; +import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain; +import org.apache.camel.dsl.jbang.core.common.VersionHelper; +import picocli.CommandLine; + [email protected](name = "mcp", + description = "MCP server for AI coding assistants", + sortOptions = false) +public class McpCommand extends CamelCommand { + + @CommandLine.Option(names = { "--http" }, + description = "Enable HTTP transport (Streamable HTTP and SSE). Default uses STDIO transport.", + defaultValue = "false") + boolean http; + + @CommandLine.Option(names = { "--port" }, + description = "HTTP server port (only used with --http)", + defaultValue = "8080") + int port = 8080; + + @CommandLine.Option(names = { "--log-level" }, + description = "Log level (ERROR, WARN, INFO, DEBUG, TRACE)", + defaultValue = "WARN") + String logLevel = "WARN"; + + @CommandLine.Option(names = { "--version" }, + description = "Camel MCP server version to use (default: current Camel version)") + String version; + + public McpCommand(CamelJBangMain main) { + super(main); + } + + @Override + public Integer doCall() throws Exception { + String mcpVersion = version; + if (mcpVersion == null || mcpVersion.isBlank()) { + mcpVersion = VersionHelper.extractCamelVersion(); + } + + List<String> cmd = new ArrayList<>(); + cmd.add("jbang"); + cmd.add("-Dquarkus.log.level=" + logLevel); + if (http) { + cmd.add("-Dquarkus.http.host-enabled=true"); + cmd.add("-Dquarkus.http.port=" + port); + } + cmd.add("org.apache.camel:camel-jbang-mcp:" + mcpVersion + ":runner"); + + ProcessBuilder pb = new ProcessBuilder(cmd); + pb.inheritIO(); + Process process = pb.start(); + return process.waitFor(); + } +} diff --git a/dsl/camel-jbang/camel-jbang-plugin-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/McpPlugin.java b/dsl/camel-jbang/camel-jbang-plugin-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/McpPlugin.java new file mode 100644 index 000000000000..4dabd794f1bc --- /dev/null +++ b/dsl/camel-jbang/camel-jbang-plugin-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/McpPlugin.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.dsl.jbang.core.commands.mcp; + +import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain; +import org.apache.camel.dsl.jbang.core.common.CamelJBangPlugin; +import org.apache.camel.dsl.jbang.core.common.Plugin; +import picocli.CommandLine; + +@CamelJBangPlugin(name = "camel-jbang-plugin-mcp", firstVersion = "4.21.0") +public class McpPlugin implements Plugin { + + @Override + public void customize(CommandLine commandLine, CamelJBangMain main) { + commandLine.addSubcommand("mcp", new CommandLine(new McpCommand(main))); + } +} diff --git a/dsl/camel-jbang/camel-launcher/pom.xml b/dsl/camel-jbang/camel-launcher/pom.xml index ef528936be47..0ded25be9733 100644 --- a/dsl/camel-jbang/camel-launcher/pom.xml +++ b/dsl/camel-jbang/camel-launcher/pom.xml @@ -101,6 +101,11 @@ <artifactId>camel-jbang-plugin-kubernetes</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-jbang-plugin-mcp</artifactId> + <version>${project.version}</version> + </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-jbang-plugin-tui</artifactId> diff --git a/dsl/camel-jbang/pom.xml b/dsl/camel-jbang/pom.xml index d6a6cf2b6d2b..c1d5899f60df 100644 --- a/dsl/camel-jbang/pom.xml +++ b/dsl/camel-jbang/pom.xml @@ -41,6 +41,7 @@ <module>camel-jbang-plugin-generate</module> <module>camel-jbang-plugin-edit</module> <module>camel-jbang-plugin-kubernetes</module> + <module>camel-jbang-plugin-mcp</module> <module>camel-jbang-plugin-route-parser</module> <module>camel-jbang-plugin-test</module> <module>camel-jbang-plugin-tui</module>
