Skip to content

Commit e4bb19c

Browse files
authored
feat: add TEST_RUNNER_ environment variable support for test tools (#102)
* feat: add TEST_RUNNER_ environment variable support for test tools Implements explicit testRunnerEnv parameter for all test tools (test_device, test_macos, test_sim) to support passing environment variables to xcodebuild test commands with automatic TEST_RUNNER_ prefix handling. ## Key Features - Added testRunnerEnv parameter to all three test tools - Automatic TEST_RUNNER_ prefix normalization for environment variables - Updated CommandExecutor infrastructure to support execution options - Enhanced executeXcodeBuildCommand to accept environment variables - Updated handleTestLogic for simulator test integration ## Security & Architecture Benefits - Explicit parameter approach prevents environment variable injection attacks - Follows principle of least privilege - only specified variables are passed - Maintains clear separation between MCP server config and tool execution - Provides audit trail of exactly which variables are used per test ## Implementation Details - normalizeTestRunnerEnv() utility automatically adds TEST_RUNNER_ prefix - CommandExecOptions interface supports env and cwd execution options - All tools validate parameters with Zod schemas - Comprehensive test coverage with 26 new tests (18 unit + 8 integration) ## Usage Example ```typescript test_device({ projectPath: "/path/to/project.xcodeproj", scheme: "MyScheme", deviceId: "device-uuid", testRunnerEnv: { "USE_DEV_MODE": "YES" } // Becomes TEST_RUNNER_USE_DEV_MODE }) ``` Addresses GitHub issue #101 with a secure, explicit approach that prevents injection vulnerabilities while providing the requested functionality. Tested via Reloaderoo with real xcodebuild execution validation. * docs: add implementation plan and reloaderoo documentation
1 parent 0fcb03b commit e4bb19c

File tree

16 files changed

+1399
-16
lines changed

16 files changed

+1399
-16
lines changed
Lines changed: 309 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,309 @@
1+
# Reloaderoo Usage Guide for XcodeBuildMCP
2+
3+
This guide explains how to use Reloaderoo for interacting with XcodeBuildMCP as a CLI to save context window space.
4+
5+
You can use this guide to prompt your agent, but providing the entire document will give you no actual benefits. You will end up using more context than just using MCP server directly. So it's recommended that you curate this document by removing the example commands that you don't need and just keeping the ones that are right for your project. You'll then want to keep this file within your project workspace and then include it in the context window when you need to interact your agent to use XcodeBuildMCP tools.
6+
7+
> [!IMPORTANT]
8+
> Please remove this introduction before you prompt your agent with this file or any derrived version of it.
9+
10+
## Installation
11+
12+
Reloaderoo is available via npm and can be used with npx for universal compatibility.
13+
14+
```bash
15+
# Use npx to run reloaderoo
16+
npx reloaderoo@latest --help
17+
```
18+
19+
**Example Tool Calls:**
20+
21+
### Dynamic Tool Discovery
22+
23+
- **`discover_tools`**: Analyzes a task description to enable relevant tools.
24+
```bash
25+
npx reloaderoo@latest inspect call-tool discover_tools --params '{"task_description": "I want to build and run my iOS app on a simulator."}' -- node build/index.js
26+
```
27+
28+
### iOS Device Development
29+
30+
- **`build_device`**: Builds an app for a physical device.
31+
```bash
32+
npx reloaderoo@latest inspect call-tool build_device --params '{"projectPath": "/path/to/MyProject.xcodeproj", "scheme": "MyScheme"}' -- node build/index.js
33+
```
34+
- **`get_device_app_path`**: Gets the `.app` bundle path for a device build.
35+
```bash
36+
npx reloaderoo@latest inspect call-tool get_device_app_path --params '{"projectPath": "/path/to/MyProject.xcodeproj", "scheme": "MyScheme"}' -- node build/index.js
37+
```
38+
- **`install_app_device`**: Installs an app on a physical device.
39+
```bash
40+
npx reloaderoo@latest inspect call-tool install_app_device --params '{"deviceId": "DEVICE_UDID", "appPath": "/path/to/MyApp.app"}' -- node build/index.js
41+
```
42+
- **`launch_app_device`**: Launches an app on a physical device.
43+
```bash
44+
npx reloaderoo@latest inspect call-tool launch_app_device --params '{"deviceId": "DEVICE_UDID", "bundleId": "com.example.MyApp"}' -- node build/index.js
45+
```
46+
- **`list_devices`**: Lists connected physical devices.
47+
```bash
48+
npx reloaderoo@latest inspect call-tool list_devices --params '{}' -- node build/index.js
49+
```
50+
- **`stop_app_device`**: Stops an app on a physical device.
51+
```bash
52+
npx reloaderoo@latest inspect call-tool stop_app_device --params '{"deviceId": "DEVICE_UDID", "processId": 12345}' -- node build/index.js
53+
```
54+
- **`test_device`**: Runs tests on a physical device.
55+
```bash
56+
npx reloaderoo@latest inspect call-tool test_device --params '{"projectPath": "/path/to/MyProject.xcodeproj", "scheme": "MyScheme", "deviceId": "DEVICE_UDID"}' -- node build/index.js
57+
```
58+
59+
### iOS Simulator Development
60+
61+
- **`boot_sim`**: Boots a simulator.
62+
```bash
63+
npx reloaderoo@latest inspect call-tool boot_sim --params '{"simulatorUuid": "SIMULATOR_UUID"}' -- node build/index.js
64+
```
65+
- **`build_run_sim`**: Builds and runs an app on a simulator.
66+
```bash
67+
npx reloaderoo@latest inspect call-tool build_run_sim --params '{"projectPath": "/path/to/MyProject.xcodeproj", "scheme": "MyScheme", "simulatorName": "iPhone 16"}' -- node build/index.js
68+
```
69+
- **`build_sim`**: Builds an app for a simulator.
70+
```bash
71+
npx reloaderoo@latest inspect call-tool build_sim --params '{"projectPath": "/path/to/MyProject.xcodeproj", "scheme": "MyScheme", "simulatorName": "iPhone 16"}' -- node build/index.js
72+
```
73+
- **`get_sim_app_path`**: Gets the `.app` bundle path for a simulator build.
74+
```bash
75+
npx reloaderoo@latest inspect call-tool get_sim_app_path --params '{"projectPath": "/path/to/MyProject.xcodeproj", "scheme": "MyScheme", "platform": "iOS Simulator", "simulatorName": "iPhone 16"}' -- node build/index.js
76+
```
77+
- **`install_app_sim`**: Installs an app on a simulator.
78+
```bash
79+
npx reloaderoo@latest inspect call-tool install_app_sim --params '{"simulatorUuid": "SIMULATOR_UUID", "appPath": "/path/to/MyApp.app"}' -- node build/index.js
80+
```
81+
- **`launch_app_logs_sim`**: Launches an app on a simulator with log capture.
82+
```bash
83+
npx reloaderoo@latest inspect call-tool launch_app_logs_sim --params '{"simulatorUuid": "SIMULATOR_UUID", "bundleId": "com.example.MyApp"}' -- node build/index.js
84+
```
85+
- **`launch_app_sim`**: Launches an app on a simulator.
86+
```bash
87+
npx reloaderoo@latest inspect call-tool launch_app_sim --params '{"simulatorName": "iPhone 16", "bundleId": "com.example.MyApp"}' -- node build/index.js
88+
```
89+
- **`list_sims`**: Lists available simulators.
90+
```bash
91+
npx reloaderoo@latest inspect call-tool list_sims --params '{}' -- node build/index.js
92+
```
93+
- **`open_sim`**: Opens the Simulator application.
94+
```bash
95+
npx reloaderoo@latest inspect call-tool open_sim --params '{}' -- node build/index.js
96+
```
97+
- **`stop_app_sim`**: Stops an app on a simulator.
98+
```bash
99+
npx reloaderoo@latest inspect call-tool stop_app_sim --params '{"simulatorName": "iPhone 16", "bundleId": "com.example.MyApp"}' -- node build/index.js
100+
```
101+
- **`test_sim`**: Runs tests on a simulator.
102+
```bash
103+
npx reloaderoo@latest inspect call-tool test_sim --params '{"projectPath": "/path/to/MyProject.xcodeproj", "scheme": "MyScheme", "simulatorName": "iPhone 16"}' -- node build/index.js
104+
```
105+
106+
### Log Capture & Management
107+
108+
- **`start_device_log_cap`**: Starts log capture for a physical device.
109+
```bash
110+
npx reloaderoo@latest inspect call-tool start_device_log_cap --params '{"deviceId": "DEVICE_UDID", "bundleId": "com.example.MyApp"}' -- node build/index.js
111+
```
112+
- **`start_sim_log_cap`**: Starts log capture for a simulator.
113+
```bash
114+
npx reloaderoo@latest inspect call-tool start_sim_log_cap --params '{"simulatorUuid": "SIMULATOR_UUID", "bundleId": "com.example.MyApp"}' -- node build/index.js
115+
```
116+
- **`stop_device_log_cap`**: Stops log capture for a physical device.
117+
```bash
118+
npx reloaderoo@latest inspect call-tool stop_device_log_cap --params '{"logSessionId": "SESSION_ID"}' -- node build/index.js
119+
```
120+
- **`stop_sim_log_cap`**: Stops log capture for a simulator.
121+
```bash
122+
npx reloaderoo@latest inspect call-tool stop_sim_log_cap --params '{"logSessionId": "SESSION_ID"}' -- node build/index.js
123+
```
124+
125+
### macOS Development
126+
127+
- **`build_macos`**: Builds a macOS app.
128+
```bash
129+
npx reloaderoo@latest inspect call-tool build_macos --params '{"projectPath": "/path/to/MyProject.xcodeproj", "scheme": "MyScheme"}' -- node build/index.js
130+
```
131+
- **`build_run_macos`**: Builds and runs a macOS app.
132+
```bash
133+
npx reloaderoo@latest inspect call-tool build_run_macos --params '{"projectPath": "/path/to/MyProject.xcodeproj", "scheme": "MyScheme"}' -- node build/index.js
134+
```
135+
- **`get_mac_app_path`**: Gets the `.app` bundle path for a macOS build.
136+
```bash
137+
npx reloaderoo@latest inspect call-tool get_mac_app_path --params '{"projectPath": "/path/to/MyProject.xcodeproj", "scheme": "MyScheme"}' -- node build/index.js
138+
```
139+
- **`launch_mac_app`**: Launches a macOS app.
140+
```bash
141+
npx reloaderoo@latest inspect call-tool launch_mac_app --params '{"appPath": "/Applications/Calculator.app"}' -- node build/index.js
142+
```
143+
- **`stop_mac_app`**: Stops a macOS app.
144+
```bash
145+
npx reloaderoo@latest inspect call-tool stop_mac_app --params '{"appName": "Calculator"}' -- node build/index.js
146+
```
147+
- **`test_macos`**: Runs tests for a macOS project.
148+
```bash
149+
npx reloaderoo@latest inspect call-tool test_macos --params '{"projectPath": "/path/to/MyProject.xcodeproj", "scheme": "MyScheme"}' -- node build/index.js
150+
```
151+
152+
### Project Discovery
153+
154+
- **`discover_projs`**: Discovers Xcode projects and workspaces.
155+
```bash
156+
npx reloaderoo@latest inspect call-tool discover_projs --params '{"workspaceRoot": "/path/to/workspace"}' -- node build/index.js
157+
```
158+
- **`get_app_bundle_id`**: Gets an app's bundle identifier.
159+
```bash
160+
npx reloaderoo@latest inspect call-tool get_app_bundle_id --params '{"appPath": "/path/to/MyApp.app"}' -- node build/index.js
161+
```
162+
- **`get_mac_bundle_id`**: Gets a macOS app's bundle identifier.
163+
```bash
164+
npx reloaderoo@latest inspect call-tool get_mac_bundle_id --params '{"appPath": "/Applications/Calculator.app"}' -- node build/index.js
165+
```
166+
- **`list_schemes`**: Lists schemes in a project or workspace.
167+
```bash
168+
npx reloaderoo@latest inspect call-tool list_schemes --params '{"projectPath": "/path/to/MyProject.xcodeproj"}' -- node build/index.js
169+
```
170+
- **`show_build_settings`**: Shows build settings for a scheme.
171+
```bash
172+
npx reloaderoo@latest inspect call-tool show_build_settings --params '{"projectPath": "/path/to/MyProject.xcodeproj", "scheme": "MyScheme"}' -- node build/index.js
173+
```
174+
175+
### Project Scaffolding
176+
177+
- **`scaffold_ios_project`**: Scaffolds a new iOS project.
178+
```bash
179+
npx reloaderoo@latest inspect call-tool scaffold_ios_project --params '{"projectName": "MyNewApp", "outputPath": "/path/to/projects"}' -- node build/index.js
180+
```
181+
- **`scaffold_macos_project`**: Scaffolds a new macOS project.
182+
```bash
183+
npx reloaderoo@latest inspect call-tool scaffold_macos_project --params '{"projectName": "MyNewMacApp", "outputPath": "/path/to/projects"}' -- node build/index.js
184+
```
185+
186+
### Project Utilities
187+
188+
- **`clean`**: Cleans build artifacts.
189+
```bash
190+
# For a project
191+
npx reloaderoo@latest inspect call-tool clean --params '{"projectPath": "/path/to/MyProject.xcodeproj"}' -- node build/index.js
192+
# For a workspace
193+
npx reloaderoo@latest inspect call-tool clean --params '{"workspacePath": "/path/to/MyWorkspace.xcworkspace", "scheme": "MyScheme"}' -- node build/index.js
194+
```
195+
196+
### Simulator Management
197+
198+
- **`reset_sim_location`**: Resets a simulator's location.
199+
```bash
200+
npx reloaderoo@latest inspect call-tool reset_sim_location --params '{"simulatorUuid": "SIMULATOR_UUID"}' -- node build/index.js
201+
```
202+
- **`set_sim_appearance`**: Sets a simulator's appearance (dark/light mode).
203+
```bash
204+
npx reloaderoo@latest inspect call-tool set_sim_appearance --params '{"simulatorUuid": "SIMULATOR_UUID", "mode": "dark"}' -- node build/index.js
205+
```
206+
- **`set_sim_location`**: Sets a simulator's GPS location.
207+
```bash
208+
npx reloaderoo@latest inspect call-tool set_sim_location --params '{"simulatorUuid": "SIMULATOR_UUID", "latitude": 37.7749, "longitude": -122.4194}' -- node build/index.js
209+
```
210+
- **`sim_statusbar`**: Overrides a simulator's status bar.
211+
```bash
212+
npx reloaderoo@latest inspect call-tool sim_statusbar --params '{"simulatorUuid": "SIMULATOR_UUID", "dataNetwork": "wifi"}' -- node build/index.js
213+
```
214+
215+
### Swift Package Manager
216+
217+
- **`swift_package_build`**: Builds a Swift package.
218+
```bash
219+
npx reloaderoo@latest inspect call-tool swift_package_build --params '{"packagePath": "/path/to/package"}' -- node build/index.js
220+
```
221+
- **`swift_package_clean`**: Cleans a Swift package.
222+
```bash
223+
npx reloaderoo@latest inspect call-tool swift_package_clean --params '{"packagePath": "/path/to/package"}' -- node build/index.js
224+
```
225+
- **`swift_package_list`**: Lists running Swift package processes.
226+
```bash
227+
npx reloaderoo@latest inspect call-tool swift_package_list --params '{}' -- node build/index.js
228+
```
229+
- **`swift_package_run`**: Runs a Swift package executable.
230+
```bash
231+
npx reloaderoo@latest inspect call-tool swift_package_run --params '{"packagePath": "/path/to/package"}' -- node build/index.js
232+
```
233+
- **`swift_package_stop`**: Stops a running Swift package process.
234+
```bash
235+
npx reloaderoo@latest inspect call-tool swift_package_stop --params '{"pid": 12345}' -- node build/index.js
236+
```
237+
- **`swift_package_test`**: Tests a Swift package.
238+
```bash
239+
npx reloaderoo@latest inspect call-tool swift_package_test --params '{"packagePath": "/path/to/package"}' -- node build/index.js
240+
```
241+
242+
### System Doctor
243+
244+
- **`doctor`**: Runs system diagnostics.
245+
```bash
246+
npx reloaderoo@latest inspect call-tool doctor --params '{}' -- node build/index.js
247+
```
248+
249+
### UI Testing & Automation
250+
251+
- **`button`**: Simulates a hardware button press.
252+
```bash
253+
npx reloaderoo@latest inspect call-tool button --params '{"simulatorUuid": "SIMULATOR_UUID", "buttonType": "home"}' -- node build/index.js
254+
```
255+
- **`describe_ui`**: Gets the UI hierarchy of the current screen.
256+
```bash
257+
npx reloaderoo@latest inspect call-tool describe_ui --params '{"simulatorUuid": "SIMULATOR_UUID"}' -- node build/index.js
258+
```
259+
- **`gesture`**: Performs a pre-defined gesture.
260+
```bash
261+
npx reloaderoo@latest inspect call-tool gesture --params '{"simulatorUuid": "SIMULATOR_UUID", "preset": "scroll-up"}' -- node build/index.js
262+
```
263+
- **`key_press`**: Simulates a key press.
264+
```bash
265+
npx reloaderoo@latest inspect call-tool key_press --params '{"simulatorUuid": "SIMULATOR_UUID", "keyCode": 40}' -- node build/index.js
266+
```
267+
- **`key_sequence`**: Simulates a sequence of key presses.
268+
```bash
269+
npx reloaderoo@latest inspect call-tool key_sequence --params '{"simulatorUuid": "SIMULATOR_UUID", "keyCodes": [40, 42, 44]}' -- node build/index.js
270+
```
271+
- **`long_press`**: Performs a long press at coordinates.
272+
```bash
273+
npx reloaderoo@latest inspect call-tool long_press --params '{"simulatorUuid": "SIMULATOR_UUID", "x": 100, "y": 200, "duration": 1500}' -- node build/index.js
274+
```
275+
- **`screenshot`**: Takes a screenshot.
276+
```bash
277+
npx reloaderoo@latest inspect call-tool screenshot --params '{"simulatorUuid": "SIMULATOR_UUID"}' -- node build/index.js
278+
```
279+
- **`swipe`**: Performs a swipe gesture.
280+
```bash
281+
npx reloaderoo@latest inspect call-tool swipe --params '{"simulatorUuid": "SIMULATOR_UUID", "x1": 100, "y1": 200, "x2": 100, "y2": 400}' -- node build/index.js
282+
```
283+
- **`tap`**: Performs a tap at coordinates.
284+
```bash
285+
npx reloaderoo@latest inspect call-tool tap --params '{"simulatorUuid": "SIMULATOR_UUID", "x": 100, "y": 200}' -- node build/index.js
286+
```
287+
- **`touch`**: Simulates a touch down or up event.
288+
```bash
289+
npx reloaderoo@latest inspect call-tool touch --params '{"simulatorUuid": "SIMULATOR_UUID", "x": 100, "y": 200, "down": true}' -- node build/index.js
290+
```
291+
- **`type_text`**: Types text into the focused element.
292+
```bash
293+
npx reloaderoo@latest inspect call-tool type_text --params '{"simulatorUuid": "SIMULATOR_UUID", "text": "Hello, World!"}' -- node build/index.js
294+
```
295+
296+
### Resources
297+
298+
- **Read devices resource**:
299+
```bash
300+
npx reloaderoo@latest inspect read-resource "xcodebuildmcp://devices" -- node build/index.js
301+
```
302+
- **Read simulators resource**:
303+
```bash
304+
npx reloaderoo@latest inspect read-resource "xcodebuildmcp://simulators" -- node build/index.js
305+
```
306+
- **Read doctor resource**:
307+
```bash
308+
npx reloaderoo@latest inspect read-resource "xcodebuildmcp://doctor" -- node build/index.js
309+
```

0 commit comments

Comments
 (0)