Skip to main content

clipboard · set_clipboard

This tool on every surface: CLI · MCP · Python · JavaScript · Go · Java · .NET

Read the device clipboard, or write it by passing text. These call app_clipboard.

clipboard​

def clipboard() -> str

What the device clipboard holds.

iOS only. On Android 10 and later only an app with focus may read the clipboard and the UiAutomator2 server has no activity, so it would answer "empty" for a clipboard that is full — this raises there instead.

set_clipboard​

def set_clipboard(text: str) -> dict

Write the device clipboard.

On iOS the write is confirmed by reading it back; on Android it is reported as sent, nothing there being able to read it.

Examples​

Put text on the clipboard​

device.set_clipboard("hello there")

The same call from the command line, mobium clipboard "hello there", printed on an Android 15 emulator:

wrote "hello there" to the clipboard — Android cannot read it back, so this is the write reported as sent. Paste into a field to see it

mobium clipboard "hello there" on an Android 15 emulator

mobium clipboard "hello there" on an Android 15 emulator

Read the clipboard​

print(device.clipboard())

The same call from the command line, mobium clipboard, was refused, exit 5 on an Android 15 emulator:

error: the uiautomator2 backend cannot read the clipboard. On Android 10 and later only an app with focus may read it, and the UiAutomator2 server has no activity of its own — it answers with an empty string however full the clipboard is, which would be reported as "empty" rather than as "unknown". Pass text to write one; to check a write, paste into a field and read that