What is MCPServerStdio?
MCPServerStdio launches your MCP server as a child process and speaks the MCP framing protocol over stdin and stdout. That mirrors how most upstream MCP samples are written, so it is the fastest way to iterate locally: no TLS, no port collisions, and your debugger attaches to the same machine as the crew.
Because everything rides on pipes, stdout must stay pristine for protocol bytes — redirect server logs to stderr or a file. Container images need the interpreter and any native deps bundled next to the command you invoke; missing shared libraries manifest as instant child crashes that look like flaky tool mounts.
Stdio does not cross network boundaries well. Once a server runs remotely or behind a corporate ingress, switch to MCPServerHTTP or MCPServerSSE and keep stdio for developer laptops and sidecar deployments.
When to Use
Local MCP servers shipped with your code.
Use Cases
- • Local dev
- • Bundled MCP servers
- • Sidecar MCP next to the crew process
- • CI tests without exposing TCP ports
Key Features
- ✓ Subprocess launch
- ✓ Stdio transport
- ✓ Fast inner-loop debugging
When NOT to Use
Hosted MCP servers — use SSE or HTTP.
Notes
Stdout discipline
Any print() to stdout corrupts framing. Configure logging to stderr or structured log files before blaming CrewAI for disconnects.
Lifecycle and zombies
Killing the parent Python process should tear down the child. If you wrap servers in shell scripts, ensure signals propagate or you will leak orphaned MCP daemons during hot reloads.
Working directory surprises
Relative paths in args resolve from the crew's cwd. Pin absolute paths in CI and document expected roots for teammates.
Import
from crewai.mcp import MCPServerStdio
Key Parameters
| Parameter | Type | Default | Purpose |
|---|---|---|---|
| command | str | — | Executable to launch. |
| args | list[str] | [] | Command arguments. |
| env | dict | None | None | Environment variables. |
Code Examples
Launch with uv
from crewai.mcp import MCPServerStdio
server = MCPServerStdio(
command='uv',
args=['run', 'python', '-m', 'my_mcp_server'],
env={'LOG_LEVEL': 'warning'},
)
Node-based MCP binary
server = MCPServerStdio(command='npx', args=['-y', '@modelcontextprotocol/server-filesystem', '/tmp/safe-root'])
Wire toward MCPServerAdapter
from crewai_tools import MCPServerAdapter
adapter = MCPServerAdapter(server=MCPServerStdio(command='uv', args=['run', 'mcp']))
tools = adapter.tools
Common Mistakes
❌ Forgetting to install the server binary
✅ Document install steps.
MCPServerStdio FAQ
What is MCPServerStdio in CrewAI?
Connect to a local MCP server launched as a subprocess via stdio transport. MCPServerStdio launches your MCP server as a child process and speaks the MCP framing protocol over stdin and stdout. That mirrors how most upstream MCP samples are written, so it is the fastest way to iterate locally: no TLS, no port collisions, and your debugger attaches to the same machine as the crew. Because everything rides on pipes, stdout must stay pristine for protocol bytes — redirect server logs to stderr or a file. Container images need the interpreter and any na…
Which package defines the CrewAI class MCPServerStdio?
DevShelfHub maps MCPServerStdio to Python module crewai.mcp (package path crewai.mcp in this reference). Pin your installed crewai version and match imports to the snippet on this page.
When should I use MCPServerStdio?
Local MCP servers shipped with your code.
When should I avoid using MCPServerStdio?
Hosted MCP servers — use SSE or HTTP.
How do I import MCPServerStdio in Python?
from crewai.mcp import MCPServerStdio
Where can I explore more CrewAI API reference pages?
Open the CrewAI API reference index on DevShelfHub to search 58 classes, 30 methods, and 16 decorators, each with runnable examples, parameters, common mistakes, and cross-links.