mobile-mcp-ai 2.5.10__tar.gz → 2.6.0__tar.gz

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.
Files changed (47) hide show
  1. {mobile_mcp_ai-2.5.10/mobile_mcp_ai.egg-info → mobile_mcp_ai-2.6.0}/PKG-INFO +1 -1
  2. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/core/basic_tools_lite.py +126 -9
  3. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0/mobile_mcp_ai.egg-info}/PKG-INFO +1 -1
  4. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/setup.py +1 -1
  5. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/LICENSE +0 -0
  6. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/MANIFEST.in +0 -0
  7. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/README.md +0 -0
  8. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/__init__.py +0 -0
  9. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/config.py +0 -0
  10. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/core/__init__.py +0 -0
  11. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/core/device_manager.py +0 -0
  12. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/core/dynamic_config.py +0 -0
  13. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/core/ios_client_wda.py +0 -0
  14. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/core/ios_device_manager_wda.py +0 -0
  15. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/core/mobile_client.py +0 -0
  16. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/core/template_matcher.py +0 -0
  17. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/core/templates/close_buttons/auto_x_0112_151217.png +0 -0
  18. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/core/templates/close_buttons/auto_x_0112_152037.png +0 -0
  19. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/core/templates/close_buttons/auto_x_0112_152840.png +0 -0
  20. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/core/templates/close_buttons/auto_x_0112_153256.png +0 -0
  21. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/core/templates/close_buttons/auto_x_0112_154847.png +0 -0
  22. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/core/templates/close_buttons/gray_x_stock_ad.png +0 -0
  23. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/core/utils/__init__.py +0 -0
  24. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/core/utils/logger.py +0 -0
  25. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/core/utils/operation_history_manager.py +0 -0
  26. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/core/utils/smart_wait.py +0 -0
  27. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/docs/iOS_SETUP_GUIDE.md +0 -0
  28. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/mcp_tools/__init__.py +0 -0
  29. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/mcp_tools/mcp_server.py +0 -0
  30. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/mobile_mcp_ai.egg-info/SOURCES.txt +0 -0
  31. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/mobile_mcp_ai.egg-info/dependency_links.txt +0 -0
  32. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/mobile_mcp_ai.egg-info/entry_points.txt +0 -0
  33. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/mobile_mcp_ai.egg-info/not-zip-safe +0 -0
  34. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/mobile_mcp_ai.egg-info/requires.txt +0 -0
  35. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/mobile_mcp_ai.egg-info/top_level.txt +0 -0
  36. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/requirements.txt +0 -0
  37. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/setup.cfg +0 -0
  38. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/templates/close_buttons/auto_x_0112_151217.png +0 -0
  39. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/templates/close_buttons/auto_x_0112_152037.png +0 -0
  40. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/templates/close_buttons/auto_x_0112_152840.png +0 -0
  41. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/templates/close_buttons/auto_x_0112_153256.png +0 -0
  42. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/templates/close_buttons/auto_x_0112_154847.png +0 -0
  43. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/templates/close_buttons/gray_x_stock_ad.png +0 -0
  44. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/utils/__init__.py +0 -0
  45. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/utils/logger.py +0 -0
  46. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/utils/xml_formatter.py +0 -0
  47. {mobile_mcp_ai-2.5.10 → mobile_mcp_ai-2.6.0}/utils/xml_parser.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mobile-mcp-ai
3
- Version: 2.5.10
3
+ Version: 2.6.0
4
4
  Summary: 移动端自动化 MCP Server - 支持 Android/iOS,AI 功能可选(基础工具不需要 AI)
5
5
  Home-page: https://github.com/test111ddff-hash/mobile-mcp-ai
6
6
  Author: douzi
@@ -2173,7 +2173,7 @@ class BasicMobileToolsLite:
2173
2173
  # ==================== 辅助工具 ====================
2174
2174
 
2175
2175
  def list_elements(self) -> List[Dict]:
2176
- """列出页面元素"""
2176
+ """列出页面元素(已优化:过滤排版容器,保留功能控件)"""
2177
2177
  try:
2178
2178
  if self._is_ios():
2179
2179
  ios_client = self._get_ios_client()
@@ -2184,23 +2184,140 @@ class BasicMobileToolsLite:
2184
2184
  xml_string = self.client.u2.dump_hierarchy(compressed=False)
2185
2185
  elements = self.client.xml_parser.parse(xml_string)
2186
2186
 
2187
+ # 功能控件类型(需要保留)
2188
+ FUNCTIONAL_WIDGETS = {
2189
+ 'TextView', 'Text', 'Label', # 文本类
2190
+ 'ImageView', 'Image', 'ImageButton', # 图片类
2191
+ 'Button', 'CheckBox', 'RadioButton', 'Switch', # 交互类
2192
+ 'SeekBar', 'ProgressBar', 'RatingBar', # 滑动/进度类
2193
+ 'EditText', 'TextInput', # 输入类
2194
+ 'VideoView', 'WebView', # 特殊功能类
2195
+ 'RecyclerView', 'ListView', 'GridView', # 列表类
2196
+ 'ScrollView', 'NestedScrollView', # 滚动容器(有实际功能)
2197
+ }
2198
+
2199
+ # 容器控件类型(需要过滤,除非有业务ID)
2200
+ CONTAINER_WIDGETS = {
2201
+ 'FrameLayout', 'LinearLayout', 'RelativeLayout',
2202
+ 'ViewGroup', 'ConstraintLayout', 'CoordinatorLayout',
2203
+ 'CardView', 'View', # 基础View也可能只是容器
2204
+ }
2205
+
2206
+ # 装饰类控件关键词(resource_id中包含这些关键词的通常可以过滤)
2207
+ # 支持匹配如 qylt_item_short_video_shadow_one 这样的命名
2208
+ DECORATIVE_KEYWORDS = {
2209
+ 'shadow', 'divider', 'separator', 'line', 'border',
2210
+ 'background', 'bg_', '_bg', 'decorative', 'decoration',
2211
+ '_shadow', 'shadow_', '_divider', 'divider_', '_line', 'line_'
2212
+ }
2213
+
2187
2214
  result = []
2188
2215
  for elem in elements:
2189
- # 获取文本内容(去除首尾空格)
2216
+ # 获取元素属性
2217
+ class_name = elem.get('class_name', '')
2218
+ resource_id = elem.get('resource_id', '').strip()
2190
2219
  text = elem.get('text', '').strip()
2191
- # 保留:可点击、可focus或有文本的元素
2192
- if elem.get('clickable') or elem.get('focusable') or text:
2220
+ content_desc = elem.get('content_desc', '').strip()
2221
+ bounds = elem.get('bounds', '')
2222
+ clickable = elem.get('clickable', False)
2223
+ focusable = elem.get('focusable', False)
2224
+ scrollable = elem.get('scrollable', False)
2225
+ enabled = elem.get('enabled', True)
2226
+
2227
+ # 1. 过滤 bounds="[0,0][0,0]" 的视觉隐藏元素
2228
+ if bounds == '[0,0][0,0]':
2229
+ continue
2230
+
2231
+ # 2. 检查是否是功能控件(直接保留)
2232
+ if class_name in FUNCTIONAL_WIDGETS:
2193
2233
  result.append({
2194
- 'resource_id': elem.get('resource_id', ''),
2195
- 'text': elem.get('text', ''),
2196
- 'content_desc': elem.get('content_desc', ''),
2197
- 'bounds': elem.get('bounds', ''),
2198
- 'clickable': elem.get('clickable', False)
2234
+ 'resource_id': resource_id,
2235
+ 'text': text,
2236
+ 'content_desc': content_desc,
2237
+ 'bounds': bounds,
2238
+ 'clickable': clickable,
2239
+ 'class': class_name
2199
2240
  })
2241
+ continue
2242
+
2243
+ # 3. 检查是否是容器控件
2244
+ if class_name in CONTAINER_WIDGETS:
2245
+ # 容器控件需要检查是否有业务相关的ID
2246
+ has_business_id = self._has_business_id(resource_id)
2247
+ if not has_business_id:
2248
+ # 无业务ID的容器控件,检查是否有其他有意义属性
2249
+ if not (clickable or focusable or scrollable or text or content_desc):
2250
+ # 所有属性都是默认值,过滤掉
2251
+ continue
2252
+ # 有业务ID或其他有意义属性,保留
2253
+ result.append({
2254
+ 'resource_id': resource_id,
2255
+ 'text': text,
2256
+ 'content_desc': content_desc,
2257
+ 'bounds': bounds,
2258
+ 'clickable': clickable,
2259
+ 'class': class_name
2260
+ })
2261
+ continue
2262
+
2263
+ # 4. 检查是否是装饰类控件
2264
+ if resource_id:
2265
+ resource_id_lower = resource_id.lower()
2266
+ if any(keyword in resource_id_lower for keyword in DECORATIVE_KEYWORDS):
2267
+ # 是装饰类控件,且没有交互属性,过滤掉
2268
+ if not (clickable or focusable or text or content_desc):
2269
+ continue
2270
+
2271
+ # 5. 检查是否所有属性均为默认值
2272
+ if not (text or content_desc or resource_id or clickable or focusable or scrollable):
2273
+ # 所有属性都是默认值,过滤掉
2274
+ continue
2275
+
2276
+ # 6. 其他情况:有意义的元素保留
2277
+ result.append({
2278
+ 'resource_id': resource_id,
2279
+ 'text': text,
2280
+ 'content_desc': content_desc,
2281
+ 'bounds': bounds,
2282
+ 'clickable': clickable,
2283
+ 'class': class_name
2284
+ })
2285
+
2200
2286
  return result
2201
2287
  except Exception as e:
2202
2288
  return [{"error": f"获取元素失败: {e}"}]
2203
2289
 
2290
+ def _has_business_id(self, resource_id: str) -> bool:
2291
+ """
2292
+ 判断resource_id是否是业务相关的ID
2293
+
2294
+ 业务相关的ID通常包含:
2295
+ - 有意义的命名(不是自动生成的)
2296
+ - 不包含常见的自动生成模式
2297
+ """
2298
+ if not resource_id:
2299
+ return False
2300
+
2301
+ # 自动生成的ID模式(通常可以忽略)
2302
+ auto_generated_patterns = [
2303
+ r'^android:id/', # 系统ID
2304
+ r':id/\d+', # 数字ID
2305
+ r':id/view_\d+', # view_数字
2306
+ r':id/item_\d+', # item_数字
2307
+ ]
2308
+
2309
+ for pattern in auto_generated_patterns:
2310
+ if re.search(pattern, resource_id):
2311
+ return False
2312
+
2313
+ # 如果resource_id有实际内容且不是自动生成的,认为是业务ID
2314
+ # 排除一些常见的系统ID
2315
+ system_ids = ['android:id/content', 'android:id/statusBarBackground']
2316
+ if resource_id in system_ids:
2317
+ return False
2318
+
2319
+ return True
2320
+
2204
2321
  def find_close_button(self) -> Dict:
2205
2322
  """智能查找关闭按钮(不点击,只返回位置)
2206
2323
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mobile-mcp-ai
3
- Version: 2.5.10
3
+ Version: 2.6.0
4
4
  Summary: 移动端自动化 MCP Server - 支持 Android/iOS,AI 功能可选(基础工具不需要 AI)
5
5
  Home-page: https://github.com/test111ddff-hash/mobile-mcp-ai
6
6
  Author: douzi
@@ -25,7 +25,7 @@ if requirements_file.exists():
25
25
 
26
26
  setup(
27
27
  name="mobile-mcp-ai",
28
- version="2.5.10", # list_elements 增加文本过滤,保留有文本的元素
28
+ version="2.6.0", # list_elements 增加文本过滤,保留有文本的元素
29
29
  author="douzi",
30
30
  author_email="1492994674@qq.com",
31
31
  description="移动端自动化 MCP Server - 支持 Android/iOS,AI 功能可选(基础工具不需要 AI)",
File without changes
File without changes
File without changes
File without changes