Package dev.tachyonmcp.core.runtime
Class DefaultChannelContext
java.lang.Object
dev.tachyonmcp.core.runtime.DefaultChannelContext
- All Implemented Interfaces:
InteractionContext,ChannelContext
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.tachyonmcp.api.runtime.InteractionContext
InteractionContext.Lifecycle -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclient()Returns typed access to the client-facing elicitation and sampling services.voidenableExtension(String extensionId) Enables an extension for this channel.<T> Optional<T> get(AttributeKey<T> key) Returns the value stored underkey, or empty if never set.booleanisExtensionEnabled(String extensionId) Returnstrueif the given extension is active for this interaction.Returns the current lifecycle phase, ornullbefore initialisation.Returns the notification sender bound to this interaction.protocol()Returns the MCP protocol version negotiated for this channel.sendRequest(String method, Object params) Sends a request to the client and returns a future that completes with the raw JSON response.@Nullable Sessionsession()Returns the current session, ornullif not yet established.<T> voidset(AttributeKey<T> key, T value) Storesvalueunderkey, visible to laterInteractionContext.get(AttributeKey)calls — seeInteractionContext.get(AttributeKey)for scope and thread-safety.voidsetLifecycle(InteractionContext.Lifecycle lifecycle) Sets the lifecycle state for this channel.voidsetSession(@Nullable Session session) Sets the session for this channel.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.tachyonmcp.core.runtime.ChannelContext
protocolVersion, sessionId
-
Constructor Details
-
DefaultChannelContext
-
-
Method Details
-
protocol
Description copied from interface:ChannelContextReturns the MCP protocol version negotiated for this channel.- Specified by:
protocolin interfaceChannelContext- Returns:
- the protocol
-
lifecycle
Description copied from interface:InteractionContextReturns the current lifecycle phase, ornullbefore initialisation.- Specified by:
lifecyclein interfaceInteractionContext- Returns:
- the lifecycle phase, or
null
-
setLifecycle
Description copied from interface:ChannelContextSets the lifecycle state for this channel.- Specified by:
setLifecyclein interfaceChannelContext- Parameters:
lifecycle- the new lifecycle state
-
session
Description copied from interface:ChannelContextReturns the current session, ornullif not yet established.- Specified by:
sessionin interfaceChannelContext- Returns:
- the session, or
null
-
setSession
Description copied from interface:ChannelContextSets the session for this channel.- Specified by:
setSessionin interfaceChannelContext- Parameters:
session- the session, ornullto clear
-
enableExtension
Description copied from interface:ChannelContextEnables an extension for this channel.- Specified by:
enableExtensionin interfaceChannelContext- Parameters:
extensionId- the extension identifier
-
isExtensionEnabled
Description copied from interface:InteractionContextReturnstrueif the given extension is active for this interaction.- Specified by:
isExtensionEnabledin interfaceInteractionContext- Parameters:
extensionId- the extension identifier- Returns:
trueif the extension is active
-
notifications
Description copied from interface:InteractionContextReturns the notification sender bound to this interaction.- Specified by:
notificationsin interfaceInteractionContext- Returns:
- the notification sender
-
sendRequest
Description copied from interface:InteractionContextSends a request to the client and returns a future that completes with the raw JSON response.Experimental escape hatch for client requests not covered by
InteractionContext.client(), such as URL-mode elicitation or sampling parameters beyond whatSamplingServicemodels.- Specified by:
sendRequestin interfaceInteractionContext- Parameters:
method- the request method nameparams- the request parameters- Returns:
- a future that completes with the raw JSON response
-
client
Description copied from interface:InteractionContextReturns typed access to the client-facing elicitation and sampling services.Prefer this over
InteractionContext.sendRequest(String, Object)for sampling/elicitation round-trips — it returns domain results instead of raw JSON.- Specified by:
clientin interfaceInteractionContext- Returns:
- the client context
-
get
Description copied from interface:InteractionContextReturns the value stored underkey, or empty if never set.Scoped to the underlying channel/session, not the current request — a value set on one request is visible to later requests on the same connection. Backed by a concurrent map: safe to call from multiple handler threads without external synchronization.
- Specified by:
getin interfaceInteractionContext- Type Parameters:
T- the type of value- Parameters:
key- the attribute key- Returns:
- the value, or empty if not set
-
set
Description copied from interface:InteractionContextStoresvalueunderkey, visible to laterInteractionContext.get(AttributeKey)calls — seeInteractionContext.get(AttributeKey)for scope and thread-safety.- Specified by:
setin interfaceInteractionContext- Type Parameters:
T- the type of value- Parameters:
key- the attribute keyvalue- the value to store
-