add_mcp_server
add_mcp_server
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
enable_mcp_server().
Parameters
url
MCP server HTTP endpoint URL.
headers
Optional HTTP headers sent with every request to the MCP server (e.g.,
{"Authorization": "Bearer sk-xxx"}).
resources
Whether to fetch the server’s resources into the agent’s global_data.
resource_vars
Variables for URI template substitution when fetching resources. Supports SignalWire
call variables such as ${caller_id_number}.
Returns
AgentBase — Returns self for method chaining.