MCPAgent class and several pre-built agent implementations for interacting with MCP environments.
Base Class
MCPAgent
setup, evaluate, response), and standardized telemetry/logging.
Constructor Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
mcp_client | AgentMCPClient | MCP client for server connections | None |
allowed_tools | list[str] | List of tool names to allow | None (all) |
disallowed_tools | list[str] | List of tool names to disallow | [] |
system_prompt | str | System prompt to seed the conversation | Default prompt |
append_setup_output | bool | Append setup tool output to initial context | True |
initial_screenshot | bool | Include an initial screenshot when supported | True |
model_name | str | Model label for telemetry/logging | "mcp-agent" |
response_agent | ResponseAgent | Optional auto-continue/stop helper | None |
auto_trace | bool | Enable automatic tracing spans | True |
verbose | bool | Verbose console logs for development | False |
metadata: dict[str, Any] | None- Injected into MCP initialize requestsrequired_tools: list[str]- Tools that must be present or initialization fails
mcp_client is provided but a Task with mcp_config is passed to run(), an MCPClient is automatically created and cleaned up.
Lifecycle & Filtering:
- Lifecycle tools (e.g.,
setup,evaluate, and auto-detectedresponse) are hidden from the model but available to the framework - Use
allowed_tools/disallowed_toolsto control the tool surface visible to your model
Pre-built Agents
ClaudeAgent
| Parameter | Type | Description | Default |
|---|---|---|---|
model_client | AsyncAnthropic | Anthropic client | Auto-created |
model | str | Claude model to use | "claude-sonnet-4-20250514" |
max_tokens | int | Maximum response tokens | 4096 |
use_computer_beta | bool | Enable computer-use beta features | True |
validate_api_key | bool | Validate key on init | True |
- Native Claude tool calling
- Automatic prompt caching
- Computer-use beta support
- Display metadata injection
OperatorAgent
| Parameter | Type | Description | Default |
|---|---|---|---|
model_client | AsyncOpenAI | OpenAI client | Auto-created |
model | str | Responses model to use | "computer-use-preview" |
environment | Literal["windows","mac","linux","browser"] | Computer environment | "linux" |
validate_api_key | bool | Validate key on init | True |
- OpenAI Responses computer-use
- Operator-style system prompt guidance
- Display metadata injection
GenericOpenAIChatAgent
| Parameter | Type | Description | Default |
|---|---|---|---|
openai_client | AsyncOpenAI | OpenAI-compatible client instance | Required |
model_name | str | Chat model name | "gpt-4o-mini" |
completion_kwargs | dict[str, Any] | Extra args forwarded to chat.completions.create | {} |
LangChainAgent
| Parameter | Type | Description | Default |
|---|---|---|---|
llm | BaseLanguageModel | LangChain-compatible model | Required |
GroundedOpenAIChatAgent
| Parameter | Type | Description | Default |
|---|---|---|---|
grounder_config | GrounderConfig | Configuration for the grounding model | Required |
model_name | str | OpenAI chat model name | "gpt-4o-mini" |
allowed_tools | list[str] | Exposed tool list (usually ["computer"]) | None |
append_setup_output | bool | Append setup output to first turn | False |
system_prompt | str | System prompt to use | Opinionated default |
Note: The grounded agent is for advanced use-cases where you want to decouple planning from grounding. For most users,ClaudeAgentorOperatorAgentis sufficient.
Helper Classes
ResponseAgent
Base class for auto-response handlers that decide when to continue or stop.Common Types
AgentResponse
Key fields:tool_calls: list[MCPToolCall]done: boolcontent: str | Nonereasoning: str | Noneinfo: dict[str, Any]isError: bool
MCPToolCall
Key fields:id: str— unique identifier (auto-generated if not provided)name: strarguments: dict[str, Any]
MCPToolResult
Key fields:content: list[ContentBlock]structuredContent: dict[str, Any] | NoneisError: bool
Trace
Key fields:reward: floatdone: boolcontent: str | NoneisError: boolinfo: dict[str, Any]task: Task | Nonetrace: list[TraceStep]— execution trace stepsmessages: list[Any]— final conversation state
Usage Examples
Simple Prompt Execution
Task Execution with Auto-Client
Custom Agent Implementation
See Also
- Create Agents - Tutorial on building agents
- Tasks - Task configuration reference
- Architecture - How agents fit in HUD
hud eval- Run agents on tasks/datasetshud rl- Train agents with GRPO