DEV Community

Phonebox
Phonebox

Posted on Originally published at phonebox.dev

Give a Google ADK agent a cloud Android phone

Short answer: To give a Google Agent Development Kit (ADK) agent an Android phone, add an McpToolset with StreamableHTTPConnectionParams pointing at https://phonebox.dev/mcp and your Phonebox API key in the Authorization header, and pass it in the agent's tools. The agent gets all 34 Phonebox tools: create a cloud phone, read the screen as numbered elements, tap, type and swipe, install APKs, move files, set location, language and timezone, record the screen, reset it and park it. No emulator, no Android SDK, nothing running on your machine.

Why give an ADK agent a phone?

ADK agents are great at calling APIs. Most mobile apps don't have one. With Phonebox, your Gemini-powered agent uses the app the way a person does: on a cloud Android phone, with its own screen, apps and sign-ins. That unlocks:

  • Testing the app you just built. Install the APK, walk the changed screens, report bugs with the exact screen text.
  • Automating apps that have no API. Read a balance, change a setting, check a listing.
  • Multi-agent workflows. One ADK sub-agent owns the phone; others plan and write up results.

Phonebox's MCP server is hosted and stateless, so ADK connects to it over HTTPS like any other remote MCP server.

The code

Install ADK with its MCP extra:

pip install "google-adk[mcp]"
export PHONEBOX_API_KEY=pbx_...
export GOOGLE_API_KEY=...   # or your Vertex AI settings
Enter fullscreen mode Exit fullscreen mode

Then run:

import asyncio
import os

from google.adk.agents import Agent
from google.adk.agents.run_config import RunConfig
from google.adk.runners import InMemoryRunner
from google.adk.tools.mcp_tool import McpToolset, StreamableHTTPConnectionParams
from google.genai import types

phonebox = McpToolset(
    connection_params=StreamableHTTPConnectionParams(
        url="https://phonebox.dev/mcp",
        headers={"Authorization": f"Bearer {os.environ['PHONEBOX_API_KEY']}"},
    ),
)

agent = Agent(
    name="android_operator",
    model="gemini-3.5-flash",
    instruction=(
        "You operate a cloud Android phone through the Phonebox tools. "
        "Start or create one phone, call observe before every action, "
        "batch steps in act, and park the phone when you are done."
    ),
    tools=[phonebox],
)


async def main() -> None:
    runner = InMemoryRunner(agent=agent, app_name="phonebox_demo")
    session = await runner.session_service.create_session(
        app_name="phonebox_demo", user_id="dev"
    )
    task = types.Content(
        role="user",
        parts=[types.Part(text="Open Settings and tell me the Android version.")],
    )
    try:
        async for event in runner.run_async(
            user_id="dev",
            session_id=session.id,
            new_message=task,
            run_config=RunConfig(max_llm_calls=60),
        ):
            if event.is_final_response() and event.content and event.content.parts:
                print(event.content.parts[0].text)
    finally:
        await phonebox.close()


if __name__ == "__main__":
    asyncio.run(main())
Enter fullscreen mode Exit fullscreen mode

McpToolset opens the MCP session when the agent first needs its tools; close() ends it. The tools appear under their own names, such as observe and act.

Using it with adk web or adk run

ADK's dev UI looks for a root_agent in your agent package. Put the phonebox toolset and the Agent in agent.py, name the agent variable root_agent, and run adk web from the parent folder. You can then watch every observe and act call in the trace view, and open the phone's live view (the live_view_url tool) in your browser to watch it, or take over for a sign-in.

Keep the tool list short

A phone task rarely needs all 34 tools. ADK's tool_filter limits what the model sees, which saves tokens and keeps the agent on task:

phonebox = McpToolset(
    connection_params=StreamableHTTPConnectionParams(
        url="https://phonebox.dev/mcp",
        headers={"Authorization": f"Bearer {os.environ['PHONEBOX_API_KEY']}"},
    ),
    tool_filter=["create_phone", "start_phone", "observe", "act",
                 "install_app", "live_view_url", "park_phone"],
)
Enter fullscreen mode Exit fullscreen mode

How the agent drives the phone

The loop is simple: create_phone (or start_phone for a parked one), then observe to read the screen as a numbered list of elements plus a screenshot, then act to tap, type or swipe. act runs up to 20 actions in one call and stops at the first failure, so the agent spends fewer model calls per task. ADK's default ceiling of 500 model calls per run is plenty; the example sets max_llm_calls=60 as a cost guard.

Which agent in a multi-agent ADK app gets the phone?

Give the Phonebox toolset only to the sub-agent that operates the phone, and let a coordinator agent delegate to it. One agent owns starting and parking the phone, and the others don't carry 34 tool schemas they never use.

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 it 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 and llm_model, used only for analytics. Gemini fills them in from the schema; the server doesn't reject calls without them.
  • Pricing: Starter is $20/month and includes $20 of phone time; phone time is $0.06 a minute, billed per second. See pricing.

What was checked

Checked on December 3, 2026 with google-adk 2.15.1 and mcp 2.3.0: ADK's McpToolset connected to https://phonebox.dev/mcp with a project API key and listed all 34 Phonebox tools. See ADK's MCP tools docs for the toolset's other options.

FAQ

Can Google ADK use a hosted MCP server?
Yes. McpToolset with StreamableHTTPConnectionParams connects to a remote MCP server over Streamable HTTP with a URL and headers. For Phonebox, use https://phonebox.dev/mcp and your project API key as a bearer token.

Which pip package do I need?
google-adk[mcp]. The MCP extra installs the mcp client library; without it, McpToolset can't be imported from google.adk.tools.mcp_tool.

Does this work with Gemini on Vertex AI?
Yes. The Phonebox connection doesn't depend on the model backend; set ADK's usual Vertex AI environment variables instead of GOOGLE_API_KEY.

Do I need an Android emulator or the Android SDK?
No. The phone runs in Phonebox's cloud and the MCP server is hosted, so nothing Android-related runs on your machine.

Can ADK agents in TypeScript or Java use Phonebox?
Any MCP client that can send an Authorization header over Streamable HTTP works with the same URL and key. This page's code is for ADK Python.

Full guide and related integrations: https://phonebox.dev/guides/google-adk-android-phone

Top comments (0)