This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch 3.40.x
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit 3dc90068c404af4cedcc82152c89390b9a3a360b
Author: croway <[email protected]>
AuthorDate: Wed Nov 18 14:45:12 2026 +0100

    Fixes #9522. mcp-server: test and document MCP protocol version 2026-07-28
    
    quarkus-mcp-server serves clients of MCP protocol version 2026-07-28 
without a
    session, next to the clients that open with initialize, on the same 
endpoint.
    Add McpServerStatelessTest (an McpAssured stateless client and a raw request
    that creates no session) with its native McpServerStatelessIT, and document 
the
    two kinds of clients. Backport of the change on main, without the resource 
read
    (3.40.x has no ai-resource).
---
 .../pages/reference/extensions/mcp-server.adoc     |  17 +++
 .../mcp-server/runtime/src/main/doc/usage.adoc     |  16 +++
 .../mcp/server/it/McpServerStatelessIT.java        |  24 +++++
 .../mcp/server/it/McpServerStatelessTest.java      | 118 +++++++++++++++++++++
 4 files changed, 175 insertions(+)

diff --git a/docs/modules/ROOT/pages/reference/extensions/mcp-server.adoc 
b/docs/modules/ROOT/pages/reference/extensions/mcp-server.adoc
index a210f60fa35..280e8f6f951 100644
--- a/docs/modules/ROOT/pages/reference/extensions/mcp-server.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/mcp-server.adoc
@@ -160,6 +160,23 @@ The tools are served over streamable HTTP only. The stdio 
transport, used
 by MCP clients that launch the server as a subprocess, is not supported by
 this extension.
 
+[id="extensions-mcp-server-usage-mcp-protocol-versions"]
+=== MCP protocol versions
+
+The quarkus-mcp-server extension serves two kinds of MCP clients on the same
+endpoint, and the Camel routes reach both without any Camel configuration:
+
+* clients of the protocol versions that open with an `initialize` handshake
+  (2025-11-25 and earlier) get a session, kept in memory by the application;
+* clients of protocol version 2026-07-28 have no session: each request carries
+  its protocol version and is served on its own, so such a client keeps working
+  when the application restarts, and any instance can answer its requests.
+  They are told about a changed tool list through a `subscriptions/listen`
+  request.
+
+Clients that open with `initialize` always get a session; serving them without
+one is not offered by this extension.
+
 
[id="extensions-mcp-server-usage-mixing-with-quarkus-mcp-server-annotated-tools"]
 === Mixing with quarkus-mcp-server annotated tools
 
diff --git a/extensions/mcp-server/runtime/src/main/doc/usage.adoc 
b/extensions/mcp-server/runtime/src/main/doc/usage.adoc
index f6c537299b0..ccf98b196cb 100644
--- a/extensions/mcp-server/runtime/src/main/doc/usage.adoc
+++ b/extensions/mcp-server/runtime/src/main/doc/usage.adoc
@@ -97,6 +97,22 @@ The tools are served over streamable HTTP only. The stdio 
transport, used
 by MCP clients that launch the server as a subprocess, is not supported by
 this extension.
 
+=== MCP protocol versions
+
+The quarkus-mcp-server extension serves two kinds of MCP clients on the same
+endpoint, and the Camel routes reach both without any Camel configuration:
+
+* clients of the protocol versions that open with an `initialize` handshake
+  (2025-11-25 and earlier) get a session, kept in memory by the application;
+* clients of protocol version 2026-07-28 have no session: each request carries
+  its protocol version and is served on its own, so such a client keeps working
+  when the application restarts, and any instance can answer its requests.
+  They are told about a changed tool list through a `subscriptions/listen`
+  request.
+
+Clients that open with `initialize` always get a session; serving them without
+one is not offered by this extension.
+
 === Mixing with quarkus-mcp-server annotated tools
 
 Camel tools coexist with tools defined natively with quarkus-mcp-server —
diff --git 
a/integration-tests/mcp-server/src/test/java/org/apache/camel/quarkus/component/mcp/server/it/McpServerStatelessIT.java
 
b/integration-tests/mcp-server/src/test/java/org/apache/camel/quarkus/component/mcp/server/it/McpServerStatelessIT.java
new file mode 100644
index 00000000000..c86aefcd60f
--- /dev/null
+++ 
b/integration-tests/mcp-server/src/test/java/org/apache/camel/quarkus/component/mcp/server/it/McpServerStatelessIT.java
@@ -0,0 +1,24 @@
+/*
+ * 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.quarkus.component.mcp.server.it;
+
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+
+@QuarkusIntegrationTest
+class McpServerStatelessIT extends McpServerStatelessTest {
+
+}
diff --git 
a/integration-tests/mcp-server/src/test/java/org/apache/camel/quarkus/component/mcp/server/it/McpServerStatelessTest.java
 
b/integration-tests/mcp-server/src/test/java/org/apache/camel/quarkus/component/mcp/server/it/McpServerStatelessTest.java
new file mode 100644
index 00000000000..cd70eb3e4c1
--- /dev/null
+++ 
b/integration-tests/mcp-server/src/test/java/org/apache/camel/quarkus/component/mcp/server/it/McpServerStatelessTest.java
@@ -0,0 +1,118 @@
+/*
+ * 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.quarkus.component.mcp.server.it;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import io.quarkiverse.mcp.server.TextContent;
+import io.quarkiverse.mcp.server.test.McpAssured;
+import io.quarkiverse.mcp.server.test.McpAssured.McpStreamableTestClient;
+import io.quarkiverse.mcp.server.test.McpAssured.ToolInfo;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.eclipse.microprofile.config.ConfigProvider;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.hamcrest.Matchers.containsString;
+
+/**
+ * Camel ai-tool routes served to a client of MCP protocol version 2026-07-28 
(CAMEL-27145): the quarkus-mcp-server
+ * extension serves that stateless protocol next to the protocol versions with 
sessions, on the same endpoint, so the
+ * Camel routes reach both kinds of client without any Camel configuration.
+ */
+@QuarkusTest
+class McpServerStatelessTest {
+
+    private McpStreamableTestClient client;
+
+    private McpStreamableTestClient client() {
+        if (client == null) {
+            client = McpAssured.newStreamableClient()
+                    
.setBaseUri(URI.create("http://localhost:%d".formatted(testPort())))
+                    .setStateless()
+                    .build()
+                    .connect();
+        }
+        return client;
+    }
+
+    private static int testPort() {
+        return ConfigProvider.getConfig().getValue("quarkus.http.test-port", 
Integer.class);
+    }
+
+    @AfterEach
+    void closeClient() {
+        if (client != null) {
+            client.disconnect();
+            client = null;
+        }
+    }
+
+    @Test
+    void testStatelessClientHasNoSession() {
+        assertThat(client().mcpSessionId()).isNull();
+    }
+
+    @Test
+    void testListToolsExposesOnlySelectedTags() {
+        client().when()
+                .toolsList(page -> 
assertThat(page.tools().stream().map(ToolInfo::name).toList())
+                        .contains("say_hello", "create_order")
+                        .doesNotContain("hidden_tool", "other_tool"))
+                .thenAssertResults();
+    }
+
+    @Test
+    void testCallTool() {
+        client().when()
+                .toolsCall("say_hello", Map.of("name", "Camel"), response -> {
+                    assertThat(response.isError()).isFalse();
+                    assertThat(response.content().stream()
+                            .filter(TextContent.class::isInstance)
+                            .map(content -> ((TextContent) content).text())
+                            .collect(Collectors.joining())).isEqualTo("Hello 
Camel");
+                })
+                .thenAssertResults();
+    }
+
+    @Test
+    void testRequestWithoutHandshakeCreatesNoSession() {
+        // a raw request of protocol version 2026-07-28: no initialize before 
it, and no session after it
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .accept("application/json, text/event-stream")
+                .header("MCP-Protocol-Version", "2026-07-28")
+                .header("Mcp-Method", "tools/call")
+                .header("Mcp-Name", "say_hello")
+                .body("""
+                        
{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"say_hello",
+                        "arguments":{"name":"stateless"},"_meta":{
+                        "io.modelcontextprotocol/protocolVersion":"2026-07-28",
+                        
"io.modelcontextprotocol/clientInfo":{"name":"test","version":"1"},
+                        "io.modelcontextprotocol/clientCapabilities":{}}}}""")
+                .post("http://localhost:%d/mcp".formatted(testPort()))
+                .then()
+                .statusCode(200)
+                .header("Mcp-Session-Id", (String) null)
+                .body(containsString("Hello stateless"));
+    }
+}

Reply via email to