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+
hdcuv
Run
uv sync
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_appis long-running. Set MCPtools/call timeoutto at least60s, and prefer120sfor cold builds.build_appdefaults tobuild_mode="debug",target="hap", andproduct="default".build_app target="hsp"builds a shared module through hvigor. Passmodule_namefor the shared module.build_app target="hap" include_hsp=truebuilds the base HAP, builds one or moretype="shared"HSP modules, injects them intoshared_libs/, and re-signs the HAP with SDK tools.- HAP builds with
include_hsp=truereturnhsp_output_pathsso callers can install the generated HSP files alongside the HAP when the device installer requires shared modules as separate install units. hsp_module_namesaccepts an explicit list of shared modules. When omitted or empty, the tool discovers all modules whosesrc/main/module.json5declarestype="shared".build_app target="hnp"builds a normal HAP first, injects built HNP packages from the modulehnpdirectory, and re-signs the output with SDK tools. It does not call project-local.bat,.ps1, or.shscripts.- HNP signing reads
build-profile.json5. If DevEco stores encrypted passwords there, setHAP_SIGN_PASSWORD, or setHAP_KEY_PASSWORDandHAP_STORE_PASSWORD, sohap-sign-tool.jarcan sign with plaintext credentials. - If a project already defines hvigor signing in
build-profile.json5,build_appreturns the hvigor artifact directly. - If hvigor only produces an unsigned HAP and the project uses a project-local MDM signing flow,
build_apptriesproject_root/hapsigner/2-<build_mode>-sign.bat. query_package.info_typesupports onlylist,abilities,main_ability, andpermissions.input_text.element_handlemust be an object returned byfind_elementorwait_element, not a JSON string.logs_querysupportsmode="errors"andmode="markers".logs_querydefaults to realtime sampling and does not fall back to historical logs unlessfallback_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.8.0
- Bundled the former
harmonyos-mcp-commoninfrastructure inside this package as an internal module. - Removed the unused
harmonyos_compile_mcpservice line from the repository and release flow. - Switched publishing to a single package:
harmonyos-dev-mcp.
Release 0.7.7
- Added
build_app target="hsp"for hvigor shared module builds. - Added
build_app target="hap" include_hsp=trueto build HSP modules, inject them undershared_libs/, and sign the integrated HAP with SDK tools. - Added auto-discovery for
type="shared"modules, plushsp_module_namesto select one or more shared modules. - Merged HSP
pack.infometadata into the repacked HAP and returnedhsp_output_pathsfor multi-file installation flows. - Added unit coverage for HSP module validation, HSP build command dispatch, and HAP repack/sign with
--shared-libs-path.
Release 0.7.6
- Added
build_app target="hnp"for direct HNP HAP packaging and signing. - Uses the SDK
app_packing_tool.jarandhap-sign-tool.jarinstead of project-local build scripts. - Detects HNP packages under module
hnpdirectories such asentry/hnp/arm64-v8a/*.hnp. - Returns
artifact_source="hnp_direct"and a signed*-signed-hnp.hapoutput. - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file harmonyos_dev_mcp-0.8.0.tar.gz.
File metadata
- Download URL: harmonyos_dev_mcp-0.8.0.tar.gz
- Upload date:
- Size: 114.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5307c69a1603194a435757d51b20077d3cb70b340a018e1830c1b6f06588872e
|
|
| MD5 |
3af03843a263ad08e5a4192261df6b91
|
|
| BLAKE2b-256 |
e7cb5d258d84d79707969260b5c883eadc42274386eb79f0812391c767c13589
|
File details
Details for the file harmonyos_dev_mcp-0.8.0-py3-none-any.whl.
File metadata
- Download URL: harmonyos_dev_mcp-0.8.0-py3-none-any.whl
- Upload date:
- Size: 106.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f616c06ad38ee35886ac371ec1edcbcda4a4534e42c0435133dad1064e0c5b80
|
|
| MD5 |
ca3d74cc1f0057ac8a659e62dc83ee23
|
|
| BLAKE2b-256 |
1402c135bb12b312fc16cd5d97cdf11ba044c0ffc04e8d2acdc99e79ecc0c83c
|