Give an OpenAI Agents SDK agent a cloud Android phone, in TypeScript or Python.

TypeScript

Install the SDK with npm install @openai/agents zod, export your keys, and run:

agent.ts
import { Agent, run, MCPServerStreamableHttp } from "@openai/agents";

const phonebox = new MCPServerStreamableHttp({
  name: "phonebox",
  url: "https://phonebox.dev/mcp",
  requestInit: { headers: { Authorization: `Bearer ${process.env.PHONEBOX_API_KEY}` } },
});

await phonebox.connect();
try {
  const agent = new Agent({
    name: "Android operator",
    instructions: "You control cloud Android phones through Phonebox. Park every phone you start when you're done.",
    mcpServers: [phonebox],
  });
  const result = await run(agent, "Create a phone named settings-check, open Settings, tell me the Android version, then park the phone.", { maxTurns: 30 });
  console.log(result.finalOutput);
} finally {
  await phonebox.close();
}

connect() opens the session and close() ends it, so keep both around the run. The agent sees the 14 Phonebox tools under their own names, such as observe and act.

Python

Install with pip install openai-agents. In Python the server is an async context manager, which connects and closes for you:

agent.py
import asyncio, os
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp

async def main():
    async with MCPServerStreamableHttp(
        name="phonebox",
        params={
            "url": "https://phonebox.dev/mcp",
            "headers": {"Authorization": f"Bearer {os.environ['PHONEBOX_API_KEY']}"},
        },
    ) as phonebox:
        agent = Agent(
            name="Android operator",
            instructions="You control cloud Android phones through Phonebox. Park every phone you start when you're done.",
            mcp_servers=[phonebox],
        )
        result = await Runner.run(agent, "Create a phone named settings-check, open Settings, tell me the Android version, then park the phone.", max_turns=30)
        print(result.final_output)

asyncio.run(main())

Why does my run stop with a max turns error?

Both versions of the SDK stop a run after 10 turns unless you pass a limit. Each look at the screen and each action is a turn, so even "open Settings and read the version" can take a dozen. The examples pass maxTurns: 30 and max_turns=30. The act tool runs up to 20 actions in one call, which keeps the count down.

Keys, costs and cleanup

Create an Agent key in API keys and export it as PHONEBOX_API_KEY. An Agent key can create, start, use and park phones but can't delete them, which is the right default for an agent. Give the key an expiry, and set a monthly spending limit in Settings: it stops new sessions when it's reached.

Tell the agent to park every phone it starts. A parked phone costs nothing and keeps its apps, files and sign-ins for the next run. Phonebox also parks a phone after its idle timeout and ends a session at its maximum length, so a crashed script doesn't leave a phone running.

Phonebox's tool schemas also list context (a short reason for the call) and llm_model, which are used only for analytics. Models fill them in from the schema, so an agent needs nothing extra. The server doesn't reject a call without them, so code that calls a tool directly can leave them out.

What was checked

Checked on December 1, 2026 with @openai/agents 0.23.0 and openai-agents 0.26.1 for Python: the framework's MCP client connected to https://phonebox.dev/mcp with a project API key, listed all 14 Phonebox tools and called get_account. That check didn't start a phone or run a model; the agent code on this page was type-checked against those versions. See the Agents SDK MCP guide for the client's other options.

OpenAI Agents SDK: common questions

Does the OpenAI Agents SDK work with a hosted MCP server?

Yes. MCPServerStreamableHttp connects to a remote MCP server over HTTP. For Phonebox, use https://phonebox.dev/mcp and send your project API key as a bearer token in the Authorization header.

Why does my OpenAI agent stop after 10 turns?

The Agents SDK's default turn limit is 10 in both TypeScript and Python. Driving a phone takes a turn for each look and action, so pass a higher limit, such as maxTurns: 30 or max_turns=30.