Mobile Agent Guardian

Mobile Agent Guardian

A five-level safety and verification layer for embodied mobile agents that provides auditable, secure phone control through vision classification, verify-after-act loops, and cryptographic anchoring.

Category
访问服务器

README

Mobile Agent Guardian

A five-level safety and verification layer for embodied mobile agents running in pi.

Mobile Agent Guardian turns raw Appium/MCP phone control into an auditable, verified protocol:

observe → classify → authorize → act → verify → record → anchor

It was designed for the unusual same-device flow where pi runs in Termux and controls that same Android phone through wireless ADB and Appium. It also works when Appium targets another Android or iOS device.

Architecture

                     ┌──────────────────────────────────────┐
                     │           Planning Agent              │
                     │  (decomposes tasks, delegates work)   │
                     └────────┬────────────────┬────────────┘
                              │ delegation     │ delegation
                              │ token          │ token
                     ┌────────▼────────┐  ┌────▼───────────┐
                     │  Mobile Worker  │  │  Browser Worker │
                     │  (Appium MCP)   │  │  (Playwright)   │
                     └────────┬────────┘  └────┬───────────┘
                              │                │
                     ┌────────▼────────────────▼───────────┐
                     │         Mobile Agent Guardian        │
                     │                                      │
                     │  L1  Vision classifier               │
                     │  L2  Verify-after-act loop            │
                     │  L3  Playwright policy bridge         │
                     │  L4  Cryptographic anchoring          │
                     │  L5  Multi-agent delegation           │
                     │                                      │
                     │  Policy · Audit chain · Redaction     │
                     └──────────┬───────────────┬──────────┘
                                │               │
                     ┌──────────▼──┐  ┌─────────▼──────────┐
                     │ Appium MCP  │  │ Remote Playwright   │
                     │ UiAutomator │  │ (Modal / headless)  │
                     └──────┬──────┘  └─────────┬──────────┘
                            │                   │
                     ┌──────▼──────┐  ┌─────────▼──────────┐
                     │   Device    │  │  Cloud Chromium     │
                     │ (ADB/WiFi)  │  │  (DOM + JS + Net)   │
                     └─────────────┘  └────────────────────┘

Five levels

Level 1: Vision classifier (src/vision.ts)

Sends screenshots to an OpenAI-compatible vision endpoint for structured risk classification. Returns labels: login, credentials, consent, payment, destructive, safe. Falls back to text heuristics from accessibility output when no vision API is configured.

GUARDIAN_VISION_API_KEY=sk-... GUARDIAN_VISION_BASE_URL=https://api.openai.com/v1 GUARDIAN_VISION_MODEL=gpt-4o-mini

Level 2: Verify-after-act loop (src/verifier.ts)

After every non-trivial mutation, captures a post-action fingerprint, diffs against the pre-action state, and classifies the outcome as expected, unexpected, unchanged, failed, or timeout. Two consecutive unexpected outcomes freeze the verifier—blocking all further mutations until the human observes the screen or runs /mobile-guard unfreeze.

Level 3: Playwright bridge (src/playwright-bridge.ts)

Exposes guardian_browse for web DOM access through a remote Playwright MCP endpoint. All calls pass through Guardian's policy engine and are audited. Configure with:

GUARDIAN_PLAYWRIGHT_URL=https://your-workspace--pi-frontend-mcp-web.modal.run/mcp

Level 4: Cryptographic anchoring (src/anchor.ts)

Periodically posts the latest audit hash + sequence number to a remote append-only endpoint, signed with HMAC-SHA256 using a device-local secret. Enables third-party verification that no events were removed from the chain.

GUARDIAN_ANCHOR_URL=https://your-anchor-endpoint/api/anchor
GUARDIAN_ANCHOR_INTERVAL=50

Level 5: Multi-agent delegation (src/delegation.ts)

Authority tokens scope what sub-agents can do:

  • Allowed tool patterns (glob syntax)
  • Maximum risk ceiling (critical is never delegatable)
  • TTL and usage limits
  • Auto-revocation on policy violation (configurable violation threshold)

Tools: guardian_delegate, guardian_revoke, guardian_check_delegation.

Install

pi install git:github.com/salus-ryan/mobile-agent-guardian

Or test a checkout:

npm install
pi -e ./src/index.ts

Quick start

# Minimal: text heuristics only, no external dependencies
pi -e ./src/index.ts

# With vision classification
GUARDIAN_VISION_API_KEY=sk-... pi -e ./src/index.ts

# With remote Playwright
GUARDIAN_PLAYWRIGHT_URL=https://... pi -e ./src/index.ts

# Monitor mode (log without enforcing)
MOBILE_GUARD_MODE=monitor pi -e ./src/index.ts

Behavior

Observation and navigation remain low-friction. When screen content contains authentication, OAuth, credential, permission, financial, or destructive indicators, Guardian changes state:

  1. Classify: vision model or text heuristics label the screen.
  2. Gate: sensitive mutation requires a fresh observation (< 30s) and human confirmation.
  3. Act: the mutation executes.
  4. Verify: post-action fingerprint is compared against pre-action state.
  5. Freeze (if needed): two consecutive unexpected outcomes block further mutations.
  6. Record: every step is hashed into the tamper-evident audit chain.
  7. Anchor: periodically signed and posted to remote storage.

OAuth URLs trigger a human handoff boundary: the agent may open the provider, but subsequent taps or typing cross the guarded boundary.

Commands and tools

Name Type Purpose
/mobile-guard Command Show state, verifier, audit integrity
/mobile-guard unfreeze Command Clear verifier freeze
mobile_guard_status Tool Model-callable status and audit verification
guardian_browse Tool Policy-gated remote Playwright navigation
guardian_delegate Tool Create scoped delegation token
guardian_revoke Tool Revoke a delegation token
guardian_check_delegation Tool Check token authorization

Audit evidence

Logs are written with mode 0600 to:

~/.pi/agent/mobile-guardian/audit-YYYY-MM-DD.jsonl

Every record includes the previous record's SHA-256 hash. Editing, deleting, or reordering an interior event breaks verification. Raw page source and sensitive argument values are not stored; the log records hashes and byte counts.

Development

npm install
npm test        # 27 tests
npm run typecheck

Status

Reference implementation. Not a substitute for Android device policy, app sandboxing, or careful review of OAuth consent.

See THREAT_MODEL.md for security boundaries and limitations.

License

Apache-2.0

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选