Skip to main content
Base agent interface for MCP tools. This module provides a base class for agents that use MCP tools.

BaseAgent

method init

Initialize a new agent.Parameters
mcp_use.client.session.MCPSession
required
The MCP session to use for tool calls.
Signature

method initialize

Initialize the agent.This method should prepare the agent for use, including initializing the MCP session and setting up any necessary components.Signature

method run

Run the agent with a query.Parameters
str
required
The query to run.
int
default:"10"
The maximum number of steps to run.
Returns
dict[str, Any]
The final result from the agent.
Signature

method step

Perform a single step of the agent.Parameters
str
required
The query to run.
list[dict[str, typing.Any]] | None
default:"None"
Optional list of previous steps.
Returns
dict[str, Any]
The result of the step.
Signature