A guide for coding agents to create agents that can invoke tools
Enhance Autonomy agents with tools that perform specific actions, access external data, and integrate with external services using Python functions or MCP servers.Key Terms: See the definitions section of the main guide.Keywords: tools, python tools, mcp tools, web search This guide shows how to create agents with both Python tools and MCP tools for external service integration.
Built-in Tools
Autonomy automatically provides built-in tools to agents:Always Available
These tools are automatically available to all agents without any configuration:get_current_time_utc- Get the current time in UTC timezoneget_current_time- Get the current time in a specific timezone (e.g., “America/New_York”, “Europe/London”, “Asia/Tokyo”)
Available When Enabled
ask_user_for_input- Request input from the user (human-in-the-loop)- Requires:
enable_ask_for_user_input=Truewhen callingAgent.start() - Default: Not enabled (defaults to
False)
- Requires:
Subagent Tools
When an agent hassubagents configured, these tools are automatically added:
start_subagent- Start a configured subagent on-demanddelegate_to_subagent- Delegate a task to a specific subagent and wait for responsedelegate_to_subagents_parallel- Delegate multiple tasks to parallel subagent instanceslist_subagents- List all configured and running subagents with their statusstop_subagent- Stop a running subagent
Creating Agents with Tools
Autonomy agents can use two types of custom tools:- Python Tools - Functions defined directly in your code
- MCP Tools - Tools from Model Context Protocol servers
Complete Example: Agent with Both Tool Types
This example shows an agent with a Python tool (time) and MCP tool (web search):Project Structure
main.py
autonomy.yaml
secrets.yaml
Dockerfile
Deploy and Test
Deploy your zone:How It Works
Python Tools: Define functions and wrap them withTool(). The agent calls these functions directly in your code.
MCP Tools: Configure MCP servers in autonomy.yaml as containers using ghcr.io/build-trust/mcp-proxy. Register them with McpClient() and reference with McpTool(). The MCP proxy runs alongside your agent in the same pod.
Tool Selection: The agent analyzes the user’s message and your instructions to decide which tools to use and when.
MCP Servers in Multi-Pod Deployments
IMPORTANT: MCP servers are accessed over localhost. When your zone has nodes distributed across multiple pods, each pod that needs MCP tools must have its own MCP server container.
Why This Matters
Containers within the same pod share a network namespace and communicate vialocalhost. When you distribute nodes across multiple pods (using clones or separate pod definitions), each pod runs on a different machine. An agent running in one pod cannot access MCP servers in another pod over localhost.
Example: Distributed Workers with MCP Tools
If you have workers across multiple pods that need MCP tools, configure the MCP server in each pod:autonomy.yaml
images/runner/main.py
- Both
main-podandrunner-podhave their ownbravecontainer - Each pod needs its own MCP server - Each clone of
runner-podgets its own MCP server - The 3 clones each run independently with their own brave container - All MCP clients use
localhost- Each node connects to the MCP server in its own pod - Environment variables are duplicated - Each pod needs the same secrets configuration
Decision Guide
| Scenario | MCP Server Configuration |
|---|---|
| Single pod with one node | One MCP server container in that pod |
| Single pod with multiple agents | One MCP server container shared by all agents |
| Multiple pods with clones | MCP server container in each pod definition |
| Only main-pod needs MCP tools | MCP server only in main-pod |
| All pods need MCP tools | MCP server in every pod definition |
Using Built-in Time Tools
Agents can check the current time without any configuration. The built-in time tools are automatically available:Example: Agent with Time Awareness
Test Time Tools
get_current_time_utc()to get UTC timeget_current_time(timezone="Asia/Tokyo")to get Tokyo time
Using the Ask User for Input Tool
Theask_user_for_input tool enables human-in-the-loop interactions where the agent can pause and request input from the user.
Example: Agent with User Input Capability
- Set
enable_ask_for_user_input=Truewhen callingAgent.start() - The agent can call this tool to pause and wait for user response
- The conversation resumes after the user provides input
- Useful for gathering missing information, confirmations, or clarifications

