native-devtools-mcp 0.1.3 → 0.1.5

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 (2) hide show
  1. package/README.md +289 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,289 @@
1
+ # native-devtools-mcp
2
+
3
+ A Model Context Protocol (MCP) server for testing native desktop applications, similar to how Chrome DevTools enables web UI testing.
4
+
5
+ > **100% Local & Private** - All processing happens on your machine. No data is sent to external servers. Screenshots, UI interactions, and app data never leave your device.
6
+
7
+ ## Platform Support
8
+
9
+ | Platform | Status |
10
+ |----------|--------|
11
+ | **macOS** | Supported |
12
+ | **Windows** | Planned |
13
+ | **Linux** | Planned |
14
+
15
+ > Windows and Linux support will be added in future releases with platform-specific backends.
16
+
17
+ ## Overview
18
+
19
+ This MCP server enables LLM-driven testing of native desktop apps by providing:
20
+ - **Screenshots** - Capture full screen, windows, or regions
21
+ - **Input simulation** - Click, type, scroll, drag via platform-native events
22
+ - **Window/app enumeration** - List and focus windows and applications
23
+
24
+ ## Two Approaches to UI Interaction
25
+
26
+ This server provides **two distinct approaches** for interacting with application UIs. They are kept separate intentionally to give the LLM full control over which approach to use based on context.
27
+
28
+ ### 1. AppDebugKit (`app_*` tools) - Element-Level Precision
29
+
30
+ For applications that embed [AppDebugKit](./AppDebugKit/), you get:
31
+ - **Element targeting by ID** - Click buttons, fill text fields by element reference
32
+ - **CSS-like selectors** - Query elements with `#id`, `.ClassName`, `[title=Save]`
33
+ - **View hierarchy inspection** - Traverse the UI tree programmatically
34
+ - **Framework-aware** - Works with AppKit and SwiftUI controls
35
+
36
+ **Best for:** Apps you control, AppKit/SwiftUI apps, when you need reliable element targeting.
37
+
38
+ ```
39
+ app_connect → app_get_tree → app_query(".NSButton") → app_click(element_id)
40
+ ```
41
+
42
+ ### 2. CGEvent (`click`, `type_text`, etc.) - Universal Compatibility
43
+
44
+ For **any application** regardless of framework:
45
+ - **Screen coordinate targeting** - Click at (x, y) positions
46
+ - **Works with any UI framework** - egui, Electron, Qt, games, anything
47
+ - **No app modification required** - Just needs Accessibility permission
48
+
49
+ **Best for:** Third-party apps, egui/Electron/Qt apps, when AppDebugKit isn't available.
50
+
51
+ ```
52
+ take_screenshot → (analyze visually) → click(x=500, y=300)
53
+ ```
54
+
55
+ ### Why Two Approaches?
56
+
57
+ The LLM needs to choose the right approach based on what it observes:
58
+
59
+ | Scenario | Recommended Approach |
60
+ |----------|---------------------|
61
+ | App with AppDebugKit embedded | `app_*` tools - reliable element IDs |
62
+ | egui/Electron/Qt app | CGEvent tools - coordinate-based |
63
+ | Unknown app | Try `app_connect`, fall back to CGEvent |
64
+ | App with poor view hierarchy | CGEvent even if AppDebugKit connected |
65
+
66
+ Merging them into auto-fallback would hide important context from the LLM and reduce its ability to make informed decisions.
67
+
68
+ ## Installation
69
+
70
+ ### Option 1: npm (Recommended)
71
+
72
+ ```bash
73
+ # Install globally
74
+ npm install -g native-devtools-mcp
75
+
76
+ # Or run directly with npx
77
+ npx native-devtools-mcp
78
+ ```
79
+
80
+ ### Option 2: Build from source
81
+
82
+ ```bash
83
+ # Clone the repository
84
+ git clone https://github.com/sh3ll3x3c/native-devtools-mcp
85
+ cd native-devtools-mcp
86
+
87
+ # Build
88
+ cargo build --release
89
+
90
+ # Binary location
91
+ ./target/release/native-devtools-mcp
92
+ ```
93
+
94
+ ## Required Permissions (macOS)
95
+
96
+ This MCP server requires macOS privacy permissions to capture screenshots and simulate input. **These permissions are required for the tools to function.**
97
+
98
+ ### Step-by-Step Setup
99
+
100
+ #### 1. Screen Recording Permission (required for screenshots)
101
+
102
+ 1. Open **System Settings** → **Privacy & Security** → **Screen Recording**
103
+ 2. Click the **+** button (you may need to unlock with your password)
104
+ 3. Add the app that runs Claude Code:
105
+ - **VS Code**: `/Applications/Visual Studio Code.app`
106
+ - **Terminal**: `/Applications/Utilities/Terminal.app`
107
+ - **iTerm**: `/Applications/iTerm.app`
108
+ 4. **Quit and restart the app completely** (not just reload)
109
+
110
+ #### 2. Accessibility Permission (required for click, type, scroll)
111
+
112
+ 1. Open **System Settings** → **Privacy & Security** → **Accessibility**
113
+ 2. Click the **+** button
114
+ 3. Add the same app as above (VS Code, Terminal, etc.)
115
+ 4. **Quit and restart the app completely**
116
+
117
+ #### 3. Tesseract OCR (required for `find_text`)
118
+
119
+ The `find_text` tool uses OCR to locate text on screen and return clickable coordinates. This is the **recommended way** to interact with apps when AppDebugKit is not available.
120
+
121
+ ```bash
122
+ brew install tesseract
123
+ ```
124
+
125
+ ### Important Notes
126
+
127
+ - **Grant permissions to the host app** (VS Code, Terminal), not to the MCP server binary itself
128
+ - **Restart is required** - Permissions don't take effect until you fully quit and reopen the app
129
+ - **No popup appears** - macOS won't prompt you; it silently fails if permissions are missing
130
+ - If you see `could not create image from display`, you need Screen Recording permission
131
+ - If clicks don't work, you need Accessibility permission
132
+
133
+ ### Privacy & Security
134
+
135
+ All data stays on your machine:
136
+ - Screenshots are captured locally and sent directly to Claude via the MCP protocol
137
+ - No data is uploaded to external servers
138
+ - The MCP server runs entirely offline
139
+ - Source code is open for audit
140
+
141
+ ## MCP Configuration
142
+
143
+ Add to your Claude Code MCP config (`~/.claude/claude_desktop_config.json`):
144
+
145
+ ```json
146
+ {
147
+ "mcpServers": {
148
+ "native-devtools": {
149
+ "command": "npx",
150
+ "args": ["-y", "native-devtools-mcp"]
151
+ }
152
+ }
153
+ }
154
+ ```
155
+
156
+ Or if you built from source:
157
+
158
+ ```json
159
+ {
160
+ "mcpServers": {
161
+ "native-devtools": {
162
+ "command": "/path/to/native-devtools-mcp"
163
+ }
164
+ }
165
+ }
166
+ ```
167
+
168
+ ## Tools
169
+
170
+ ### System Tools (work with any app)
171
+
172
+ | Tool | Description |
173
+ |------|-------------|
174
+ | `take_screenshot` | Capture screen, window, or region (base64 PNG) |
175
+ | `list_windows` | List visible windows with IDs, titles, bounds |
176
+ | `list_apps` | List running applications |
177
+ | `focus_window` | Bring window/app to front |
178
+ | `get_displays` | Get display info (bounds, scale factors) for coordinate conversion |
179
+
180
+ ### CGEvent Input Tools (work with any app, require Accessibility permission)
181
+
182
+ | Tool | Description |
183
+ |------|-------------|
184
+ | `click` | Click at screen/window/screenshot coordinates |
185
+ | `type_text` | Type text at cursor position |
186
+ | `press_key` | Press key combo (e.g., "return", modifiers: ["command"]) |
187
+ | `scroll` | Scroll at position |
188
+ | `drag` | Drag from point to point |
189
+ | `move_mouse` | Move cursor to position |
190
+
191
+ ### AppDebugKit Tools (require app to embed AppDebugKit)
192
+
193
+ | Tool | Description |
194
+ |------|-------------|
195
+ | `app_connect` | Connect to app's debug server (ws://127.0.0.1:9222) |
196
+ | `app_disconnect` | Disconnect from app |
197
+ | `app_get_info` | Get app metadata (name, bundle ID, version) |
198
+ | `app_get_tree` | Get view hierarchy |
199
+ | `app_query` | Find elements by CSS-like selector |
200
+ | `app_get_element` | Get element details by ID |
201
+ | `app_click` | Click element by ID |
202
+ | `app_type` | Type text into element |
203
+ | `app_press_key` | Press key in app context |
204
+ | `app_focus` | Focus element (make first responder) |
205
+ | `app_screenshot` | Screenshot element or window |
206
+ | `app_list_windows` | List app's windows |
207
+ | `app_focus_window` | Focus specific window |
208
+
209
+ ## Coordinate Systems and Display Scaling
210
+
211
+ The `click` tool supports three coordinate input methods to handle macOS display scaling:
212
+
213
+ ```json
214
+ // Direct screen coordinates
215
+ { "x": 500, "y": 300 }
216
+
217
+ // Window-relative (converted using window bounds)
218
+ { "window_x": 100, "window_y": 50, "window_id": 1234 }
219
+
220
+ // Screenshot pixels (converted using backing scale factor)
221
+ { "screenshot_x": 200, "screenshot_y": 100, "screenshot_window_id": 1234 }
222
+ ```
223
+
224
+ Use `get_displays` to understand the display configuration:
225
+ ```json
226
+ {
227
+ "displays": [{
228
+ "id": 1,
229
+ "is_main": true,
230
+ "bounds": { "x": 0, "y": 0, "width": 3008, "height": 1692 },
231
+ "backing_scale_factor": 2.0,
232
+ "pixel_width": 6016,
233
+ "pixel_height": 3384
234
+ }]
235
+ }
236
+ ```
237
+
238
+ ## Example Usage
239
+
240
+ ### With CGEvent (any app)
241
+
242
+ ```
243
+ User: Click the Submit button in the app
244
+
245
+ Claude: [calls take_screenshot]
246
+ [analyzes screenshot, finds Submit button at approximately x=450, y=320]
247
+ [calls click with x=450, y=320]
248
+ ```
249
+
250
+ ### With AppDebugKit (embedded app)
251
+
252
+ ```
253
+ User: Click the Submit button in the app
254
+
255
+ Claude: [calls app_connect with url="ws://127.0.0.1:9222"]
256
+ [calls app_query with selector="[title=Submit]"]
257
+ [receives element_id="view-42"]
258
+ [calls app_click with element_id="view-42"]
259
+ ```
260
+
261
+ ## Architecture
262
+
263
+ ```
264
+ ┌─────────────────┐ JSON-RPC 2.0 ┌──────────────────┐
265
+ │ Claude/Client │ ◄──────────────────► │ native-devtools │
266
+ │ (with vision) │ stdio │ MCP Server │
267
+ └─────────────────┘ └────────┬─────────┘
268
+
269
+ ┌────────────────────────┼────────────────────────┐
270
+ │ │ │
271
+ ▼ ▼ ▼
272
+ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
273
+ │ AppDebugKit │ │ CGEvent │ │ System │
274
+ │ (WebSocket) │ │ Input │ │ APIs │
275
+ │ │ │ │ │ │
276
+ │ Element-level│ │ Coordinate │ │ Screenshots │
277
+ │ interaction │ │ based input │ │ Window enum │
278
+ └─────────────┘ └─────────────┘ └─────────────┘
279
+ │ │
280
+ ▼ ▼
281
+ ┌─────────────┐ ┌─────────────┐
282
+ │ Apps with │ │ Any app │
283
+ │ AppDebugKit │ │ (egui, etc) │
284
+ └─────────────┘ └─────────────┘
285
+ ```
286
+
287
+ ## License
288
+
289
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-devtools-mcp",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "MCP server for testing native desktop applications",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,7 +24,7 @@
24
24
  "bin"
25
25
  ],
26
26
  "optionalDependencies": {
27
- "@sh3ll3x3c/native-devtools-mcp-darwin-arm64": "0.1.3"
27
+ "@sh3ll3x3c/native-devtools-mcp-darwin-arm64": "0.1.5"
28
28
  },
29
29
  "engines": {
30
30
  "node": ">=18"