mobile-mcp-ai 2.7.3__tar.gz → 2.7.4__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.7.3/mobile_mcp_ai.egg-info → mobile_mcp_ai-2.7.4}/PKG-INFO +1 -1
  2. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/core/basic_tools_lite.py +52 -24
  3. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4/mobile_mcp_ai.egg-info}/PKG-INFO +1 -1
  4. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/setup.py +1 -1
  5. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/LICENSE +0 -0
  6. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/MANIFEST.in +0 -0
  7. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/README.md +0 -0
  8. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/__init__.py +0 -0
  9. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/config.py +0 -0
  10. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/core/__init__.py +0 -0
  11. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/core/device_manager.py +0 -0
  12. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/core/dynamic_config.py +0 -0
  13. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/core/ios_client_wda.py +0 -0
  14. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/core/ios_device_manager_wda.py +0 -0
  15. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/core/mobile_client.py +0 -0
  16. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/core/template_matcher.py +0 -0
  17. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/core/templates/close_buttons/auto_x_0112_151217.png +0 -0
  18. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/core/templates/close_buttons/auto_x_0112_152037.png +0 -0
  19. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/core/templates/close_buttons/auto_x_0112_152840.png +0 -0
  20. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/core/templates/close_buttons/auto_x_0112_153256.png +0 -0
  21. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/core/templates/close_buttons/auto_x_0112_154847.png +0 -0
  22. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/core/templates/close_buttons/gray_x_stock_ad.png +0 -0
  23. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/core/utils/__init__.py +0 -0
  24. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/core/utils/logger.py +0 -0
  25. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/core/utils/operation_history_manager.py +0 -0
  26. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/core/utils/smart_wait.py +0 -0
  27. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/docs/iOS_SETUP_GUIDE.md +0 -0
  28. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/mcp_tools/__init__.py +0 -0
  29. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/mcp_tools/mcp_server.py +0 -0
  30. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/mobile_mcp_ai.egg-info/SOURCES.txt +0 -0
  31. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/mobile_mcp_ai.egg-info/dependency_links.txt +0 -0
  32. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/mobile_mcp_ai.egg-info/entry_points.txt +0 -0
  33. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/mobile_mcp_ai.egg-info/not-zip-safe +0 -0
  34. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/mobile_mcp_ai.egg-info/requires.txt +0 -0
  35. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/mobile_mcp_ai.egg-info/top_level.txt +0 -0
  36. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/requirements.txt +0 -0
  37. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/setup.cfg +0 -0
  38. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/templates/close_buttons/auto_x_0112_151217.png +0 -0
  39. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/templates/close_buttons/auto_x_0112_152037.png +0 -0
  40. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/templates/close_buttons/auto_x_0112_152840.png +0 -0
  41. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/templates/close_buttons/auto_x_0112_153256.png +0 -0
  42. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/templates/close_buttons/auto_x_0112_154847.png +0 -0
  43. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/templates/close_buttons/gray_x_stock_ad.png +0 -0
  44. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/utils/__init__.py +0 -0
  45. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/utils/logger.py +0 -0
  46. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/utils/xml_formatter.py +0 -0
  47. {mobile_mcp_ai-2.7.3 → mobile_mcp_ai-2.7.4}/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.7.3
3
+ Version: 2.7.4
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
@@ -1313,13 +1313,13 @@ class BasicMobileToolsLite:
1313
1313
  page_texts = self._get_page_texts(10)
1314
1314
  return {"success": True, "page_texts": page_texts}
1315
1315
 
1316
- # 选择器失败,用坐标兜底
1316
+ # 选择器失败,用控件中心坐标点兜底
1317
1317
  if bounds:
1318
1318
  x = (bounds[0] + bounds[2]) // 2
1319
1319
  y = (bounds[1] + bounds[3]) // 2
1320
1320
  self.client.u2.click(x, y)
1321
1321
  time.sleep(0.3)
1322
- self._record_click('percent', f"{x_pct}%,{y_pct}%", x_pct, y_pct,
1322
+ self._record_click('coords', f"{x},{y}", x_pct, y_pct,
1323
1323
  element_desc=text)
1324
1324
  # 验证逻辑
1325
1325
  if verify:
@@ -1373,12 +1373,14 @@ class BasicMobileToolsLite:
1373
1373
  except Exception as e:
1374
1374
  return {"success": True, "verified": False, "hint": f"验证异常: {e}"}
1375
1375
 
1376
- def _find_element_in_tree(self, text: str, position: Optional[str] = None) -> Optional[Dict]:
1377
- """在 XML 树中查找包含指定文本的元素,优先返回可点击的元素
1376
+ def _find_element_in_tree(self, text: str, position: Optional[str] = None, exact_match: bool = True) -> Optional[Dict]:
1377
+ """在 XML 树中查找指定文本的元素,优先返回可点击的元素
1378
1378
 
1379
1379
  Args:
1380
1380
  text: 要查找的文本
1381
1381
  position: 位置信息,用于在有多个相同文案时筛选
1382
+ exact_match: 是否精确匹配。True=优先精确匹配(用于定位元素如点击),
1383
+ False=只进行包含匹配(用于验证元素)
1382
1384
  """
1383
1385
  try:
1384
1386
  xml = self.client.u2.dump_hierarchy(compressed=False)
@@ -1410,26 +1412,40 @@ class BasicMobileToolsLite:
1410
1412
  attr_type = None
1411
1413
  attr_value = None
1412
1414
 
1413
- # 精确匹配 text
1414
- if elem_text == text:
1415
- is_match = True
1416
- attr_type = 'text'
1417
- attr_value = text
1418
- # 精确匹配 content-desc
1419
- elif elem_desc == text:
1420
- is_match = True
1421
- attr_type = 'description'
1422
- attr_value = text
1423
- # 模糊匹配 text
1424
- elif text in elem_text:
1425
- is_match = True
1426
- attr_type = 'textContains'
1427
- attr_value = text
1428
- # 模糊匹配 content-desc
1429
- elif text in elem_desc:
1430
- is_match = True
1431
- attr_type = 'descriptionContains'
1432
- attr_value = text
1415
+ if exact_match:
1416
+ # 精确匹配模式(用于定位元素):优先精确匹配
1417
+ # 精确匹配 text
1418
+ if elem_text == text:
1419
+ is_match = True
1420
+ attr_type = 'text'
1421
+ attr_value = text
1422
+ # 精确匹配 content-desc
1423
+ elif elem_desc == text:
1424
+ is_match = True
1425
+ attr_type = 'description'
1426
+ attr_value = text
1427
+ # 精确匹配找不到时,再尝试包含匹配(作为兜底)
1428
+ elif text in elem_text:
1429
+ is_match = True
1430
+ attr_type = 'textContains'
1431
+ attr_value = text
1432
+ # 包含匹配 content-desc
1433
+ elif text in elem_desc:
1434
+ is_match = True
1435
+ attr_type = 'descriptionContains'
1436
+ attr_value = text
1437
+ else:
1438
+ # 包含匹配模式(用于验证元素):只进行包含匹配
1439
+ # 包含匹配 text
1440
+ if text in elem_text:
1441
+ is_match = True
1442
+ attr_type = 'textContains'
1443
+ attr_value = text
1444
+ # 包含匹配 content-desc
1445
+ elif text in elem_desc:
1446
+ is_match = True
1447
+ attr_type = 'descriptionContains'
1448
+ attr_value = text
1433
1449
 
1434
1450
  if is_match and bounds:
1435
1451
  # 计算元素的中心点坐标
@@ -1448,6 +1464,17 @@ class BasicMobileToolsLite:
1448
1464
  if not matched_elements:
1449
1465
  return None
1450
1466
 
1467
+ # 精确匹配模式下,优先返回精确匹配的元素(text/description),再返回包含匹配的元素
1468
+ if exact_match:
1469
+ exact_matches = [m for m in matched_elements if m['attr_type'] in ['text', 'description']]
1470
+ contains_matches = [m for m in matched_elements if m['attr_type'] in ['textContains', 'descriptionContains']]
1471
+ # 如果有精确匹配,优先使用精确匹配的结果
1472
+ if exact_matches:
1473
+ matched_elements = exact_matches + contains_matches
1474
+ # 如果没有精确匹配,使用包含匹配的结果
1475
+ else:
1476
+ matched_elements = contains_matches
1477
+
1451
1478
  # 如果有位置信息,根据位置筛选
1452
1479
  if position and len(matched_elements) > 1:
1453
1480
  position_lower = position.lower()
@@ -1486,6 +1513,7 @@ class BasicMobileToolsLite:
1486
1513
  }
1487
1514
 
1488
1515
  # 没有位置信息时,优先返回可点击的元素
1516
+ # 由于前面已经排序(精确匹配在前),这里会优先返回精确匹配且可点击的元素
1489
1517
  for match in matched_elements:
1490
1518
  if match['clickable']:
1491
1519
  return {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mobile-mcp-ai
3
- Version: 2.7.3
3
+ Version: 2.7.4
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.7.3", # 优化resource-id匹配和弹窗关闭功能
28
+ version="2.7.4", # 优化_find_element_in_tree支持精确匹配和包含匹配,优化点击失败时使用控件中心坐标
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
File without changes
File without changes