pub struct StdioTransport { /* private fields */ }Expand description
MCP stdio transport proxy.
Spawns the upstream MCP server as a child process and proxies MCP messages between the client (our stdin/stdout) and the server (child process stdin/stdout), applying policy evaluation on tool calls.
Implementations§
Source§impl StdioTransport
impl StdioTransport
Sourcepub fn new(
engine: Engine,
audit: AuditLogger,
command: String,
args: Vec<String>,
fail_open: bool,
) -> Self
pub fn new( engine: Engine, audit: AuditLogger, command: String, args: Vec<String>, fail_open: bool, ) -> Self
Creates a new stdio transport proxy.
Creates a new stdio transport proxy with a shared engine reference.
Use this when hot-reload is enabled — the caller retains a clone
of the Arc<RwLock<Engine>> and can swap the engine atomically
while the proxy is running.
Sourcepub fn with_approval_backend(self, backend: Arc<dyn ApprovalBackend>) -> Self
pub fn with_approval_backend(self, backend: Arc<dyn ApprovalBackend>) -> Self
Sets the approval backend for handling RequireApproval decisions.
Sourcepub fn engine(&self) -> &Arc<RwLock<Engine>>
pub fn engine(&self) -> &Arc<RwLock<Engine>>
Returns a reference to the shared engine (for hot-reload wiring).
Sourcepub async fn run(&self) -> Result<(), Box<dyn Error>>
pub async fn run(&self) -> Result<(), Box<dyn Error>>
Runs the stdio proxy with graceful shutdown.
Spawns the upstream MCP server as a child process, then proxies all MCP messages through the policy engine. This function blocks until the client disconnects (stdin EOF), the child process exits, or a shutdown signal (SIGTERM/SIGINT) is received.
On shutdown signal:
- Active proxy loop is allowed to drain (up to 30s by default)
- Audit log is flushed
- Upstream child process is terminated cleanly