Onsense

io.github.hufirst由 GitHub 账号 hufirst 发布v0.3.20更新于 Oct 24, 2026

Android phone camera, sensors & files for any MCP client — local, no cloud, no ADB.

概览

AI 生成的概览

让 AI 助手通过本地 Wi-Fi 查看已配对 Android 手机的摄像头、读取传感器,并在手机与电脑之间传输照片、文件和剪贴板内容。

可以做什么
Onsense 是 onSense Android 应用在电脑端的 stdio MCP 代理。工具包括 get_live_frame(获取当前摄像头画面)、read_sensors(读取电量、环境光、加速度计)、recent_photos 与 get_photo(浏览和获取手机照片)、rename_photo(重命名已获取的文件)、get_reference(获取手机指定的摄像头画面、照片或任意文件),以及 get_cam_fps/set_cam_fps(读取和设置摄像头帧率)。可选的 clip 桥接守护进程监听 8770 端口,可将手机上的图片、文件和剪贴板内容推送到电脑,启用后也可拉取电脑剪贴板。
适用场景
当电脑上的助手需要来自附近 Android 手机的实时画面或传感器数据,或需要在手机与电脑之间传输照片、文件和剪贴板内容时使用。适合不希望使用云中转和 ADB 的本地隐私场景。
运行要求
通过 uvx 在本地运行(uv 会自动下载托管的 Python)。需要手机安装 onSense Android 应用并与电脑处于同一本地 Wi-Fi 网络,需要兼容 MCP 的 stdio 客户端,并需一次性配对,将手机地址和令牌保存到 ~/.onsense/pair.json。可选环境变量包括 PHONE_BASE、PHONE_TOKEN、ONSENSE_CLIP_DIR、ONSENSE_CLIP_MAX_MB、ONSENSE_CLIP_ALLOW_PULL、ONSENSE_CLIP_SET_CLIPBOARD 和 ONSENSE_TEST_FRAME。
安装前请注意
配对令牌是保存在 ~/.onsense/pair.json 中的凭据,用于 HMAC 签名和 AES-256-GCM 加密请求,应妥善保管。clip 守护进程绑定所有网络接口,并在应用层拒绝非私有 IP 连接,不要将其暴露到互联网。剪贴板注入和电脑到手机的剪贴板拉取默认关闭,启用后手机可读取或覆盖电脑剪贴板。获取的照片和文件会写入磁盘,大文件传输会在内存中缓冲。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Onsense,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

onsense — Phone Camera, Sensors & Files for PC AI Agents

Don't describe it. Let your AI see it. onsense is the PC-side MCP broker for the onSense Android app: run uvx onsense pair on your PC, and any MCP-capable AI — Claude Code, Claude Desktop, Codex, or your own agent — can see through your phone's camera, read its sensors, and move files & clipboard both ways. No cloud relay. No ADB.

[onSense demo — Claude Code reads the phone's sensors and camera through onSense]

Claude Code, running on the PC, reads the phone's sensors and looks through its camera to answer — live, over local Wi-Fi.

[onSense demo — Codex does the same through onSense]

…and the same with Codex. onSense is a standard MCP server, so any MCP client works.


Architecture

text
Android phone (onSense app)           PC (this package)           AI client  HTTP provider :8080        ←→    stdio MCP broker          Claude / Codex / …  camera frames, photos,           onsense serve               natural-language or  sensors, QR pairing              onsense clip :8770          /onsense tool calls
  • The phone runs an HTTP provider on port 8080. It exposes camera frames, recent photos, and sensor readings, all gated by a pairing token.
  • The PC package (onsense) is a stdio MCP broker. It translates MCP tool calls from your AI client into HTTP requests to the phone.
  • Discovery uses mDNS (_onsense._tcp.local.). If the phone's IP changes, the broker rediscovers it automatically — no manual reconfiguration needed.
  • An optional clip bridge daemon on port 8770 lets the phone push camera frames, files, and clipboard content to the PC (and, if enabled, lets the phone pull from the PC clipboard).

Requirements

  • uv (provides uvx; downloads a managed Python automatically — no separate Python install needed)
  • The onSense Android app installed on a phone on the same local Wi-Fi network as your PC
  • An MCP-compatible AI client such as Claude Code, Codex, or any stdio MCP client

Quick Start

0. Fresh PC without uv? Use the app's setup helper (recommended)

On a clean PC, uvx doesn't exist yet and the command below will fail with "'uvx' is not recognized". The easiest fix: install the onSense app first, tap "Start PC setup helper", and open the shown address on your PC. It gives you a one-line command that installs uv, pairs, and registers the MCP server in one go — and because the PC connects out to the phone, it also sidesteps the Windows firewall entirely.

Prefer installing uv yourself? One line:

powershell
# Windows (PowerShell)irm https://astral.sh/uv/install.ps1 | iex$env:Path = "$env:USERPROFILE\.local\bin;$env:Path"   # make uvx visible in this same shell
bash
# macOS / Linuxcurl -LsSf https://astral.sh/uv/install.sh | shexport PATH="$HOME/.local/bin:$PATH"

1. Pair your phone

Run this once. The PC prints a QR code; scan it from the onSense app ("Scan PC QR"). The phone pushes its address and token to the PC, which registers the MCP server automatically.

bash
uvx onsense pair

After pairing, restart your AI client once so it picks up the new onsense MCP server.

2. Use it

Ask your AI client naturally:

"Take a photo of what's in front of my phone." "What are the current sensor readings?" "Show me the last 5 photos on my phone."

The MCP tools are called automatically. In Claude Code you can also use the bundled /onsense slash command (installed during pairing).

3. Diagnose problems

bash
uvx onsense doctor           # checks Python, uv, MCP, Claude registration, mDNS, phone reachabilityuvx onsense doctor --base http://192.168.1.5:8080 --token YOUR_PAIRING_TOKEN

Windows: QR scan times out?

The #1 cause is the Windows firewall dropping the phone's inbound connection:

  • If your Wi-Fi network profile is Public, inbound traffic is blocked hard. Switch it to Private (Settings → Network → your Wi-Fi → Network profile), or just use the app's PC setup helper, which needs no inbound port at all.

  • On a Private network, add a durable allow rule once (run as administrator):

    powershell
    uvx onsense pair --fix-firewall

    The first-run firewall popup is program-path-scoped and uvx's ephemeral paths silently invalidate it — the port-scoped rule above (TCP 8765–8774, Private) is what actually sticks.

  • If port 8765 is taken, pair automatically falls back to the next free port (up to 8774) and the QR reflects the real port — no action needed.


Subcommands

CommandWhat it does
uvx onsense pairDisplay a QR code on the PC; phone scans it and pushes {base, token}; registers MCP automatically
uvx onsense pair "onsense://pair?base=...&token=..."Parse a pairing URI directly (phone-displayed QR → manual copy)
uvx onsense pair --img screenshot.pngDecode a pairing QR from a screenshot file (requires opencv)
uvx onsense serveRun the MCP server (stdio). Also starts the clip daemon automatically unless --no-clip is passed
uvx onsense serve --no-clipRun the MCP server only, without starting the clip daemon
uvx onsense clipRun the clip bridge daemon standalone (port 8770)
uvx onsense clip --allow-pullEnable phone→pull: phone can GET /clip to retrieve the PC clipboard
uvx onsense clip --set-clipboardAuto-inject received content into the PC OS clipboard (off by default)
uvx onsense pair --fix-firewall(Windows, admin) Add the durable port-scoped firewall rule, then pair as usual
uvx onsense doctorDiagnose installation, connectivity, and phone reachability
uvx onsense statsShow local-only activation stats (--json, --reset). Nothing is uploaded automatically

Other MCP clients (Claude Desktop, Codex, …)

uvx onsense pair auto-registers the server with Claude Code (via claude mcp add) — this one-line auto-setup is Claude Code-specific. The MCP server itself is standard stdio MCP, so any MCP-compatible client works once you add it manually. Run uvx onsense pair once first: it saves your phone's address and token to ~/.onsense/pair.json, which the server reads at request time — so you don't put the token in each client's config, and the phone's IP is auto-tracked via mDNS.

Claude Desktop — add to claude_desktop_config.json:

json
{ "mcpServers": { "onsense": { "command": "uvx", "args": ["onsense", "serve"] } } }

Codex — register via the CLI (verified with Codex CLI 0.142.5):

bash
codex mcp add onsense -- uvx onsense serve

Codex sandbox note: Codex's default sandbox blocks network access, so the MCP server can't reach your phone and tool calls fail silently. Run Codex with network access enabled (e.g. --sandbox danger-full-access, or a sandbox policy that permits network) so onsense can talk to the phone on your LAN.

or add to ~/.codex/config.toml:

toml
[mcp_servers.onsense]command = "uvx"args = ["onsense", "serve"]

Restart the client once after adding the server. Any other stdio MCP client works the same way — point it at uvx onsense serve.


MCP Tools

These tools are exposed to your AI client after pairing:

ToolDescription
get_live_frame()Capture the current camera frame from the phone (returns JPEG image)
read_sensors()Return phone sensor readings as JSON: battery level/charging state, ambient light (lux), accelerometer (x/y/z)
recent_photos(limit=10)List recent photos on the phone: id, name, date_added, size, width, height
get_photo(id, max_width=1024, save_original=False)Fetch a specific photo by id (downscaled to max_width); use ids from recent_photos. Also saves it to the same Downloads folder as get_reference and returns the path, so the image survives the conversation. save_original=True archives full resolution instead of the downscaled copy
rename_photo(path, name)Rename a fetched file to describe what the image actually shows (photo_1000024531.jpg → whiteboard_sprint_plan.jpg). The AI calls this right after viewing, so it costs no extra tokens
get_reference()Fetch whatever the phone has designated as its reference source — a live camera frame, a captured photo, or an arbitrary file (incl. non-images) — saved to disk with path + metadata. The core of the file/capture bridge
get_cam_fps()Read the phone's current camera FPS setting (15 = high-performance, 2 = balanced, 0 = on-demand)
set_cam_fps(fps)Set the phone's camera FPS: 15 (high-performance), 2 (balanced, recommended), or 0 (power-saving / on-demand)

If the phone's IP changes, the broker retries using mDNS autodiscovery before surfacing an error.


Clip Bridge (Phone ↔ PC File & Clipboard)

onsense serve automatically starts a clip daemon on port 8770. You can also run it standalone with onsense clip.

Phone → PC push (POST /clip)

The onSense Android app can push content to the PC:

  • Images are saved to disk as latest.jpg (in ONSENSE_CLIP_DIR, default <tempdir>/onsense/).
  • Text files are saved to disk.
  • Other files (video, PDF, etc.) are saved to disk by filename.
  • If --set-clipboard is active, images and text are also injected into the PC OS clipboard so you can paste with Ctrl+V immediately.

By default, --set-clipboard is off — files are saved to disk but the clipboard is not touched.

PC → Phone pull (GET /clip)

Off by default. Enable with:

bash
uvx onsense clip --allow-pull

When enabled, the phone can GET /clip to retrieve the current PC clipboard content (copied files first, then images, then text). Returns 204 if the clipboard is empty.

Ports and environment variables

VariableDefaultPurpose
PHONE_BASE(from pairing)Phone HTTP base URL, e.g. http://192.168.1.5:8080
PHONE_TOKEN(from pairing)Pairing auth token
ONSENSE_CLIP_DIR<tempdir>/onsenseDirectory where pushed files are saved
ONSENSE_CLIP_MAX_MB200Maximum incoming file size in MB (0 = unlimited)
ONSENSE_CLIP_ALLOW_PULL0Set to 1 to enable PC→phone pull without the CLI flag
ONSENSE_CLIP_SET_CLIPBOARD0Set to 1 to auto-inject into OS clipboard without the CLI flag
ONSENSE_TEST_FRAME(unset)Local JPEG path returned by get_live_frame when phone is unreachable

Security

Local network only. The PC-side services bind to all interfaces but reject connections from non-private IP addresses at the application layer. They are not intended to be exposed to the internet.

HMAC request signing. The pairing token is never sent in cleartext. Every authenticated request is signed with HMAC-SHA256 over METHOD\npath\ntimestamp\nnonce\nalgorithm, keyed by a signing key derived from the pairing token via HKDF-SHA256 (a key separate from the encryption key), and carries X-Ts / X-Nonce / X-Sig / X-Enc headers. Servers verify in constant time, reject timestamps outside a ±300 s window, and reject reused nonces — so a sniffed request cannot be replayed and the token cannot be stolen off the wire. New Android installs generate a 128-bit random token, stored on the phone and in ~/.onsense/pair.json (chmod 600) after pairing. (The /health endpoint is unauthenticated.) See PROTOCOL.md for the exact wire format.

Pull and clipboard injection are off by default. GET /clip (phone pulls PC clipboard) and OS clipboard auto-injection (phone push → Ctrl+V) are disabled unless you explicitly pass --allow-pull or --set-clipboard.

Encrypted bodies (AES-256-GCM). Sensitive payloads — camera frames, photos, sensor data, files, and clipboard content — are encrypted between the phone and your PC with AES-256-GCM (no cloud in between, so there is no third party to decrypt them). The key is derived from the pairing token via HKDF-SHA256 (a key separate from the signing key); each message uses a fresh 96-bit nonce, and the GCM tag authenticates the body and binds it to its request (so tampering or response substitution is rejected). A passive sniffer on the same Wi-Fi sees only ciphertext. Low-sensitivity metadata stays plaintext: the open /version and /health endpoints, HTTP error responses, and the saved-file path returned after a push. (Note: large transfers currently buffer the body in memory while encrypting/decrypting — chunked streaming for very large files is a future step. Transport-level TLS is also a possible future hardening.)

File size cap. Incoming pushes are rejected if they exceed ONSENSE_CLIP_MAX_MB (default 200 MB). Set to 0 to remove the cap.

Reporting a vulnerability. Please report security issues privately — see SECURITY.md. Do not open a public issue for security reports.


License

MIT. See LICENSE.

来源:README.md,提交 8027d37

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

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

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分