Harmonyos

io.github.FadingLight9291117由 GitHub 帳號 FadingLight9291117 發布v1.0.3更新於 Oct 24, 2026

MCP server for HarmonyOS development - interact with projects, devices, and applications

已驗證STDIO僅桌面檔案與儲存開發者工具

概覽

AI 產生的概覽

針對 HarmonyOS 開發的在地 MCP 伺服器,讓助理查詢已連線裝置、專案設定、建置產物與已安裝應用程式。

可以做什麼
列出已連線的 HarmonyOS 裝置,並依裝置 ID 讀取型號、廠商、系統版本等詳細資訊。從 app.json5 讀取專案中繼資料,並列出專案各模組及其 HAP/HSP/HAR 類型。檢查建置產物是否存在,並列出產生的 HAP 與 HSP 檔案。列出裝置上已安裝的應用程式,並查看版本、安裝時間、是否為系統應用程式等詳細資訊。
適用情境
適合在開發 HarmonyOS 專案時,讓助理不必手動執行 hdc 指令就能查看裝置、專案結構、建置產物與已安裝應用程式。README 將其定位為快速唯讀查詢,建置與部署則交由 shell 指令完成。
執行需求
需要 Node.js 18 或更新版本,透過 npm 或 npx 在本機安裝。需安裝 HarmonyOS DevEco Studio,並確認其 hdc 命令列工具位於 PATH 中。查詢裝置與應用程式時,需以 USB 連接 HarmonyOS 裝置並開啟開發人員選項與 USB 偵錯。
安裝前請注意
裝置與應用程式查詢需要連接裝置並開啟 USB 偵錯,這會把裝置與已安裝應用程式的資訊暴露給助理。專案相關工具需要絕對專案路徑。伺服器本身只讀取資訊;建置、部署與啟動透過助理可能執行的 shell 指令完成,允許前請先確認這些操作。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Harmonyos,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

MCP HarmonyOS

npm: https://www.npmjs.com/package/mcp-harmonyos

[NPM Version] [GitHub Stars] [License]

A Model Context Protocol (MCP) server for HarmonyOS development. This server enables AI assistants like Claude to interact with HarmonyOS projects, devices, and applications.

Features

  • Device Management: List and query connected HarmonyOS devices
  • Project Information: Read project configuration, modules, and build outputs
  • Application Management: List and inspect installed applications on devices
  • Build Verification: Check build outputs and project structure

Prerequisites

  • Node.js 18+
  • HarmonyOS DevEco Studio (for hdc command-line tools)
  • hdc must be available in your PATH

Installation

Global Installation (Recommended)

bash
npm install -g mcp-harmonyos

Or use with npx

bash
npx mcp-harmonyos

Configuration

For OpenCode

Add to your ~/.config/opencode/opencode.json:

json
{  "$schema": "https://opencode.ai/config.json",  "mcp": {    "harmonyos": {      "type": "local",      "command": ["npx", "-y", "mcp-harmonyos"],      "enabled": true    }  }}

For Claude Desktop

Add to your Claude Desktop configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

json
{  "mcpServers": {    "harmonyos": {      "command": "mcp-harmonyos"    }  }}

Available Tools

Device Management

harmonyos_list_devices

List all connected HarmonyOS devices.

Returns: Array of devices with UDID and status

json
[  {    "udid": "7001005458323933328a01bcf4251a00",    "status": "connected"  }]
harmonyos_get_device_info

Get detailed information about a specific device.

Parameters:

  • deviceId (string): The device UDID

Returns: Device information including model, manufacturer, OS version, etc.

json
{  "udid": "7001005458323933328a01bcf4251a00",  "model": "HUAWEI Mate 60 Pro",  "brand": "HUAWEI",  "manufacturer": "HUAWEI",  "osVersion": "4.0.0",  "sdkVersion": "11",  "buildId": "Mate60Pro 4.0.0.96"}

Project Information

harmonyos_get_project_info

Get HarmonyOS project information from app.json5.

Parameters:

  • projectPath (string): Absolute path to the HarmonyOS project root

Returns: Project metadata including bundleName, version, and modules

json
{  "bundleName": "com.example.myapp",  "versionCode": 1000000,  "versionName": "1.0.0",  "minCompatibleVersionCode": 1000000,  "targetAPIVersion": 11,  "modules": ["entry", "library"]}
harmonyos_list_modules

List all modules in a project with their types (HAP/HSP/HAR).

Parameters:

  • projectPath (string): Absolute path to the HarmonyOS project root

Returns: Array of modules with name, type, and path

json
[  {    "name": "entry",    "type": "HAP",    "path": "/path/to/project/entry",    "srcPath": "entry"  },  {    "name": "library",    "type": "HSP",    "path": "/path/to/project/library",    "srcPath": "library"  }]
harmonyos_check_build_outputs

Check if build outputs exist and list them.

Parameters:

  • projectPath (string): Absolute path to the HarmonyOS project root

Returns: Build output information

json
{  "hasOutputs": true,  "outputDir": "/path/to/project/outputs",  "files": ["entry-default-signed.hap", "library-default-signed.hsp"],  "haps": ["entry-default-signed.hap"],  "hsps": ["library-default-signed.hsp"]}

Application Management

harmonyos_list_installed_apps

List all installed applications on a device.

Parameters:

  • deviceId (string): The device UDID

Returns: Array of installed applications

json
[  {    "bundleName": "com.example.myapp",    "versionCode": "1000000",    "versionName": "1.0.0"  }]
harmonyos_get_app_info

Get detailed information about an installed application.

Parameters:

  • deviceId (string): The device UDID
  • bundleName (string): The application bundle name

Returns: Detailed application information

json
{  "bundleName": "com.example.myapp",  "versionCode": "1000000",  "versionName": "1.0.0",  "uid": "20010044",  "installTime": "2026-02-15 10:30:00",  "updateTime": "2026-02-15 10:30:00",  "isSystemApp": false,  "isRemovable": true}

Usage Examples

With OpenCode

After configuring the MCP server, you can ask OpenCode questions like:

"List all connected HarmonyOS devices""What's the bundleName of the project in /path/to/my/project?""Check if there are build outputs in my project""List all installed apps on device 7001005458323933328a01bcf4251a00""Show me information about com.example.myapp on my device"

OpenCode will use the MCP tools to query information and can combine them with bash commands for building and deploying:

"Build the project and deploy to device"# OpenCode will:# 1. Use harmonyos_get_project_info to get bundleName# 2. Use bash: hvigorw assembleApp --no-daemon# 3. Use harmonyos_check_build_outputs to verify# 4. Use bash: hdc file send and bm install to deploy# 5. Use bash: aa start to launch the app

Design Philosophy

This MCP server follows the "lightweight query + external operations" pattern:

  • MCP tools provide fast, structured queries (device info, project metadata, app status)
  • Bash commands handle long-running operations (building, deploying)
  • AI assistants intelligently combine both for complete workflows

This design ensures:

  • ✅ Fast response times (all queries < 1 second)
  • ✅ No timeout issues with long builds
  • ✅ Clear error messages and logs
  • ✅ Easy to maintain and extend

Development

Build from Source

bash
git clone <your-repo>cd mcp-harmonyosnpm installnpm run buildnpm start

Project Structure

mcp-harmonyos/├── src/│   ├── server.ts              # Main MCP server implementation│   └── types/│       └── harmonyos-types.ts # TypeScript type definitions├── build/                      # Compiled JavaScript output├── package.json├── tsconfig.json└── README.md

Troubleshooting

"hdc command not found"

Make sure DevEco Studio is installed and hdc is in your PATH:

bash
# macOS/Linuxexport PATH="$PATH:/path/to/deveco-studio/tools"
# Windowsset PATH=%PATH%;C:\path\to\deveco-studio\tools

"No devices connected"

  1. Enable Developer Options on your device (tap Build Number 7 times)
  2. Enable USB Debugging
  3. Connect device via USB
  4. Run hdc list targets to verify connection

"app.json5 not found"

Make sure you provide the absolute path to the project root directory (where AppScope/app.json5 is located).

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Related Resources

來源:README.md,提交 72f0e79

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.0.3最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分