mobile-mcp-ai 2.1.2__py3-none-any.whl → 2.5.8__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.
Files changed (65) hide show
  1. mobile_mcp/__init__.py +34 -0
  2. mobile_mcp/config.py +142 -0
  3. mobile_mcp/core/basic_tools_lite.py +3266 -0
  4. {core → mobile_mcp/core}/device_manager.py +2 -2
  5. mobile_mcp/core/dynamic_config.py +272 -0
  6. mobile_mcp/core/ios_client_wda.py +569 -0
  7. mobile_mcp/core/ios_device_manager_wda.py +306 -0
  8. {core → mobile_mcp/core}/mobile_client.py +279 -39
  9. mobile_mcp/core/template_matcher.py +429 -0
  10. mobile_mcp/core/templates/close_buttons/auto_x_0112_151217.png +0 -0
  11. mobile_mcp/core/templates/close_buttons/auto_x_0112_152037.png +0 -0
  12. mobile_mcp/core/templates/close_buttons/auto_x_0112_152840.png +0 -0
  13. mobile_mcp/core/templates/close_buttons/auto_x_0112_153256.png +0 -0
  14. mobile_mcp/core/templates/close_buttons/auto_x_0112_154847.png +0 -0
  15. mobile_mcp/core/templates/close_buttons/gray_x_stock_ad.png +0 -0
  16. {core → mobile_mcp/core}/utils/smart_wait.py +3 -3
  17. mobile_mcp/mcp_tools/__init__.py +10 -0
  18. mobile_mcp/mcp_tools/mcp_server.py +1071 -0
  19. mobile_mcp_ai-2.5.8.dist-info/METADATA +469 -0
  20. mobile_mcp_ai-2.5.8.dist-info/RECORD +32 -0
  21. mobile_mcp_ai-2.5.8.dist-info/entry_points.txt +2 -0
  22. mobile_mcp_ai-2.5.8.dist-info/licenses/LICENSE +201 -0
  23. mobile_mcp_ai-2.5.8.dist-info/top_level.txt +1 -0
  24. core/ai/__init__.py +0 -11
  25. core/ai/ai_analyzer.py +0 -197
  26. core/ai/ai_config.py +0 -116
  27. core/ai/ai_platform_adapter.py +0 -399
  28. core/ai/smart_test_executor.py +0 -520
  29. core/ai/test_generator.py +0 -365
  30. core/ai/test_generator_from_history.py +0 -391
  31. core/ai/test_generator_standalone.py +0 -293
  32. core/assertion/__init__.py +0 -9
  33. core/assertion/smart_assertion.py +0 -341
  34. core/basic_tools.py +0 -377
  35. core/h5/__init__.py +0 -10
  36. core/h5/h5_handler.py +0 -548
  37. core/ios_client.py +0 -219
  38. core/ios_device_manager.py +0 -252
  39. core/locator/__init__.py +0 -10
  40. core/locator/cursor_ai_auto_analyzer.py +0 -119
  41. core/locator/cursor_vision_helper.py +0 -414
  42. core/locator/mobile_smart_locator.py +0 -1640
  43. core/locator/position_analyzer.py +0 -813
  44. core/locator/script_updater.py +0 -157
  45. core/nl_test_runner.py +0 -585
  46. core/smart_app_launcher.py +0 -334
  47. core/smart_tools.py +0 -311
  48. mcp/__init__.py +0 -8
  49. mcp/mcp_server.py +0 -1919
  50. mcp/mcp_server_simple.py +0 -476
  51. mobile_mcp_ai-2.1.2.dist-info/METADATA +0 -567
  52. mobile_mcp_ai-2.1.2.dist-info/RECORD +0 -45
  53. mobile_mcp_ai-2.1.2.dist-info/entry_points.txt +0 -2
  54. mobile_mcp_ai-2.1.2.dist-info/top_level.txt +0 -4
  55. vision/__init__.py +0 -10
  56. vision/vision_locator.py +0 -404
  57. {core → mobile_mcp/core}/__init__.py +0 -0
  58. {core → mobile_mcp/core}/utils/__init__.py +0 -0
  59. {core → mobile_mcp/core}/utils/logger.py +0 -0
  60. {core → mobile_mcp/core}/utils/operation_history_manager.py +0 -0
  61. {utils → mobile_mcp/utils}/__init__.py +0 -0
  62. {utils → mobile_mcp/utils}/logger.py +0 -0
  63. {utils → mobile_mcp/utils}/xml_formatter.py +0 -0
  64. {utils → mobile_mcp/utils}/xml_parser.py +0 -0
  65. {mobile_mcp_ai-2.1.2.dist-info → mobile_mcp_ai-2.5.8.dist-info}/WHEEL +0 -0
mobile_mcp/__init__.py ADDED
@@ -0,0 +1,34 @@
1
+ """
2
+ 移动端AI驱动自动化测试模块
3
+
4
+ 功能:
5
+ 1. Android原生App自动化测试
6
+ 2. iOS原生App自动化测试(后续)
7
+ 3. AI驱动的元素定位(复用现有SmartLocator)
8
+ 4. 多模态视觉识别支持
9
+ 5. 成本优化(规则匹配优先,AI降级)
10
+
11
+ 使用示例:
12
+ from mobile_mcp.core.mobile_client import MobileClient
13
+
14
+ # 连接设备
15
+ client = MobileClient(device_id=None)
16
+
17
+ # 启动App
18
+ await client.launch_app("com.example.app")
19
+
20
+ # 自然语言定位(AI自动定位)
21
+ await client.click("登录按钮")
22
+ await client.type_text("用户名输入框", "test@example.com")
23
+ """
24
+
25
+ __version__ = "1.0.0"
26
+
27
+ from .core.mobile_client import MobileClient
28
+ from .core.device_manager import DeviceManager
29
+
30
+ __all__ = [
31
+ 'MobileClient',
32
+ 'DeviceManager',
33
+ ]
34
+
mobile_mcp/config.py ADDED
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ Mobile MCP 配置系统
5
+
6
+ 功能:
7
+ 1. 功能开关(启用/禁用AI增强)
8
+ 2. 平台选择(强制使用特定平台)
9
+ 3. 降级策略配置
10
+ """
11
+ import os
12
+ from typing import Optional
13
+
14
+
15
+ class Config:
16
+ """Mobile MCP 配置类"""
17
+
18
+ # ==================== AI增强功能 ====================
19
+ # AI增强功能开关(默认启用)
20
+ AI_ENHANCEMENT_ENABLED: bool = os.getenv(
21
+ "AI_ENHANCEMENT_ENABLED",
22
+ "true"
23
+ ).lower() == "true"
24
+
25
+ # 优先使用的AI平台(None=自动检测)
26
+ # 可选值: "cursor", "claude", "openai", "gemini", None
27
+ PREFERRED_AI_PLATFORM: Optional[str] = os.getenv(
28
+ "PREFERRED_AI_PLATFORM",
29
+ None
30
+ )
31
+
32
+ # AI失败时是否降级到基础功能
33
+ FALLBACK_TO_BASIC_ON_AI_FAILURE: bool = os.getenv(
34
+ "FALLBACK_TO_BASIC_ON_AI_FAILURE",
35
+ "true"
36
+ ).lower() == "true"
37
+
38
+ # ==================== 平台支持 ====================
39
+ # iOS支持开关(默认启用,需要安装iOS依赖)
40
+ IOS_SUPPORT_ENABLED: bool = os.getenv(
41
+ "IOS_SUPPORT_ENABLED",
42
+ "true"
43
+ ).lower() == "true"
44
+
45
+ # 默认平台("android" 或 "ios")
46
+ # 兼容两种环境变量名:MOBILE_PLATFORM(新)和 DEFAULT_PLATFORM(旧)
47
+ DEFAULT_PLATFORM: str = os.getenv(
48
+ "MOBILE_PLATFORM",
49
+ os.getenv("DEFAULT_PLATFORM", "android")
50
+ )
51
+
52
+ # Android支持(默认启用)
53
+ ANDROID_SUPPORT_ENABLED: bool = os.getenv(
54
+ "ANDROID_SUPPORT_ENABLED",
55
+ "true"
56
+ ).lower() == "true"
57
+
58
+ # ==================== 设备管理 ====================
59
+ # 默认设备ID("auto"=自动选择第一个)
60
+ DEFAULT_DEVICE_ID: str = os.getenv("MOBILE_DEVICE_ID", "auto")
61
+
62
+ # 锁定屏幕方向(默认启用)
63
+ LOCK_SCREEN_ORIENTATION: bool = os.getenv(
64
+ "LOCK_SCREEN_ORIENTATION",
65
+ "true"
66
+ ).lower() == "true"
67
+
68
+ # ==================== 智能定位 ====================
69
+ # 启用智能定位(默认启用)
70
+ SMART_LOCATOR_ENABLED: bool = os.getenv(
71
+ "SMART_LOCATOR_ENABLED",
72
+ "true"
73
+ ).lower() == "true"
74
+
75
+ # 启用H5处理(默认启用)
76
+ H5_HANDLER_ENABLED: bool = os.getenv(
77
+ "H5_HANDLER_ENABLED",
78
+ "true"
79
+ ).lower() == "true"
80
+
81
+ # ==================== 性能优化 ====================
82
+ # 快照缓存TTL(秒)
83
+ SNAPSHOT_CACHE_TTL: int = int(os.getenv("SNAPSHOT_CACHE_TTL", "1"))
84
+
85
+ # 定位缓存TTL(秒)
86
+ LOCATOR_CACHE_TTL: int = int(os.getenv("LOCATOR_CACHE_TTL", "300"))
87
+
88
+ # ==================== HTTP服务器 ====================
89
+ # HTTP服务器默认端口
90
+ HTTP_SERVER_PORT: int = int(os.getenv("HTTP_SERVER_PORT", "8080"))
91
+
92
+ # HTTP服务器默认主机
93
+ HTTP_SERVER_HOST: str = os.getenv("HTTP_SERVER_HOST", "0.0.0.0")
94
+
95
+ # ==================== 日志 ====================
96
+ # 日志级别
97
+ LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO")
98
+
99
+ # 启用详细日志
100
+ VERBOSE_LOGGING: bool = os.getenv(
101
+ "VERBOSE_LOGGING",
102
+ "false"
103
+ ).lower() == "true"
104
+
105
+ @classmethod
106
+ def get_ai_platform(cls) -> Optional[str]:
107
+ """获取优先使用的AI平台"""
108
+ return cls.PREFERRED_AI_PLATFORM
109
+
110
+ @classmethod
111
+ def is_ai_enhancement_enabled(cls) -> bool:
112
+ """检查AI增强功能是否启用"""
113
+ return cls.AI_ENHANCEMENT_ENABLED
114
+
115
+ @classmethod
116
+ def should_fallback_on_ai_failure(cls) -> bool:
117
+ """检查AI失败时是否降级"""
118
+ return cls.FALLBACK_TO_BASIC_ON_AI_FAILURE
119
+
120
+ @classmethod
121
+ def get_summary(cls) -> dict:
122
+ """获取配置摘要"""
123
+ return {
124
+ "ai_enhancement": {
125
+ "enabled": cls.AI_ENHANCEMENT_ENABLED,
126
+ "preferred_platform": cls.PREFERRED_AI_PLATFORM or "auto",
127
+ "fallback_on_failure": cls.FALLBACK_TO_BASIC_ON_AI_FAILURE,
128
+ },
129
+ "platform_support": {
130
+ "android": cls.ANDROID_SUPPORT_ENABLED,
131
+ "ios": cls.IOS_SUPPORT_ENABLED,
132
+ },
133
+ "features": {
134
+ "smart_locator": cls.SMART_LOCATOR_ENABLED,
135
+ "h5_handler": cls.H5_HANDLER_ENABLED,
136
+ },
137
+ "device": {
138
+ "default_device_id": cls.DEFAULT_DEVICE_ID,
139
+ "lock_orientation": cls.LOCK_SCREEN_ORIENTATION,
140
+ }
141
+ }
142
+