Skip to main content
AgentConfig.MCPClient accepts a client that discovers tools, reports connector status, and executes calls. Use pkg/agents/mcpclient.NewClient with one or more configuration stores. The root hastekit.NewMCPClient is an alias for this store-based constructor.

Configure a server

Import pkg/agents/mcpclient and pkg/agents/prompts. With model configured:
Replace the endpoint with your MCP server. Definitions with an empty Namespace are global, developer-owned, and always enabled. Namespace-owned definitions are enabled unless the run disables them. A global definition wins over a user definition with the same name. Use mcpclient.NewFileStore(path) for persisted definitions or implement MCPServerConfigStore.ListServerConfigs(ctx, namespace, runContext). NewClient(storeA, storeB) combines sources. WithMCPServerConfig returns a new view, copies inline configuration, and shares backing persistence.

Transports and tool filters

Filters use mcpclient.ToolFilter{Include: ..., Exclude: ...}. Empty Include selects all; Exclude wins. Configure a prefix when different servers expose the same tool name.

Select tools for one run

Set Input.MCP using agents.MCPSelection:
Selections use original, unprefixed tool names and only narrow the configured filter. Global servers cannot be disabled. Unknown names are ignored across handoffs. AG-UI accepts the same object at forwardedProps.mcp; send it again on new turns and approval resumes.

Discovery and execution

A run lists the current catalog. Individual connection and authentication failures become connector statuses, allowing other servers to work. Disabled servers contribute no tools or statuses. Store errors, invalid global definitions, and collisions between global tool names fail discovery; invalid user definitions fail their own connector. ResolveConnectors, included in the default prompt resolvers, tells the model about availability. Calls resolve the current configuration and credentials again. Editing a definition can therefore affect a tool listed earlier. Temporal and Restate carry descriptors and statuses through their histories; workers resolve connection secrets inside the activity or step. Global definitions may template headers and metadata from run context. User-owned definitions must be literal, use public HTTP endpoints, and cannot launch processes or request the shared credential provider. Application authentication determines which namespace may manage them.

Credentials and schema caching

Add a shared credential provider and cache to the client:
cache is pkg/cache. For custom credentials on global definitions, set UseCredentials: true; public servers do not use the provider. OAuth application settings belong in ServerConfig.Authorization. See MCP configuration and OAuth for persisted credentials and browser connection flows. Set CacheTTLSeconds and DefaultCacheScope per server. Explicit server cache scope wins; unspecified scope defaults to private. Use public scope only when every user sees the same schemas. Filters apply after cache lookup. Cache Get, Set, and Delete use the same byte-oriented signatures as the skill cache; the interfaces remain separate.

Approvals and progress

MCP annotations flow into tool descriptors. Approval requirements, form elicitations, and URL elicitations use the normal human-input flow. Progress notifications become agent progress events. For a large catalog, combine filters with deferred discovery.