Creates an MCP agent.
Call initialize before the first local run unless
autoInitialize is enabled. Setting agentId creates a remote agent.
Model, MCP connection, and execution settings.
Runs a single model completion without MCP tools.
Provider-neutral messages and optional cancellation signal.
Final assistant text.
Removes all stored user and assistant messages.
Closes MCP sessions created by this agent and resets initialization state.
Existing clients supplied by the caller remain open.
A shallow copy of stored provider-neutral conversation history.
Resolves the model configuration, connects MCP servers, and loads tools.
Calling this method more than once has no effect until close.
Runs the agent and resolves with the final assistant text.
Input and per-run execution settings.
Final assistant text.
Runs the agent and resolves with the final assistant text.
Input and per-run execution settings.
Final assistant text.
Replaces the system instruction used by subsequent runs.
New system instruction.
Runs the agent, yielding each completed tool step.
The generator's return value is the final assistant text.
Input and per-run execution settings.
An async generator of completed tool steps.
Runs the agent, yielding each completed tool step.
The generator's return value is the final assistant text.
Input and per-run execution settings.
An async generator of completed tool steps.
Runs the agent and yields provider-neutral token, tool, usage, and lifecycle events.
Input and per-run execution settings.
An async generator of low-level stream events.
Runs the agent and yields provider-neutral token, tool, usage, and lifecycle events.
Input and per-run execution settings.
An async generator of low-level stream events.
StaticgetThe installed @mcp-use/agent package version.
Runs provider-neutral LLM tool loops against one or more MCP servers.