What is stdio in MCP? Local server connections
By Flavio
Stdio connects an MCP client to a server process through standard input and output. Learn when to use it, how coding tools configure it, and common mistakes.
stdio is an MCP transport that carries messages through a server process’s standard input and output. The client starts that process and communicates with it through those streams.
Read What is MCP? for the tested filesystem-server walkthrough. Build an MCP server shows how to write the server itself.
How stdio works
The stdio specification uses newline-delimited JSON-RPC messages. The client writes to the server’s stdin and reads from its stdout. Diagnostic messages go to stderr.
The transport needs no listening HTTP port. The process still has the filesystem and network access allowed by its environment.
In coding tools
Claude Code accepts a server command after -- in claude mcp add. Codex uses command and optional args in its MCP configuration.
Cursor lists stdio as a client-managed local process. Grok Build also accepts a command after -- in grok mcp add.
Details checked against each vendor’s documentation in November 2026.
A concrete example
The MCP walkthrough connects a filesystem server restricted to /tmp/mcp-practice. Its Claude Code configuration includes:
{
"mcpServers": {
"practice-files": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/[email protected]",
"/tmp/mcp-practice"
]
}
}
}
Create the practice directory first and follow the tutorial’s setup and approval steps. The directory restriction belongs to that filesystem server.
When to use stdio
Use it for a server the client can launch in its own environment. It’s useful for local files and command-line integrations. Use Streamable HTTP when you need to connect to an independently running endpoint.
Pitfalls
Printing a banner or debug text to stdout corrupts the protocol stream. Send logs to stderr.
A local server executes code with the access you give it. Inspect the package and its configuration before starting it. A folder argument only restricts access when the server implements that restriction.
For an app built around an MCP workflow, see Cloudflare Domains Toolkit and its explicit purchase approval tutorial. Transport choice and approval checks solve different parts of the workflow.
Related glossary entries
- Streamable HTTP (MCP transport): Streamable HTTP connects MCP clients to a server endpoint using HTTP requests. Learn how coding tools use it, when it helps, and how it differs from stdio.
- Tool calling: Tool calling is when a model names a function and its arguments, and the app runs it. How Claude Code, Codex, Cursor and Grok Build take that step.
- Sandbox: An agent sandbox limits which files and hosts a coding agent's commands can reach. How the boundary works in Claude Code, Codex, Cursor and Grok Build.
Want me to talk about your product? You can sponsor this site.