Table of Contents

TTMSMCPSessionState Class

Per-connection state held by the server for one client session: the negotiated protocol version, the extensions the client declared, the resource and prompt collections scoped to that client, its resource subscriptions, and arbitrary application values stored against it.

API unit family: TMS.MCP.Server

Syntax

TTMSMCPSessionState = class

Remarks

Sessions exist only on session-aware transports such as streamable HTTP. Single-connection transports such as standard input/output or a named pipe have no session identifier, so no session state is created for them. Instances are created and destroyed by the server; do not construct or free one directly.

Properties

Name Description
Prompts Prompt collection scoped to this session, for prompts that exist only for this client rather than for the whole server.
ProtocolVersion Protocol version negotiated with this client, for example 2025-06-18. It is refreshed each time the client re-initializes and governs which capabilities apply to requests on this session.
Resources Resource collection scoped to this session, for resources that exist only for this client rather than for the whole server.
SessionId Transport-assigned identifier of this session, fixed at creation.
Subscriptions URIs this client subscribed to through resources/subscribe. The list is sorted and ignores duplicates, and it is what SendResourceUpdatedForSession tests before sending an update.

Methods

Name Description
ClientSupports Indicates whether the client declared support for an extension. Returns True only when the identifier is not empty and was present in the declared extension set.
RemoveUserData Detaches the interface reference stored under an identifier, releasing the session's reference to it.
RemoveValue Discards the string value stored under a key. Nothing happens when the key is absent.
SetClientExtensions Replaces the recorded set of extensions the client declared during initialization. Only pairs whose value is an object are kept, and each is stored as an independent copy.
SetUserData Attaches a reference-counted object to this session under a caller-chosen identifier, replacing any earlier entry for the same identifier. Use it to keep per-client application state alive for the lifetime of the session.
SetValue Stores a string value against this session, replacing any earlier value for the same key.
TryGetUserData Retrieves an interface reference previously attached to this session.
TryGetValue Reads a string value previously stored against this session.

Used by