appium-mcp 0.1.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 (35) hide show
  1. appium_mcp-0.1.0/LICENSE +21 -0
  2. appium_mcp-0.1.0/PKG-INFO +239 -0
  3. appium_mcp-0.1.0/README.md +198 -0
  4. appium_mcp-0.1.0/appium_mcp.egg-info/PKG-INFO +239 -0
  5. appium_mcp-0.1.0/appium_mcp.egg-info/SOURCES.txt +33 -0
  6. appium_mcp-0.1.0/appium_mcp.egg-info/dependency_links.txt +1 -0
  7. appium_mcp-0.1.0/appium_mcp.egg-info/entry_points.txt +5 -0
  8. appium_mcp-0.1.0/appium_mcp.egg-info/requires.txt +14 -0
  9. appium_mcp-0.1.0/appium_mcp.egg-info/top_level.txt +23 -0
  10. appium_mcp-0.1.0/bedrock_client.py +457 -0
  11. appium_mcp-0.1.0/command.py +145 -0
  12. appium_mcp-0.1.0/config.py +101 -0
  13. appium_mcp-0.1.0/generate_page_objects.py +445 -0
  14. appium_mcp-0.1.0/generate_regression_test.py +677 -0
  15. appium_mcp-0.1.0/generate_test_from_workflow.py +179 -0
  16. appium_mcp-0.1.0/generate_test_with_page_objects.py +242 -0
  17. appium_mcp-0.1.0/logger.py +54 -0
  18. appium_mcp-0.1.0/mcp_client.py +197 -0
  19. appium_mcp-0.1.0/orchestrator.py +565 -0
  20. appium_mcp-0.1.0/page_objects/__init__.py +7 -0
  21. appium_mcp-0.1.0/page_objects/home_page.py +36 -0
  22. appium_mcp-0.1.0/page_objects/login_page.py +50 -0
  23. appium_mcp-0.1.0/page_objects/product_details_page.py +42 -0
  24. appium_mcp-0.1.0/pyproject.toml +108 -0
  25. appium_mcp-0.1.0/server.py +577 -0
  26. appium_mcp-0.1.0/session_store.py +93 -0
  27. appium_mcp-0.1.0/setup.cfg +4 -0
  28. appium_mcp-0.1.0/tools_app_management.py +165 -0
  29. appium_mcp-0.1.0/tools_context.py +54 -0
  30. appium_mcp-0.1.0/tools_documentation.py +46 -0
  31. appium_mcp-0.1.0/tools_interactions.py +386 -0
  32. appium_mcp-0.1.0/tools_navigations.py +96 -0
  33. appium_mcp-0.1.0/tools_session.py +142 -0
  34. appium_mcp-0.1.0/tools_test_generation.py +113 -0
  35. appium_mcp-0.1.0/yaml_loader.py +163 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Pavan Kumar S
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,239 @@
1
+ Metadata-Version: 2.4
2
+ Name: appium-mcp
3
+ Version: 0.1.0
4
+ Summary: AI-driven mobile automation with Appium MCP server and AWS Bedrock integration
5
+ Author-email: You Can Automate <youcanautomate@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/youcanautomate-yca/appium-mcp
8
+ Project-URL: Documentation, https://github.com/youcanautomate-yca/appium-mcp#readme
9
+ Project-URL: Repository, https://github.com/youcanautomate-yca/appium-mcp.git
10
+ Project-URL: Issues, https://github.com/youcanautomate-yca/appium-mcp/issues
11
+ Keywords: appium,mobile-automation,mcp,model-context-protocol,ai,bedrock,testing,ios,android
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Natural Language :: English
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Software Development :: Testing
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Requires-Python: >=3.8
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: mcp>=1.0.0
28
+ Requires-Dist: pydantic>=2.11.0
29
+ Requires-Dist: appium-python-client==3.1.0
30
+ Requires-Dist: pyyaml>=6.0.3
31
+ Requires-Dist: python-dotenv==1.0.0
32
+ Requires-Dist: boto3>=1.26.0
33
+ Requires-Dist: rich>=13.0.0
34
+ Provides-Extra: dev
35
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
36
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
37
+ Requires-Dist: black>=23.0.0; extra == "dev"
38
+ Requires-Dist: flake8>=6.0.0; extra == "dev"
39
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
40
+ Dynamic: license-file
41
+
42
+ # Appium MCP Python Implementation
43
+
44
+ This is a Python implementation of the Appium MCP (Model Context Protocol) server that mirrors all tools from the TypeScript [appium-mcp](../appium-mcp) server.
45
+
46
+ ## Overview
47
+
48
+ This project provides a Python-based MCP server for Appium mobile automation with AI integration. It supports both iOS and Android automation with comprehensive tool coverage.
49
+
50
+ ## Features
51
+
52
+ - **Session Management**: Create and manage Appium sessions
53
+ - **Element Interactions**: Click, tap, long press, drag, text input, and more
54
+ - **Navigation**: Scroll, swipe, and navigate through UI
55
+ - **App Management**: Install, uninstall, activate, terminate apps
56
+ - **Context Switching**: Switch between native and web contexts
57
+ - **iOS Support**: Simulator management and WebDriverAgent setup
58
+ - **Screenshot Capture**: Full page and element-specific screenshots
59
+ - **Test Generation**: Auto-generate test scripts from actions
60
+ - **Locator Generation**: Parse page source and generate element locators
61
+
62
+ ## Installation
63
+
64
+ ### Requirements
65
+ - Python 3.8+
66
+ - pip
67
+
68
+ ### Setup
69
+
70
+ 1. Install dependencies:
71
+
72
+ ```bash
73
+ pip install -r requirements.txt
74
+ ```
75
+
76
+ 2. Ensure Appium server is running:
77
+
78
+ ```bash
79
+ appium --address localhost --port 4723
80
+ ```
81
+
82
+ ## Architecture
83
+
84
+ The server is organized into modular components:
85
+
86
+ ```
87
+ ai-driven-mobile-automation/
88
+ ├── server.py # Main MCP server and tool registration
89
+ ├── session_store.py # Global driver and session management
90
+ ├── command.py # Core Appium command execution
91
+ ├── logger.py # Logging utilities
92
+ ├── tools_session.py # Session management tools
93
+ ├── tools_interactions.py # Element interaction tools
94
+ ├── tools_navigations.py # Navigation tools
95
+ ├── tools_app_management.py # App management tools
96
+ ├── tools_context.py # Context switching tools
97
+ ├── tools_ios.py # iOS-specific tools
98
+ ├── tools_test_generation.py # Test generation tools
99
+ ├── tools_documentation.py # Documentation/help tools
100
+ ├── requirements.txt # Python dependencies
101
+ └── README.md # This file
102
+ ```
103
+
104
+ ## Mirrored Tools from TypeScript Implementation
105
+
106
+ ### Session Management
107
+ - `select_platform` - Select iOS or Android platform
108
+ - `select_device` - Select target device
109
+ - `create_session` - Create new Appium session
110
+ - `delete_session` - Delete active session
111
+ - `open_notifications` - Open notifications panel
112
+
113
+ ### Element Interactions
114
+ - `appium_click` - Click on element
115
+ - `appium_find_element` - Find element by strategy/selector
116
+ - `appium_double_tap` - Double tap element
117
+ - `appium_long_press` - Long press element
118
+ - `appium_drag_and_drop` - Drag element to target
119
+ - `appium_press_key` - Press key
120
+ - `appium_set_value` - Set text value
121
+ - `appium_get_text` - Get element text
122
+ - `appium_get_active_element` - Get focused element
123
+ - `appium_screenshot` - Take screenshot
124
+ - `appium_element_screenshot` - Screenshot of element
125
+ - `appium_get_orientation` - Get device orientation
126
+ - `appium_set_orientation` - Set device orientation
127
+ - `appium_handle_alert` - Handle alert dialogs
128
+
129
+ ### Navigation
130
+ - `appium_scroll` - Scroll up/down/left/right
131
+ - `appium_scroll_to_element` - Scroll until element visible
132
+ - `appium_swipe` - Perform swipe gesture
133
+
134
+ ### App Management
135
+ - `appium_activate_app` - Activate installed app
136
+ - `appium_install_app` - Install app
137
+ - `appium_uninstall_app` - Uninstall app
138
+ - `appium_terminate_app` - Terminate running app
139
+ - `appium_list_apps` - List installed apps
140
+ - `appium_is_app_installed` - Check if app installed
141
+ - `appium_deep_link` - Open deep link
142
+
143
+ ### Context Management
144
+ - `appium_get_contexts` - Get available contexts
145
+ - `appium_switch_context` - Switch between contexts
146
+
147
+ ### iOS Tools
148
+ - `appium_boot_simulator` - Boot iOS simulator
149
+ - `appium_setup_wda` - Setup WebDriverAgent
150
+ - `appium_install_wda` - Install WebDriverAgent
151
+
152
+ ### Test Generation
153
+ - `appium_generate_locators` - Generate element locators
154
+ - `appium_generate_tests` - Generate test scripts
155
+
156
+ ### Documentation
157
+ - `appium_answer_appium` - Answer Appium questions
158
+
159
+ ## Running the Server
160
+
161
+ ```bash
162
+ python server.py
163
+ ```
164
+
165
+ The server will start listening on stdin/stdout for MCP protocol messages.
166
+
167
+ ## Usage Example
168
+
169
+ ```python
170
+ import asyncio
171
+ from mcp.client import StdioClient
172
+
173
+ async def main():
174
+ # Create client
175
+ client = StdioClient("python", ["server.py"])
176
+
177
+ # Call a tool
178
+ result = await client.call_tool(
179
+ "select_platform",
180
+ {"platform": "ios"}
181
+ )
182
+ print(result)
183
+
184
+ asyncio.run(main())
185
+ ```
186
+
187
+ ## Tool Schemas
188
+
189
+ Each tool includes:
190
+ - `name`: Unique tool identifier
191
+ - `description`: Human-readable description
192
+ - `inputSchema`: JSON schema for parameters
193
+ - `execute`: Async function that implements the tool
194
+
195
+ ## Error Handling
196
+
197
+ All tools return a status JSON response:
198
+
199
+ ```json
200
+ {
201
+ "status": "success|error|warning",
202
+ "message": "Human-readable message",
203
+ ...tool-specific fields
204
+ }
205
+ ```
206
+
207
+ ## Logging
208
+
209
+ Logs are written to stderr with format:
210
+ ```
211
+ [TOOL START] tool_name: arguments
212
+ [TOOL END] tool_name
213
+ [TOOL ERROR] tool_name: error message
214
+ ```
215
+
216
+ ## Differences from TypeScript Implementation
217
+
218
+ 1. **Async/Await**: Python version uses async/await instead of Promise-based TypeScript
219
+ 2. **Module Organization**: Simplified into single Python files instead of separate TypeScript modules
220
+ 3. **Error Handling**: Try-catch blocks instead of TypeScript error handling
221
+ 4. **Type System**: Uses type hints instead of TypeScript types
222
+
223
+ ## Contributing
224
+
225
+ To add new tools:
226
+
227
+ 1. Create a function in the appropriate `tools_*.py` file
228
+ 2. Register it in `server.py` in the `register_tools()` function
229
+ 3. Document the tool parameters and return values
230
+
231
+ ## License
232
+
233
+ Same as parent appium-mcp project.
234
+
235
+ ## Related
236
+
237
+ - [TypeScript Implementation](../appium-mcp/README.md)
238
+ - [Appium Documentation](https://appium.io)
239
+ - [MCP Specification](https://modelcontextprotocol.io)
@@ -0,0 +1,198 @@
1
+ # Appium MCP Python Implementation
2
+
3
+ This is a Python implementation of the Appium MCP (Model Context Protocol) server that mirrors all tools from the TypeScript [appium-mcp](../appium-mcp) server.
4
+
5
+ ## Overview
6
+
7
+ This project provides a Python-based MCP server for Appium mobile automation with AI integration. It supports both iOS and Android automation with comprehensive tool coverage.
8
+
9
+ ## Features
10
+
11
+ - **Session Management**: Create and manage Appium sessions
12
+ - **Element Interactions**: Click, tap, long press, drag, text input, and more
13
+ - **Navigation**: Scroll, swipe, and navigate through UI
14
+ - **App Management**: Install, uninstall, activate, terminate apps
15
+ - **Context Switching**: Switch between native and web contexts
16
+ - **iOS Support**: Simulator management and WebDriverAgent setup
17
+ - **Screenshot Capture**: Full page and element-specific screenshots
18
+ - **Test Generation**: Auto-generate test scripts from actions
19
+ - **Locator Generation**: Parse page source and generate element locators
20
+
21
+ ## Installation
22
+
23
+ ### Requirements
24
+ - Python 3.8+
25
+ - pip
26
+
27
+ ### Setup
28
+
29
+ 1. Install dependencies:
30
+
31
+ ```bash
32
+ pip install -r requirements.txt
33
+ ```
34
+
35
+ 2. Ensure Appium server is running:
36
+
37
+ ```bash
38
+ appium --address localhost --port 4723
39
+ ```
40
+
41
+ ## Architecture
42
+
43
+ The server is organized into modular components:
44
+
45
+ ```
46
+ ai-driven-mobile-automation/
47
+ ├── server.py # Main MCP server and tool registration
48
+ ├── session_store.py # Global driver and session management
49
+ ├── command.py # Core Appium command execution
50
+ ├── logger.py # Logging utilities
51
+ ├── tools_session.py # Session management tools
52
+ ├── tools_interactions.py # Element interaction tools
53
+ ├── tools_navigations.py # Navigation tools
54
+ ├── tools_app_management.py # App management tools
55
+ ├── tools_context.py # Context switching tools
56
+ ├── tools_ios.py # iOS-specific tools
57
+ ├── tools_test_generation.py # Test generation tools
58
+ ├── tools_documentation.py # Documentation/help tools
59
+ ├── requirements.txt # Python dependencies
60
+ └── README.md # This file
61
+ ```
62
+
63
+ ## Mirrored Tools from TypeScript Implementation
64
+
65
+ ### Session Management
66
+ - `select_platform` - Select iOS or Android platform
67
+ - `select_device` - Select target device
68
+ - `create_session` - Create new Appium session
69
+ - `delete_session` - Delete active session
70
+ - `open_notifications` - Open notifications panel
71
+
72
+ ### Element Interactions
73
+ - `appium_click` - Click on element
74
+ - `appium_find_element` - Find element by strategy/selector
75
+ - `appium_double_tap` - Double tap element
76
+ - `appium_long_press` - Long press element
77
+ - `appium_drag_and_drop` - Drag element to target
78
+ - `appium_press_key` - Press key
79
+ - `appium_set_value` - Set text value
80
+ - `appium_get_text` - Get element text
81
+ - `appium_get_active_element` - Get focused element
82
+ - `appium_screenshot` - Take screenshot
83
+ - `appium_element_screenshot` - Screenshot of element
84
+ - `appium_get_orientation` - Get device orientation
85
+ - `appium_set_orientation` - Set device orientation
86
+ - `appium_handle_alert` - Handle alert dialogs
87
+
88
+ ### Navigation
89
+ - `appium_scroll` - Scroll up/down/left/right
90
+ - `appium_scroll_to_element` - Scroll until element visible
91
+ - `appium_swipe` - Perform swipe gesture
92
+
93
+ ### App Management
94
+ - `appium_activate_app` - Activate installed app
95
+ - `appium_install_app` - Install app
96
+ - `appium_uninstall_app` - Uninstall app
97
+ - `appium_terminate_app` - Terminate running app
98
+ - `appium_list_apps` - List installed apps
99
+ - `appium_is_app_installed` - Check if app installed
100
+ - `appium_deep_link` - Open deep link
101
+
102
+ ### Context Management
103
+ - `appium_get_contexts` - Get available contexts
104
+ - `appium_switch_context` - Switch between contexts
105
+
106
+ ### iOS Tools
107
+ - `appium_boot_simulator` - Boot iOS simulator
108
+ - `appium_setup_wda` - Setup WebDriverAgent
109
+ - `appium_install_wda` - Install WebDriverAgent
110
+
111
+ ### Test Generation
112
+ - `appium_generate_locators` - Generate element locators
113
+ - `appium_generate_tests` - Generate test scripts
114
+
115
+ ### Documentation
116
+ - `appium_answer_appium` - Answer Appium questions
117
+
118
+ ## Running the Server
119
+
120
+ ```bash
121
+ python server.py
122
+ ```
123
+
124
+ The server will start listening on stdin/stdout for MCP protocol messages.
125
+
126
+ ## Usage Example
127
+
128
+ ```python
129
+ import asyncio
130
+ from mcp.client import StdioClient
131
+
132
+ async def main():
133
+ # Create client
134
+ client = StdioClient("python", ["server.py"])
135
+
136
+ # Call a tool
137
+ result = await client.call_tool(
138
+ "select_platform",
139
+ {"platform": "ios"}
140
+ )
141
+ print(result)
142
+
143
+ asyncio.run(main())
144
+ ```
145
+
146
+ ## Tool Schemas
147
+
148
+ Each tool includes:
149
+ - `name`: Unique tool identifier
150
+ - `description`: Human-readable description
151
+ - `inputSchema`: JSON schema for parameters
152
+ - `execute`: Async function that implements the tool
153
+
154
+ ## Error Handling
155
+
156
+ All tools return a status JSON response:
157
+
158
+ ```json
159
+ {
160
+ "status": "success|error|warning",
161
+ "message": "Human-readable message",
162
+ ...tool-specific fields
163
+ }
164
+ ```
165
+
166
+ ## Logging
167
+
168
+ Logs are written to stderr with format:
169
+ ```
170
+ [TOOL START] tool_name: arguments
171
+ [TOOL END] tool_name
172
+ [TOOL ERROR] tool_name: error message
173
+ ```
174
+
175
+ ## Differences from TypeScript Implementation
176
+
177
+ 1. **Async/Await**: Python version uses async/await instead of Promise-based TypeScript
178
+ 2. **Module Organization**: Simplified into single Python files instead of separate TypeScript modules
179
+ 3. **Error Handling**: Try-catch blocks instead of TypeScript error handling
180
+ 4. **Type System**: Uses type hints instead of TypeScript types
181
+
182
+ ## Contributing
183
+
184
+ To add new tools:
185
+
186
+ 1. Create a function in the appropriate `tools_*.py` file
187
+ 2. Register it in `server.py` in the `register_tools()` function
188
+ 3. Document the tool parameters and return values
189
+
190
+ ## License
191
+
192
+ Same as parent appium-mcp project.
193
+
194
+ ## Related
195
+
196
+ - [TypeScript Implementation](../appium-mcp/README.md)
197
+ - [Appium Documentation](https://appium.io)
198
+ - [MCP Specification](https://modelcontextprotocol.io)
@@ -0,0 +1,239 @@
1
+ Metadata-Version: 2.4
2
+ Name: appium-mcp
3
+ Version: 0.1.0
4
+ Summary: AI-driven mobile automation with Appium MCP server and AWS Bedrock integration
5
+ Author-email: You Can Automate <youcanautomate@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/youcanautomate-yca/appium-mcp
8
+ Project-URL: Documentation, https://github.com/youcanautomate-yca/appium-mcp#readme
9
+ Project-URL: Repository, https://github.com/youcanautomate-yca/appium-mcp.git
10
+ Project-URL: Issues, https://github.com/youcanautomate-yca/appium-mcp/issues
11
+ Keywords: appium,mobile-automation,mcp,model-context-protocol,ai,bedrock,testing,ios,android
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Natural Language :: English
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Software Development :: Testing
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Requires-Python: >=3.8
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: mcp>=1.0.0
28
+ Requires-Dist: pydantic>=2.11.0
29
+ Requires-Dist: appium-python-client==3.1.0
30
+ Requires-Dist: pyyaml>=6.0.3
31
+ Requires-Dist: python-dotenv==1.0.0
32
+ Requires-Dist: boto3>=1.26.0
33
+ Requires-Dist: rich>=13.0.0
34
+ Provides-Extra: dev
35
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
36
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
37
+ Requires-Dist: black>=23.0.0; extra == "dev"
38
+ Requires-Dist: flake8>=6.0.0; extra == "dev"
39
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
40
+ Dynamic: license-file
41
+
42
+ # Appium MCP Python Implementation
43
+
44
+ This is a Python implementation of the Appium MCP (Model Context Protocol) server that mirrors all tools from the TypeScript [appium-mcp](../appium-mcp) server.
45
+
46
+ ## Overview
47
+
48
+ This project provides a Python-based MCP server for Appium mobile automation with AI integration. It supports both iOS and Android automation with comprehensive tool coverage.
49
+
50
+ ## Features
51
+
52
+ - **Session Management**: Create and manage Appium sessions
53
+ - **Element Interactions**: Click, tap, long press, drag, text input, and more
54
+ - **Navigation**: Scroll, swipe, and navigate through UI
55
+ - **App Management**: Install, uninstall, activate, terminate apps
56
+ - **Context Switching**: Switch between native and web contexts
57
+ - **iOS Support**: Simulator management and WebDriverAgent setup
58
+ - **Screenshot Capture**: Full page and element-specific screenshots
59
+ - **Test Generation**: Auto-generate test scripts from actions
60
+ - **Locator Generation**: Parse page source and generate element locators
61
+
62
+ ## Installation
63
+
64
+ ### Requirements
65
+ - Python 3.8+
66
+ - pip
67
+
68
+ ### Setup
69
+
70
+ 1. Install dependencies:
71
+
72
+ ```bash
73
+ pip install -r requirements.txt
74
+ ```
75
+
76
+ 2. Ensure Appium server is running:
77
+
78
+ ```bash
79
+ appium --address localhost --port 4723
80
+ ```
81
+
82
+ ## Architecture
83
+
84
+ The server is organized into modular components:
85
+
86
+ ```
87
+ ai-driven-mobile-automation/
88
+ ├── server.py # Main MCP server and tool registration
89
+ ├── session_store.py # Global driver and session management
90
+ ├── command.py # Core Appium command execution
91
+ ├── logger.py # Logging utilities
92
+ ├── tools_session.py # Session management tools
93
+ ├── tools_interactions.py # Element interaction tools
94
+ ├── tools_navigations.py # Navigation tools
95
+ ├── tools_app_management.py # App management tools
96
+ ├── tools_context.py # Context switching tools
97
+ ├── tools_ios.py # iOS-specific tools
98
+ ├── tools_test_generation.py # Test generation tools
99
+ ├── tools_documentation.py # Documentation/help tools
100
+ ├── requirements.txt # Python dependencies
101
+ └── README.md # This file
102
+ ```
103
+
104
+ ## Mirrored Tools from TypeScript Implementation
105
+
106
+ ### Session Management
107
+ - `select_platform` - Select iOS or Android platform
108
+ - `select_device` - Select target device
109
+ - `create_session` - Create new Appium session
110
+ - `delete_session` - Delete active session
111
+ - `open_notifications` - Open notifications panel
112
+
113
+ ### Element Interactions
114
+ - `appium_click` - Click on element
115
+ - `appium_find_element` - Find element by strategy/selector
116
+ - `appium_double_tap` - Double tap element
117
+ - `appium_long_press` - Long press element
118
+ - `appium_drag_and_drop` - Drag element to target
119
+ - `appium_press_key` - Press key
120
+ - `appium_set_value` - Set text value
121
+ - `appium_get_text` - Get element text
122
+ - `appium_get_active_element` - Get focused element
123
+ - `appium_screenshot` - Take screenshot
124
+ - `appium_element_screenshot` - Screenshot of element
125
+ - `appium_get_orientation` - Get device orientation
126
+ - `appium_set_orientation` - Set device orientation
127
+ - `appium_handle_alert` - Handle alert dialogs
128
+
129
+ ### Navigation
130
+ - `appium_scroll` - Scroll up/down/left/right
131
+ - `appium_scroll_to_element` - Scroll until element visible
132
+ - `appium_swipe` - Perform swipe gesture
133
+
134
+ ### App Management
135
+ - `appium_activate_app` - Activate installed app
136
+ - `appium_install_app` - Install app
137
+ - `appium_uninstall_app` - Uninstall app
138
+ - `appium_terminate_app` - Terminate running app
139
+ - `appium_list_apps` - List installed apps
140
+ - `appium_is_app_installed` - Check if app installed
141
+ - `appium_deep_link` - Open deep link
142
+
143
+ ### Context Management
144
+ - `appium_get_contexts` - Get available contexts
145
+ - `appium_switch_context` - Switch between contexts
146
+
147
+ ### iOS Tools
148
+ - `appium_boot_simulator` - Boot iOS simulator
149
+ - `appium_setup_wda` - Setup WebDriverAgent
150
+ - `appium_install_wda` - Install WebDriverAgent
151
+
152
+ ### Test Generation
153
+ - `appium_generate_locators` - Generate element locators
154
+ - `appium_generate_tests` - Generate test scripts
155
+
156
+ ### Documentation
157
+ - `appium_answer_appium` - Answer Appium questions
158
+
159
+ ## Running the Server
160
+
161
+ ```bash
162
+ python server.py
163
+ ```
164
+
165
+ The server will start listening on stdin/stdout for MCP protocol messages.
166
+
167
+ ## Usage Example
168
+
169
+ ```python
170
+ import asyncio
171
+ from mcp.client import StdioClient
172
+
173
+ async def main():
174
+ # Create client
175
+ client = StdioClient("python", ["server.py"])
176
+
177
+ # Call a tool
178
+ result = await client.call_tool(
179
+ "select_platform",
180
+ {"platform": "ios"}
181
+ )
182
+ print(result)
183
+
184
+ asyncio.run(main())
185
+ ```
186
+
187
+ ## Tool Schemas
188
+
189
+ Each tool includes:
190
+ - `name`: Unique tool identifier
191
+ - `description`: Human-readable description
192
+ - `inputSchema`: JSON schema for parameters
193
+ - `execute`: Async function that implements the tool
194
+
195
+ ## Error Handling
196
+
197
+ All tools return a status JSON response:
198
+
199
+ ```json
200
+ {
201
+ "status": "success|error|warning",
202
+ "message": "Human-readable message",
203
+ ...tool-specific fields
204
+ }
205
+ ```
206
+
207
+ ## Logging
208
+
209
+ Logs are written to stderr with format:
210
+ ```
211
+ [TOOL START] tool_name: arguments
212
+ [TOOL END] tool_name
213
+ [TOOL ERROR] tool_name: error message
214
+ ```
215
+
216
+ ## Differences from TypeScript Implementation
217
+
218
+ 1. **Async/Await**: Python version uses async/await instead of Promise-based TypeScript
219
+ 2. **Module Organization**: Simplified into single Python files instead of separate TypeScript modules
220
+ 3. **Error Handling**: Try-catch blocks instead of TypeScript error handling
221
+ 4. **Type System**: Uses type hints instead of TypeScript types
222
+
223
+ ## Contributing
224
+
225
+ To add new tools:
226
+
227
+ 1. Create a function in the appropriate `tools_*.py` file
228
+ 2. Register it in `server.py` in the `register_tools()` function
229
+ 3. Document the tool parameters and return values
230
+
231
+ ## License
232
+
233
+ Same as parent appium-mcp project.
234
+
235
+ ## Related
236
+
237
+ - [TypeScript Implementation](../appium-mcp/README.md)
238
+ - [Appium Documentation](https://appium.io)
239
+ - [MCP Specification](https://modelcontextprotocol.io)