Connect a Local MCP Server to an OpenAI Agent
Use MCPServerStdio when the agent runtime should launch a local MCP subprocess.
Typical use cases
- Filesystem tools scoped to a workspace.
- Local Git operations.
- Developer utilities not exposed over the network.
Security
The subprocess inherits whatever environment and OS access you give it. Pass only necessary directories and credentials. Avoid launching untrusted MCP packages with broad filesystem access.
Tool filtering
If the server exposes many capabilities, allowlist only the tools the agent needs. Local MCP classes in the Agents SDK support static and dynamic filters.