Skip to main content

Vercel Sandbox commands now support stdin

By Steven Van ·

Vercel Sandbox's TypeScript and Python SDKs can now write to a running command's stdin, including from a Node.js stream.

Commands running in Vercel Sandbox can now receive input through standard input (stdin) while they run. Vercel lists two uses: exchanging messages with stdio MCP servers such as agent-browser, and sending data to other command-line programs mid-run.

TypeScript SDK

In the TypeScript SDK, set stdin: true and detached: true in runCommand(). Call writeStdin() to send input and closeStdin() when finished. Strings are encoded as UTF-8, and Uint8Array data is also accepted. Writes reach the process in the order they are made, and each resolves once the process has accepted the data.

Closing stdin signals end of input once the process has consumed everything written, which matters for commands such as cat or sort that wait for it. Both methods take an optional abortSignal.

stdin can also be set to a Node.js readable stream, such as process.stdin. The SDK forwards the stream's data and closes the command's stdin when the stream ends.

Python SDK

In the Python SDK, set stdin=subprocess.PIPE and send input with server.stdin.send(). Calling communicate() closes stdin, collects the remaining output and waits for the process to exit. For commands that receive all their input at once, input can be passed directly to run_process().

Limits and failures

  • The process reads from a pipe, not a terminal.
  • A write fails after 30 seconds if the process isn't reading stdin.
  • If a write fails, part of it may have reached the process, and later writes to that command are rejected. closeStdin() and kill() still work.
  • Write to a command from one place at a time.
  • On a finished command, writeStdin() and closeStdin() always reject, because the process has exited.

The change is part of Vercel Sandbox, and the details are in the SDK reference.

Vercel
Vercel
The platform for frontend developers — deploy, preview, and scale web apps and AI agents with zero config.
View Vercel →

Original source

Read Vercel Sandbox commands now support stdin on Creators Toolbox