Docs menu
DocsAPI reference

Subprocesses

process.spawn — pipes without a PTY, for MCP stdio servers and line protocols.

terminal.spawn attaches a PTY — right for interactive CLIs, wrong for line-delimited protocols (a PTY's line discipline corrupts them). For MCP stdio servers and any pipe-based subprocess, use process. Capability: terminal (same per-prefix approval).

const session = await window.chatoss.process.spawn('npx', {
  args: ['-y', '@modelcontextprotocol/server-filesystem', '/path'],
  cwd: null,
  env: { EXTRA: '1' },
}); // null = user denied
// session.id
// await session.write(data)
// await session.kill()
// session.onData(cb)
// session.onStderr(cb)
// session.onExit(cb)

This is the substrate under the MCP client API's stdio transport — reach for it directly only when you're speaking some other line protocol.