> ## Documentation Index
> Fetch the complete documentation index at: https://toolgrain.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Stdio transport

> Serve local clients through newline-delimited JSON on stdin and stdout.

Use `stdio()` from `@toolgrain/node` when a client launches your server as a local process. The adapter handles framing and lifecycle; MCP method handling stays in `@toolgrain/mcp`.

```ts theme={null}
import { stdio } from "@toolgrain/node";
await server.listen(stdio({ maxMessageBytes: 1024 * 1024 }));
```

## Framing and limits

Messages are newline-delimited UTF-8 JSON. The default incoming-message limit is 1 MiB, excluding the newline. Malformed JSON or UTF-8 reports a parse error and permits later messages. Oversized frames terminate the transport. Outgoing writes respect writable backpressure and preserve ordering.

`input` and `output` may be supplied as Node streams; they default to `process.stdin` and `process.stdout`. A transport instance is single-use. A server accepts one transport, and close is terminal.

## Shutdown

EOF is the normal stdio shutdown signal. Closing detaches listeners and pauses input without destroying or ending supplied streams or calling `process.exit()`. Active request signals abort on connection close. A handler that ignores its signal may continue running, but its response is discarded.

Auth-configured servers reject message transports before startup. Use HTTP when configuring endpoint authorization.

## Operational guidance

Keep all logs off stdout. Use absolute compiled entry-point paths in client configuration. Reconnect after rebuilding so the client launches a fresh process. Separate build output from protocol stdout. See [client setup](https://toolgrain.mintlify.site/getting-started/clients.md) and the [Node API](https://toolgrain.mintlify.site/reference/node.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.