Interface ChannelContext

All Superinterfaces:
InteractionContext
All Known Subinterfaces:
DispatchContext
All Known Implementing Classes:
DefaultChannelContext, DefaultDispatchContext, NoopInteractionContext

@InternalApi public interface ChannelContext extends InteractionContext
Context for an MCP channel, providing access to the protocol, session, and lifecycle.
  • Method Details

    • protocol

      Protocol protocol()
      Returns the MCP protocol version negotiated for this channel.
      Returns:
      the protocol
    • protocolVersion

      default String protocolVersion()
      Description copied from interface: InteractionContext
      Returns the protocol version negotiated during initialisation.
      Specified by:
      protocolVersion in interface InteractionContext
      Returns:
      the negotiated protocol version
    • session

      @Nullable Session session()
      Returns the current session, or null if not yet established.
      Returns:
      the session, or null
    • sessionId

      default @Nullable String sessionId()
      Description copied from interface: InteractionContext
      Returns the session identifier, or null in stateless mode.
      Specified by:
      sessionId in interface InteractionContext
      Returns:
      the session ID, or null
    • setLifecycle

      void setLifecycle(InteractionContext.Lifecycle lifecycle)
      Sets the lifecycle state for this channel.
      Parameters:
      lifecycle - the new lifecycle state
    • setSession

      void setSession(@Nullable Session session)
      Sets the session for this channel.
      Parameters:
      session - the session, or null to clear
    • enableExtension

      void enableExtension(String extensionId)
      Enables an extension for this channel.
      Parameters:
      extensionId - the extension identifier