Run, Stream, RunAsync, 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
| Transport | Type | Use case |
|---|---|---|
| Stdio | mcp.MCPStdio | Local subprocess — requires Node or another runtime for the MCP server process |
| Streamable HTTP | mcp.MCPStreamableHTTP | Remote server — supports Token, OAuthClientCreds, custom Headers, SkipTLSVerify |
Command and Args.
MCPConfig fields
| Field | Description |
|---|---|
Transport | Stdio or streamable HTTP config from pkg/mcp |
ToolFilter | AllowTools or BlockTools — applied at tool discovery |
Timeout | Per-call timeout — zero uses client default |
RetryAttempts | Retry count for transient failures |
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
Dynamic Capabilities
Register MCP servers at runtime
Production Readiness
MCP security checklist