mobile-mcp-ai 2.5.3__py3-none-any.whl → 2.5.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mobile_mcp/mcp_tools/mcp_server.py +37 -2
- {mobile_mcp_ai-2.5.3.dist-info → mobile_mcp_ai-2.5.4.dist-info}/METADATA +1 -1
- {mobile_mcp_ai-2.5.3.dist-info → mobile_mcp_ai-2.5.4.dist-info}/RECORD +7 -7
- {mobile_mcp_ai-2.5.3.dist-info → mobile_mcp_ai-2.5.4.dist-info}/WHEEL +0 -0
- {mobile_mcp_ai-2.5.3.dist-info → mobile_mcp_ai-2.5.4.dist-info}/entry_points.txt +0 -0
- {mobile_mcp_ai-2.5.3.dist-info → mobile_mcp_ai-2.5.4.dist-info}/licenses/LICENSE +0 -0
- {mobile_mcp_ai-2.5.3.dist-info → mobile_mcp_ai-2.5.4.dist-info}/top_level.txt +0 -0
|
@@ -100,9 +100,17 @@ class MobileMCPServer:
|
|
|
100
100
|
|
|
101
101
|
async def initialize(self):
|
|
102
102
|
"""延迟初始化设备连接"""
|
|
103
|
-
#
|
|
103
|
+
# 如果已成功初始化,检查连接是否仍然有效
|
|
104
104
|
if self._initialized and self.tools is not None:
|
|
105
|
-
|
|
105
|
+
# 验证设备连接是否仍然有效
|
|
106
|
+
if self._is_connection_valid():
|
|
107
|
+
return
|
|
108
|
+
else:
|
|
109
|
+
# 连接已失效,重置状态
|
|
110
|
+
print("⚠️ 检测到设备连接已断开,正在重新连接...", file=sys.stderr)
|
|
111
|
+
self._initialized = False
|
|
112
|
+
self.client = None
|
|
113
|
+
self.tools = None
|
|
106
114
|
|
|
107
115
|
platform = self._detect_platform()
|
|
108
116
|
|
|
@@ -122,6 +130,33 @@ class MobileMCPServer:
|
|
|
122
130
|
self._last_error = error_msg # 保存错误信息
|
|
123
131
|
# 不设置 _initialized = True,下次调用会重试
|
|
124
132
|
|
|
133
|
+
def _is_connection_valid(self) -> bool:
|
|
134
|
+
"""检查设备连接是否仍然有效"""
|
|
135
|
+
try:
|
|
136
|
+
if self.client is None:
|
|
137
|
+
return False
|
|
138
|
+
|
|
139
|
+
# Android: 检查 u2 连接
|
|
140
|
+
if hasattr(self.client, 'u2') and self.client.u2:
|
|
141
|
+
# 尝试获取设备信息,如果失败说明连接断开
|
|
142
|
+
self.client.u2.info
|
|
143
|
+
return True
|
|
144
|
+
|
|
145
|
+
# iOS: 检查 wda 连接
|
|
146
|
+
if hasattr(self.client, 'wda') and self.client.wda:
|
|
147
|
+
self.client.wda.status()
|
|
148
|
+
return True
|
|
149
|
+
|
|
150
|
+
# iOS (通过 _ios_client)
|
|
151
|
+
if hasattr(self.client, '_ios_client') and self.client._ios_client:
|
|
152
|
+
if hasattr(self.client._ios_client, 'wda') and self.client._ios_client.wda:
|
|
153
|
+
self.client._ios_client.wda.status()
|
|
154
|
+
return True
|
|
155
|
+
|
|
156
|
+
return False
|
|
157
|
+
except Exception:
|
|
158
|
+
return False
|
|
159
|
+
|
|
125
160
|
def _detect_platform(self) -> str:
|
|
126
161
|
"""自动检测设备平台"""
|
|
127
162
|
platform = os.getenv("MOBILE_PLATFORM", "").lower()
|
|
@@ -19,14 +19,14 @@ mobile_mcp/core/utils/logger.py,sha256=XXQAHUwT1jc70pq_tYFmL6f_nKrFlYm3hcgl-5RYR
|
|
|
19
19
|
mobile_mcp/core/utils/operation_history_manager.py,sha256=gi8S8HJAMqvkUrY7_-kVbko3Xt7c4GAUziEujRd-N-Y,4792
|
|
20
20
|
mobile_mcp/core/utils/smart_wait.py,sha256=PvKXImfN9Irru3bQJUjf4FLGn8LjY2VLzUNEl-i7xLE,8601
|
|
21
21
|
mobile_mcp/mcp_tools/__init__.py,sha256=xkro8Rwqv_55YlVyhh-3DgRFSsLE3h1r31VIb3bpM6E,143
|
|
22
|
-
mobile_mcp/mcp_tools/mcp_server.py,sha256=
|
|
22
|
+
mobile_mcp/mcp_tools/mcp_server.py,sha256=wqNOkjWYxxPYTAjU8e8yn8EyeRtO9NMhPTqGZ18jfnM,47471
|
|
23
23
|
mobile_mcp/utils/__init__.py,sha256=8EH0i7UGtx1y_j_GEgdN-cZdWn2sRtZSEOLlNF9HRnY,158
|
|
24
24
|
mobile_mcp/utils/logger.py,sha256=Sqq2Nr0Y4p03erqcrbYKVPCGiFaNGHMcE_JwCkeOfU4,3626
|
|
25
25
|
mobile_mcp/utils/xml_formatter.py,sha256=uwTRb3vLbqhT8O-udzWT7s7LsV-DyDUz2DkofD3hXOE,4556
|
|
26
26
|
mobile_mcp/utils/xml_parser.py,sha256=QhL8CWbdmNDzmBLjtx6mEnjHgMFZzJeHpCL15qfXSpI,3926
|
|
27
|
-
mobile_mcp_ai-2.5.
|
|
28
|
-
mobile_mcp_ai-2.5.
|
|
29
|
-
mobile_mcp_ai-2.5.
|
|
30
|
-
mobile_mcp_ai-2.5.
|
|
31
|
-
mobile_mcp_ai-2.5.
|
|
32
|
-
mobile_mcp_ai-2.5.
|
|
27
|
+
mobile_mcp_ai-2.5.4.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
|
|
28
|
+
mobile_mcp_ai-2.5.4.dist-info/METADATA,sha256=EUiIZ3uxIiyK-P9Sf558k8nu6dAWnl1U6mcjBby0Lso,9745
|
|
29
|
+
mobile_mcp_ai-2.5.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
30
|
+
mobile_mcp_ai-2.5.4.dist-info/entry_points.txt,sha256=KB_FglozgPHBprSM1vFbIzGyheFuHFmGanscRdMJ_8A,68
|
|
31
|
+
mobile_mcp_ai-2.5.4.dist-info/top_level.txt,sha256=lLm6YpbTv855Lbh8BIA0rPxhybIrvYUzMEk9OErHT94,11
|
|
32
|
+
mobile_mcp_ai-2.5.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|