Interface McpSessionContext
Immutable key/value bag associated with an MCP session.
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionasMap()Provides an immutable snapshot of all stored session values.Checks whether a session value is present for the given key.static @NonNull McpSessionContextCreates an empty session context.static @NonNull McpSessionContextCreates a session context from the provided values.Retrieves a stored session value without type conversion.Retrieves a stored session value with an assignability check.Returns a new session context containing the given key/value pair.Returns a new session context without the given key.
-
Method Details
-
get
-
get
Retrieves a stored session value with an assignability check.- Type Parameters:
T- the desired type- Parameters:
key- the session keytype- the desired type- Returns:
- the stored value cast to
type, if present - Throws:
IllegalArgumentException- if the stored value exists but is not assignable totype
-
contains
-
with
-
without
Returns a new session context without the given key.- Parameters:
key- the session key to remove- Returns:
- a new session context without the key, or this instance if the key was absent
-
asMap
-
fromBlankSlate
Creates an empty session context.- Returns:
- a blank session context
-
fromValues
Creates a session context from the provided values.- Parameters:
values- the values to seed into the new session context- Returns:
- a new immutable session context containing
values
-