|
Entropic 2.3.8
Local-first agentic inference engine
|
Stdio transport: fork/exec child, pipe stdin/stdout. More...
#include <entropic/mcp/transport_stdio.h>


Public Member Functions | |
| StdioTransport (std::string command, std::vector< std::string > args, std::map< std::string, std::string > env={}, uint32_t default_timeout_ms=30000) | |
| Construct with command, arguments, and environment. | |
| StdioTransport (std::string display_name, std::string command, std::vector< std::string > args, std::map< std::string, std::string > env, uint32_t default_timeout_ms) | |
| Construct with a display name for stderr labeling (gh#19). | |
| ~StdioTransport () override | |
| Destructor — ensures child is cleaned up. | |
| bool | open () override |
| Spawn child process and open pipes. | |
| void | close () override |
| Send SIGTERM, reap child, close pipes. | |
| std::string | send_request (const std::string &request_json, uint32_t timeout_ms=0) override |
| Send JSON-RPC request via stdin, read response from stdout. | |
| bool | is_connected () const override |
| Check if child process is alive. | |
| void | interrupt () override |
| Abort any blocking read and mark transport uncancellable. | |
| const std::string & | display_name () const |
| Get the sanitized display name used for stderr labeling. | |
Stdio transport: fork/exec child, pipe stdin/stdout.
JSON-RPC 2.0 over newline-delimited JSON. Child process lifetime tied to transport lifetime (SIGTERM on close, SIGKILL if needed).
Definition at line 37 of file transport_stdio.h.
| entropic::StdioTransport::StdioTransport | ( | std::string | command, |
| std::vector< std::string > | args, | ||
| std::map< std::string, std::string > | env = {}, |
||
| uint32_t | default_timeout_ms = 30000 |
||
| ) |
Construct with command, arguments, and environment.
| command | Executable to spawn. |
| args | Command-line arguments. |
| env | Environment variable overrides (merged with parent). |
| default_timeout_ms | Default timeout for send_request (0 = 30s). |
| command | Executable to spawn. |
| args | Command-line arguments. |
| env | Environment variable overrides. |
| default_timeout_ms | Default request timeout. |
Definition at line 82 of file transport_stdio.cpp.
| entropic::StdioTransport::StdioTransport | ( | std::string | display_name, |
| std::string | command, | ||
| std::vector< std::string > | args, | ||
| std::map< std::string, std::string > | env, | ||
| uint32_t | default_timeout_ms | ||
| ) |
Construct with a display name for stderr labeling (gh#19).
Construct with explicit display name (gh#19, v2.1.5).
The display name is used as the bracketed label on every child stderr line, replacing the v2.1.4 behavior of using the resolved spawn command (argv[0]). When multiple servers spawn via the same entrypoint (e.g. /usr/bin/env python), the command-based label collides and consumers cannot tell servers apart. The display name (typically the registered server name) is unique per registration and free of leading slashes, which also avoids Rich BBCode parsing collisions on consumers that pipe stderr through rich.console.print.
| display_name | Bracketed label used for stderr lines and lifecycle log messages. Should be the server name passed to entropic_register_mcp_server. |
| command | Executable to spawn. |
| args | Command-line arguments. |
| env | Environment variable overrides. |
| default_timeout_ms | Default timeout for send_request. |
Use this overload when registering an MCP server so stderr lines carry the registered server name instead of the resolved spawn command.
| display_name | Bracketed label for stderr/lifecycle logs. |
| command | Executable to spawn. |
| args | Command-line arguments. |
| env | Environment variable overrides. |
| default_timeout_ms | Default request timeout. |
Definition at line 108 of file transport_stdio.cpp.
|
override |
Destructor — ensures child is cleaned up.
Definition at line 126 of file transport_stdio.cpp.
|
overridevirtual |
Send SIGTERM, reap child, close pipes.
Implements entropic::Transport.
Definition at line 210 of file transport_stdio.cpp.
|
inline |
Get the sanitized display name used for stderr labeling.
Exposed for unit tests (gh#19) and consumer diagnostics. The value is the bracketed label that appears in log lines from the stderr pump and lifecycle events. Sanitization (leading / stripped, bracket / control chars removed) is applied at construction.
Definition at line 141 of file transport_stdio.h.
|
overridevirtual |
Abort any blocking read and mark transport uncancellable.
Cancel any in-flight read by tripping cancel_flag_.
Sets cancel_flag_ which poll_until_ready() checks after every poll tick. The next send_request() returns empty immediately. (P1-10, 2.0.6-rc16)
read_line / poll_until_ready short-circuit the next poll tick so the pending send_request returns empty within ~50ms (one poll slice). Subsequent send_request calls also early-exit until the flag is cleared implicitly by a successful open(). (P1-10)
Reimplemented from entropic::Transport.
Definition at line 285 of file transport_stdio.cpp.
|
overridevirtual |
Check if child process is alive.
Check if child process is alive via kill(pid, 0).
Implements entropic::Transport.
Definition at line 264 of file transport_stdio.cpp.
|
overridevirtual |
Spawn child process and open pipes.
Implements entropic::Transport.
Definition at line 154 of file transport_stdio.cpp.
|
overridevirtual |
Send JSON-RPC request via stdin, read response from stdout.
| request_json | JSON-RPC request string. |
| timeout_ms | Timeout in milliseconds (0 = default). |
| request_json | JSON-RPC request string. |
| timeout_ms | Timeout (0 = default). |
Implements entropic::Transport.
Definition at line 233 of file transport_stdio.cpp.