Add Android hardware MCP module

VerifiedSafe

Guide to add or modify a hardware MCP module in an Android client, with strict rules and verification without the Android SDK.

Sby Skills Guide Bot
DevelopmentAdvanced
8/29/2026
Claude CodeCursor
#android#kotlin#mcp#json-rpc#mobile

Recommended for

Automated summary

Defines the contract for adding or modifying an in-process hardware MCP module in the Edison-Watch/mobile Android client, and how to verify its logic without the Android SDK.

Strengths

  • Clear module contract: a FooSource interface isolating all android.* access, a FooModule that is pure-JVM testable, and a matching unit test.
  • Concrete hard rules: every precondition failure stays in-band via JsonRpc.textToolResult, binary payloads use hex strings, and MissingPermission must be caught in the same function as the call site.
  • Actionable SDK-less verification recipe: a throwaway Gradle project in /tmp/scratch containing only LocalMcpModule.kt, the new module, and its test.
  • Points to existing modules (BatteryModule, UsbModule) as templates and lists the registration step in TunnelService.connect() plus the README bullet.

Limitations

  • Sandbox verification covers neither lint nor real Android wiring; only CI confirms those.
  • Tightly coupled to one repository and its exact file paths (ai/sealgate/stdiod/mcp/), so it is not portable as-is.
  • Assumes solid Kotlin, JSON-RPC, and async-bridging knowledge (CountDownLatch, BlockingQueue, ConcurrentHashMap).
When to use it

Use it when creating or editing a *Module under app/.../mcp/ in this Android client, wiring a new *Source, or sanity-checking module logic when no Android SDK is available.

When not to use it

Do not use it for general Android work, for adding an external subprocess-based MCP server, or for diagnosing lint/build failures other than MissingPermission.

Security analysis

Safe
Quality score88/100

The skill is documentation for adding an Android MCP module and verifying it without the SDK. It contains build commands like gradle test and git pull as examples, but no destructive, exfiltrating, or obfuscated actions. It does not instruct disabling safety or handling secrets. No meaningful execution risk.

No concerns found

How this analysis is made

Examples

Add a new hardware module
Add a TorchModule to the mobile MCP client following the module contract: a TorchSource interface, a pure-JVM TorchModule with toolDescriptors and dispatch, an AndroidTorchSource, and a TorchModuleTest with a fake source. Register it in TunnelService.connect() and add the README bullet.
Fix a lint MissingPermission error
Lint fails with MissingPermission on my BLE GATT helper in AndroidBluetoothSource. Restructure it so the SecurityException is caught in the same function that makes the call, returning an in-band textToolResult error instead.
Verify logic without the Android SDK
Set up a /tmp/scratch Gradle project with kotlin("jvm") and the serialization plugin at the version from gradle/libs.versions.toml, copy in only LocalMcpModule.kt, UsbModule.kt and its test plus a hand-written FakeUsbSource, and run gradle test.

name: add-mobile-module description: Add or modify an in-process hardware MCP module in the Edison-Watch/mobile Android client, and verify its logic without the Android SDK. Use when adding or editing a *Module under app/.../mcp/, wiring a new *Source, hitting a lint MissingPermission error, or when ./gradlew fails because there is no Android SDK in the sandbox.

Add a mobile hardware MCP module

The mobile app exposes each phone capability as an in-process "MCP server": a Kotlin module answering MCP JSON-RPC directly (no subprocess). This skill is the contract + how to verify it in the SDK-less cloud sandbox.

The module contract

Two files per module, plus a test.

  1. FooModule.kt in app/src/main/java/ai/sealgate/stdiod/mcp/

    • A FooSource interface holding all android.* access (so module logic is pure JVM, testable with a fake source).
    • class FooModule(private val source: FooSource) : BaseMcpModule() (BaseMcpModule + JsonRpc live in LocalMcpModule.kt).
    • Override val name (the server name the backend addresses) and toolDescriptors(): JsonElement (the tools/list array). Dispatch tool calls in the body — copy BatteryModule (simplest) or UsbModule.
  2. AndroidFoo.kt / AndroidFooSource.kt — the real FooSource implementation over the Android APIs. This file is not JVM-compilable and is excluded from scratch verification (below).

  3. FooModuleTest.kt in app/src/test/java/ai/sealgate/stdiod/mcp/ — drive the module with a fake FooSource; assert on the JSON it returns.

Then register it in TunnelService.connect():

FooModule(AndroidFooSource(this)),

And add a bullet to README.md's module list.

Hard rules

  • Every precondition failure is in-band, never a crash and never a JSON-RPC error: return JsonRpc.textToolResult(id, text, isError = true) (missing permission, device not found, adapter off, …). The gateway must always get a tool result.
  • Binary payloads travel as hex strings in tool args/results (see BluetoothModule/UsbModule), not base64, not byte arrays.
  • lint MissingPermission is checked per call-site and does NOT follow a try/catch (SecurityException) up into callers. A permission-requiring call (BLE GATT, UsbManager, etc.) must catch SecurityException in the same function that makes the call. If lint fails only on a helper, wrap the helper's body in its own try/catch returning an error reason. This is one of the few things only the real toolchain (CI) catches — JVM tests won't.
  • Async Android callbacks bridge to the synchronous handle() with latches/timeouts (CountDownLatch for GATT) or reader threads + BlockingQueue (SPP, notifications). Hold live connections in a ConcurrentHashMap keyed by address/id.

Verify without the Android SDK

The cloud sandbox has no Android SDK (dl.google.com is proxy-blocked), so ./gradlew assembleDebug|lintDebug|testDebugUnitTest all fail locally. CI is the real gate. To sanity-check module + test logic before pushing, compile just the pure-JVM slice in a throwaway Gradle project:

/tmp/scratch/
  build.gradle.kts        # kotlin("jvm") + kotlin("plugin.serialization")
  settings.gradle.kts
  src/main/kotlin/  <- LocalMcpModule.kt + FooModule.kt   (NOT AndroidFoo*.kt)
  src/test/kotlin/  <- FooModuleTest.kt + a hand-written FakeFooSource
  • build.gradle.kts: kotlin("jvm") and kotlin("plugin.serialization") at the same version as kotlin in gradle/libs.versions.toml; deps kotlinx-serialization-json (1.7.x is fine) and junit:junit:4.13.2.
  • Copy in only LocalMcpModule.kt, your FooModule.kt, and the test. Exclude every Android*.kt — those need the SDK.
  • gradle test. Green here means the JSON/dispatch logic holds; it does not cover lint or Android wiring — push and let CI confirm those.

After push

CI ("Build & unit test") runs assembleDebug + testDebugUnitTest + lintDebug. Green there is the real pass. Then on a device: git pull && ./gradlew installDebug. The new tools appear in MCP Tester once a server row of name is registered and the tool list refreshed.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/add-android-hardware-mcp-module-mte1lgrn/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/add-android-hardware-mcp-module-mte1lgrn' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/add-android-hardware-mcp-module-mte1lgrn/download' --output '.skill-downloads/add-android-hardware-mcp-module-mte1lgrn/SKILL.md.part' && mv '.skill-downloads/add-android-hardware-mcp-module-mte1lgrn/SKILL.md.part' '.skill-downloads/add-android-hardware-mcp-module-mte1lgrn/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/add-android-hardware-mcp-module-mte1lgrn/SKILL.md' && test -s '.skill-downloads/add-android-hardware-mcp-module-mte1lgrn/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/add-mobile-module' && cp -R '.skill-downloads/add-android-hardware-mcp-module-mte1lgrn' '.claude/skills/add-mobile-module'

Cursor
test -f '.skill-downloads/add-android-hardware-mcp-module-mte1lgrn/SKILL.md' && test -s '.skill-downloads/add-android-hardware-mcp-module-mte1lgrn/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/add-mobile-module' && cp -R '.skill-downloads/add-android-hardware-mcp-module-mte1lgrn' '.cursor/skills/add-mobile-module'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/add-android-hardware-mcp-module-mte1lgrn'

openskills read 'add-android-hardware-mcp-module-mte1lgrn'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/add-android-hardware-mcp-module-mte1lgrn/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills