addMcpServer
Connect the agent to an external Model Context Protocol (MCP) server. Tools are discovered via the MCP protocol at session start and automatically registered as SWAIG functions. Optionally, the server’s resources can be fetched into the agent’s global data.
This method connects your agent to an MCP server as a client. To expose your
agent’s own tools as an MCP server, use
enableMcpServer().
Parameters
url
MCP server HTTP endpoint URL.
opts
Optional configuration.
opts.headers
HTTP headers sent with every request to the MCP server (e.g.,
{ Authorization: 'Bearer sk-xxx' }).
opts.resources
Whether to fetch the server’s resources into the agent’s global_data.
opts.resourceVars
Variables for URI template substitution when fetching resources. Supports SignalWire
call variables such as ${caller_id_number}.
Returns
AgentBase — Returns this for method chaining.