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

Croway pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 00e8b66b6aaa CAMEL-26360, CAMEL-27563, CAMEL-27564: camel-mcp-server - 
caller identity for resource and prompt routes, invalid tool schemas, dot 
segments in template variables (#30801)
00e8b66b6aaa is described below

commit 00e8b66b6aaab8f48f67cf0139ce7ae799aac10f
Author: Federico Mariani <[email protected]>
AuthorDate: Thu Nov 26 10:45:06 2026 +0100

    CAMEL-26360, CAMEL-27563, CAMEL-27564: camel-mcp-server - caller identity 
for resource and prompt routes, invalid tool schemas, dot segments in template 
variables (#30801)
    
    * CAMEL-26360: camel-ai-resource - percent-encoded dot segments do not 
match a template variable
    
    A template variable value that, once percent-decoded, is a . or .. dot
    segment, or contains one between / or \ separators (such as %2e%2e or
    ..%2F..%2Fetc%2Fpasswd), no longer matches, like the literal . and ..
    segments. The route still receives matching values verbatim.
    
    * CAMEL-26360: camel-mcp-server - refuse a tool whose schema is not a valid 
JSON Schema in every protocol era
    
    The MCP SDK refused a tool whose input or output schema is not a valid
    JSON Schema 2020-12 document with an IllegalArgumentException when it
    was added to a server of the legacy era, but not when it was added to
    the catalog of protocol version 2026-07-28. The exception escaped the
    engine: the dual era hid the tool from every client with a generic
    WARN, the modern era served it, and a route started before the MCP
    server failed the start of the CamelContext.
    
    The Vert.x engine now checks both schemas with the SDK validator before
    adding the tool to any server, and the stdio engine checks the input
    schema it serves before queuing or adding the tool. An invalid one is
    refused with McpServerRefusedException: the bridge logs an ERROR, the
    route keeps running and the other tools are served.
    
    * CAMEL-26360: camel-mcp-server - resource and prompt routes receive the 
MCP caller identity
    
    An authenticated MCP caller reached ai-tool routes as exchange properties
    (CamelMcpSecurityPrincipal, CamelAiToolSecurityPrincipalName/Roles and the
    CamelMcpOAuth* properties), but ai-resource (fixed and uriTemplate) and
    ai-prompt routes got nothing, so a resource such as crm://customers/{id}
    could not check who is asking.
    
    - McpResourceReadHandler, McpResourceTemplateReadHandler and 
McpPromptHandler
      get a default overload taking an McpToolCallContext that delegates to the
      original method, so engines that do not pass a caller keep working.
    - McpServerBridge implements the overloads and stamps the caller identity on
      the resource, template and prompt exchange with the same code as for 
tools;
      a missing or empty context stamps nothing.
    - The Vert.x engine passes the transport caller context on every path: the
      session and stateless legacy servers, the 2026-07-28 catalog, and
      McpPromptSdkSupport (new overloads taking a caller-context function). 
stdio
      has no caller and keeps the empty context.
    
    * CAMEL-26360: camel-mcp-server - upgrade guide entry for tools refused for 
an invalid schema
    
    * CAMEL-27563: camel-ai-resource - a dot segment followed by path 
parameters does not match a template variable
    
    Tomcat and Spring drop the path parameters of a segment (";x") before
    they resolve dot segments, so "..;x" or "%2e%2e%3b" in a variable value
    becomes ".." for a route that forwards the value into such a URL. A
    segment of the decoded value now counts up to its first ";".
    
    * CAMEL-27564: camel-mcp-server - upgrade guide: the modern era, not stdio, 
served a tool with an invalid schema
    
    The stdio transport added tools through the MCP SDK addTool, which checks
    the input schema, so a tool with an invalid one failed the start of the
    server or was left out with a WARN from the tool registry, as in the
    legacy and dual eras.
---
 .../camel/catalog/docs/ai-prompt-component.adoc    |  11 +
 .../camel/catalog/docs/ai-resource-component.adoc  |  27 ++-
 .../org/apache/camel/catalog/docs/mcp-server.adoc  |  22 +-
 .../src/main/docs/ai-prompt-component.adoc         |  11 +
 .../src/main/docs/ai-resource-component.adoc       |  27 ++-
 .../ai/resource/AiResourceUriTemplate.java         |  77 ++++++-
 .../ai/resource/AiResourceUriTemplateTest.java     |  73 +++++++
 .../component/mcp/server/McpPromptHandler.java     |  23 +++
 .../mcp/server/McpResourceReadHandler.java         |  15 ++
 .../mcp/server/McpResourceTemplateReadHandler.java |  16 ++
 .../component/mcp/server/McpServerBridge.java      |  60 ++++--
 .../component/mcp/server/McpToolCallContext.java   |  18 +-
 .../server/McpServerBridgeCallerIdentityTest.java  | 224 +++++++++++++++++++++
 .../McpServerResourceConformanceTestSupport.java   |  11 +
 .../camel-mcp-server/src/main/docs/mcp-server.adoc |  22 +-
 .../component/mcp/server/McpPromptSdkSupport.java  |  52 ++++-
 .../mcp/server/stdio/StdioMcpServerEngine.java     |  59 ++++--
 .../mcp/server/vertx/McpModernCatalog.java         |   9 +-
 .../mcp/server/vertx/VertxMcpServerEngine.java     |  42 +++-
 .../main/McpServerMainCallerIdentityTest.java      | 172 ++++++++++++++++
 .../mcp/server/stdio/StdioMcpServerEngineTest.java |  37 +++-
 .../vertx/VertxMcpServerInvalidToolSchemaTest.java | 212 +++++++++++++++++++
 .../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc    |   9 +
 23 files changed, 1164 insertions(+), 65 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ai-prompt-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ai-prompt-component.adoc
index ab11a91d4202..946dacc6914d 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ai-prompt-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ai-prompt-component.adoc
@@ -101,3 +101,14 @@ ticket comments, emails or documents, that data can 
contain instructions aimed a
 (prompt injection). Camel does not filter or mark such content. Include only 
data from sources
 you trust, or clearly mark untrusted content in the prompt, for example by 
placing it in its own
 delimited block and telling the model to treat it as data.
+
+When the xref:others:mcp-server.adoc[MCP server] of Camel Main or Camel JBang 
serves a prompt to an
+authenticated MCP client, the route receives the caller as exchange 
properties, as an `ai-tool` route
+does: `CamelAiToolSecurityPrincipalName` (the caller name), 
`CamelAiToolSecurityPrincipalRoles` (the
+caller roles, when the token carries them), `CamelMcpSecurityPrincipal` (the 
raw principal) and, with
+OAuth, `CamelMcpOAuthSubject`, `CamelMcpOAuthScopes` and `CamelMcpOAuthClaims` 
of the validated token.
+A route that builds a prompt from data of the caller checks these properties 
first, and throws an
+exception to refuse; the client then receives a generic prompt error.
+Take the caller from these properties only, never from the arguments, which 
are headers set by the
+client. Without an authenticated caller, as over stdio, the properties are not 
set. The prompt has no
+`allowedRoles` or `authorizationPolicy` option.
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ai-resource-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ai-resource-component.adoc
index 793bc6f9340c..6dedb9b1a027 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ai-resource-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ai-resource-component.adoc
@@ -47,7 +47,11 @@ clients use to read the resource. The uri must be unique 
within the CamelContext
 A `uriTemplate` follows RFC 6570 level 1: each variable must occupy an entire 
path segment, for example
 `crm://customers/\{id\}`. Variables do not match across `/` separators. A 
concrete variable must use
 RFC 3986 `pchar` characters (including well-formed percent-encoded octets); 
raw query/fragment
-characters, controls, malformed percent escapes, and `.` or `..` dot segments 
do not match.
+characters, controls and malformed percent escapes do not match. Nor does a 
value that, once
+percent-decoded, is a `.` or `..` dot segment or contains one between `/` or 
`+\+` separators, such as
+`..`, `%2e%2e` or `..%2F..%2Fetc%2Fpasswd`. A segment counts up to its first 
`;`, because servers such as Tomcat
+drop path parameters before resolving dot segments, so `..;x` and `%2e%2e%3b` 
do not match either.
+The route still receives the value verbatim, percent-encoding included.
 Fixed resources take precedence over a matching template when the same 
concrete URI is read.
 Tagged templates in one CamelContext must not overlap, even when they belong 
to different tags;
 a conflicting route fails startup rather than depending on registration order. 
A fixed
@@ -61,10 +65,11 @@ include::partial$component-endpoint-headers.adoc[]
 
 == Usage
 
-A resource read carries no arguments: the route is invoked with an empty 
exchange and its message body is the
-content returned to the client. Retrieval therefore uses whatever Camel 
already offers for reading on demand: a
-producer with a read operation (`aws2-s3` with `operation=getObject`), or 
`pollEnrich` for the polling components
-(`file`, `ftp`, `sftp`), whose producers write rather than read.
+A resource read carries no arguments: the route is invoked with an empty 
message body (see <<Caller identity>> for
+the exchange properties that identify the caller) and its message body is the 
content returned to the client.
+Retrieval therefore uses whatever Camel already offers for reading on demand: 
a producer with a read operation
+(`aws2-s3` with `operation=getObject`), or `pollEnrich` for the polling 
components (`file`, `ftp`, `sftp`), whose
+producers write rather than read.
 
 Always give `pollEnrich` an explicit `timeout` - it is a parameter of the EIP, 
not an endpoint option. It
 defaults to `-1`, which waits until a message is available and
@@ -167,6 +172,18 @@ default pool that `camel-mcp-server` never exposes: 
crossing the boundary to a r
 per-route opt-in. See the xref:others:mcp-server.adoc[MCP server] 
documentation for how the tag patterns are
 configured.
 
+== Caller identity
+
+When the xref:others:mcp-server.adoc[MCP server] of Camel Main or Camel JBang 
serves a resource to an authenticated
+MCP client, the route receives the caller as exchange properties, as an 
`ai-tool` route does:
+`CamelAiToolSecurityPrincipalName` (the caller name), 
`CamelAiToolSecurityPrincipalRoles` (the caller roles, when
+the token carries them), `CamelMcpSecurityPrincipal` (the raw principal) and, 
with OAuth, `CamelMcpOAuthSubject`,
+`CamelMcpOAuthScopes` and `CamelMcpOAuthClaims` of the validated token. A 
route that serves data per caller, such as
+`crm://customers/\{id\}`, checks these properties before it reads, and throws 
an exception to refuse; the client
+then receives a generic read error. Take the caller from these properties 
only, never from the URI or the template
+variables, which come from the client. Without an authenticated caller, as 
over stdio, the properties are not set.
+The resource has no `allowedRoles` or `authorizationPolicy` option.
+
 == Lifecycle
 
 A resource is registered when its route starts or resumes and deregistered 
when the route stops or suspends.
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/mcp-server.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/mcp-server.adoc
index 55b4fb902b48..e2f422d341ce 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/mcp-server.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/mcp-server.adoc
@@ -74,6 +74,11 @@ An engine refuses a tool, resource or prompt it cannot 
serve, for example a name
 runtime already serves, by throwing `McpServerRefusedException` from
 `toolAdded`, `resourceAdded` or `promptAdded`. The bridge logs an ERROR, as for
 its own name clashes, and does not track the refused item as published.
+The engines of `camel-mcp-server` (HTTP and stdio) refuse that way, in every 
protocol
+era, a tool whose input or output schema fails the JSON Schema 2020-12 check 
of the MCP
+Java SDK (a schema that declares another `$schema` dialect is not checked); 
its route
+keeps running. Over stdio, which does not serve output schemas, only the input 
schema
+is checked.
 
 == Usage
 
@@ -139,7 +144,7 @@ from("ai-resource:app_config"
 
 An MCP client then sees the resource in `resources/list` and fetches it with
 `resources/read`. A read carries no arguments: the route is invoked with an
-empty exchange and its body is the content. The `mimeType` decides the wire
+empty message body and its body is the content. The `mimeType` decides the wire
 format — textual types are sent as text, everything else as a base64 blob —
 see xref:ROOT:ai-resource-component.adoc[ai-resource] for the details.
 
@@ -620,7 +625,8 @@ subject; requests from another subject receive the same 
not-found response as an
 session ID. A token without a non-empty subject cannot initialize an 
OAuth-protected MCP
 session. This prevents a session identifier from being reused across 
authenticated users.
 
-For an authenticated tool call, the bridge exposes the following exchange 
properties:
+For an authenticated tool call, resource read or prompt get, the bridge 
exposes the following exchange
+properties:
 
 * `CamelMcpOAuthSubject`, `CamelMcpOAuthScopes`, and `CamelMcpOAuthClaims` 
contain the subject,
   scopes, and claims from the validated token.
@@ -636,6 +642,18 @@ For an authenticated tool call, the bridge exposes the 
following exchange proper
 * `CamelOAuthTokenValidationResult` contains the full Camel OAuth validation 
result for route code
   that already consumes the standard HTTP OAuth exchange property.
 
+An `ai-resource` route, with a fixed `resourceUri` or a `uriTemplate`, and an 
`ai-prompt` route get
+the same caller properties as an `ai-tool` route, including 
`CamelMcpSecurityPrincipal`, the raw caller
+principal. This holds for every protocol version, with or without sessions, 
and for the
+`camel.server.authentication*` settings of the embedded server as well as for 
OAuth. A route can then
+check who is asking, for example before it returns the customer behind 
`crm://customers/\{id\}`.
+Unlike an `ai-tool` route, these routes have no `allowedRoles` or 
`authorizationPolicy` option: the
+route checks the properties itself, and to refuse it throws an exception, 
which the client receives
+as the generic read or prompt error. Check the properties only, never the 
headers: the template
+variables and the prompt arguments are headers, and they come from the client. 
Without an
+authenticated caller, as over stdio or on a server without authentication, 
none of these properties
+is set.
+
 These options configure OAuth only on the Camel Main / JBang Vert.x HTTP 
engine. Camel Main stdio
 mode has no HTTP authentication layer: it logs a warning and ignores these 
OAuth options. Native
 Spring Boot and Quarkus MCP engines own their security configuration; passing 
these Camel-engine
diff --git 
a/components/camel-ai/camel-ai-prompt/src/main/docs/ai-prompt-component.adoc 
b/components/camel-ai/camel-ai-prompt/src/main/docs/ai-prompt-component.adoc
index ab11a91d4202..946dacc6914d 100644
--- a/components/camel-ai/camel-ai-prompt/src/main/docs/ai-prompt-component.adoc
+++ b/components/camel-ai/camel-ai-prompt/src/main/docs/ai-prompt-component.adoc
@@ -101,3 +101,14 @@ ticket comments, emails or documents, that data can 
contain instructions aimed a
 (prompt injection). Camel does not filter or mark such content. Include only 
data from sources
 you trust, or clearly mark untrusted content in the prompt, for example by 
placing it in its own
 delimited block and telling the model to treat it as data.
+
+When the xref:others:mcp-server.adoc[MCP server] of Camel Main or Camel JBang 
serves a prompt to an
+authenticated MCP client, the route receives the caller as exchange 
properties, as an `ai-tool` route
+does: `CamelAiToolSecurityPrincipalName` (the caller name), 
`CamelAiToolSecurityPrincipalRoles` (the
+caller roles, when the token carries them), `CamelMcpSecurityPrincipal` (the 
raw principal) and, with
+OAuth, `CamelMcpOAuthSubject`, `CamelMcpOAuthScopes` and `CamelMcpOAuthClaims` 
of the validated token.
+A route that builds a prompt from data of the caller checks these properties 
first, and throws an
+exception to refuse; the client then receives a generic prompt error.
+Take the caller from these properties only, never from the arguments, which 
are headers set by the
+client. Without an authenticated caller, as over stdio, the properties are not 
set. The prompt has no
+`allowedRoles` or `authorizationPolicy` option.
diff --git 
a/components/camel-ai/camel-ai-resource/src/main/docs/ai-resource-component.adoc
 
b/components/camel-ai/camel-ai-resource/src/main/docs/ai-resource-component.adoc
index 793bc6f9340c..6dedb9b1a027 100644
--- 
a/components/camel-ai/camel-ai-resource/src/main/docs/ai-resource-component.adoc
+++ 
b/components/camel-ai/camel-ai-resource/src/main/docs/ai-resource-component.adoc
@@ -47,7 +47,11 @@ clients use to read the resource. The uri must be unique 
within the CamelContext
 A `uriTemplate` follows RFC 6570 level 1: each variable must occupy an entire 
path segment, for example
 `crm://customers/\{id\}`. Variables do not match across `/` separators. A 
concrete variable must use
 RFC 3986 `pchar` characters (including well-formed percent-encoded octets); 
raw query/fragment
-characters, controls, malformed percent escapes, and `.` or `..` dot segments 
do not match.
+characters, controls and malformed percent escapes do not match. Nor does a 
value that, once
+percent-decoded, is a `.` or `..` dot segment or contains one between `/` or 
`+\+` separators, such as
+`..`, `%2e%2e` or `..%2F..%2Fetc%2Fpasswd`. A segment counts up to its first 
`;`, because servers such as Tomcat
+drop path parameters before resolving dot segments, so `..;x` and `%2e%2e%3b` 
do not match either.
+The route still receives the value verbatim, percent-encoding included.
 Fixed resources take precedence over a matching template when the same 
concrete URI is read.
 Tagged templates in one CamelContext must not overlap, even when they belong 
to different tags;
 a conflicting route fails startup rather than depending on registration order. 
A fixed
@@ -61,10 +65,11 @@ include::partial$component-endpoint-headers.adoc[]
 
 == Usage
 
-A resource read carries no arguments: the route is invoked with an empty 
exchange and its message body is the
-content returned to the client. Retrieval therefore uses whatever Camel 
already offers for reading on demand: a
-producer with a read operation (`aws2-s3` with `operation=getObject`), or 
`pollEnrich` for the polling components
-(`file`, `ftp`, `sftp`), whose producers write rather than read.
+A resource read carries no arguments: the route is invoked with an empty 
message body (see <<Caller identity>> for
+the exchange properties that identify the caller) and its message body is the 
content returned to the client.
+Retrieval therefore uses whatever Camel already offers for reading on demand: 
a producer with a read operation
+(`aws2-s3` with `operation=getObject`), or `pollEnrich` for the polling 
components (`file`, `ftp`, `sftp`), whose
+producers write rather than read.
 
 Always give `pollEnrich` an explicit `timeout` - it is a parameter of the EIP, 
not an endpoint option. It
 defaults to `-1`, which waits until a message is available and
@@ -167,6 +172,18 @@ default pool that `camel-mcp-server` never exposes: 
crossing the boundary to a r
 per-route opt-in. See the xref:others:mcp-server.adoc[MCP server] 
documentation for how the tag patterns are
 configured.
 
+== Caller identity
+
+When the xref:others:mcp-server.adoc[MCP server] of Camel Main or Camel JBang 
serves a resource to an authenticated
+MCP client, the route receives the caller as exchange properties, as an 
`ai-tool` route does:
+`CamelAiToolSecurityPrincipalName` (the caller name), 
`CamelAiToolSecurityPrincipalRoles` (the caller roles, when
+the token carries them), `CamelMcpSecurityPrincipal` (the raw principal) and, 
with OAuth, `CamelMcpOAuthSubject`,
+`CamelMcpOAuthScopes` and `CamelMcpOAuthClaims` of the validated token. A 
route that serves data per caller, such as
+`crm://customers/\{id\}`, checks these properties before it reads, and throws 
an exception to refuse; the client
+then receives a generic read error. Take the caller from these properties 
only, never from the URI or the template
+variables, which come from the client. Without an authenticated caller, as 
over stdio, the properties are not set.
+The resource has no `allowedRoles` or `authorizationPolicy` option.
+
 == Lifecycle
 
 A resource is registered when its route starts or resumes and deregistered 
when the route stops or suspends.
diff --git 
a/components/camel-ai/camel-ai-resource/src/main/java/org/apache/camel/component/ai/resource/AiResourceUriTemplate.java
 
b/components/camel-ai/camel-ai-resource/src/main/java/org/apache/camel/component/ai/resource/AiResourceUriTemplate.java
index 33aec6c73551..11c3eeb85d2a 100644
--- 
a/components/camel-ai/camel-ai-resource/src/main/java/org/apache/camel/component/ai/resource/AiResourceUriTemplate.java
+++ 
b/components/camel-ai/camel-ai-resource/src/main/java/org/apache/camel/component/ai/resource/AiResourceUriTemplate.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.ai.resource;
 
+import java.io.ByteArrayOutputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.LinkedHashMap;
@@ -30,8 +32,9 @@ import java.util.regex.Pattern;
  * <p>
  * Each expression must occupy an entire path segment, for example {@code 
crm://customers/{id}}. Variables match one
  * non-empty path segment and are returned verbatim (including 
percent-encoding); they are never decoded, interpreted as
- * Camel expressions, or resolved as property placeholders. Query and fragment 
expressions are intentionally not
- * supported.
+ * Camel expressions, or resolved as property placeholders. A value that, once 
percent-decoded, is a {@code .} or
+ * {@code ..} dot segment or contains one between {@code /} or {@code \} 
separators does not match, including one
+ * followed by path parameters such as {@code ..;x}. Query and fragment 
expressions are intentionally not supported.
  *
  * @since 4.24
  */
@@ -144,8 +147,9 @@ public final class AiResourceUriTemplate {
         Map<String, String> values = new LinkedHashMap<>();
         for (int i = 0; i < variableNames.size(); i++) {
             String value = matcher.group(i + 1);
-            // Dot segments can be normalized by downstream URI/path consumers.
-            if (".".equals(value) || "..".equals(value)) {
+            // Dot segments can be normalized by downstream URI/path 
consumers. RFC 3986 makes %2E equivalent to
+            // ".", and a consumer that decodes the value also turns %2F (or 
%5C) into a path separator.
+            if (containsDotSegment(value)) {
                 return Optional.empty();
             }
             values.put(variableNames.get(i), value);
@@ -153,6 +157,71 @@ public final class AiResourceUriTemplate {
         return Optional.of(Collections.unmodifiableMap(values));
     }
 
+    /**
+     * Whether the value, once percent-decoded, is a dot segment or contains 
one between {@code /} or {@code \}
+     * separators, for example {@code ..}, {@code %2e%2E} or {@code 
..%2F..%2Fetc%2Fpasswd}. A segment counts up to its
+     * first {@code ;}, because servers such as Tomcat drop the path 
parameters of a segment before resolving dot
+     * segments: {@code ..;x} is a dot segment too.
+     */
+    private static boolean containsDotSegment(String value) {
+        String decoded = percentDecode(value);
+        int start = 0;
+        // where the path parameters of the current segment begin, -1 when it 
has none
+        int parameters = -1;
+        for (int i = 0; i <= decoded.length(); i++) {
+            char c = i < decoded.length() ? decoded.charAt(i) : '/';
+            if (c == ';' && parameters < 0) {
+                parameters = i;
+            } else if (c == '/' || c == '\\') {
+                int length = (parameters < 0 ? i : parameters) - start;
+                if ((length == 1 || length == 2) && 
decoded.startsWith(".".repeat(length), start)) {
+                    return true;
+                }
+                start = i + 1;
+                parameters = -1;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Decodes percent-encoded octets as UTF-8. Unlike {@code URLDecoder} it 
keeps {@code +} as is and never throws: a
+     * malformed escape is kept verbatim and invalid UTF-8 becomes the 
replacement character.
+     */
+    private static String percentDecode(String value) {
+        if (value.indexOf('%') < 0) {
+            return value;
+        }
+        ByteArrayOutputStream bytes = new 
ByteArrayOutputStream(value.length());
+        for (int i = 0; i < value.length(); i++) {
+            char c = value.charAt(i);
+            int high = c == '%' && i + 2 < value.length() ? 
hexDigit(value.charAt(i + 1)) : -1;
+            int low = high >= 0 ? hexDigit(value.charAt(i + 2)) : -1;
+            if (low >= 0) {
+                bytes.write((high << 4) | low);
+                i += 2;
+            } else if (c < 0x80) {
+                // a matched value is ASCII: the pattern allows only 
percent-encoded octets beyond it
+                bytes.write(c);
+            } else {
+                byte[] encoded = 
String.valueOf(c).getBytes(StandardCharsets.UTF_8);
+                bytes.write(encoded, 0, encoded.length);
+            }
+        }
+        return bytes.toString(StandardCharsets.UTF_8);
+    }
+
+    private static int hexDigit(char c) {
+        if (c >= '0' && c <= '9') {
+            return c - '0';
+        } else if (c >= 'A' && c <= 'F') {
+            return c - 'A' + 10;
+        } else if (c >= 'a' && c <= 'f') {
+            return c - 'a' + 10;
+        }
+        return -1;
+    }
+
     /**
      * Returns true when there is at least one concrete URI that both 
templates can match.
      */
diff --git 
a/components/camel-ai/camel-ai-resource/src/test/java/org/apache/camel/component/ai/resource/AiResourceUriTemplateTest.java
 
b/components/camel-ai/camel-ai-resource/src/test/java/org/apache/camel/component/ai/resource/AiResourceUriTemplateTest.java
index 915399fcf4e8..e1c310d564ec 100644
--- 
a/components/camel-ai/camel-ai-resource/src/test/java/org/apache/camel/component/ai/resource/AiResourceUriTemplateTest.java
+++ 
b/components/camel-ai/camel-ai-resource/src/test/java/org/apache/camel/component/ai/resource/AiResourceUriTemplateTest.java
@@ -59,6 +59,66 @@ class AiResourceUriTemplateTest {
         assertThat(template.match("crm://customers/%2")).isEmpty();
     }
 
+    @Test
+    void rejectsPercentEncodedDotSegmentsAndEncodedTraversal() {
+        AiResourceUriTemplate template = new 
AiResourceUriTemplate("crm://customers/{id}");
+
+        assertThat(template.match("crm://customers/%2e")).isEmpty();
+        assertThat(template.match("crm://customers/%2E")).isEmpty();
+        assertThat(template.match("crm://customers/%2e%2e")).isEmpty();
+        assertThat(template.match("crm://customers/%2E%2E")).isEmpty();
+        assertThat(template.match("crm://customers/.%2e")).isEmpty();
+        assertThat(template.match("crm://customers/%2e.")).isEmpty();
+        
assertThat(template.match("crm://customers/..%2F..%2Fetc%2Fpasswd")).isEmpty();
+        assertThat(template.match("crm://customers/a%2f..%2fb")).isEmpty();
+        assertThat(template.match("crm://customers/a%2F%2e")).isEmpty();
+        assertThat(template.match("crm://customers/.%2Fa")).isEmpty();
+        
assertThat(template.match("crm://customers/..%5C..%5Cwindows")).isEmpty();
+        assertThat(template.match("crm://customers/%2e%2")).isEmpty();
+    }
+
+    @Test
+    void rejectsDotSegmentsFollowedByPathParameters() {
+        // Tomcat and Spring drop ";..." from a segment before resolving dot 
segments, so "..;x" becomes ".."
+        AiResourceUriTemplate template = new 
AiResourceUriTemplate("crm://customers/{id}");
+
+        assertThat(template.match("crm://customers/..;")).isEmpty();
+        
assertThat(template.match("crm://customers/..;jsessionid=1")).isEmpty();
+        assertThat(template.match("crm://customers/.;x")).isEmpty();
+        assertThat(template.match("crm://customers/..;a;b")).isEmpty();
+        assertThat(template.match("crm://customers/%2e%2e%3b")).isEmpty();
+        assertThat(template.match("crm://customers/%2E%2E%3Bx")).isEmpty();
+        assertThat(template.match("crm://customers/a%2F..;x%2Fb")).isEmpty();
+        assertThat(template.match("crm://customers/b;x%2F..;y")).isEmpty();
+        assertThat(template.match("crm://customers/..;x%5Cwindows")).isEmpty();
+    }
+
+    @Test
+    void keepsValuesWithPathParametersThatAreNotDotSegments() {
+        AiResourceUriTemplate template = new 
AiResourceUriTemplate("crm://customers/{id}");
+
+        
assertThat(template.match("crm://customers/a;b")).hasValue(Map.of("id", "a;b"));
+        
assertThat(template.match("crm://customers/42;..")).hasValue(Map.of("id", 
"42;.."));
+        
assertThat(template.match("crm://customers/...;x")).hasValue(Map.of("id", 
"...;x"));
+        
assertThat(template.match("crm://customers/;..")).hasValue(Map.of("id", ";.."));
+        
assertThat(template.match("crm://customers/.x;y")).hasValue(Map.of("id", 
".x;y"));
+        
assertThat(template.match("crm://customers/a;..%2Fb")).hasValue(Map.of("id", 
"a;..%2Fb"));
+    }
+
+    @Test
+    void keepsValuesWithDotsThatAreNotDotSegments() {
+        AiResourceUriTemplate template = new 
AiResourceUriTemplate("crm://customers/{id}");
+
+        
assertThat(template.match("crm://customers/a.b")).hasValue(Map.of("id", "a.b"));
+        
assertThat(template.match("crm://customers/...")).hasValue(Map.of("id", "..."));
+        
assertThat(template.match("crm://customers/.hidden")).hasValue(Map.of("id", 
".hidden"));
+        
assertThat(template.match("crm://customers/%2E%2Ex")).hasValue(Map.of("id", 
"%2E%2Ex"));
+        
assertThat(template.match("crm://customers/%2e%2e%2e")).hasValue(Map.of("id", 
"%2e%2e%2e"));
+        
assertThat(template.match("crm://customers/a%2F...%2Fb.c")).hasValue(Map.of("id",
 "a%2F...%2Fb.c"));
+        
assertThat(template.match("crm://customers/%252e%252e")).hasValue(Map.of("id", 
"%252e%252e"));
+        
assertThat(template.match("crm://customers/%C0%AE%C0%AE")).hasValue(Map.of("id",
 "%C0%AE%C0%AE"));
+    }
+
     @Test
     void detectsOverlappingTemplates() {
         AiResourceUriTemplate left = new 
AiResourceUriTemplate("crm://customers/{id}");
@@ -69,6 +129,19 @@ class AiResourceUriTemplateTest {
         assertThat(left.overlaps(different)).isFalse();
     }
 
+    @Test
+    void overlapsOnADotSegmentLiteralThatAVariableDoesNotMatch() {
+        // the URI-template matcher of an MCP server matches 
crm://customers/%2e/profile with both templates and may
+        // pick the first one, whose variable then refuses it: such templates 
must not be registered together
+        AiResourceUriTemplate profile = new 
AiResourceUriTemplate("crm://customers/{id}/profile");
+        AiResourceUriTemplate encodedDot = new 
AiResourceUriTemplate("crm://customers/%2e/{name}");
+
+        assertThat(profile.match("crm://customers/%2e/profile")).isEmpty();
+        
assertThat(encodedDot.match("crm://customers/%2e/profile")).hasValue(Map.of("name",
 "profile"));
+        assertThat(profile.overlaps(encodedDot)).isTrue();
+        assertThat(encodedDot.overlaps(profile)).isTrue();
+    }
+
     @Test
     void rejectsExpressionsThatAreNotWholePathSegments() {
         assertThatThrownBy(() -> new 
AiResourceUriTemplate("crm://customers/pre-{id}"))
diff --git 
a/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpPromptHandler.java
 
b/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpPromptHandler.java
index 9050b603298f..93880f78d3cf 100644
--- 
a/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpPromptHandler.java
+++ 
b/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpPromptHandler.java
@@ -26,5 +26,28 @@ import java.util.Map;
 @FunctionalInterface
 public interface McpPromptHandler {
 
+    /**
+     * Gets the prompt messages for the given arguments.
+     *
+     * @param  arguments the prompt arguments sent in {@code prompts/get}
+     * @return           the sanitized result
+     */
     McpPromptResult get(Map<String, String> arguments);
+
+    /**
+     * Gets the prompt messages for the given arguments on behalf of the 
transport-supplied caller, so the prompt route
+     * can check who is asking. The default ignores the context and calls 
{@link #get(Map)}; the bridge overrides it to
+     * stamp the caller identity onto the prompt exchange, as for a tool call. 
Engines that can determine a caller
+     * identity (such as the Vert.x streamable HTTP transport) call this 
overload; others keep calling
+     * {@link #get(Map)}.
+     *
+     * @param  arguments the prompt arguments sent in {@code prompts/get}
+     * @param  context   the transport-supplied caller context, never null 
(use {@link McpToolCallContext#EMPTY} when
+     *                   there is no caller identity)
+     * @return           the sanitized result
+     * @since            4.24
+     */
+    default McpPromptResult get(Map<String, String> arguments, 
McpToolCallContext context) {
+        return get(arguments);
+    }
 }
diff --git 
a/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpResourceReadHandler.java
 
b/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpResourceReadHandler.java
index 6d318f843e6a..e50072d5eea5 100644
--- 
a/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpResourceReadHandler.java
+++ 
b/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpResourceReadHandler.java
@@ -34,4 +34,19 @@ public interface McpResourceReadHandler {
      * @return the sanitized result, never null
      */
     McpResourceReadResult read();
+
+    /**
+     * Reads the resource contents on behalf of the transport-supplied caller, 
so the resource route can check who is
+     * asking. The default ignores the context and calls {@link #read()}; the 
bridge overrides it to stamp the caller
+     * identity onto the resource exchange, as for a tool call. Engines that 
can determine a caller identity (such as
+     * the Vert.x streamable HTTP transport) call this overload; others keep 
calling {@link #read()}.
+     *
+     * @param  context the transport-supplied caller context, never null (use 
{@link McpToolCallContext#EMPTY} when
+     *                 there is no caller identity)
+     * @return         the sanitized result, never null
+     * @since          4.24
+     */
+    default McpResourceReadResult read(McpToolCallContext context) {
+        return read();
+    }
 }
diff --git 
a/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpResourceTemplateReadHandler.java
 
b/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpResourceTemplateReadHandler.java
index 864d8885c495..e40c685f6a8d 100644
--- 
a/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpResourceTemplateReadHandler.java
+++ 
b/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpResourceTemplateReadHandler.java
@@ -33,4 +33,20 @@ public interface McpResourceTemplateReadHandler {
      * @return             sanitized resource read result
      */
     McpResourceReadResult read(String resourceUri);
+
+    /**
+     * Reads the supplied concrete URI on behalf of the transport-supplied 
caller, so the resource route can check who
+     * is asking. The default ignores the context and calls {@link 
#read(String)}; the bridge overrides it to stamp the
+     * caller identity onto the resource exchange, as for a tool call. Engines 
that can determine a caller identity
+     * (such as the Vert.x streamable HTTP transport) call this overload; 
others keep calling {@link #read(String)}.
+     *
+     * @param  resourceUri concrete URI sent in {@code resources/read}
+     * @param  context     the transport-supplied caller context, never null 
(use {@link McpToolCallContext#EMPTY} when
+     *                     there is no caller identity)
+     * @return             sanitized resource read result
+     * @since              4.24
+     */
+    default McpResourceReadResult read(String resourceUri, McpToolCallContext 
context) {
+        return read(resourceUri);
+    }
 }
diff --git 
a/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpServerBridge.java
 
b/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpServerBridge.java
index b7f006771f2a..29950a9bd639 100644
--- 
a/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpServerBridge.java
+++ 
b/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpServerBridge.java
@@ -483,7 +483,17 @@ public class McpServerBridge extends ServiceSupport 
implements CamelContextAware
     }
 
     private McpServerResourceTemplate 
createResourceTemplate(AiResourceTemplateSpec spec) {
-        McpResourceTemplateReadHandler handler = resourceUri -> read(spec, 
resourceUri);
+        McpResourceTemplateReadHandler handler = new 
McpResourceTemplateReadHandler() {
+            @Override
+            public McpResourceReadResult read(String resourceUri) {
+                return readTemplate(spec, resourceUri, null);
+            }
+
+            @Override
+            public McpResourceReadResult read(String resourceUri, 
McpToolCallContext context) {
+                return readTemplate(spec, resourceUri, context);
+            }
+        };
         return new McpServerResourceTemplate() {
             @Override
             public String uriTemplate() {
@@ -518,7 +528,17 @@ public class McpServerBridge extends ServiceSupport 
implements CamelContextAware
     }
 
     private McpServerResource createResource(AiResourceSpec spec) {
-        McpResourceReadHandler handler = () -> read(spec);
+        McpResourceReadHandler handler = new McpResourceReadHandler() {
+            @Override
+            public McpResourceReadResult read() {
+                return readResource(spec, null);
+            }
+
+            @Override
+            public McpResourceReadResult read(McpToolCallContext context) {
+                return readResource(spec, context);
+            }
+        };
         return new McpServerResource() {
             @Override
             public String uri() {
@@ -552,8 +572,9 @@ public class McpServerBridge extends ServiceSupport 
implements CamelContextAware
         };
     }
 
-    private McpResourceReadResult read(AiResourceSpec spec) {
+    private McpResourceReadResult readResource(AiResourceSpec spec, 
McpToolCallContext context) {
         Exchange exchange = spec.getConsumer().getEndpoint().createExchange();
+        stampCallerIdentity(exchange, context);
         return read(spec, exchange);
     }
 
@@ -598,7 +619,8 @@ public class McpServerBridge extends ServiceSupport 
implements CamelContextAware
         }
     }
 
-    private McpResourceReadResult read(AiResourceTemplateSpec spec, String 
resourceUri) {
+    private McpResourceReadResult readTemplate(
+            AiResourceTemplateSpec spec, String resourceUri, 
McpToolCallContext context) {
         Map<String, String> variables = spec.match(resourceUri).orElse(null);
         if (variables == null) {
             // Defensive guard: the protocol engine normally calls this 
handler only after a URI-template match.
@@ -611,6 +633,7 @@ public class McpServerBridge extends ServiceSupport 
implements CamelContextAware
         exchange.getMessage().setHeader(AiResource.RESOURCE_URI_HEADER, 
resourceUri);
         variables.forEach((name, value) -> exchange.getMessage().setHeader(
                 AiResource.TEMPLATE_VARIABLE_HEADER_PREFIX + name, value));
+        stampCallerIdentity(exchange, context);
         return read(spec.asResourceSpec(resourceUri), exchange);
     }
 
@@ -666,7 +689,17 @@ public class McpServerBridge extends ServiceSupport 
implements CamelContextAware
     }
 
     private McpServerPrompt createPrompt(AiPromptSpec spec) {
-        McpPromptHandler handler = arguments -> executePrompt(spec, arguments);
+        McpPromptHandler handler = new McpPromptHandler() {
+            @Override
+            public McpPromptResult get(Map<String, String> arguments) {
+                return executePrompt(spec, arguments, null);
+            }
+
+            @Override
+            public McpPromptResult get(Map<String, String> arguments, 
McpToolCallContext context) {
+                return executePrompt(spec, arguments, context);
+            }
+        };
         return new McpServerPrompt() {
             @Override
             public String name() {
@@ -698,8 +731,9 @@ public class McpServerBridge extends ServiceSupport 
implements CamelContextAware
         };
     }
 
-    private McpPromptResult executePrompt(AiPromptSpec spec, Map<String, 
String> arguments) {
+    private McpPromptResult executePrompt(AiPromptSpec spec, Map<String, 
String> arguments, McpToolCallContext context) {
         Exchange exchange = spec.getConsumer().getEndpoint().createExchange();
+        stampCallerIdentity(exchange, context);
 
         // 0 = queued/not started, 1 = running, 2 = exchange ownership 
completed.
         // The worker releases the exchange after route execution. The caller 
only
@@ -851,9 +885,7 @@ public class McpServerBridge extends ServiceSupport 
implements CamelContextAware
 
     private McpToolCallResult execute(AiToolSpec spec, Map<String, Object> 
arguments, McpToolCallContext context) {
         Exchange exchange = spec.getConsumer().getEndpoint().createExchange();
-        if (context != null) {
-            stampCallerIdentity(exchange, context);
-        }
+        stampCallerIdentity(exchange, context);
         boolean release = true;
         try {
             Future<AiToolResult> future = executor.submit(() -> 
AiToolExecutor.execute(spec, arguments, exchange));
@@ -900,11 +932,15 @@ public class McpServerBridge extends ServiceSupport 
implements CamelContextAware
     }
 
     /**
-     * Stamps the MCP caller identity onto the tool exchange as exchange 
properties the model cannot set: the raw
-     * transport principal, and the runtime-neutral name and roles when the 
engine could derive them. A tool route's
-     * {@link org.apache.camel.spi.AuthorizationPolicy} authorizes on these.
+     * Stamps the MCP caller identity onto the tool, resource or prompt 
exchange as exchange properties the client and
+     * the model cannot set: the raw transport principal, and the 
runtime-neutral name and roles when the engine could
+     * derive them. A tool route's {@link 
org.apache.camel.spi.AuthorizationPolicy} authorizes on these, and a resource
+     * or prompt route can check them itself. A {@code null} context (an 
engine that passed none) stamps nothing.
      */
     private static void stampCallerIdentity(Exchange exchange, 
McpToolCallContext context) {
+        if (context == null) {
+            return;
+        }
         Object principal = context.securityPrincipal();
         if (principal != null) {
             
exchange.setProperty(McpToolCallContext.SECURITY_PRINCIPAL_PROPERTY, principal);
diff --git 
a/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpToolCallContext.java
 
b/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpToolCallContext.java
index ffb856689e33..e169e08b9ff1 100644
--- 
a/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpToolCallContext.java
+++ 
b/components/camel-ai/camel-mcp-server-api/src/main/java/org/apache/camel/component/mcp/server/McpToolCallContext.java
@@ -26,13 +26,19 @@ import org.apache.camel.component.ai.tool.AiToolConstants;
 import org.apache.camel.spi.OAuthTokenValidationResult;
 
 /**
- * Transport-supplied context for a single MCP tool call, carrying the 
caller's authenticated security principal when
- * the transport can determine one, together with a runtime-neutral view of 
it. An engine builds it from its transport
- * (for the Vert.x streamable HTTP transport, from the authenticated {@code 
RoutingContext} user) and passes it to
+ * Transport-supplied context for a single MCP request, carrying the caller's 
authenticated security principal when the
+ * transport can determine one, together with a runtime-neutral view of it. An 
engine builds it from its transport (for
+ * the Vert.x streamable HTTP transport, from the authenticated {@code 
RoutingContext} user) and passes it to
  * {@link McpToolCallHandler#call(java.util.Map, McpToolCallContext)}; the 
bridge then stamps the principal and its
  * neutral view onto the tool exchange as exchange properties so a tool route's
  * {@link org.apache.camel.spi.AuthorizationPolicy} can authorize on them.
  * <p>
+ * Despite its name, the same context is also used for resource reads and 
prompt gets (since 4.24): an engine passes it
+ * to {@link McpResourceReadHandler#read(McpToolCallContext)},
+ * {@link McpResourceTemplateReadHandler#read(String, McpToolCallContext)} and
+ * {@link McpPromptHandler#get(java.util.Map, McpToolCallContext)}, and the 
bridge stamps the same exchange properties
+ * on the resource or prompt exchange, so an {@code ai-resource} or {@code 
ai-prompt} route can check who is asking.
+ * <p>
  * The raw {@link #securityPrincipal()} is an opaque {@link Object} (for 
example an {@code io.vertx.ext.auth.User}) so
  * this transport-agnostic API does not depend on any transport library. A 
policy can read it directly, but only when it
  * knows the runtime type. The {@link #principalName()} and {@link 
#principalRoles()} (both since 4.24) are the
@@ -67,9 +73,9 @@ public record McpToolCallContext(
     public static final McpToolCallContext EMPTY = new 
McpToolCallContext(null, null, null, null, null, null, null);
 
     /**
-     * Exchange property under which the bridge stamps {@link 
#securityPrincipal()} on the tool exchange, so a tool
-     * route (or its {@link org.apache.camel.spi.AuthorizationPolicy}) can 
read the MCP caller identity via
-     * {@code exchangeProperty.CamelMcpSecurityPrincipal}.
+     * Exchange property under which the bridge stamps {@link 
#securityPrincipal()} on the tool, resource or prompt
+     * exchange, so the route (or a tool route's {@link 
org.apache.camel.spi.AuthorizationPolicy}) can read the MCP
+     * caller identity via {@code exchangeProperty.CamelMcpSecurityPrincipal}.
      */
     public static final String SECURITY_PRINCIPAL_PROPERTY = 
"CamelMcpSecurityPrincipal";
 
diff --git 
a/components/camel-ai/camel-mcp-server-api/src/test/java/org/apache/camel/component/mcp/server/McpServerBridgeCallerIdentityTest.java
 
b/components/camel-ai/camel-mcp-server-api/src/test/java/org/apache/camel/component/mcp/server/McpServerBridgeCallerIdentityTest.java
new file mode 100644
index 000000000000..b53da482d51b
--- /dev/null
+++ 
b/components/camel-ai/camel-mcp-server-api/src/test/java/org/apache/camel/component/mcp/server/McpServerBridgeCallerIdentityTest.java
@@ -0,0 +1,224 @@
+/*
+ * 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.component.mcp.server;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.ai.resource.AiResource;
+import org.apache.camel.spi.OAuthTokenValidationResult;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * The bridge stamps the MCP caller identity on the exchange of a resource 
read (fixed and templated) and a prompt get,
+ * exactly as for a tool call, when the engine passes a caller context; an 
engine that calls the methods without a
+ * context, or passes the empty context, gets no identity on the exchange.
+ */
+class McpServerBridgeCallerIdentityTest extends CamelTestSupport {
+
+    private static final List<String> IDENTITY_PROPERTIES = List.of(
+            McpToolCallContext.SECURITY_PRINCIPAL_PROPERTY,
+            McpToolCallContext.SECURITY_PRINCIPAL_NAME_PROPERTY,
+            McpToolCallContext.SECURITY_PRINCIPAL_ROLES_PROPERTY,
+            McpToolCallContext.OAUTH_SUBJECT_PROPERTY,
+            McpToolCallContext.OAUTH_SCOPES_PROPERTY,
+            McpToolCallContext.OAUTH_CLAIMS_PROPERTY,
+            McpToolCallContext.OAUTH_TOKEN_VALIDATION_RESULT_PROPERTY);
+
+    private final RecordingMcpServerEngine engine = new 
RecordingMcpServerEngine();
+    // the identity properties each route saw on its last request, keyed by 
route
+    private final Map<String, Map<String, Object>> seen = new 
ConcurrentHashMap<>();
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+        camelContext.getRegistry().bind("mcpServerEngine", engine);
+        McpServerConfiguration configuration = new McpServerConfiguration();
+        configuration.setTags("secured");
+        camelContext.addService(new McpServerBridge(configuration));
+        return camelContext;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                
from("ai-resource:who_res?resourceUri=camel:///whoami&tags=secured&mimeType=text/plain")
+                        .process(exchange -> capture("resource", exchange));
+
+                
from("ai-resource:who_template?uriTemplate=crm://customers/{id}&tags=secured&mimeType=text/plain")
+                        .process(exchange -> capture("template", exchange));
+
+                
from("ai-prompt:who_prompt?tags=secured&argument.topic.required=false")
+                        .process(exchange -> capture("prompt", exchange));
+            }
+        };
+    }
+
+    private void capture(String route, Exchange exchange) {
+        Map<String, Object> properties = new HashMap<>();
+        for (String name : IDENTITY_PROPERTIES) {
+            Object value = exchange.getProperty(name);
+            if (value != null) {
+                properties.put(name, value);
+            }
+        }
+        seen.put(route, properties);
+        exchange.getMessage().setBody("name=" + 
exchange.getProperty(McpToolCallContext.SECURITY_PRINCIPAL_NAME_PROPERTY)
+                                      + ",id=" + exchange.getMessage()
+                                              
.getHeader(AiResource.TEMPLATE_VARIABLE_HEADER_PREFIX + "id")
+                                      + ",topic=" + 
exchange.getMessage().getHeader("topic"));
+    }
+
+    private static McpToolCallContext callerContext(Object principal) {
+        Map<String, Object> claims = Map.of("sub", "alice", "roles", 
List.of("crm-reader"));
+        OAuthTokenValidationResult validation = 
OAuthTokenValidationResult.valid(
+                "alice", "https://id.example.test";, List.of("mcp-server"), 
List.of("mcp:read"), claims, 123L);
+        return new McpToolCallContext(
+                principal, "alice", List.of("crm-reader"), "alice", 
List.of("mcp:read"), claims, validation);
+    }
+
+    private void assertCallerStamped(String route, Object principal, 
McpToolCallContext context) {
+        assertThat(seen.get(route))
+                .containsEntry(McpToolCallContext.SECURITY_PRINCIPAL_PROPERTY, 
principal)
+                
.containsEntry(McpToolCallContext.SECURITY_PRINCIPAL_NAME_PROPERTY, "alice")
+                
.containsEntry(McpToolCallContext.SECURITY_PRINCIPAL_ROLES_PROPERTY, 
List.of("crm-reader"))
+                .containsEntry(McpToolCallContext.OAUTH_SUBJECT_PROPERTY, 
"alice")
+                .containsEntry(McpToolCallContext.OAUTH_SCOPES_PROPERTY, 
List.of("mcp:read"))
+                .containsEntry(McpToolCallContext.OAUTH_CLAIMS_PROPERTY, 
context.oauthClaims())
+                
.containsEntry(McpToolCallContext.OAUTH_TOKEN_VALIDATION_RESULT_PROPERTY,
+                        context.oauthTokenValidationResult());
+        
assertThat(seen.get(route).get(McpToolCallContext.SECURITY_PRINCIPAL_PROPERTY)).isSameAs(principal);
+    }
+
+    @Test
+    void resourceReadWithCallerStampsIdentity() {
+        Object principal = new Object();
+        McpToolCallContext context = callerContext(principal);
+
+        McpResourceReadResult result = 
engine.resources().get("camel:///whoami").handler().read(context);
+
+        assertThat(result.isError()).isFalse();
+        assertThat(result.text()).startsWith("name=alice,");
+        assertCallerStamped("resource", principal, context);
+    }
+
+    @Test
+    void resourceReadWithoutContextStampsNothing() {
+        McpResourceReadResult result = 
engine.resources().get("camel:///whoami").handler().read();
+
+        assertThat(result.isError()).isFalse();
+        assertThat(result.text()).startsWith("name=null,");
+        assertThat(seen.get("resource")).isEmpty();
+    }
+
+    @Test
+    void resourceReadWithEmptyContextStampsNothing() {
+        McpResourceReadResult result = 
engine.resources().get("camel:///whoami").handler()
+                .read(McpToolCallContext.EMPTY);
+
+        assertThat(result.isError()).isFalse();
+        assertThat(seen.get("resource")).isEmpty();
+    }
+
+    @Test
+    void templateReadWithCallerStampsIdentityAndKeepsTheVariables() {
+        Object principal = new Object();
+        McpToolCallContext context = callerContext(principal);
+
+        McpResourceReadResult result = 
engine.resourceTemplates().get("crm://customers/{id}").handler()
+                .read("crm://customers/42", context);
+
+        assertThat(result.isError()).isFalse();
+        assertThat(result.text()).isEqualTo("name=alice,id=42,topic=null");
+        assertCallerStamped("template", principal, context);
+    }
+
+    @Test
+    void templateReadWithoutContextStampsNothing() {
+        McpResourceReadResult result = 
engine.resourceTemplates().get("crm://customers/{id}").handler()
+                .read("crm://customers/42");
+
+        assertThat(result.isError()).isFalse();
+        assertThat(result.text()).isEqualTo("name=null,id=42,topic=null");
+        assertThat(seen.get("template")).isEmpty();
+    }
+
+    @Test
+    void templateReadWithEmptyContextStampsNothing() {
+        McpResourceReadResult result = 
engine.resourceTemplates().get("crm://customers/{id}").handler()
+                .read("crm://customers/42", McpToolCallContext.EMPTY);
+
+        assertThat(result.isError()).isFalse();
+        assertThat(seen.get("template")).isEmpty();
+    }
+
+    @Test
+    void promptGetWithCallerStampsIdentity() {
+        Object principal = new Object();
+        McpToolCallContext context = callerContext(principal);
+
+        McpPromptResult result = 
engine.prompts().get("who_prompt").handler().get(Map.of("topic", "orders"), 
context);
+
+        assertThat(result.isError()).isFalse();
+        assertThat(result.messages()).singleElement()
+                
.extracting(McpPromptMessage::content).isEqualTo("name=alice,id=null,topic=orders");
+        assertCallerStamped("prompt", principal, context);
+    }
+
+    @Test
+    void promptGetWithoutContextStampsNothing() {
+        McpPromptResult result = 
engine.prompts().get("who_prompt").handler().get(Map.of("topic", "orders"));
+
+        assertThat(result.isError()).isFalse();
+        assertThat(result.messages()).singleElement()
+                
.extracting(McpPromptMessage::content).isEqualTo("name=null,id=null,topic=orders");
+        assertThat(seen.get("prompt")).isEmpty();
+    }
+
+    @Test
+    void promptGetWithEmptyContextStampsNothing() {
+        McpPromptResult result = 
engine.prompts().get("who_prompt").handler().get(Map.of(), 
McpToolCallContext.EMPTY);
+
+        assertThat(result.isError()).isFalse();
+        assertThat(seen.get("prompt")).isEmpty();
+    }
+
+    @Test
+    void handlerWithoutContextOverloadIgnoresTheContext() {
+        // a handler that implements only the original method, as an 
engine-side lambda does, keeps working when an
+        // engine passes a caller context: the default overload delegates to 
the original method
+        McpToolCallContext context = callerContext(new Object());
+        McpResourceReadHandler resource = () -> 
McpResourceReadResult.text("fixed");
+        McpResourceTemplateReadHandler template = uri -> 
McpResourceReadResult.text("read " + uri);
+        McpPromptHandler prompt = arguments -> McpPromptResult.success("d",
+                List.of(new McpPromptMessage("user", "hello " + 
arguments.get("name"))));
+
+        assertThat(resource.read(context).text()).isEqualTo("fixed");
+        assertThat(template.read("crm://customers/7", 
context).text()).isEqualTo("read crm://customers/7");
+        assertThat(prompt.get(Map.of("name", "Camel"), 
context).messages()).singleElement()
+                .extracting(McpPromptMessage::content).isEqualTo("hello 
Camel");
+    }
+}
diff --git 
a/components/camel-ai/camel-mcp-server-api/src/test/java/org/apache/camel/component/mcp/server/conformance/McpServerResourceConformanceTestSupport.java
 
b/components/camel-ai/camel-mcp-server-api/src/test/java/org/apache/camel/component/mcp/server/conformance/McpServerResourceConformanceTestSupport.java
index e349788671d0..1e7e814cd3b5 100644
--- 
a/components/camel-ai/camel-mcp-server-api/src/test/java/org/apache/camel/component/mcp/server/conformance/McpServerResourceConformanceTestSupport.java
+++ 
b/components/camel-ai/camel-mcp-server-api/src/test/java/org/apache/camel/component/mcp/server/conformance/McpServerResourceConformanceTestSupport.java
@@ -277,6 +277,17 @@ public abstract class 
McpServerResourceConformanceTestSupport extends CamelTestS
         assertThat(customerTemplateInvocations).hasValue(0);
     }
 
+    @Test
+    void testEncodedDotSegmentTemplateUriReturnsNotFoundWithoutCallingRoute() {
+        customerTemplateInvocations.set(0);
+        for (String uri : List.of("camel:///customers/%2e%2e", 
"camel:///customers/..%2F..%2Fetc%2Fpasswd")) {
+            assertThatThrownBy(() -> client().readResource(new 
McpSchema.ReadResourceRequest(uri)))
+                    .as(uri)
+                    .hasMessageContaining("Resource not found");
+        }
+        assertThat(customerTemplateInvocations).hasValue(0);
+    }
+
     @Test
     void testResourceTemplateLifecycleSendsListChangedNotifications() throws 
Exception {
         AtomicInteger notifications = new AtomicInteger();
diff --git a/components/camel-ai/camel-mcp-server/src/main/docs/mcp-server.adoc 
b/components/camel-ai/camel-mcp-server/src/main/docs/mcp-server.adoc
index 55b4fb902b48..e2f422d341ce 100644
--- a/components/camel-ai/camel-mcp-server/src/main/docs/mcp-server.adoc
+++ b/components/camel-ai/camel-mcp-server/src/main/docs/mcp-server.adoc
@@ -74,6 +74,11 @@ An engine refuses a tool, resource or prompt it cannot 
serve, for example a name
 runtime already serves, by throwing `McpServerRefusedException` from
 `toolAdded`, `resourceAdded` or `promptAdded`. The bridge logs an ERROR, as for
 its own name clashes, and does not track the refused item as published.
+The engines of `camel-mcp-server` (HTTP and stdio) refuse that way, in every 
protocol
+era, a tool whose input or output schema fails the JSON Schema 2020-12 check 
of the MCP
+Java SDK (a schema that declares another `$schema` dialect is not checked); 
its route
+keeps running. Over stdio, which does not serve output schemas, only the input 
schema
+is checked.
 
 == Usage
 
@@ -139,7 +144,7 @@ from("ai-resource:app_config"
 
 An MCP client then sees the resource in `resources/list` and fetches it with
 `resources/read`. A read carries no arguments: the route is invoked with an
-empty exchange and its body is the content. The `mimeType` decides the wire
+empty message body and its body is the content. The `mimeType` decides the wire
 format — textual types are sent as text, everything else as a base64 blob —
 see xref:ROOT:ai-resource-component.adoc[ai-resource] for the details.
 
@@ -620,7 +625,8 @@ subject; requests from another subject receive the same 
not-found response as an
 session ID. A token without a non-empty subject cannot initialize an 
OAuth-protected MCP
 session. This prevents a session identifier from being reused across 
authenticated users.
 
-For an authenticated tool call, the bridge exposes the following exchange 
properties:
+For an authenticated tool call, resource read or prompt get, the bridge 
exposes the following exchange
+properties:
 
 * `CamelMcpOAuthSubject`, `CamelMcpOAuthScopes`, and `CamelMcpOAuthClaims` 
contain the subject,
   scopes, and claims from the validated token.
@@ -636,6 +642,18 @@ For an authenticated tool call, the bridge exposes the 
following exchange proper
 * `CamelOAuthTokenValidationResult` contains the full Camel OAuth validation 
result for route code
   that already consumes the standard HTTP OAuth exchange property.
 
+An `ai-resource` route, with a fixed `resourceUri` or a `uriTemplate`, and an 
`ai-prompt` route get
+the same caller properties as an `ai-tool` route, including 
`CamelMcpSecurityPrincipal`, the raw caller
+principal. This holds for every protocol version, with or without sessions, 
and for the
+`camel.server.authentication*` settings of the embedded server as well as for 
OAuth. A route can then
+check who is asking, for example before it returns the customer behind 
`crm://customers/\{id\}`.
+Unlike an `ai-tool` route, these routes have no `allowedRoles` or 
`authorizationPolicy` option: the
+route checks the properties itself, and to refuse it throws an exception, 
which the client receives
+as the generic read or prompt error. Check the properties only, never the 
headers: the template
+variables and the prompt arguments are headers, and they come from the client. 
Without an
+authenticated caller, as over stdio or on a server without authentication, 
none of these properties
+is set.
+
 These options configure OAuth only on the Camel Main / JBang Vert.x HTTP 
engine. Camel Main stdio
 mode has no HTTP authentication layer: it logs a warning and ignores these 
OAuth options. Native
 Spring Boot and Quarkus MCP engines own their security configuration; passing 
these Camel-engine
diff --git 
a/components/camel-ai/camel-mcp-server/src/main/java/org/apache/camel/component/mcp/server/McpPromptSdkSupport.java
 
b/components/camel-ai/camel-mcp-server/src/main/java/org/apache/camel/component/mcp/server/McpPromptSdkSupport.java
index 404aa302e820..e9b0079338a4 100644
--- 
a/components/camel-ai/camel-mcp-server/src/main/java/org/apache/camel/component/mcp/server/McpPromptSdkSupport.java
+++ 
b/components/camel-ai/camel-mcp-server/src/main/java/org/apache/camel/component/mcp/server/McpPromptSdkSupport.java
@@ -20,7 +20,9 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.function.Function;
 
+import io.modelcontextprotocol.common.McpTransportContext;
 import io.modelcontextprotocol.json.McpJsonMapper;
 import io.modelcontextprotocol.server.McpServerFeatures;
 import io.modelcontextprotocol.server.McpStatelessServerFeatures;
@@ -34,13 +36,35 @@ import io.modelcontextprotocol.spec.McpSchema;
  */
 public final class McpPromptSdkSupport {
 
+    // an engine without a caller identity, such as stdio
+    private static final Function<McpTransportContext, McpToolCallContext> 
NO_CALLER
+            = transportContext -> McpToolCallContext.EMPTY;
+
     private McpPromptSdkSupport() {
     }
 
     public static McpServerFeatures.SyncPromptSpecification buildSpecification(
             McpServerPrompt prompt, McpJsonMapper jsonMapper) {
+        return buildSpecification(prompt, jsonMapper, NO_CALLER);
+    }
+
+    /**
+     * Builds the specification for the MCP SDK session server, passing the 
caller of each {@code prompts/get} to the
+     * prompt handler, so the bridge stamps the caller identity onto the 
prompt exchange.
+     *
+     * @param  prompt        the prompt to serve
+     * @param  jsonMapper    the JSON mapper of the MCP server
+     * @param  callerContext derives the caller context from the MCP transport 
context of the request; it returns
+     *                       {@link McpToolCallContext#EMPTY} when there is no 
caller identity
+     * @return               the prompt specification
+     * @since                4.24
+     */
+    public static McpServerFeatures.SyncPromptSpecification buildSpecification(
+            McpServerPrompt prompt, McpJsonMapper jsonMapper,
+            Function<McpTransportContext, McpToolCallContext> callerContext) {
         return new McpServerFeatures.SyncPromptSpecification(
-                buildPrompt(prompt), (exchange, request) -> getPrompt(prompt, 
request, jsonMapper));
+                buildPrompt(prompt), (exchange, request) -> getPrompt(prompt, 
request, jsonMapper,
+                        callerContext.apply(exchange.transportContext())));
     }
 
     /**
@@ -50,8 +74,27 @@ public final class McpPromptSdkSupport {
      */
     public static McpStatelessServerFeatures.SyncPromptSpecification 
buildStatelessSpecification(
             McpServerPrompt prompt, McpJsonMapper jsonMapper) {
+        return buildStatelessSpecification(prompt, jsonMapper, NO_CALLER);
+    }
+
+    /**
+     * Builds the specification for the MCP SDK stateless server, which serves 
each request without a session, passing
+     * the caller of each {@code prompts/get} to the prompt handler, so the 
bridge stamps the caller identity onto the
+     * prompt exchange.
+     *
+     * @param  prompt        the prompt to serve
+     * @param  jsonMapper    the JSON mapper of the MCP server
+     * @param  callerContext derives the caller context from the MCP transport 
context of the request; it returns
+     *                       {@link McpToolCallContext#EMPTY} when there is no 
caller identity
+     * @return               the prompt specification
+     * @since                4.24
+     */
+    public static McpStatelessServerFeatures.SyncPromptSpecification 
buildStatelessSpecification(
+            McpServerPrompt prompt, McpJsonMapper jsonMapper,
+            Function<McpTransportContext, McpToolCallContext> callerContext) {
         return new McpStatelessServerFeatures.SyncPromptSpecification(
-                buildPrompt(prompt), (transportContext, request) -> 
getPrompt(prompt, request, jsonMapper));
+                buildPrompt(prompt), (transportContext, request) -> 
getPrompt(prompt, request, jsonMapper,
+                        callerContext.apply(transportContext)));
     }
 
     private static McpSchema.Prompt buildPrompt(McpServerPrompt prompt) {
@@ -70,7 +113,8 @@ public final class McpPromptSdkSupport {
     }
 
     private static McpSchema.GetPromptResult getPrompt(
-            McpServerPrompt prompt, McpSchema.GetPromptRequest request, 
McpJsonMapper jsonMapper) {
+            McpServerPrompt prompt, McpSchema.GetPromptRequest request, 
McpJsonMapper jsonMapper,
+            McpToolCallContext callerContext) {
         Map<String, String> arguments = new LinkedHashMap<>();
         if (request.arguments() != null) {
             request.arguments().forEach((name, value) -> {
@@ -82,7 +126,7 @@ public final class McpPromptSdkSupport {
                 arguments.put(name, stringValue);
             });
         }
-        McpPromptResult result = prompt.handler().get(arguments);
+        McpPromptResult result = prompt.handler().get(arguments, 
callerContext);
         if (result == null) {
             throw McpError.builder(McpSchema.ErrorCodes.INTERNAL_ERROR)
                     .message("Prompt execution failed")
diff --git 
a/components/camel-ai/camel-mcp-server/src/main/java/org/apache/camel/component/mcp/server/stdio/StdioMcpServerEngine.java
 
b/components/camel-ai/camel-mcp-server/src/main/java/org/apache/camel/component/mcp/server/stdio/StdioMcpServerEngine.java
index ac299d7014fb..172e342fb26b 100644
--- 
a/components/camel-ai/camel-mcp-server/src/main/java/org/apache/camel/component/mcp/server/stdio/StdioMcpServerEngine.java
+++ 
b/components/camel-ai/camel-mcp-server/src/main/java/org/apache/camel/component/mcp/server/stdio/StdioMcpServerEngine.java
@@ -27,9 +27,11 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.function.Supplier;
 
 import io.modelcontextprotocol.json.McpJsonDefaults;
 import io.modelcontextprotocol.json.McpJsonMapper;
+import io.modelcontextprotocol.json.schema.JsonSchemaValidator;
 import io.modelcontextprotocol.server.McpServer;
 import io.modelcontextprotocol.server.McpServerFeatures;
 import io.modelcontextprotocol.server.McpSyncServer;
@@ -43,6 +45,7 @@ import 
org.apache.camel.component.mcp.server.McpResourceReadResult;
 import org.apache.camel.component.mcp.server.McpServerEngine;
 import org.apache.camel.component.mcp.server.McpServerInfo;
 import org.apache.camel.component.mcp.server.McpServerPrompt;
+import org.apache.camel.component.mcp.server.McpServerRefusedException;
 import org.apache.camel.component.mcp.server.McpServerResource;
 import org.apache.camel.component.mcp.server.McpServerResourceTemplate;
 import org.apache.camel.component.mcp.server.McpServerTool;
@@ -74,6 +77,7 @@ public class StdioMcpServerEngine extends ServiceSupport 
implements McpServerEng
     private CamelContext camelContext;
     private McpServerInfo info;
     private McpJsonMapper jsonMapper;
+    private JsonSchemaValidator schemaValidator;
     private StdioServerTransportProvider transport;
     private McpSyncServer server;
     private InputStream inputStream;
@@ -114,21 +118,36 @@ public class StdioMcpServerEngine extends ServiceSupport 
implements McpServerEng
      */
     private McpJsonMapper jsonMapper() {
         if (jsonMapper == null) {
-            ClassLoader cl = camelContext != null ? 
camelContext.getApplicationContextClassLoader() : null;
-            if (cl == null) {
-                cl = StdioMcpServerEngine.class.getClassLoader();
-            }
-            ClassLoader tccl = Thread.currentThread().getContextClassLoader();
-            try {
-                Thread.currentThread().setContextClassLoader(cl);
-                jsonMapper = McpJsonDefaults.getMapper();
-            } finally {
-                Thread.currentThread().setContextClassLoader(tccl);
-            }
+            jsonMapper = 
withApplicationClassLoader(McpJsonDefaults::getMapper);
         }
         return jsonMapper;
     }
 
+    /**
+     * The JSON schema validator of the MCP SDK, the one its server checks the 
schema of a tool with, found as
+     * {@link #jsonMapper()}.
+     */
+    private JsonSchemaValidator schemaValidator() {
+        if (schemaValidator == null) {
+            schemaValidator = 
withApplicationClassLoader(McpJsonDefaults::getSchemaValidator);
+        }
+        return schemaValidator;
+    }
+
+    private <T> T withApplicationClassLoader(Supplier<T> supplier) {
+        ClassLoader cl = camelContext != null ? 
camelContext.getApplicationContextClassLoader() : null;
+        if (cl == null) {
+            cl = StdioMcpServerEngine.class.getClassLoader();
+        }
+        ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+        try {
+            Thread.currentThread().setContextClassLoader(cl);
+            return supplier.get();
+        } finally {
+            Thread.currentThread().setContextClassLoader(tccl);
+        }
+    }
+
     /**
      * Optional test hook: when both streams are set, the engine uses them 
instead of {@link System#in} and
      * {@link System#out}.
@@ -483,7 +502,7 @@ public class StdioMcpServerEngine extends ServiceSupport 
implements McpServerEng
     }
 
     private McpServerFeatures.SyncToolSpecification 
buildToolSpecification(McpServerTool tool) {
-        McpSchema.Tool mcpTool = buildMcpTool(tool);
+        McpSchema.Tool mcpTool = buildValidMcpTool(tool);
         return McpServerFeatures.SyncToolSpecification.builder()
                 .tool(mcpTool)
                 .callHandler((exchange, request) -> {
@@ -500,6 +519,22 @@ public class StdioMcpServerEngine extends ServiceSupport 
implements McpServerEng
                 .build();
     }
 
+    /**
+     * Builds the tool, refusing it when its schema is not a valid JSON Schema 
document, as the MCP SDK server would
+     * when the tool is added to it: checked before the tool is queued or 
added, so it is refused alike before and after
+     * the server starts. The output schema is not served over stdio, so it is 
not checked.
+     */
+    private McpSchema.Tool buildValidMcpTool(McpServerTool tool) {
+        try {
+            McpSchema.Tool mcpTool = buildMcpTool(tool);
+            schemaValidator().assertConforms("Tool '" + tool.name() + "' 
inputSchema", mcpTool.inputSchema());
+            return mcpTool;
+        } catch (IllegalArgumentException e) {
+            throw new McpServerRefusedException(
+                    "MCP tool '" + tool.name() + "' has an invalid input 
schema: " + e.getMessage(), e);
+        }
+    }
+
     private McpSchema.Tool buildMcpTool(McpServerTool tool) {
         String schema = tool.inputSchemaJson() != null ? 
tool.inputSchemaJson() : EMPTY_OBJECT_SCHEMA;
         McpSchema.Tool.Builder builder = McpSchema.Tool.builder(tool.name(), 
jsonMapper(), schema)
diff --git 
a/components/camel-ai/camel-mcp-server/src/main/java/org/apache/camel/component/mcp/server/vertx/McpModernCatalog.java
 
b/components/camel-ai/camel-mcp-server/src/main/java/org/apache/camel/component/mcp/server/vertx/McpModernCatalog.java
index 9fd883592ca8..0a18d7778c19 100644
--- 
a/components/camel-ai/camel-mcp-server/src/main/java/org/apache/camel/component/mcp/server/vertx/McpModernCatalog.java
+++ 
b/components/camel-ai/camel-mcp-server/src/main/java/org/apache/camel/component/mcp/server/vertx/McpModernCatalog.java
@@ -228,13 +228,15 @@ final class McpModernCatalog {
         if (resource != null) {
             McpServerResource source = resource.source();
             return McpSyncResource.of((c, request) -> McpSyncResponse.result(
-                    readResult(request.uri(), source.mimeType(), 
source.handler().read())));
+                    readResult(request.uri(), source.mimeType(),
+                            
source.handler().read(VertxMcpServerEngine.toToolCallContext(c.transportContext())))));
         }
         for (TemplateEntry template : templates.values()) {
             if (template.matcher().matches(uri)) {
                 McpServerResourceTemplate source = template.source();
                 return McpSyncResource.of((c, request) -> 
McpSyncResponse.result(
-                        readResult(request.uri(), source.mimeType(), 
source.handler().read(request.uri()))));
+                        readResult(request.uri(), source.mimeType(), 
source.handler().read(request.uri(),
+                                
VertxMcpServerEngine.toToolCallContext(c.transportContext())))));
             }
         }
         return null;
@@ -271,7 +273,8 @@ final class McpModernCatalog {
         }
         prompts.put(prompt.name(), McpSyncPrompt.of(builder.build(), (ctx, 
request) -> {
             Map<String, String> arguments = request.arguments() != null ? 
request.arguments() : Map.of();
-            McpPromptResult result = prompt.handler().get(arguments);
+            McpPromptResult result
+                    = prompt.handler().get(arguments, 
VertxMcpServerEngine.toToolCallContext(ctx.transportContext()));
             if (result == null) {
                 throw new McpException(ErrorCodes.INTERNAL_ERROR, "Prompt 
execution failed");
             }
diff --git 
a/components/camel-ai/camel-mcp-server/src/main/java/org/apache/camel/component/mcp/server/vertx/VertxMcpServerEngine.java
 
b/components/camel-ai/camel-mcp-server/src/main/java/org/apache/camel/component/mcp/server/vertx/VertxMcpServerEngine.java
index 568370112338..e0102fe5b5c1 100644
--- 
a/components/camel-ai/camel-mcp-server/src/main/java/org/apache/camel/component/mcp/server/vertx/VertxMcpServerEngine.java
+++ 
b/components/camel-ai/camel-mcp-server/src/main/java/org/apache/camel/component/mcp/server/vertx/VertxMcpServerEngine.java
@@ -27,6 +27,7 @@ import java.util.Set;
 import io.modelcontextprotocol.common.McpTransportContext;
 import io.modelcontextprotocol.json.McpJsonDefaults;
 import io.modelcontextprotocol.json.McpJsonMapper;
+import io.modelcontextprotocol.json.schema.JsonSchemaValidator;
 import io.modelcontextprotocol.modern.server.feature.McpChangeFeed;
 import io.modelcontextprotocol.server.McpServer;
 import io.modelcontextprotocol.server.McpServerFeatures;
@@ -46,6 +47,7 @@ import org.apache.camel.component.mcp.server.McpServerEngine;
 import org.apache.camel.component.mcp.server.McpServerIcon;
 import org.apache.camel.component.mcp.server.McpServerInfo;
 import org.apache.camel.component.mcp.server.McpServerPrompt;
+import org.apache.camel.component.mcp.server.McpServerRefusedException;
 import org.apache.camel.component.mcp.server.McpServerResource;
 import org.apache.camel.component.mcp.server.McpServerResourceTemplate;
 import org.apache.camel.component.mcp.server.McpServerTool;
@@ -91,7 +93,8 @@ public class VertxMcpServerEngine extends ServiceSupport 
implements McpServerEng
 
     /**
      * Key under which {@link VertxMcpStreamableServerTransportProvider} 
stashes the authenticated caller principal in
-     * the MCP transport context, so the tool-call handler reads it back via 
{@code exchange.transportContext()}.
+     * the MCP transport context, so the tool, resource and prompt handlers 
read it back via
+     * {@code exchange.transportContext()}.
      */
     static final String TRANSPORT_PRINCIPAL_KEY = "CamelMcpTransportPrincipal";
     static final String TRANSPORT_OAUTH_RESULT_KEY = 
"CamelMcpOAuthTokenValidationResult";
@@ -270,7 +273,7 @@ public class VertxMcpServerEngine extends ServiceSupport 
implements McpServerEng
 
     @Override
     public void toolAdded(McpServerTool tool) {
-        McpSchema.Tool mcpTool = buildMcpTool(tool);
+        McpSchema.Tool mcpTool = buildValidMcpTool(tool);
         if (server != null) {
             server.addTool(McpServerFeatures.SyncToolSpecification.builder()
                     .tool(mcpTool)
@@ -418,13 +421,14 @@ public class VertxMcpServerEngine extends ServiceSupport 
implements McpServerEng
         if (server != null) {
             server.addResource(new McpServerFeatures.SyncResourceSpecification(
                     mcpResource,
-                    (exchange, request) -> readResult(resource.uri(), 
resource.mimeType(), resource.handler().read())));
+                    (exchange, request) -> readResult(resource.uri(), 
resource.mimeType(),
+                            
resource.handler().read(toToolCallContext(exchange.transportContext())))));
         }
         if (statelessServer != null) {
             statelessServer.addResource(new 
McpStatelessServerFeatures.SyncResourceSpecification(
                     mcpResource,
                     (transportContext, request) -> readResult(resource.uri(), 
resource.mimeType(),
-                            resource.handler().read())));
+                            
resource.handler().read(toToolCallContext(transportContext)))));
         }
         if (modernCatalog != null) {
             modernCatalog.addResource(resource);
@@ -486,13 +490,14 @@ public class VertxMcpServerEngine extends ServiceSupport 
implements McpServerEng
             server.addResourceTemplate(new 
McpServerFeatures.SyncResourceTemplateSpecification(
                     mcpTemplate,
                     (exchange, request) -> readResult(request.uri(), 
resourceTemplate.mimeType(),
-                            resourceTemplate.handler().read(request.uri()))));
+                            resourceTemplate.handler().read(request.uri(),
+                                    
toToolCallContext(exchange.transportContext())))));
         }
         if (statelessServer != null) {
             statelessServer.addResourceTemplate(new 
McpStatelessServerFeatures.SyncResourceTemplateSpecification(
                     mcpTemplate,
                     (transportContext, request) -> readResult(request.uri(), 
resourceTemplate.mimeType(),
-                            resourceTemplate.handler().read(request.uri()))));
+                            resourceTemplate.handler().read(request.uri(), 
toToolCallContext(transportContext)))));
         }
         if (modernCatalog != null) {
             modernCatalog.addResourceTemplate(resourceTemplate);
@@ -527,10 +532,12 @@ public class VertxMcpServerEngine extends ServiceSupport 
implements McpServerEng
     @Override
     public void promptAdded(McpServerPrompt prompt) {
         if (server != null) {
-            server.addPrompt(McpPromptSdkSupport.buildSpecification(prompt, 
jsonMapper));
+            server.addPrompt(McpPromptSdkSupport.buildSpecification(
+                    prompt, jsonMapper, 
VertxMcpServerEngine::toToolCallContext));
         }
         if (statelessServer != null) {
-            
statelessServer.addPrompt(McpPromptSdkSupport.buildStatelessSpecification(prompt,
 jsonMapper));
+            
statelessServer.addPrompt(McpPromptSdkSupport.buildStatelessSpecification(
+                    prompt, jsonMapper, 
VertxMcpServerEngine::toToolCallContext));
         }
         if (modernCatalog != null) {
             modernCatalog.addPrompt(prompt);
@@ -575,6 +582,25 @@ public class VertxMcpServerEngine extends ServiceSupport 
implements McpServerEng
         return builder.build();
     }
 
+    /**
+     * Builds the tool, refusing it when its input or output schema is not a 
valid JSON Schema document. The MCP SDK
+     * checks the schemas when a tool is added to a server of the legacy era, 
but not to the catalog of protocol version
+     * 2026-07-28: they are checked once here, with the same validator, before 
the tool is added to any server, so every
+     * era refuses the tool alike and none serves it alone.
+     */
+    private McpSchema.Tool buildValidMcpTool(McpServerTool tool) {
+        try {
+            McpSchema.Tool mcpTool = buildMcpTool(tool);
+            JsonSchemaValidator validator = 
McpJsonDefaults.getSchemaValidator();
+            validator.assertConforms("Tool '" + tool.name() + "' inputSchema", 
mcpTool.inputSchema());
+            validator.assertConforms("Tool '" + tool.name() + "' 
outputSchema", mcpTool.outputSchema());
+            return mcpTool;
+        } catch (IllegalArgumentException e) {
+            throw new McpServerRefusedException(
+                    "MCP tool '" + tool.name() + "' has an invalid input or 
output schema: " + e.getMessage(), e);
+        }
+    }
+
     private McpSchema.Tool buildMcpTool(McpServerTool tool) {
         String schema = tool.inputSchemaJson() != null ? 
tool.inputSchemaJson() : EMPTY_OBJECT_SCHEMA;
         McpSchema.Tool.Builder builder = McpSchema.Tool.builder(tool.name(), 
jsonMapper, schema)
diff --git 
a/components/camel-ai/camel-mcp-server/src/test/java/org/apache/camel/component/mcp/server/main/McpServerMainCallerIdentityTest.java
 
b/components/camel-ai/camel-mcp-server/src/test/java/org/apache/camel/component/mcp/server/main/McpServerMainCallerIdentityTest.java
new file mode 100644
index 000000000000..aa19b8292df3
--- /dev/null
+++ 
b/components/camel-ai/camel-mcp-server/src/test/java/org/apache/camel/component/mcp/server/main/McpServerMainCallerIdentityTest.java
@@ -0,0 +1,172 @@
+/*
+ * 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.component.mcp.server.main;
+
+import java.time.Duration;
+import java.util.Base64;
+import java.util.Map;
+
+import io.modelcontextprotocol.client.McpClient;
+import io.modelcontextprotocol.client.McpSyncClient;
+import 
io.modelcontextprotocol.client.transport.HttpClientStreamableHttpTransport;
+import io.modelcontextprotocol.modern.client.transport.HttpClientMcpTransport;
+import 
io.modelcontextprotocol.modern.client.transport.McpHttpRequestCustomizer;
+import io.modelcontextprotocol.spec.McpSchema;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mcp.server.McpToolCallContext;
+import org.apache.camel.component.platform.http.main.MainHttpServer;
+import org.apache.camel.main.Main;
+import org.junit.jupiter.api.Test;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * An authenticated MCP caller reaches {@code ai-resource} (fixed and 
templated) and {@code ai-prompt} routes as it
+ * reaches {@code ai-tool} routes (CAMEL-26360): the caller identity is 
stamped as exchange properties on a request of
+ * each protocol era, with and without sessions, and an anonymous request 
stamps nothing.
+ */
+class McpServerMainCallerIdentityTest {
+
+    private static final String CALLER = "name=camel,principal=true";
+    private static final String NO_CALLER = "name=null,principal=false";
+    private static final String CREDENTIALS = 
Base64.getEncoder().encodeToString("camel:mcpPass".getBytes(UTF_8));
+
+    @Test
+    void legacySessionAndModernRequestsCarryTheCaller() {
+        Main main = startMain(true, false);
+        try {
+            assertLegacyClientSees(port(main), true, CALLER);
+            assertModernClientSees(port(main), true, CALLER);
+        } finally {
+            main.stop();
+        }
+    }
+
+    @Test
+    void statelessLegacyRequestsCarryTheCaller() {
+        Main main = startMain(true, true);
+        try {
+            assertLegacyClientSees(port(main), true, CALLER);
+        } finally {
+            main.stop();
+        }
+    }
+
+    @Test
+    void anonymousRequestsCarryNoCaller() {
+        Main main = startMain(false, false);
+        try {
+            assertLegacyClientSees(port(main), false, NO_CALLER);
+            assertModernClientSees(port(main), false, NO_CALLER);
+        } finally {
+            main.stop();
+        }
+    }
+
+    private static void assertLegacyClientSees(int port, boolean 
authenticated, String expected) {
+        HttpClientStreamableHttpTransport.Builder transport
+                = 
HttpClientStreamableHttpTransport.builder("http://localhost:"; + port);
+        if (authenticated) {
+            transport.httpRequestCustomizer(
+                    (builder, method, uri, body, context) -> 
builder.header("Authorization", "Basic " + CREDENTIALS));
+        }
+        McpSyncClient client = McpClient.sync(transport.build())
+                .requestTimeout(Duration.ofSeconds(10))
+                .initializationTimeout(Duration.ofSeconds(10))
+                .build();
+        try {
+            client.initialize();
+
+            assertThat(client.readResource(new 
McpSchema.ReadResourceRequest("camel:///whoami")).contents())
+                    
.singleElement().isInstanceOfSatisfying(McpSchema.TextResourceContents.class,
+                            text -> 
assertThat(text.text()).isEqualTo(expected));
+            assertThat(client.readResource(new 
McpSchema.ReadResourceRequest("crm://customers/42")).contents())
+                    
.singleElement().isInstanceOfSatisfying(McpSchema.TextResourceContents.class,
+                            text -> 
assertThat(text.text()).isEqualTo(expected));
+            assertThat(client.getPrompt(new 
McpSchema.GetPromptRequest("who_prompt", Map.of())).messages())
+                    .singleElement().satisfies(message -> 
assertThat(message.content())
+                            
.isInstanceOfSatisfying(McpSchema.TextContent.class,
+                                    text -> 
assertThat(text.text()).isEqualTo(expected)));
+        } finally {
+            client.closeGracefully();
+        }
+    }
+
+    private static void assertModernClientSees(int port, boolean 
authenticated, String expected) {
+        HttpClientMcpTransport.Builder transport = 
HttpClientMcpTransport.builder("http://localhost:"; + port + "/mcp");
+        if (authenticated) {
+            transport.requestCustomizer(McpHttpRequestCustomizer.fromSync(
+                    (request, headers, context) -> 
headers.set("Authorization", "Basic " + CREDENTIALS)));
+        }
+        io.modelcontextprotocol.modern.client.McpSyncClient client = 
io.modelcontextprotocol.modern.client.McpClient
+                .sync(transport.build())
+                
.clientInfo(io.modelcontextprotocol.modern.McpSchema.Implementation.builder("test",
 "1").build())
+                .build();
+
+        
assertThat(client.resource("camel:///whoami").read().contents()).singleElement()
+                
.isInstanceOfSatisfying(io.modelcontextprotocol.modern.McpSchema.TextResourceContents.class,
+                        text -> assertThat(text.text()).isEqualTo(expected));
+        
assertThat(client.resource("crm://customers/42").read().contents()).singleElement()
+                
.isInstanceOfSatisfying(io.modelcontextprotocol.modern.McpSchema.TextResourceContents.class,
+                        text -> assertThat(text.text()).isEqualTo(expected));
+        
assertThat(client.prompt("who_prompt").arguments(Map.of()).get().messages()).singleElement()
+                .satisfies(message -> assertThat(message.content())
+                        
.isInstanceOfSatisfying(io.modelcontextprotocol.modern.McpSchema.TextContent.class,
+                                text -> 
assertThat(text.text()).isEqualTo(expected)));
+    }
+
+    private static Main startMain(boolean authenticated, boolean stateless) {
+        Main main = new Main();
+        main.configure().addRoutesBuilder(new RouteBuilder() {
+            @Override
+            public void configure() {
+                
from("ai-resource:who_resource?resourceUri=camel:///whoami&tags=secured&mimeType=text/plain")
+                        .process(McpServerMainCallerIdentityTest::who);
+                
from("ai-resource:who_template?uriTemplate=crm://customers/{id}&tags=secured&mimeType=text/plain")
+                        .process(McpServerMainCallerIdentityTest::who);
+                from("ai-prompt:who_prompt?tags=secured")
+                        .process(McpServerMainCallerIdentityTest::who);
+            }
+        });
+        main.addInitialProperty("camel.server.enabled", "true");
+        // port 0: the OS picks a free port, read back from the started server
+        main.addInitialProperty("camel.server.port", "0");
+        main.addInitialProperty("camel.server.mcp-enabled", "true");
+        main.addInitialProperty("camel.server.mcp-tags", "secured");
+        if (authenticated) {
+            main.addInitialProperty("camel.server.authentication-enabled", 
"true");
+            main.addInitialProperty("camel.server.basic-properties-file", 
"mcp-basic-auth.properties");
+        }
+        if (stateless) {
+            main.addInitialProperty("camel.server.mcp-stateless", "true");
+        }
+        main.start();
+        return main;
+    }
+
+    private static int port(Main main) {
+        return 
main.getCamelContext().hasService(MainHttpServer.class).getPort();
+    }
+
+    private static void who(Exchange exchange) {
+        Object name = 
exchange.getProperty(McpToolCallContext.SECURITY_PRINCIPAL_NAME_PROPERTY);
+        Object principal = 
exchange.getProperty(McpToolCallContext.SECURITY_PRINCIPAL_PROPERTY);
+        exchange.getMessage().setBody("name=" + name + ",principal=" + 
(principal != null));
+    }
+}
diff --git 
a/components/camel-ai/camel-mcp-server/src/test/java/org/apache/camel/component/mcp/server/stdio/StdioMcpServerEngineTest.java
 
b/components/camel-ai/camel-mcp-server/src/test/java/org/apache/camel/component/mcp/server/stdio/StdioMcpServerEngineTest.java
index 40e680604a6e..e2cd7e33022c 100644
--- 
a/components/camel-ai/camel-mcp-server/src/test/java/org/apache/camel/component/mcp/server/stdio/StdioMcpServerEngineTest.java
+++ 
b/components/camel-ai/camel-mcp-server/src/test/java/org/apache/camel/component/mcp/server/stdio/StdioMcpServerEngineTest.java
@@ -35,6 +35,7 @@ import org.apache.camel.component.mcp.server.McpServerBridge;
 import org.apache.camel.component.mcp.server.McpServerConfiguration;
 import org.apache.camel.component.mcp.server.McpServerInfo;
 import org.apache.camel.component.mcp.server.McpServerPrompt;
+import org.apache.camel.component.mcp.server.McpServerRefusedException;
 import org.apache.camel.component.mcp.server.McpServerResource;
 import org.apache.camel.component.mcp.server.McpServerResourceTemplate;
 import org.apache.camel.component.mcp.server.McpServerTool;
@@ -45,6 +46,7 @@ import org.junit.jupiter.api.Test;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 class StdioMcpServerEngineTest extends CamelTestSupport {
 
@@ -197,6 +199,32 @@ class StdioMcpServerEngineTest extends CamelTestSupport {
         }
     }
 
+    @Test
+    void toolWithAnInvalidSchemaIsRefusedBeforeAndAfterStart() throws 
Exception {
+        // a JSON object, so Camel accepts it, but "strng" is not a JSON 
Schema type
+        String invalidSchema = 
"{\"type\":\"object\",\"properties\":{\"q\":{\"type\":\"strng\"}}}";
+        StdioMcpServerEngine engine = new StdioMcpServerEngine();
+        engine.initialize(new McpServerInfo(
+                "test", "1.0", "/mcp", 0, 0, null, null, null, null, null));
+        engine.setTransportStreams(new ByteArrayInputStream(new byte[0]), new 
ByteArrayOutputStream());
+
+        // refused instead of queued, so it cannot fail the start of the server
+        assertThatThrownBy(() -> engine.toolAdded(sampleTool("queued_bad", 
"Queued before start", invalidSchema, null)))
+                .isInstanceOf(McpServerRefusedException.class)
+                .hasMessageContaining("Tool 'queued_bad' inputSchema is not a 
valid JSON Schema 2020-12 document");
+        try {
+            assertThatCode(engine::start).doesNotThrowAnyException();
+            assertThatThrownBy(() -> engine.toolAdded(sampleTool("late_bad", 
"Added after start", invalidSchema, null)))
+                    .isInstanceOf(McpServerRefusedException.class)
+                    .hasMessageContaining("Tool 'late_bad' inputSchema is not 
a valid JSON Schema 2020-12 document");
+            // the output schema is not served over stdio
+            assertThatCode(() -> 
engine.toolAdded(sampleTool("unserved_output", "Added after start", null, 
invalidSchema)))
+                    .doesNotThrowAnyException();
+        } finally {
+            engine.stop();
+        }
+    }
+
     private static McpServerResource sampleResource(String uri) {
         return new McpServerResource() {
             @Override
@@ -286,6 +314,11 @@ class StdioMcpServerEngineTest extends CamelTestSupport {
     }
 
     private static McpServerTool sampleTool(String name, String description) {
+        return sampleTool(name, description, null, null);
+    }
+
+    private static McpServerTool sampleTool(
+            String name, String description, String inputSchemaJson, String 
outputSchemaJson) {
         McpToolCallHandler handler = arguments -> new McpToolCallResult("ok", 
false);
         return new McpServerTool() {
             @Override
@@ -300,7 +333,7 @@ class StdioMcpServerEngineTest extends CamelTestSupport {
 
             @Override
             public String inputSchemaJson() {
-                return null;
+                return inputSchemaJson;
             }
 
             @Override
@@ -320,7 +353,7 @@ class StdioMcpServerEngineTest extends CamelTestSupport {
 
             @Override
             public String outputSchemaJson() {
-                return null;
+                return outputSchemaJson;
             }
         };
     }
diff --git 
a/components/camel-ai/camel-mcp-server/src/test/java/org/apache/camel/component/mcp/server/vertx/VertxMcpServerInvalidToolSchemaTest.java
 
b/components/camel-ai/camel-mcp-server/src/test/java/org/apache/camel/component/mcp/server/vertx/VertxMcpServerInvalidToolSchemaTest.java
new file mode 100644
index 000000000000..1b1009a110db
--- /dev/null
+++ 
b/components/camel-ai/camel-mcp-server/src/test/java/org/apache/camel/component/mcp/server/vertx/VertxMcpServerInvalidToolSchemaTest.java
@@ -0,0 +1,212 @@
+/*
+ * 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.component.mcp.server.vertx;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.time.Duration;
+import java.util.List;
+import java.util.Map;
+
+import io.modelcontextprotocol.client.McpClient;
+import io.modelcontextprotocol.client.McpSyncClient;
+import 
io.modelcontextprotocol.client.transport.HttpClientStreamableHttpTransport;
+import io.modelcontextprotocol.modern.McpSchema.Implementation;
+import io.modelcontextprotocol.modern.client.transport.HttpClientMcpTransport;
+import io.modelcontextprotocol.spec.McpSchema;
+import org.apache.camel.CamelContext;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.ai.tool.AiToolParameterHelper.ParameterDef;
+import org.apache.camel.component.mcp.server.McpServerBridge;
+import org.apache.camel.component.mcp.server.McpServerConfiguration;
+import org.apache.camel.component.mcp.server.McpServerEngine;
+import org.apache.camel.component.mcp.server.McpServerRefusedException;
+import org.apache.camel.component.mcp.server.McpServerTool;
+import org.apache.camel.component.mcp.server.McpToolCallHandler;
+import org.apache.camel.component.mcp.server.McpToolCallResult;
+import org.apache.camel.component.platform.http.main.MainHttpServer;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.main.Main;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/**
+ * An {@code ai-tool} route whose input or output schema is a JSON object but 
not a valid JSON Schema 2020-12 document
+ * is refused by every protocol era, whether its route starts after the MCP 
server or before it: the engine refuses the
+ * tool before adding it to the server of any era, so it is not served to any 
client, its route keeps running, and the
+ * other tools are served.
+ */
+class VertxMcpServerInvalidToolSchemaTest {
+
+    // a JSON object, so Camel accepts it, but "strng" is not a JSON Schema 
type
+    private static final String INVALID_INPUT_SCHEMA = """
+            {"type":"object","properties":{"q":{"type":"strng"}}}""";
+    private static final String INVALID_OUTPUT_SCHEMA = """
+            {"type":"object","properties":{"total":{"type":"numbr"}}}""";
+
+    @TempDir
+    Path dir;
+
+    private Path inputSchema;
+    private Path outputSchema;
+
+    @BeforeEach
+    void writeSchemas() throws Exception {
+        inputSchema = Files.writeString(dir.resolve("input-schema.json"), 
INVALID_INPUT_SCHEMA);
+        outputSchema = Files.writeString(dir.resolve("output-schema.json"), 
INVALID_OUTPUT_SCHEMA);
+    }
+
+    @ParameterizedTest(name = "era {0}, stateless {1}")
+    @CsvSource({ "legacy, false", "dual, false", "dual, true", "modern, false" 
})
+    void routeStartedAfterTheServer(String era, boolean stateless) throws 
Exception {
+        Main main = new Main();
+        main.configure().addRoutesBuilder(routes());
+        main.addInitialProperty("camel.server.enabled", "true");
+        main.addInitialProperty("camel.server.port", "0");
+        main.addInitialProperty("camel.server.mcp-enabled", "true");
+        main.addInitialProperty("camel.server.mcp-tags", "crm");
+        main.addInitialProperty("camel.server.mcp-protocol-era", era);
+        main.addInitialProperty("camel.server.mcp-stateless", 
String.valueOf(stateless));
+        main.start();
+        try {
+            int port = 
main.getCamelContext().hasService(MainHttpServer.class).getPort();
+            assertServedTools(main.getCamelContext(), port, era);
+        } finally {
+            main.stop();
+        }
+    }
+
+    @ParameterizedTest(name = "era {0}")
+    @CsvSource({ "legacy", "dual", "modern" })
+    void routeStartedBeforeTheServer(String era) throws Exception {
+        try (DefaultCamelContext camelContext = new DefaultCamelContext()) {
+            MainHttpServer server = new MainHttpServer();
+            server.setCamelContext(camelContext);
+            server.setHost("0.0.0.0");
+            server.setPort(0);
+            camelContext.addService(server);
+            McpServerConfiguration configuration = new 
McpServerConfiguration();
+            configuration.setTags("crm");
+            configuration.setProtocolEra(era);
+            McpServerBridge bridge = new McpServerBridge(configuration);
+            camelContext.addService(bridge);
+            camelContext.addRoutes(routes());
+
+            // the MCP server publishes the tools of the routes started before 
it when it starts: a refused tool must
+            // not fail the start of the CamelContext
+            camelContext.start();
+
+            assertThat(bridge.isStarted()).isTrue();
+            assertServedTools(camelContext, server.getPort(), era);
+        }
+    }
+
+    private RouteBuilder routes() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("ai-tool:bad_input?tags=crm&description=Bad input 
schema&argSchema=file:" + inputSchema)
+                        .routeId("bad-input-route")
+                        .setBody(constant("ran"));
+                from("ai-tool:bad_output?tags=crm&description=Bad output 
schema&outputSchema=file:" + outputSchema)
+                        .routeId("bad-output-route")
+                        .setBody(constant("{\"total\":1}"));
+                from("ai-tool:good?tags=crm&description=Good tool")
+                        .setBody(constant("ok"));
+            }
+        };
+    }
+
+    private static void assertServedTools(CamelContext camelContext, int port, 
String era) {
+        // the engine refuses the tool before adding it to the server of any 
era
+        McpServerEngine engine = 
camelContext.hasService(McpServerBridge.class).getEngine();
+        assertThatThrownBy(() -> engine.toolAdded(tool("direct_bad", 
INVALID_INPUT_SCHEMA, null)))
+                .isInstanceOf(McpServerRefusedException.class)
+                .hasMessageContaining("Tool 'direct_bad' inputSchema is not a 
valid JSON Schema 2020-12 document");
+        assertThatThrownBy(() -> engine.toolAdded(tool("direct_bad", null, 
INVALID_OUTPUT_SCHEMA)))
+                .isInstanceOf(McpServerRefusedException.class)
+                .hasMessageContaining("Tool 'direct_bad' outputSchema is not a 
valid JSON Schema 2020-12 document");
+
+        if (!"modern".equals(era)) {
+            McpSyncClient legacy = McpClient.sync(
+                    
HttpClientStreamableHttpTransport.builder("http://localhost:"; + port).build())
+                    .requestTimeout(Duration.ofSeconds(10))
+                    .initializationTimeout(Duration.ofSeconds(10))
+                    .build();
+            try {
+                legacy.initialize();
+                List<String> tools = 
legacy.listTools().tools().stream().map(McpSchema.Tool::name).toList();
+                assertThat(tools).as("tools served to a legacy 
client").containsExactly("good");
+            } finally {
+                legacy.closeGracefully();
+            }
+        }
+        if (!"legacy".equals(era)) {
+            io.modelcontextprotocol.modern.client.McpSyncClient modern = 
io.modelcontextprotocol.modern.client.McpClient
+                    .sync(HttpClientMcpTransport.builder("http://localhost:"; + 
port + "/mcp").build())
+                    .clientInfo(Implementation.builder("test", "1").build())
+                    .build();
+            List<String> tools = modern.listTools().list().tools().stream()
+                    
.map(io.modelcontextprotocol.modern.McpSchema.Tool::name).toList();
+            assertThat(tools).as("tools served to a client of protocol version 
2026-07-28").containsExactly("good");
+        }
+        
assertThat(camelContext.getRouteController().getRouteStatus("bad-input-route"))
+                .isEqualTo(ServiceStatus.Started);
+        
assertThat(camelContext.getRouteController().getRouteStatus("bad-output-route"))
+                .isEqualTo(ServiceStatus.Started);
+    }
+
+    private static McpServerTool tool(String name, String inputSchemaJson, 
String outputSchemaJson) {
+        return new McpServerTool() {
+            @Override
+            public String name() {
+                return name;
+            }
+
+            @Override
+            public String description() {
+                return "Invalid schema";
+            }
+
+            @Override
+            public String inputSchemaJson() {
+                return inputSchemaJson;
+            }
+
+            @Override
+            public Map<String, ParameterDef> parameters() {
+                return Map.of();
+            }
+
+            @Override
+            public McpToolCallHandler handler() {
+                return arguments -> new McpToolCallResult("ran", false);
+            }
+
+            @Override
+            public String outputSchemaJson() {
+                return outputSchemaJson;
+            }
+        };
+    }
+}
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index 4966251fbb46..0845a308794d 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -942,6 +942,15 @@ undeclared argument; previously Camel accepted the call 
and dropped the argument
 arguments, set `additionalProperties` in the schema yourself; the route still 
receives only the declared top-level
 arguments.
 
+=== camel-mcp-server - a tool whose schema is not a valid JSON Schema is 
refused
+
+The MCP server now refuses an `ai-tool` route whose input schema (`argSchema`) 
or output schema is not a valid
+JSON Schema 2020-12 document, in every protocol era. It logs an ERROR naming 
the tool; the route keeps running and
+the other tools are still served. Previously, a tool whose route started 
before the MCP server failed the
+CamelContext startup, and a tool added later was left out with a generic WARN 
from the tool registry, except in the
+`modern` protocol era, which served it without any check. The stdio transport 
checks the input schema only, because
+it does not publish output schemas.
+
 === camel-docling - the CamelDoclingOutputFilePath header is a relative path 
unless outputBaseDirectory is set
 
 When the `outputBaseDirectory` option is not set, the 
`CamelDoclingOutputFilePath` header must now be a relative

Reply via email to