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 TypeMethodDescriptionio.modelcontextprotocol.modern.McpSchema.ClientCapabilitiesThe client capabilities declared for this request.@Nullable io.modelcontextprotocol.modern.McpSchema.ImplementationThe client info declared for this request, if any.io.modelcontextprotocol.modern.server.McpRequestContextcontext()The SDK request context.<T> @Nullable TinputResponse(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.booleanisRetry()Whether this call is a retry carrying input responses or request state.@Nullable ObjectThe progress token, ornullif the client did not request progress.The protocol version the client declared for this request.The request_metamap.@Nullable StringThe request state the server attached to its input-required result, if any.io.modelcontextprotocol.common.McpTransportContextThe 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
The request_metamap. -
transportContext
io.modelcontextprotocol.common.McpTransportContext transportContext()The transport context (headers, connection info, ...). -
progressToken
@Nullable Object progressToken()The progress token, ornullif the client did not request progress. -
isRetry
boolean isRetry()Whether this call is a retry carrying input responses or request state. -
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
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 resulttype- the type to convert the response to- Returns:
- the response, or
nullif the client did not answer this request
-