TTMSMCPClientTransportSTDIO Class
Client transport that launches a server as a child process and exchanges protocol messages with it over that process' standard input and output streams.
API unit family: TMS.MCP.Client.Transport.STDIO
Inherits from: TTMSMCPClientTransport
Syntax
TTMSMCPClientTransportSTDIO = class(TTMSMCPClientTransport)
Remarks
Configure Command, and optionally Args and Env, then call Start to launch the process. Each message is written as one line to the child's standard input, and every line the child writes back is reported through OnMessage. Standard output is therefore protocol traffic in both directions: a server that prints diagnostics on it corrupts the stream. The child's error stream is merged into the same pipe, so anything written there is parsed as protocol traffic as well, and a server must keep its logging off both streams. Reading runs on a background worker, so OnMessage is raised on that worker and not on the thread that started the transport. Applications normally do not create this class directly, because the client component selects and configures a transport from the transport type recorded on the server entry; create one explicitly only when driving the protocol by hand. Launching a child process is supported on desktop platforms only. Where it is not, the instance can still be created but never runs: Start does nothing and IsRunning stays False.
Properties
| Name | Description |
|---|---|
| Args | Arguments passed to the server process, one per line. |
| Command | Program that is launched as the server process. |
| Env | Environment variables made available to the server process, as Name=Value lines. |
Methods
| Name | Description |
|---|---|
| IsRunning | Reports whether the child process is still alive. |
| Send | Writes one JSON-RPC message, given only its payload, to the child process' standard input. This is the overload to call in the ordinary case, where the serialized message is all the caller has. |
| Start | Launches the configured server process and begins reading its output. |
| Stop | Ends the child process, stops the reader worker and closes both pipes. |