Skip to main content

What this snippet demonstrates

AFK agents can consume tools from external MCP (Model Context Protocol) servers just like local tools. This snippet shows how to connect to an MCP server, discover available tools, and attach them to an agent — all with the same validation, policy gates, and telemetry as local tools.

Consuming MCP tools

Connect, discover, and attach

Using the Agent’s built-in MCP support

For simpler setups, pass MCP server refs directly to the agent:

Mixing local and MCP tools

Combine your own tools with external MCP tools:

Security with MCP tools

Apply policy rules to MCP-sourced tools just like local tools:
MCP tools are transparent. Once attached to an agent, they go through the same validation, policy gates, sanitization, and telemetry as local tools. The agent doesn’t know whether a tool is local or remote.