Documentation Index
Fetch the complete documentation index at: https://docs.mcp-use.com/llms.txt
Use this file to discover all available pages before exploring further.
Base agent interface for MCP tools.
This module provides a base class for agents that use MCP tools.
BaseAgent
from mcp_use.agents.base import BaseAgent
method init
Initialize a new agent.Parameters
session
mcp_use.client.session.MCPSession
required
The MCP session to use for tool calls.
Signaturedef __init__(session: mcp_use.client.session.MCPSession):
method initialize
Initialize the agent.This method should prepare the agent for use, including initializing
the MCP session and setting up any necessary components.Signaturemethod run
Run the agent with a query.Parameters
The maximum number of steps to run.
Returns
The final result from the agent.
Signaturedef run(query: str, max_steps: int = 10):
method step
Perform a single step of the agent.Parameters
previous_steps
list[dict[str, typing.Any]] | None
default:"None"
Optional list of previous steps.
Returns
Signaturedef step(query: str, previous_steps: list[dict[str, typing.Any]] | None = None):