Skip to main content

No project description provided

Project description

HarmonyOS Dev MCP

harmonyos_dev_mcp is the current mainline HarmonyOS MCP service for device automation, app deployment, UI interaction, E2E support, and log-based validation.

What It Provides

This service exposes HarmonyOS automation capabilities as MCP tools so they can be called from:

  • MCP clients
  • AI agents
  • test platforms
  • custom automation scripts

Typical use cases:

  • build and install a HarmonyOS app
  • launch an app and verify the target window
  • find, click, input, swipe, and capture screenshots
  • wait for UI state changes
  • inspect the UI tree
  • query logs for errors or business markers

Requirements

  • Python 3.12+
  • DevEco Studio 5.0+
  • hdc
  • uv

Run

uv sync --all-packages
uv run harmonyos-dev-mcp

Tool Groups

  • General: list_devices, query_package, logs_query
  • Build: build_app, install_app, run_app, uninstall_app
  • UI: screenshot, click_element, long_press_element, input_text, swipe, drag, press_key, find_element
  • E2E: get_ui_tree, list_windows, wait_element

Parameter Docs

The detailed parameter reference is maintained here:

That document covers:

  • parameter names and types
  • defaults
  • required and optional inputs
  • mutual exclusion and dependency rules
  • key result fields
  • common error codes
  • minimal call examples

Important Call Notes

  • build_app is long-running. Set MCP tools/call timeout to at least 60s, and prefer 120s for cold builds.
  • build_app defaults to build_mode="debug", target="hap", and product="default".
  • build_app target="hnp" builds a normal HAP first, injects built HNP packages from the module hnp directory, and re-signs the output with SDK tools. It does not call project-local .bat, .ps1, or .sh scripts.
  • HNP signing reads build-profile.json5. If DevEco stores encrypted passwords there, set HAP_SIGN_PASSWORD, or set HAP_KEY_PASSWORD and HAP_STORE_PASSWORD, so hap-sign-tool.jar can sign with plaintext credentials.
  • If a project already defines hvigor signing in build-profile.json5, build_app returns the hvigor artifact directly.
  • If hvigor only produces an unsigned HAP and the project uses a project-local MDM signing flow, build_app tries project_root/hapsigner/2-<build_mode>-sign.bat.
  • query_package.info_type supports only list, abilities, main_ability, and permissions.
  • input_text.element_handle must be an object returned by find_element or wait_element, not a JSON string.
  • logs_query supports mode="errors" and mode="markers".
  • logs_query defaults to realtime sampling and does not fall back to historical logs unless fallback_to_historical=true.

Examples

Query installed packages:

result = await client.call_tool("query_package", {
    "device_id": "3QC0124C11000711",
    "info_type": "list"
})

Click an element using a handle from find_element:

element = await client.call_tool("find_element", {
    "device_id": "3QC0124C11000711",
    "text": "Login"
})

await client.call_tool("click_element", {
    "device_id": "3QC0124C11000711",
    "element_handle": element["structuredContent"]["result"]["elements"][0]["element_handle"]
})

Fetch the UI tree:

ui_tree = await client.call_tool("get_ui_tree", {
    "device_id": "3QC0124C11000711"
})

Result Shape

All tools return a unified MCP envelope:

{
  "content": [{"type": "text", "text": "tool_name: ok"}],
  "structuredContent": {
    "tool": "tool_name",
    "ok": true,
    "result": {},
    "error": null,
    "meta": {
      "request_id": "uuid",
      "timestamp": "2026-03-19T00:00:00+00:00",
      "duration_ms": 123
    }
  },
  "isError": false
}

Development

Run tests:

uv run pytest services/harmonyos_dev_mcp/tests/unit -v

Release 0.7.6

  • Added build_app target="hnp" for direct HNP HAP packaging and signing.
  • Uses the SDK app_packing_tool.jar and hap-sign-tool.jar instead of project-local build scripts.
  • Detects HNP packages under module hnp directories such as entry/hnp/arm64-v8a/*.hnp.
  • Returns artifact_source="hnp_direct" and a signed *-signed-hnp.hap output.
  • Added edge-case coverage for missing HNP packages, missing SDK packaging jars, missing hvigor packaging inputs, and ordinary target="hap" builds that should not trigger HNP repackaging.

Docs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

harmonyos_dev_mcp-0.7.6.tar.gz (100.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

harmonyos_dev_mcp-0.7.6-py3-none-any.whl (90.6 kB view details)

Uploaded Python 3

File details

Details for the file harmonyos_dev_mcp-0.7.6.tar.gz.

File metadata

  • Download URL: harmonyos_dev_mcp-0.7.6.tar.gz
  • Upload date:
  • Size: 100.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for harmonyos_dev_mcp-0.7.6.tar.gz
Algorithm Hash digest
SHA256 040bc01717b28adf5ac1f73ee57cab291034c1d8d8c1c236ab2ce45caa4b9aa4
MD5 c42767fdee2142dfbd64c408634a7af3
BLAKE2b-256 805cf32a5eb4e90e7133afbf051ced340186119e85d522ba563fb64195eb8436

See more details on using hashes here.

File details

Details for the file harmonyos_dev_mcp-0.7.6-py3-none-any.whl.

File metadata

File hashes

Hashes for harmonyos_dev_mcp-0.7.6-py3-none-any.whl
Algorithm Hash digest
SHA256 27cf8fe833d14433db3c5f669226aed9a1fa48c748499eb803d163d1997e7625
MD5 270c06d514b81144639e516ea7a94803
BLAKE2b-256 bab222ab23bd59486237fe822d0573f5cbc25a47e16d397d66e6b926f50c1e11

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page