Scrcpy Mcp

io.github.JuanCF由 GitHub 帳號 JuanCF 發布v0.5.0更新於 Nov 10, 2026

MCP server for Android device control via ADB and scrcpy

概覽

AI 產生的概覽

本機 MCP 伺服器,讓 AI 助理透過 ADB 與 scrcpy 檢視並操控已連線的 Android 裝置:截圖、點擊、輸入、應用程式、檔案與 shell。

可以做什麼
  • 檢視畫面:回傳影像的截圖、螢幕錄影,以及可回傳點擊座標的 UI 階層匯出與元素尋找。
  • 控制輸入:點擊、滑動、長按、拖曳、捲動、輸入文字與送出按鍵事件。
  • 管理應用程式:啟動、強制停止、安裝、解除安裝、列出套件,並查看前景應用程式。
  • 處理裝置狀態:列出與檢視裝置、喚醒或關閉螢幕、旋轉、展開通知與快速設定面板,以及連線或中斷無線 ADB。
  • 執行 shell 與傳輸檔案:執行任意 ADB shell 指令,推送、拉取與列出檔案,讀寫剪貼簿。
  • 串流媒體:啟動 MJPEG 視訊串流、將裝置音訊串流到主機,以及錄製音訊片段或檔案。
適用情境
適合讓助理實際操作或測試真實 Android 手機或模擬器的情境:走查應用程式流程、查看畫面上有什麼、自動化重複點擊與文字輸入,或取得日誌與檔案。啟用 scrcpy 工作階段可大幅加快輸入與截圖,只用 ADB 也能使用大多數互動工具。
執行需求
透過 npx 或全域 npm 安裝,以 stdio 在本機執行。需要 Node.js 24+、PATH 中可用的 ADB(或以 ADB_PATH 指定),以及已開啟 USB 偵錯並接受 RSA 指紋提示的裝置。可選裝 scrcpy 以取得快速路徑,以及 ffmpeg/ffplay 用於視訊串流與音訊。多台裝置連線時需設定 ANDROID_SERIAL;SCRCPY_SERVER_PATH 可指向非標準位置的 scrcpy-server。
安裝前請注意
助理將取得對已連線裝置的完整控制:shell_exec 可執行任意指令,file_push/file_pull 可讀寫 shell 使用者能存取的任何檔案,也能安裝或解除安裝應用程式。只連接自己擁有且信任的裝置,並信任所使用的 AI 代理。讀取 scrcpy 版本會執行該安裝的可執行檔,因此 SCRCPY_SERVER_PATH 只應指向可信的安裝;該 server 檔案會被推送到裝置並在裝置上執行。使用預設 output 音源擷取音訊時,裝置本身的喇叭會被靜音。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Scrcpy Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

scrcpy-mcp

MCP server that gives AI agents full vision and control over Android devices via ADB and scrcpy.

Connect any MCP-compatible AI assistant (Claude Code, OpenCode, Cursor, VS Code Copilot, etc.) to your Android device. The AI can see the screen, tap, swipe, type, launch apps, inspect UI elements, transfer files, and run shell commands.

[MCP Badge]

Features

  • 44 tools covering screenshots, input, apps, UI automation, shell, files, clipboard, video streaming, and audio streaming/recording
  • scrcpy-first: uses scrcpy's binary control protocol for 10-50x faster input and near-instant screenshots (~33ms)
  • ADB fallback: interaction tools work without scrcpy — slower but always available (the audio tools start_audio_stream/audio_record_start and the video stream require scrcpy)
  • Image-returning screenshots: the AI actually sees the screen, not just a file path
  • UI element finding: ui_find_element returns tap coordinates so the AI can act on what it sees
  • Audio streaming & recording: stream device audio to host speakers (start_audio_stream) or capture to .wav/.opus (audio_record_start)
  • Clipboard that works on Android 10+: scrcpy bypasses the restrictions that break ADB-only solutions

Prerequisites

Required

RequirementInstallVerify
Node.js 24+nodejs.org or nvm install (uses .nvmrc)node --version
ADB (Android Platform Tools)developer.android.com/tools/releases/platform-toolsadb version
Android device with USB debugging (Android 11+ for audio)Settings → Developer Options → USB Debuggingadb devices

Optional (for enhanced performance)

RequirementInstallBenefit
scrcpygithub.com/Genymobile/scrcpy10-50x faster input, ~33ms screenshots
ffmpegapt install ffmpeg / brew install ffmpegRequired for scrcpy video stream decoding, audio recording, and audio clip capture
ffplayUsually packaged with ffmpegRequired for audio playback and the MJPEG viewer window

Device setup

  1. Enable Developer Options: Settings → About Phone → tap "Build Number" 7 times
  2. Enable USB Debugging: Settings → Developer Options → USB Debugging
  3. Connect device via USB
  4. Accept the RSA fingerprint prompt on the device
  5. Verify: adb devices should show your device as device (not unauthorized)

Installation

bash
# Run directly with npx (no install needed)npx scrcpy-mcp
# Or install globallynpm install -g scrcpy-mcp

MCP Client Configuration

Claude Code

bash
claude mcp add android -- npx scrcpy-mcp

Or add to .mcp.json in your project root:

json
{  "mcpServers": {    "android": {      "command": "npx",      "args": ["scrcpy-mcp"]    }  }}

OpenCode

Add to .mcp.json:

json
{  "mcpServers": {    "android": {      "command": "npx",      "args": ["scrcpy-mcp"]    }  }}

Cursor

Settings → MCP → Add Server:

json
{  "android": {    "command": "npx",    "args": ["scrcpy-mcp"]  }}

Claude Desktop

Edit ~/.config/Claude/claude_desktop_config.json (Linux) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

json
{  "mcpServers": {    "android": {      "command": "npx",      "args": ["scrcpy-mcp"]    }  }}

VS Code (GitHub Copilot)

Add to .vscode/mcp.json:

json
{  "servers": {    "android": {      "command": "npx",      "args": ["scrcpy-mcp"]    }  }}

Customizing Environment Variables

If you need to configure custom options (such as pointing to a non-standard scrcpy-server path), you can add the "env" object to your server configuration. For example:

json
{  "mcpServers": {    "android": {      "command": "npx",      "args": ["scrcpy-mcp"],      "env": {        "SCRCPY_SERVER_PATH": "C:\\path\\to\\scrcpy-server"      }    }  }}

Note: only set SCRCPY_SERVER_VERSION if version auto-detection fails — it overrides detection, so a stale value causes the version mismatch described in Troubleshooting. Match it to your installed scrcpy (scrcpy --version).

Note: On Windows, remember to double-escape backslashes (\\) in your configuration paths.

OpenCode users: OpenCode uses "environment" instead of "env" for passing environment variables to MCP servers. Replace "env" with "environment" in the example above if you're configuring scrcpy-mcp in opencode.json.

Tool Reference

Session Management

ToolDescription
start_sessionStart a scrcpy session. When active, input and screenshots use the fast path (10-50x faster).
stop_sessionStop the scrcpy session. Tools fall back to ADB.
versionReport which scrcpy-server version the session pushes and where that version was resolved from.

start_session options:

OptionDefaultDescription
maxSize1024Max video frame dimension in pixels
maxFps30Max frames per second
audiofalseCapture audio (see the heads-up below)
audioSourceoutputAudio source (output, playback, mic, voice-call, …)
audioDupfalseKeep device playback audible with audioSource: "playback" (Android 13+)
stayAwakefalseKeep the device on for the whole session (scrcpy --stay-awake). Applies only while the device is plugged in.
screenOffTimeout(device setting)Screen-off timeout in seconds for the whole session (scrcpy --screen-off-timeout). Works on battery too. Needs scrcpy 2.5+.

Both screen-awake options are temporary: scrcpy restores the device's original values when the session ends, including when a tool restarts the session to turn audio on.

Video Streaming

ToolDescription
start_video_streamStart an HTTP MJPEG video stream and open a viewer window (ffplay). Auto-starts a scrcpy session if needed.
stop_video_streamStop the video stream and close the viewer window.

Audio Streaming & Recording

Heads up: Audio capture is opt-in and requires Android 11+. The default source output uses REMOTE_SUBMIX, which mutes the device's own speakers while capturing — the audio is moved to the host, not copied. Use audioSource: "playback" with audioDup: true (Android 13+) to keep the device audible. Recordings are saved on the host filesystem.

ToolDescription
start_audio_streamStream device audio to the host's speakers via ffplay. Restarts the scrcpy session if it was started without audio.
stop_audio_streamStop streaming audio to the host.
audio_record_startStart recording device audio to .wav (default) or .opus on the host. Restarts the scrcpy session if needed. Stops automatically after maxDuration seconds (default 300).
audio_record_stopStop the recording and finalise the host-side file.
audio_captureCapture a bounded clip of device audio and return it as an audio content block. Restarts the scrcpy session if needed. durationSeconds defaults to 5 (integer, max 30; a 5s default becomes 2.5s when ffmpeg has no libopus and the WAV fallback is used). audioSource/audioDup default to the running audio session's settings, so a clip can be taken during a recording or stream without interrupting it.

Device Management

ToolDescription
device_listList all connected devices with serial, state, and model
device_infoGet model, Android version, screen size, SDK level, battery
screen_onWake the device screen
screen_offTurn the screen off
rotate_deviceRotate the screen (requires active session)
expand_notificationsPull down the notification panel (requires active session)
expand_settingsPull down the quick settings panel (requires active session)
collapse_panelsCollapse notification/settings panels (requires active session)
connect_wifiEnable WiFi ADB and connect to the device wirelessly. Returns the connection address.
disconnect_wifiDisconnect from a wireless ADB device

Vision

ToolDescription
screenshotCapture the screen and return it as an image. ~33ms with scrcpy, ~500ms via ADB.
screen_record_startStart recording the screen to a file on the device
screen_record_stopStop recording and optionally pull the file to the host

Input Control

All input tools use scrcpy (~5-10ms) when a session is active, otherwise fall back to ADB (~100-300ms).

ToolDescription
tapTap at screen coordinates
swipeSwipe from one point to another
long_pressLong press at coordinates
drag_dropDrag from one point to another
input_textType a text string into the focused field
key_eventSend a key event: HOME, BACK, ENTER, VOLUME_UP, VOLUME_DOWN, POWER, etc.
scrollScroll at a position (dx=horizontal, dy=vertical)

App Management

ToolDescription
app_startLaunch an app by package name. Prefix with + to force-stop before launch.
app_stopForce-stop an app
app_installInstall an APK from the host machine
app_uninstallUninstall an app
app_listList installed packages, optionally filter by name or system/third-party
app_currentGet the current foreground app and activity

UI Automation

ToolDescription
ui_dumpDump the full UI hierarchy as XML
ui_find_elementFind elements by text, resource ID, class name, or content description. Returns tap coordinates.

Shell & Files

ToolDescription
shell_execExecute an arbitrary ADB shell command and return the output
file_pushPush a file from the host machine to the device
file_pullPull a file from the device to the host machine
file_listList directory contents on the device

Clipboard

ToolDescription
clipboard_getGet clipboard content. Uses scrcpy to bypass Android 10+ restrictions.
clipboard_setSet clipboard content. Pass paste: true to also paste immediately.

Performance

Operationscrcpy (session active)ADB fallback
Screenshot~33ms~500ms
Tap / Swipe~5-10ms~100-300ms
Text input~5ms~100-300ms
Clipboard~10msunreliable on Android 10+

Start a session once at the beginning to unlock the fast path:

start_session → take screenshots → tap → swipe → ...

Environment Variables

VariableDefaultDescription
ADB_PATHadbPath to the ADB binary
ANDROID_SERIAL(none)Default device serial, overrides auto-detection
SCRCPY_SERVER_PATH(auto)Path to the scrcpy-server binary
SCRCPY_SERVER_VERSION(auto)Version of the scrcpy-server binary
FFMPEG_PATHffmpegPath to the ffmpeg binary
FFPLAY_PATHffplayPath to the ffplay binary (video stream viewer and audio playback)

When only one device is connected, tools auto-detect it. With multiple devices, pass the serial parameter explicitly or set ANDROID_SERIAL.

Troubleshooting

adb devices shows unauthorized Accept the RSA fingerprint prompt on the device. If the prompt doesn't appear, revoke USB debugging authorizations in Developer Options and reconnect.

start_session fails Make sure scrcpy is installed and the scrcpy-server binary is accessible. On Windows, add the folder containing both scrcpy.exe and scrcpy-server to your PATH, or set SCRCPY_SERVER_PATH to the full path of the scrcpy-server file.

  • File vs Directory: Ensure SCRCPY_SERVER_PATH points directly to the scrcpy-server file itself (e.g. C:\path\to\scrcpy-server), NOT to its parent folder.
  • Android Directory Conflict: If you previously pushed a directory to the server path, /data/local/tmp/scrcpy-server.jar on the Android device might have been created as a folder. Run adb shell rm -rf /data/local/tmp/scrcpy-server.jar to delete it.
  • Version Mismatch: The client must send the exact version of the scrcpy-server file it pushes. To guarantee that, the server and the version are never resolved separately — one scrcpy install is resolved as a pair, and the version comes from the client belonging to that same install. The install is found in this order: SCRCPY_SERVER_PATH if set (its client is then located beside the server, or one prefix step away at ../../bin/scrcpy); otherwise the scrcpy on your PATH, whose server is located beside it or at ../share/scrcpy/scrcpy-server; otherwise whatever your package manager reports (dpkg, pacman, rpm, apk, brew). A symlinked client is resolved to its real directory before its counterpart is derived, so a link farm such as Homebrew's bin/scrcpy pairs with the install it points at rather than with the link's own directory. SCRCPY_SERVER_VERSION overrides the detected version if set. So on Windows, or when a GUI app launches the MCP without your shell PATH, pointing SCRCPY_SERVER_PATH at a server inside a complete scrcpy install is enough on its own, and it wins even if a different scrcpy comes first on your PATH — note that reading the version runs that install's executable, so point SCRCPY_SERVER_PATH only at an install you trust (the same trust the server file itself already requires, since it gets pushed to your device and executed there). If no client can be found for the resolved server (for example a lone scrcpy-server downloaded from the releases page), the client falls back to the default version and the server may exit with a version-mismatch error; set SCRCPY_SERVER_VERSION to your installed version (e.g., "4.1"). Run the version tool to see which version is in use and where it was resolved from. See the Environment Variables table above.

Screenshots are slow (~500ms) Start a scrcpy session with start_session to enable the fast video stream path. Requires scrcpy and ffmpeg.

expand_notifications / expand_settings / collapse_panels fail These tools require an active scrcpy session. Run start_session first.

The device screen keeps turning off during long automations Start the session with stayAwake: true (plugged in only) or screenOffTimeout: <seconds>, which also works on battery. Both are restored when the session ends.

start_audio_stream says ffplay was not found Install ffmpeg (ffplay ships with it), or set FFPLAY_PATH to the binary. The same applies to audio_record_start and FFMPEG_PATH.

Audio recording is silent REMOTE_SUBMIX only captures what apps are actually playing — a recording made while nothing plays is digital silence, which is expected. Also check the device is not muted, and remember the default output source moves the audio to the host, so the device goes quiet while capturing. Use audioSource: "playback" with audioDup: true (Android 13+) to keep it audible.

Audio tools report audio as unavailable Audio capture needs Android 11+ (SDK 30). On older devices the session still works for video, input, and clipboard.

Clipboard doesn't work on Android 10+ ADB clipboard access is restricted on Android 10+. Start a scrcpy session — the scrcpy clipboard protocol bypasses this restriction.

Multiple devices connected Pass serial to each tool or set the ANDROID_SERIAL environment variable.

Security

This server provides full control over connected Android devices. The shell_exec tool can run arbitrary commands, and file_push/file_pull can read and write any file accessible to the shell user.

  • The server runs locally over stdio — it is not exposed to the network
  • ADB requires USB debugging to be explicitly enabled on the device
  • The device must accept your host's RSA key on first connection
  • Only connect devices you own and trust the AI agent you are using

License

MIT — see LICENSE

來源:README.md,提交 5f93d15

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.5.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分