Skip to main content
View the source code for this module on GitHub: https://github.com/mcp-use/mcp-use/blob/main/mcp_use/agents/remote.py
Remote agent implementation for executing agents via API.

RemoteAgent

from mcp_use.agents.remote import RemoteAgent

method init

Initialize remote agent.Parameters
agent_id
str
required
The ID of the remote agent to execute
chat_id
str | None
default:"None"
The ID of the chat session to use. If None, a new chat session will be created.
api_key
str | None
default:"None"
API key for authentication. If None, will check MCP_USE_API_KEY env var
base_url
str
default:"https://cloud.mcp-use.com"
Base URL for the remote API
Signature
def __init__(agent_id: str, chat_id: str | None = None, api_key: str | None = None, base_url: str = "https://cloud.mcp-use.com"):

method close

Close the HTTP client.Signature
def close():

method run

Run a query on the remote agent.Parameters
query
str
required
The query to execute
max_steps
int | None
default:"None"
Maximum number of steps (default: 10)
external_history
list[langchain_core.messages.base.BaseMessage] | None
default:"None"
External history (not supported yet for remote execution)
output_schema
type[~T] | None
default:"None"
Optional Pydantic model for structured output
Returns
returns
str | mcp_use.agents.remote.T
The result from the remote agent execution (string or structured output)
Signature
def run(
query: str,
    max_steps: int | None = None,
    external_history: list[langchain_core.messages.base.BaseMessage] | None = None,
    output_schema: type[~T] | None = None
):
I