Back to MCP directory
publicPublicdnsLocal runtime

HarmonyOS-mcp-server

这是一个用于操控HarmonyOS设备的MCP服务器项目,支持通过Claude Desktop或openai-agents SDK进行设备操作。

article

README

🚀 HarmonyOS MCP 服务器

这是一个用于操作 HarmonyOS 设备的 MCP 服务器,借助它可以方便地对 HarmonyOS 设备进行相关操作。

🚀 快速开始

📦 安装指南

  1. 克隆此仓库
git clone https://github.com/XixianLiang/HarmonyOS-mcp-server.git
cd HarmonyOS-mcp-server
  1. 设置环境
uv python install 3.13
uv sync

💻 使用示例

基础用法

你可以使用 Claude Desktop 来尝试我们的工具。

高级用法

你也可以使用 openai-agents SDK 来尝试此 MCP 服务器。以下是一个示例:

"""
示例:使用 Openai-agents SDK 调用 HarmonyOS-mcp-server
"""
import asyncio
import os

from agents import Agent, Runner, gen_trace_id, trace
from agents.mcp import MCPServerStdio, MCPServer

async def run(mcp_server: MCPServer):
    agent = Agent(
        name="Assistant",
        instructions="使用工具来操作 HarmonyOS 设备并完成任务。",
        mcp_servers=[mcp_server],
    )

    message = "在手机上启动 `settings` 应用"
    print(f"运行:{message}")
    result = await Runner.run(starting_agent=agent, input=message)
    print(result.final_output)


async def main():

    # 使用异步上下文管理器初始化服务器
    async with MCPServerStdio(
        params={
            "command": "<...>/bin/uv",
            "args": [
                "--directory",
                "<...>/harmonyos-mcp-server",
                "run",
                "server.py"
            ]
        }
    ) as server:
        trace_id = gen_trace_id()
        with trace(workflow_name="MCP HarmonyOS", trace_id=trace_id):
            print(f"查看跟踪:https://platform.openai.com/traces/trace?trace_id={trace_id}\n")
            await run(server)


if __name__ == "__main__":
    asyncio.run(main())
help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client