TTMSMCPServer Class
Ready-to-use Model Context Protocol server component. It adds no behavior of its own to
TTMSMCPCustomServerand only publishes the inherited settings and events so the server can be dropped on a form or data module and configured at design time.
API unit family: TMS.MCP.Server
Inherits from: TTMSMCPCustomServer
Syntax
TTMSMCPServer = class(TTMSMCPCustomServer)
Properties
| Name | Description |
|---|---|
| CurrentLogLevel | Minimum severity the connected client asked to receive. It is updated whenever a client issues a logging/setLevel request, and reading it lets a server skip building log records the client would discard. (inherited from TTMSMCPCustomServer) |
| DefaultPageSize | Number of entries returned per page by the list requests for tools, resources and prompts. (inherited from TTMSMCPCustomServer) |
| DefaultTaskPollInterval | Interval in milliseconds that new tasks report as the suggested delay between client status polls. A client may override it per request. (inherited from TTMSMCPCustomServer) |
| EnableCompletions | When True, the completion capability is advertised during initialization, so clients may ask for argument suggestions through completion/complete. Pair it with OnCompletion, without which the server answers every request with an empty candidate list. (inherited from TTMSMCPCustomServer) |
| EnableElicitation | When True, the elicitation capability is advertised during initialization, RequestElicitation is allowed to run, and inbound elicitation/create requests are accepted. When False, RequestElicitation raises an exception and inbound requests are rejected. (inherited from TTMSMCPCustomServer) |
| EnableLogging | When True, the logging capability is advertised during initialization, so clients may select a severity through logging/setLevel and expect log notifications. (inherited from TTMSMCPCustomServer) |
| EnablePromptNotifications | When True, a change to the prompt collection broadcasts a notifications/prompts/list_changed message so connected clients know to re-read the list. When False, changes are silent. (inherited from TTMSMCPCustomServer) |
| EnableResourceNotifications | When True, a change to the resource collection broadcasts a notifications/resources/list_changed message so connected clients know to re-read the list. When False, changes are silent. (inherited from TTMSMCPCustomServer) |
| EnableResourceSubscriptions | When True, the resource-subscription capability is advertised during initialization, so clients may watch individual resources through resources/subscribe and receive update notifications for them. (inherited from TTMSMCPCustomServer) |
| EnableSampling | When True, the sampling capability is advertised during initialization and RequestSampling is allowed to run. When False, RequestSampling raises an exception. (inherited from TTMSMCPCustomServer) |
| EnableTasks | When True, the task capability is advertised during initialization and a client may ask for a call to be executed asynchronously, receiving a task handle instead of a result. (inherited from TTMSMCPCustomServer) |
| EnableToolNotifications | When True, a change to the tool collection broadcasts a notifications/tools/list_changed message so connected clients know to re-read the list. When False, changes are silent. (inherited from TTMSMCPCustomServer) |
| Instructions | Free-form guidance reported to clients during initialization, describing how the exposed tools, resources and prompts are meant to be used. (inherited from TTMSMCPCustomServer) |
| Prompts | Prompt templates this server exposes, reported by prompts/list and expanded through prompts/get. (inherited from TTMSMCPCustomServer) |
| ProtocolVersion | Protocol version this server offers to clients, for example 2025-06-18. It is the version reported when a client asks for one the server cannot serve, and the fallback for transports that have no sessions. (inherited from TTMSMCPCustomServer) |
| ProtocolVersionEnum | The same setting as ProtocolVersion expressed as an enumerated value, for code that prefers a compile-time-checked constant over a version string. (inherited from TTMSMCPCustomServer) |
| Resources | Resources this server exposes, reported by resources/list and read through resources/read. (inherited from TTMSMCPCustomServer) |
| ServerDescription | Free-form description of this server, reported to clients during initialization alongside the name and version. (inherited from TTMSMCPCustomServer) |
| ServerIconsJSON | Icon declaration reported to clients during initialization, supplied as a raw JSON array of icon objects. Leave empty to declare no icons. (inherited from TTMSMCPCustomServer) |
| ServerName | Name this server reports to clients during initialization, used to identify it in client user interfaces. (inherited from TTMSMCPCustomServer) |
| ServerVersion | Version string this server reports to clients during initialization. It describes the hosted server application, not the component library. (inherited from TTMSMCPCustomServer) |
| TaskRegistry | Registry holding every task this server created, with their status, result and expiry. It backs the task-related protocol methods and is owned by the server. (inherited from TTMSMCPCustomServer) |
| TaskResultTimeoutMs | Time in milliseconds a tasks/result request waits for a task that is still running before it gives up. (inherited from TTMSMCPCustomServer) |
| Tools | Tools this server exposes. Each entry maps a callable name and argument schema onto a method, and the collection is what tools/list reports and tools/call resolves against. (inherited from TTMSMCPCustomServer) |
| Transport | Transport that carries messages to and from clients, for example standard input/output or streamable HTTP. Assigning one wires the server's request, session and protocol-version callbacks into it. (inherited from TTMSMCPCustomServer) |
Methods
| Name | Description |
|---|---|
| ActiveSessionIds | Returns the identifiers of the sessions the transport currently holds open. (inherited from TTMSMCPCustomServer) |
| BroadcastNotification | Sends a ready-made JSON-RPC notification to every connected session. Does nothing when no transport is assigned. (inherited from TTMSMCPCustomServer) |
| ClientSupportsExtension | Indicates whether the client whose request is being handled on the calling thread declared support for an extension. Use it to offer extension behavior only to clients that understand it. (inherited from TTMSMCPCustomServer) |
| CreateBuilder | Starts a fluent configuration chain and returns the builder class to continue it on. Finish the chain with Build to obtain the configured server. (inherited from TTMSMCPCustomServer) |
| CurrentSessionId | Returns the identifier of the session whose request is being handled on the calling thread, which is how a tool implementation learns which client it is serving. (inherited from TTMSMCPCustomServer) |
| CurrentSessionState | Returns the state object of the session whose request is being handled on the calling thread. (inherited from TTMSMCPCustomServer) |
| EffectiveProtocolVersion | Returns the protocol version that governs the request currently being handled on the calling thread: the version carried by the request when one is present, otherwise the version negotiated for the current session, and finally the server-wide setting. (inherited from TTMSMCPCustomServer) |
| FlagToolCallError | Marks the tool call running on the calling thread as failed, so the response carries an error flag while still returning the content the tool produced. (inherited from TTMSMCPCustomServer) |
| GetSessionProtocolVersion | Returns the protocol version negotiated for a specific session, regardless of which request is currently being handled. (inherited from TTMSMCPCustomServer) |
| GetTask | Looks up a task by identifier. (inherited from TTMSMCPCustomServer) |
| IsExtensionRegistered | Indicates whether this server declares an extension. (inherited from TTMSMCPCustomServer) |
| IsInitializedForRequest | Indicates whether the request currently being handled may proceed, which is the case once a client has completed initialization or when the request itself carries the capability information that makes a prior handshake unnecessary. (inherited from TTMSMCPCustomServer) |
| ProcessRequest | Processes one inbound JSON-RPC message and returns the response text. This is the entry point a transport calls for every message it receives. (inherited from TTMSMCPCustomServer) |
| RegisterExtension | Declares a protocol extension this server supports, so it is advertised to clients during initialization. Registering the same identifier again replaces the earlier configuration. (inherited from TTMSMCPCustomServer) |
| RegisteredExtensions | Returns the identifiers of every extension this server declares. (inherited from TTMSMCPCustomServer) |
| RemoveSessionValue | Discards a string value stored against the session whose request is being handled on the calling thread. Does nothing outside a request or on a transport without sessions. (inherited from TTMSMCPCustomServer) |
| RequestElicitation | Asks the connected client to collect input from its user and blocks until the client answers. (inherited from TTMSMCPCustomServer) |
| RequestRootsList | Asks the connected client for the roots it exposes, typically the workspace folders the user has opened. (inherited from TTMSMCPCustomServer) |
| RequestSampling | Asks the connected client to run a model completion on the server's behalf and blocks until the client answers. (inherited from TTMSMCPCustomServer) |
| RequestTaskElicitation | Collects user input in the middle of a running task, tagging the request with the task so the client can relate the two. (inherited from TTMSMCPCustomServer) |
| Run | Runs the assigned transport's message loop, blocking the calling thread until the transport stops. This is the usual entry point for a console host. (inherited from TTMSMCPCustomServer) |
| SendLogMessage | Sends a log record to connected clients as a notifications/message notification. This is the log channel the client actually sees, as opposed to the local OnLog trace, which never leaves the process. (inherited from TTMSMCPCustomServer) |
| SendNotificationToSession | Sends a ready-made JSON-RPC notification to one session. Use it for notifications the server does not build itself. Does nothing when no transport is assigned. (inherited from TTMSMCPCustomServer) |
| SendProgressNotification | Broadcasts a progress update for a long-running operation the client is tracking through a progress token. (inherited from TTMSMCPCustomServer) |
| SendPromptsChangedNotification | Broadcasts a notifications/prompts/list_changed message to every connected client. (inherited from TTMSMCPCustomServer) |
| SendResourceUpdatedForSession | Sends a resource-updated notification to one session, but only when that session subscribed to the URI. A session that did not subscribe receives nothing. (inherited from TTMSMCPCustomServer) |
| SendResourceUpdatedNotification | Broadcasts a notifications/resources/updated message for one resource to every connected client, without testing subscriptions. (inherited from TTMSMCPCustomServer) |
| SendResourcesChangedNotification | Broadcasts a notifications/resources/list_changed message to every connected client. (inherited from TTMSMCPCustomServer) |
| SendToolsChangedNotification | Broadcasts a notifications/tools/list_changed message to every connected client. Call it after changing the tool collection from code that bypasses the collection's own change tracking. (inherited from TTMSMCPCustomServer) |
| SessionCount | Returns how many client sessions the transport currently holds open. (inherited from TTMSMCPCustomServer) |
| SetSessionValue | Stores a string value against the session whose request is being handled on the calling thread, so state can be carried between calls from the same client. (inherited from TTMSMCPCustomServer) |
| SetTaskError | Completes a task with a failure and notifies the client that owns it. (inherited from TTMSMCPCustomServer) |
| SetTaskResult | Completes a task successfully with the payload a later tasks/result request will return, and notifies the client that owns it. (inherited from TTMSMCPCustomServer) |
| Start | Starts serving: creates a standard input/output transport when none was assigned, then starts the transport so it begins accepting messages. (inherited from TTMSMCPCustomServer) |
| Stop | Stops the transport and with it the serving of requests. Safe to call when the server is not running or has no transport. (inherited from TTMSMCPCustomServer) |
| TryGetSessionValue | Reads a string value stored against the session whose request is being handled on the calling thread. (inherited from TTMSMCPCustomServer) |
| UnregisterExtension | Withdraws a previously declared extension so it is no longer advertised. Nothing happens when the identifier was not registered. (inherited from TTMSMCPCustomServer) |
| UpdateTaskStatus | Moves a task to a new status and notifies the client that owns it. Use it to report progress from long-running work. (inherited from TTMSMCPCustomServer) |
Events
| Name | Description |
|---|---|
| OnAfterExecute | Occurs after a tool method has returned, with both the native return value and the JSON form that will be sent back to the client. (inherited from TTMSMCPCustomServer) |
| OnBeforeExecute | Occurs immediately before a tool method runs, with the raw request arguments and the values resolved from them. Use it to trace or audit calls. (inherited from TTMSMCPCustomServer) |
| OnCompletion | Occurs when a client asks for argument auto-completion candidates for a prompt or resource template. (inherited from TTMSMCPCustomServer) |
| OnElicitationComplete | Occurs when a client reports that an out-of-band elicitation finished. The handler takes ownership of the content object passed to it. (inherited from TTMSMCPCustomServer) |
| OnElicitationRequest | Occurs when an elicitation/create request arrives at this server and user input must be collected. Without a handler the request is rejected with an error. (inherited from TTMSMCPCustomServer) |
| OnListPrompts | Occurs while a prompts/list request is answered, so the reported prompt collection can be adjusted for the calling client. (inherited from TTMSMCPCustomServer) |
| OnListResources | Occurs while a resources/list request is answered, so the reported resource collection can be adjusted for the calling client. (inherited from TTMSMCPCustomServer) |
| OnListTools | Occurs while a tools/list request is answered, so the reported tool collection can be adjusted for the calling client. (inherited from TTMSMCPCustomServer) |
| OnLog | Occurs when the server produces a local diagnostic trace entry, such as protocol negotiation, transport start and stop, or an inbound notification. (inherited from TTMSMCPCustomServer) |
| OnLogLevelChanged | Occurs after a client has changed the requested log severity through a logging/setLevel request. (inherited from TTMSMCPCustomServer) |
| OnRootsChanged | Occurs when a client reports that its exposed roots changed. Call RequestRootsList from the handler to retrieve the new list. (inherited from TTMSMCPCustomServer) |
| OnSamplingRequest | Occurs when a sampling/createMessage request arrives at this server and a model completion must be produced. Assign a result in the handler. (inherited from TTMSMCPCustomServer) |
| OnSessionCreated | Occurs when the transport opens a new client session. Raised only by session-aware transports. (inherited from TTMSMCPCustomServer) |
| OnSessionDestroyed | Occurs after a client session has been torn down and its session state discarded. Raised only by session-aware transports. (inherited from TTMSMCPCustomServer) |
| OnTaskCancel | Occurs when a client cancels a task, so work already in progress can be abandoned. (inherited from TTMSMCPCustomServer) |
| OnTaskCreate | Occurs immediately after a task has been created for an asynchronous request and before its execution starts. (inherited from TTMSMCPCustomServer) |
| OnTaskExecute | Occurs on a background thread to execute a task. Assigning a handler replaces the built-in tool runner, making the handler responsible for completing the task through SetTaskResult or SetTaskError. (inherited from TTMSMCPCustomServer) |