Run, Stream, and approval gates.
At NewAgent, the SDK connects to each server, discovers tools, applies any tool filter, and validates the setup — failing fast if a server is unreachable.
MCP tool names use the prefix
mcp_<serverKey>_<toolName> — for example, a server named "remote" with a search tool registers as mcp_remote_search. This prevents collisions when multiple servers expose tools with the same logical name.Register MCP servers
Two equivalent paths. Use one or combine both — server names must be unique across both.WithMCPConfig
Declare servers in a map — key is the stable server name:WithMCPClients
Build clients withpkg/mcp/client for custom transport or pre-connected clients:
Transports
Stdio prerequisite: the MCP server runs as a subprocess. You need the server’s runtime installed (e.g. Node for npm-based servers, Python for uv/pip-based servers). The SDK launches and manages the subprocess — you only provide
Command and Args.
MCPConfig fields
Runtime changes
Add or remove MCP servers afterNewAgent via a.MCPRegistry() — the next run picks up the current registry state.
Examples
MCP Config
WithMCPConfig from environment
MCP Client
WithMCPClients with explicit clients
Related
Tools
Native and custom tool registration
Approvals
MCP tools follow the same approval policy