harmonyos-dev-mcp
Enables HarmonyOS device discovery, app build and deployment, UI automation, E2E inspection, and log validation through MCP tools.
README
HarmonyOS Dev MCP
harmonyos_dev_mcp provides HarmonyOS MCP tools for device discovery, app build and deployment, UI automation, E2E inspection, and log validation.
Links
- PyPI: harmonyos-dev-mcp
- Tool reference: docs/tool_reference.md
- Logs query guide: docs/logs_query.md
What It Provides
The package exposes 18 MCP tools:
Parameter notation:
name: requiredname?: optionalname*: conditionally required, depending on the selected mode or target
General tools:
| Tool | Parameters |
|---|---|
list_devices |
none |
query_package |
device_id?, bundle_name*, keyword?, info_type?="list" |
logs_query |
device_id?, logs?, input_file?, input_files?, lines?=100, level?, tag?, tag_search?, keyword?, domain?, pid?, package_name?, start_time?, end_time?, seconds?, save_path?, time_expr?, include_crash?=false, mode?="errors", marker_keywords?, fallback_to_historical?=false, realtime_wait_ms?=1000, context_lines?=0 |
Build tools:
| Tool | Parameters |
|---|---|
build_app |
project_path, build_mode?="debug", target?="hap", product?="default", module_name*, is_clean?=false, include_hsp?=false, hsp_module_names? |
install_app |
hap_path, device_id? |
run_app |
bundle_name, device_id?, ability_name?, module_name?, auto_detect?=true |
uninstall_app |
bundle_name, device_id? |
UI tools:
| Tool | Parameters |
|---|---|
screenshot |
device_id?, local_path?, display_id?=0, left*, top*, right*, bottom* |
click_element |
device_id?, x*, y*, element_handle*, text*, element_type*, element_id*, double_click?=false, bundle_name? |
long_press_element |
device_id?, x*, y*, element_handle*, text*, element_type*, element_id*, bundle_name? |
input_text |
device_id?, x*, y*, text, element_handle*, element_text*, element_type*, element_id*, bundle_name? |
swipe |
device_id?, from_x*, from_y*, to_x*, to_y*, direction*, speed?=600 |
drag |
device_id?, from_x, from_y, to_x, to_y, speed?=600 |
press_key |
device_id?, key |
find_element |
device_id?, text*, element_type*, element_id*, bundle_name?, window_id? |
E2E tools:
| Tool | Parameters |
|---|---|
get_ui_tree |
device_id?, bundle_name?, window_id? |
list_windows |
device_id?, bundle_name? |
wait_element |
device_id?, bundle_name?, window_id?, text*, element_type*, element_id*, state?="found", timeout_ms?=5000, interval_ms?=300 |
build_app supports HarmonyOS HAP, HAR, HSP, APP, and HNP build flows. HSP outputs can also be integrated into a HAP with include_hsp=true.
Detailed validation rules, result fields, errors, and examples are in the tool reference.
Layout
mcp_ho_dev/
|- src/harmonyos_dev_mcp/
| |- build/ # Hvigor build helpers, signing, packaging, and target handlers
| |- device/hdc/ # HDC device, package, app, file, and UI adapters
| |- logs/ # Log query parsing and history support
| |- runtime/ # Server factory and explicit MCP tool registration
| |- tools/ # Public MCP tool entrypoints
| |- ui/ # UI tree parsing, selectors, actions, and normalization
| |- utils/ # Compatibility wrappers
| `- _common/ # Shared runtime infrastructure bundled in this package
|- tests/unit/ # Unit tests grouped by domain
|- docs/ # Public tool and log query documentation
|- scripts/ # Release helpers
|- pyproject.toml # Project metadata and build config
|- uv.lock
|- README.md
Requirements
- Python 3.12+
- DevEco Studio 5.0+
- HarmonyOS SDK toolchains, including
hdc uv
Install
Install from PyPI:
pip install harmonyos-dev-mcp
Install from source for local development:
uv sync
Run
uv run harmonyos-dev-mcp
Check connected devices:
hdc list targets
Documentation
Build Examples
Build a debug HAP:
await build_app(r"C:\path\to\project", target="hap", build_mode="debug", product="default")
Build HSP modules and integrate them into a HAP:
await build_app(
r"C:\path\to\project",
target="hap",
build_mode="debug",
product="default",
include_hsp=True,
hsp_module_names=["library_one", "library_two"],
)
Build an HNP-injected HAP:
await build_app(r"C:\path\to\project", target="hnp", build_mode="debug", product="default")
Development
Run unit tests:
uv run pytest tests/unit -v
Run with coverage:
uv run pytest tests/unit -v --cov=harmonyos_dev_mcp
Build package artifacts:
uv build --out-dir dist --clear
Notes
build_appis a long-running tool. Set MCPtools/call timeoutto at least60s, and prefer120sfor cold builds.build_app target="hnp"builds a base HAP, injects module HNP packages fromentry/hnp, and signs the HAP through SDK packaging tools.build_app target="hsp"builds shared modules;build_app target="hap" include_hsp=truecan integrate one or more HSP outputs into the HAP.logs_querysupportserrorsandmarkersmodes.- The shared infrastructure that used to live in a separate common package is bundled in
harmonyos_dev_mcp._common.
License
Apache License 2.0
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.