Interface McpModernRequestContext

All Known Subinterfaces:
McpModernSyncRequestContext
All Known Implementing Classes:
DefaultMcpModernSyncRequestContext

public interface McpModernRequestContext
The request context injected into annotated methods served by a 2026-07-28 ("modern") MCP server. The modern protocol is stateless: there is no session and no in-call elicitation, sampling, roots or logging. Instead, server-initiated input is requested with an InputRequiredResult and arrives on the retried call through inputResponses().

Nothing in this context blocks, so the same interface serves the synchronous and the asynchronous programming model; McpModernSyncRequestContext is its synchronous alias. This parameter does not change the shape of the response: a method that declares it alone answers with a plain result. To push progress notifications before the result, declare the SDK McpSyncNotifier (sync) or McpAsyncNotifier (async) as well; that parameter, and only that one, makes the method a streaming response.

Since:
2.1.0
Author:
Christian Tzolov
  • Method Summary

    Modifier and Type
    Method
    Description
    io.modelcontextprotocol.modern.McpSchema.ClientCapabilities
    The client capabilities declared for this request.
    @Nullable io.modelcontextprotocol.modern.McpSchema.Implementation
    The client info declared for this request, if any.
    io.modelcontextprotocol.modern.server.McpRequestContext
    The SDK request context.
    <T> @Nullable T
    inputResponse(String key, Class<T> type)
    The client's response for one input request, converted to the given type.
    The raw input responses of a retried call, keyed as the server requested them.
    boolean
    Whether this call is a retry carrying input responses or request state.
    @Nullable Object
    The progress token, or null if the client did not request progress.
    The protocol version the client declared for this request.
    The request _meta map.
    @Nullable String
    The request state the server attached to its input-required result, if any.
    io.modelcontextprotocol.common.McpTransportContext
    The transport context (headers, connection info, ...).
  • Method Details

    • context

      io.modelcontextprotocol.modern.server.McpRequestContext context()
      The SDK request context.
    • protocolVersion

      String protocolVersion()
      The protocol version the client declared for this request.
    • clientCapabilities

      io.modelcontextprotocol.modern.McpSchema.ClientCapabilities clientCapabilities()
      The client capabilities declared for this request.
    • clientInfo

      @Nullable io.modelcontextprotocol.modern.McpSchema.Implementation clientInfo()
      The client info declared for this request, if any.
    • requestMeta

      Map<String,Object> requestMeta()
      The request _meta map.
    • transportContext

      io.modelcontextprotocol.common.McpTransportContext transportContext()
      The transport context (headers, connection info, ...).
    • progressToken

      @Nullable Object progressToken()
      The progress token, or null if the client did not request progress.
    • isRetry

      boolean isRetry()
      Whether this call is a retry carrying input responses or request state.
    • inputResponses

      Map<String,Object> inputResponses()
      The raw input responses of a retried call, keyed as the server requested them.
    • requestState

      @Nullable String requestState()
      The request state the server attached to its input-required result, if any.
    • inputResponse

      <T> @Nullable T inputResponse(String key, Class<T> type)
      The client's response for one input request, converted to the given type.
      Type Parameters:
      T - the response type
      Parameters:
      key - the server-assigned key used in the input-required result
      type - the type to convert the response to
      Returns:
      the response, or null if the client did not answer this request