BaseTool
and return standardized MCP content blocks.
Base Classes
BaseTool
Parameter | Type | Description | Default |
---|---|---|---|
env | Any | Optional stateful context (game, executor, browser) | None |
name | str | Tool name for MCP registration | Auto from class |
title | str | Human-readable display name | Auto from class |
description | str | Tool description | Auto from docstring |
mcp
- FastMCP FunctionTool wrapper for registration
BaseHub
- Internal tool dispatcher pattern
- Automatic resource catalog generation
- Hidden internal tools from MCP clients
Core Tools
BashTool
Parameter | Type | Description | Default |
---|---|---|---|
session | _BashSession | Pre-configured bash session | None |
Parameter | Type | Description | Default |
---|---|---|---|
command | str | Bash command to execute | Required |
restart | bool | Restart the bash session | False |
EditTool
Parameter | Type | Description | Default |
---|---|---|---|
file_history | dict[Path, list[str]] | Edit history per file | None |
Command | Parameters | Description |
---|---|---|
view | path , view_range | View file or directory contents |
create | path , file_text | Create new file |
str_replace | path , old_str , new_str | Replace string in file |
insert | path , insert_line , new_str | Insert text at line |
undo_edit | path | Undo last edit |
PlaywrightTool
Parameter | Type | Description | Default |
---|---|---|---|
page | Page | Existing Playwright page | None |
cdp_url | str | Chrome DevTools Protocol URL | None |
Action | Parameters | Description |
---|---|---|
navigate | url , wait_for_load_state | Navigate to URL |
screenshot | - | Capture page screenshot |
click | selector | Click element |
type | selector , text | Type text in element |
get_page_info | - | Get page title and URL |
wait_for_element | selector | Wait for element to appear |
Computer Control Tools
HudComputerTool
Parameter | Type | Description | Default |
---|---|---|---|
executor | BaseExecutor | Executor to use | Auto-detect |
platform_type | "auto" , "xdo" , "pyautogui" | Executor type | "auto" |
display_num | int | X display number | From env |
width | int | Agent screen width | 1280 |
height | int | Agent screen height | 720 |
rescale_images | bool | Rescale screenshots | True |
Action | Parameters | Description |
---|---|---|
screenshot | - | Capture screen |
click | x , y , button , pattern , hold_keys | Mouse click |
write | text , enter_after , delay | Type text |
press | keys | Press key combination |
scroll | x , y , scroll_x , scroll_y | Scroll |
drag | start_x , start_y , end_x , end_y | Drag mouse |
AnthropicComputerTool
- Pre-configured for 1280x720 resolution
- Optimized action names for Claude
- Built-in screenshot scaling
OpenAIComputerTool
- Pre-configured for 1920x1080 resolution
- Simplified action interface
- No automatic screenshot scaling
Executors
Executors provide platform-specific implementations for computer control actions.BaseExecutor
click(x, y, button, pattern, hold_keys)
- Mouse clickwrite(text, enter_after, delay)
- Type textpress(keys)
- Press key combinationscroll(x, y, scroll_x, scroll_y)
- Scrolldrag(start_x, start_y, end_x, end_y)
- Drag mousescreenshot()
- Capture screenget_screen_size()
- Get display dimensions
PyAutoGUIExecutor
- Works on Windows, macOS, Linux
- Real mouse/keyboard control
- Screenshot capture
- Automatic failsafe
XDOExecutor
- Native X11 integration
- Faster than PyAutoGUI on Linux
- Support for X display selection
- Window management capabilities
Common Types
ContentBlock
MCP standard output format (frommcp.types
):
EvaluationResult
ContentResult
Integration Examples
Adding Tools to Environment
Custom Tool Implementation
Hub Pattern for Evaluators
Callback Functions
Callback functions help you monitor certain types of actions and hook behaviors to them. You can manage callbacks using three main methods,async def
For example, when you want to take a screenshot every
time the webpage changes in Playwright
See Also
- Build Environments - Using tools in environments
- Architecture - How tools fit in HUD
- Adapting Software - Tool patterns