Interface McpRequestContext


@DoNotInherit public interface McpRequestContext
Context information available during MCP endpoint request processing.

Provides access to request metadata including headers, authentication information, and tracing capabilities for MCP endpoint methods. This context is available during the processing of MCP tool calls, resource requests, and prompt requests.

Access Methods:

  • Extend AbstractMcpEndpoint and use requestContext()
  • Inject as constructor parameter into MCP endpoint classes

Authentication invalid input: '&' Authorization: Use getPrincipals() and getJwtClaims() to access authentication information for custom authorization logic. MCP endpoints support ACL annotations and JWT validation.

Custom Headers: Access request headers via requestHeader(String) for custom authentication schemes or client-specific metadata.

Not for user extension, implementation provided by the SDK.

  • Method Details

    • getPrincipals

      Principals getPrincipals()
      Get the principals associated with this request.
      Returns:
      The principals associated with this request.
    • getJwtClaims

      JwtClaims getJwtClaims()
      Returns:
      The JWT claims, if any, associated with this request.
    • tracing

      Tracing tracing()
      Access to tracing for custom app specific tracing.
    • requestHeader

      Optional<akka.http.javadsl.model.HttpHeader> requestHeader(String headerName)
      Returns:
      A header with the given name (case ignored) if present in the current request, Optional.empty() if not.
    • allRequestHeaders

      List<akka.http.javadsl.model.HttpHeader> allRequestHeaders()
      Returns:
      A list with all the headers of the current request