devlens-mcp 0.3.2 → 0.3.3

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.
@@ -1,354 +1,3 @@
1
- # DevLens MCP - Installation Guide for Developers
1
+ # Installation Guide
2
2
 
3
- ## What is DevLens?
4
-
5
- DevLens is a Playwright-style MCP (Model Context Protocol) server that gives AI agents the ability to **see, interact with, and verify** mobile apps running on simulators/emulators. It enables automated React Native development workflows with Figma design verification.
6
-
7
- ---
8
-
9
- ## Prerequisites
10
-
11
- Before installing DevLens, ensure you have:
12
-
13
- - **Node.js** >= 18
14
- - **For Android**: Android SDK with `adb` in PATH (installed via Android Studio)
15
- - **For iOS** (macOS only): Xcode with Command Line Tools
16
- - **React Native**: Metro bundler running (`npx react-native start`)
17
-
18
- ---
19
-
20
- ## Installation Methods
21
-
22
- ### Method 1: Cursor IDE (Recommended for Cursor users)
23
-
24
- #### Step 1: Create or Edit MCP Configuration
25
-
26
- Navigate to your project root and create/edit `.cursor/mcp.json`:
27
-
28
- ```json
29
- {
30
- "mcpServers": {
31
- "devlens": {
32
- "command": "npx",
33
- "args": ["devlens-mcp@latest"],
34
- "env": {
35
- "METRO_PORT": "8081",
36
- "FIGMA_TOKEN": "figd_xxxxx"
37
- }
38
- }
39
- }
40
- }
41
- ```
42
-
43
- #### Step 2: Configure Environment Variables
44
-
45
- | Variable | Required | Description |
46
- |----------|----------|-------------|
47
- | `METRO_PORT` | No | Metro bundler port (default: 8081) |
48
- | `FIGMA_TOKEN` | Yes* | Figma personal access token (required for Figma comparison) |
49
- | `DEVLENS_CONFIG` | No | Path to `devlens.config.json` for design system context |
50
- | `DEVICE_ID` | No | Target specific device (defaults to first available) |
51
-
52
- *Required only if using `devlens_compare_with_figma`
53
-
54
- #### Step 3: Get Figma Token (if needed)
55
-
56
- 1. Go to https://www.figma.com/settings
57
- 2. Scroll to "Personal access tokens"
58
- 3. Click "Create new token"
59
- 4. Give it a name (e.g., "DevLens")
60
- 5. Required scope: **File content: Read**
61
- 6. Copy the token (starts with `figd_`)
62
- 7. Add to `mcp.json` as shown above
63
-
64
- #### Step 4: Restart Cursor
65
-
66
- Close and reopen Cursor IDE. DevLens tools will be available in the AI agent context.
67
-
68
- ---
69
-
70
- ### Method 2: Claude Code CLI (Recommended for Claude Code)
71
-
72
- #### One Command Install:
73
-
74
- ```bash
75
- claude mcp add devlens -- npx devlens-mcp@latest
76
- ```
77
-
78
- This automatically configures DevLens in your Claude Code environment.
79
-
80
- #### Manual Configuration:
81
-
82
- If the command above doesn't work, edit `~/.config/claude/claude_desktop_config.json`:
83
-
84
- ```json
85
- {
86
- "mcpServers": {
87
- "devlens": {
88
- "command": "npx",
89
- "args": ["devlens-mcp@latest"],
90
- "env": {
91
- "METRO_PORT": "8081",
92
- "FIGMA_TOKEN": "figd_xxxxx"
93
- }
94
- }
95
- }
96
- }
97
- ```
98
-
99
- ---
100
-
101
- ### Method 3: Claude Desktop App
102
-
103
- #### Step 1: Locate Config File
104
-
105
- **macOS:**
106
- ```
107
- ~/Library/Application Support/Claude/claude_desktop_config.json
108
- ```
109
-
110
- **Windows:**
111
- ```
112
- %APPDATA%/Claude/claude_desktop_config.json
113
- ```
114
-
115
- **Linux:**
116
- ```
117
- ~/.config/Claude/claude_desktop_config.json
118
- ```
119
-
120
- #### Step 2: Edit Configuration
121
-
122
- ```json
123
- {
124
- "mcpServers": {
125
- "devlens": {
126
- "command": "npx",
127
- "args": ["devlens-mcp@latest"],
128
- "env": {
129
- "METRO_PORT": "8081",
130
- "FIGMA_TOKEN": "figd_xxxxx"
131
- }
132
- }
133
- }
134
- }
135
- ```
136
-
137
- #### Step 3: Restart Claude Desktop
138
-
139
- Completely quit and restart the Claude Desktop app.
140
-
141
- ---
142
-
143
- ### Method 4: Local Development (For Contributors)
144
-
145
- If you want to modify DevLens or use it from source:
146
-
147
- ```bash
148
- # Clone the repository
149
- git clone https://dev.azure.com/JioOmni/OmniAI/_git/mcp-devlens
150
- cd mcp-devlens
151
-
152
- # Install dependencies
153
- npm install
154
-
155
- # Build the project
156
- npm run build
157
-
158
- # Auto-register with Claude Code (if installed)
159
- npm run register
160
- ```
161
-
162
- #### For Cursor (Local Development):
163
-
164
- Create `.cursor/mcp.json` in your project:
165
-
166
- ```json
167
- {
168
- "mcpServers": {
169
- "devlens": {
170
- "command": "node",
171
- "args": ["/absolute/path/to/mcp-devlens/dist/bin/cli.js"],
172
- "env": {
173
- "METRO_PORT": "8081",
174
- "FIGMA_TOKEN": "figd_xxxxx"
175
- }
176
- }
177
- }
178
- }
179
- ```
180
-
181
- Replace `/absolute/path/to/mcp-devlens` with your actual path.
182
-
183
- ---
184
-
185
- ## Verification
186
-
187
- ### Test if DevLens is Working
188
-
189
- 1. Start your Android emulator or iOS simulator
190
- 2. Launch your React Native app
191
- 3. In Cursor/Claude, ask the AI: "List running devices"
192
- 4. The AI should use `devlens_list_devices` and show your device
193
-
194
- ### Example Commands to Test:
195
-
196
- - "Take a screenshot of the app"
197
- - "Show me the UI element tree"
198
- - "What elements are on the screen?"
199
- - "Compare the current screen with this Figma design: [URL]"
200
-
201
- ---
202
-
203
- ## Configuration Files
204
-
205
- ### Design System Context (Optional)
206
-
207
- To enable `devlens_ds_context` for design token awareness, create `devlens.config.json` in your app root:
208
-
209
- ```json
210
- {
211
- "designSystem": {
212
- "tokensFile": "src/theme/tokens.ts",
213
- "componentsDir": "src/components/designSystem",
214
- "usagePatterns": {
215
- "include": ["src/**/*.tsx"],
216
- "exclude": ["node_modules/**", "**/*.test.tsx"]
217
- }
218
- }
219
- }
220
- ```
221
-
222
- Then set the environment variable:
223
-
224
- ```json
225
- {
226
- "mcpServers": {
227
- "devlens": {
228
- "command": "npx",
229
- "args": ["devlens-mcp@latest"],
230
- "env": {
231
- "DEVLENS_CONFIG": "/absolute/path/to/your/app/devlens.config.json",
232
- "METRO_PORT": "8081",
233
- "FIGMA_TOKEN": "figd_xxxxx"
234
- }
235
- }
236
- }
237
- }
238
- ```
239
-
240
- ---
241
-
242
- ## Troubleshooting
243
-
244
- ### Issue: "No running simulators or emulators"
245
-
246
- **Solution:** Start a device from Android Studio or Xcode before using DevLens.
247
-
248
- ```bash
249
- # Android
250
- emulator -avd <your_avd_name>
251
-
252
- # iOS (macOS)
253
- xcrun simctl boot <device_uuid>
254
- ```
255
-
256
- ### Issue: "Could not connect to Metro bundler"
257
-
258
- **Solution:** Ensure Metro is running:
259
-
260
- ```bash
261
- npx react-native start
262
- ```
263
-
264
- Check that `METRO_PORT` matches your Metro port (usually 8081).
265
-
266
- ### Issue: "ADB command not found"
267
-
268
- **Solution:** Add Android SDK platform-tools to your PATH:
269
-
270
- ```bash
271
- # Add to ~/.zshrc or ~/.bashrc
272
- export ANDROID_HOME=$HOME/Library/Android/sdk
273
- export PATH=$PATH:$ANDROID_HOME/platform-tools
274
- ```
275
-
276
- ### Issue: "simctl not found" (iOS)
277
-
278
- **Solution:** Install Xcode Command Line Tools:
279
-
280
- ```bash
281
- xcode-select --install
282
- ```
283
-
284
- ### Issue: DevLens tools not showing in Cursor/Claude
285
-
286
- **Solutions:**
287
- 1. Check MCP config file syntax (valid JSON)
288
- 2. Restart Cursor/Claude completely
289
- 3. Check Console/Logs for MCP connection errors
290
- 4. For local development, verify the path is absolute and correct
291
- 5. Run `npx devlens-mcp@latest` in terminal to verify it works standalone
292
-
293
- ### Issue: "Invalid token" on Figma compare
294
-
295
- **Solution:**
296
- - Use a personal access token (starts with `figd_`), not OAuth
297
- - Required scope: **File content: Read**
298
- - Generate at https://www.figma.com/settings
299
-
300
- ### Issue: "File not exportable" on Figma compare
301
-
302
- **Solution:** In Figma, disable "Prevent viewers from copying and exporting" in share settings.
303
-
304
- ---
305
-
306
- ## What's Next?
307
-
308
- ### Basic Workflow
309
-
310
- 1. **Check Metro**: Ask AI to check if Metro is healthy
311
- 2. **Take Screenshots**: Capture current app state
312
- 3. **Interact**: Tap buttons, fill forms, navigate
313
- 4. **Verify**: Compare with Figma designs
314
- 5. **Iterate**: Make code changes, hot reload, repeat
315
-
316
- ### Advanced Workflows
317
-
318
- - **Figma-to-Code Loop**: Automated design implementation with visual verification
319
- - **Design System Integration**: Use `devlens_ds_context` for token-aware code generation
320
- - **Flow Testing**: Use `devlens_capture_flow` for multi-step interaction capture
321
- - **Layout Debugging**: Per-element comparison scores to pinpoint UI issues
322
-
323
- ### Example AI Prompts
324
-
325
- - "Take a screenshot and compare it with this Figma design: [URL]"
326
- - "Navigate to the login screen and verify all elements are present"
327
- - "Fill out the registration form with test data"
328
- - "Show me the design system tokens and components available"
329
- - "Capture a flow of: tap login → enter credentials → tap submit"
330
-
331
- ---
332
-
333
- ## Support
334
-
335
- - **Documentation**: See [README.md](./README.md) for full tool reference
336
- - **Issues**: Report issues to your team's Azure DevOps
337
- - **Updates**: Run `npx devlens-mcp@latest` to always get the latest version
338
-
339
- ---
340
-
341
- ## Quick Reference
342
-
343
- ### Available Tools (34 total)
344
-
345
- - **Device Management** (3): list_devices, device_info, set_orientation
346
- - **App Management** (4): launch_app, terminate_app, install_app, list_apps
347
- - **Snapshot & Elements** (5): snapshot, find_element, wait_for_element, wait_for_screen, element_info
348
- - **Interaction** (8): tap, type, swipe, scroll, long_press, press_button, fill_form, capture_flow
349
- - **Screenshots & Visual** (5): screenshot, compare_screenshot, element_screenshot, compare_images, compare_with_figma
350
- - **React Native / Metro** (6): metro_status, metro_logs, component_tree, hot_reload, network_requests, dismiss_overlays
351
- - **Navigation** (2): open_url, go_back
352
- - **Design System** (1): ds_context
353
-
354
- See full documentation in [README.md](./README.md) for detailed tool descriptions.
3
+ This file has moved. See **[docs/setup-guide.md](./docs/setup-guide.md)** for all installation, configuration, and troubleshooting instructions.
package/QUICK_START.md CHANGED
@@ -1,153 +1,3 @@
1
- # DevLens MCP - Quick Start Guide
1
+ # Quick Start
2
2
 
3
- ## 🚀 Pushing Code to Azure DevOps
4
-
5
- ### Option 1: Using the Script (Easiest)
6
-
7
- ```bash
8
- ./PUSH_COMMANDS.sh
9
- ```
10
-
11
- The script will guide you through:
12
- 1. Generating a Personal Access Token (PAT)
13
- 2. Configuring the remote
14
- 3. Pushing the code
15
-
16
- ### Option 2: Manual Steps
17
-
18
- 1. **Generate PAT**: Visit https://dev.azure.com/JioOmni/_usersSettings/tokens
19
- - Click "New Token"
20
- - Name: "DevLens MCP"
21
- - Permissions: Code → Read & Write
22
- - Copy the token
23
-
24
- 2. **Push Code**:
25
- ```bash
26
- git remote set-url origin https://JioOmni:YOUR_PAT@dev.azure.com/JioOmni/OmniAI/_git/mcp-devlens
27
- git push -u origin main
28
- ```
29
-
30
- 3. **Verify**: https://dev.azure.com/JioOmni/OmniAI/_git/mcp-devlens
31
-
32
- ---
33
-
34
- ## 👥 How Developers Install DevLens
35
-
36
- ### For Cursor IDE Users
37
-
38
- Add to `.cursor/mcp.json` in their project root:
39
-
40
- ```json
41
- {
42
- "mcpServers": {
43
- "devlens": {
44
- "command": "npx",
45
- "args": ["devlens-mcp@latest"],
46
- "env": {
47
- "METRO_PORT": "8081",
48
- "FIGMA_TOKEN": "figd_xxxxx"
49
- }
50
- }
51
- }
52
- }
53
- ```
54
-
55
- Then restart Cursor.
56
-
57
- ### For Claude Desktop Users
58
-
59
- **macOS**: Edit `~/Library/Application Support/Claude/claude_desktop_config.json`
60
-
61
- **Windows**: Edit `%APPDATA%/Claude/claude_desktop_config.json`
62
-
63
- Add the same configuration as above, then restart Claude Desktop.
64
-
65
- ### For Claude Code CLI Users
66
-
67
- ```bash
68
- claude mcp add devlens -- npx devlens-mcp@latest
69
- ```
70
-
71
- ---
72
-
73
- ## 🔧 What Developers Need
74
-
75
- ### Prerequisites
76
-
77
- - Node.js >= 18
78
- - Android SDK (for Android) OR Xcode (for iOS on macOS)
79
- - React Native app with Metro running
80
-
81
- ### Environment Variables
82
-
83
- | Variable | Required | Description |
84
- |----------|----------|-------------|
85
- | `FIGMA_TOKEN` | Optional* | Figma personal access token (for design comparison) |
86
- | `METRO_PORT` | No | Default: 8081 |
87
- | `DEVLENS_CONFIG` | No | Path to design system config |
88
-
89
- *Required only for Figma comparison features
90
-
91
- ### Getting Figma Token
92
-
93
- 1. Go to https://www.figma.com/settings
94
- 2. Create new token with "File content: Read" scope
95
- 3. Copy token (starts with `figd_`)
96
- 4. Add to MCP config
97
-
98
- ---
99
-
100
- ## 📚 Key Documentation Files
101
-
102
- - **INSTALLATION_GUIDE.md** - Complete installation instructions for all platforms
103
- - **README.md** - Full tool reference and features
104
- - **AZURE_DEVOPS_SETUP.md** - Detailed push instructions
105
- - **docs/setup-guide.md** - Design system configuration
106
- - **docs/figma-workflow.md** - Figma integration guide
107
-
108
- ---
109
-
110
- ## ✅ Testing the Installation
111
-
112
- After installation, developers can test by asking the AI:
113
-
114
- 1. "List running devices" → Should show their emulator/simulator
115
- 2. "Take a screenshot" → Should capture the app screen
116
- 3. "Show the element tree" → Should display UI hierarchy
117
-
118
- ---
119
-
120
- ## 🎯 Key Features to Share
121
-
122
- - **34 Tools** for mobile app automation
123
- - **Figma Design Comparison** with per-element similarity scores
124
- - **React Native Integration** with Metro bundler
125
- - **Playwright-style API** with element references (no coordinate guessing)
126
- - **Design System Context** for token-aware code generation
127
- - **Works with Android & iOS**
128
-
129
- ---
130
-
131
- ## 📞 Quick Links
132
-
133
- - **Azure Repo**: https://dev.azure.com/JioOmni/OmniAI/_git/mcp-devlens
134
- - **Figma Settings**: https://www.figma.com/settings
135
- - **Azure PAT Creation**: https://dev.azure.com/JioOmni/_usersSettings/tokens
136
-
137
- ---
138
-
139
- ## 🐛 Common Issues
140
-
141
- ### "No devices found"
142
- Start emulator/simulator first
143
-
144
- ### "Metro not connected"
145
- Run `npx react-native start`
146
-
147
- ### "Invalid Figma token"
148
- Use personal token (figd_), not OAuth
149
-
150
- ### "DevLens tools not showing"
151
- Restart Cursor/Claude completely
152
-
153
- See INSTALLATION_GUIDE.md for detailed troubleshooting.
3
+ This file has moved. See **[docs/setup-guide.md](./docs/setup-guide.md)** for all installation, configuration, and troubleshooting instructions.
@@ -1,74 +1,90 @@
1
1
  # DevLens Setup Guide
2
2
 
3
- Get DevLens running in under 5 minutes. This guide covers prerequisites, installation, configuration, and verification.
3
+ ## 1-Minute Install (Cursor IDE)
4
4
 
5
- ---
5
+ Add this to `~/.cursor/mcp.json` and restart Cursor:
6
6
 
7
- ## Prerequisites
7
+ ```json
8
+ {
9
+ "mcpServers": {
10
+ "devlens": {
11
+ "command": "npx",
12
+ "args": ["devlens-mcp@latest"],
13
+ "env": {
14
+ "METRO_PORT": "8081"
15
+ }
16
+ }
17
+ }
18
+ }
19
+ ```
8
20
 
9
- ### For Android Development
10
- 1. **Android Studio** installed with SDK
11
- 2. **Android Emulator** running (start one from Android Studio > Device Manager)
12
- 3. **ADB** accessible in PATH (comes with Android SDK)
21
+ That's it. DevLens tools will appear in Cursor's MCP panel.
13
22
 
14
- Verify:
15
- ```bash
16
- adb devices
17
- # Should show your running emulator, e.g.:
18
- # emulator-5554 device
19
- ```
23
+ > **Getting `env: node: No such file or directory`?** Jump to [Fix: nvm/PATH issue](#fix-nvmpath-issue-env-node-no-such-file-or-directory).
20
24
 
21
- ### For iOS Development (macOS only)
22
- 1. **Xcode** installed with Command Line Tools
23
- 2. **iOS Simulator** booted (open from Xcode > Window > Devices & Simulators)
25
+ ---
24
26
 
25
- Verify:
26
- ```bash
27
- xcrun simctl list devices | grep Booted
28
- # Should show your booted simulator, e.g.:
29
- # iPhone 16 (XXXX-XXXX) (Booted)
30
- ```
27
+ ## Installation for Other Clients
31
28
 
32
- ### For React Native Metro Integration
33
- 1. **Metro bundler** running:
29
+ ### Claude Code
34
30
  ```bash
35
- cd your-rn-project
36
- npx react-native start
37
- # or
38
- npx expo start
31
+ claude mcp add devlens -- npx devlens-mcp@latest
39
32
  ```
40
33
 
41
- ---
42
-
43
- ## Installation
44
-
45
- ### Option 1: Cursor IDE
46
- Add to `~/.cursor/mcp.json`:
34
+ ### Claude Desktop
35
+ Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:
47
36
  ```json
48
37
  {
49
38
  "mcpServers": {
50
39
  "devlens": {
51
40
  "command": "npx",
52
41
  "args": ["devlens-mcp@latest"],
53
- "env": {
54
- "METRO_PORT": "8081",
55
- "FIGMA_TOKEN": "figd_xxxxx",
56
- "DEVLENS_CONFIG": "/path/to/your-app/devlens.config.json"
57
- }
42
+ "env": { "METRO_PORT": "8081" }
58
43
  }
59
44
  }
60
45
  }
61
46
  ```
62
47
 
63
- Restart Cursor after saving. DevLens tools will appear in the MCP tools panel.
48
+ ### Local Development (Build from Source)
49
+ ```bash
50
+ git clone https://JioOmni@dev.azure.com/JioOmni/OmniAI/_git/mcp-devlens
51
+ cd mcp-devlens && npm install && npm run build
52
+ npm run register # auto-registers with Claude Code
53
+ ```
54
+
55
+ For Cursor with local build, use `"command": "node"` and `"args": ["/absolute/path/to/mcp-devlens/dist/bin/cli.js"]` instead of `npx`.
56
+
57
+ ---
64
58
 
65
- ### Option 2: Claude Code
59
+ ## Prerequisites
60
+
61
+ - **Node.js** >= 18
62
+ - **Android**: Android SDK with `adb` in PATH (via Android Studio)
63
+ - **iOS** (macOS only): Xcode with Command Line Tools
64
+ - **React Native**: Metro bundler running (`npx react-native start`)
65
+
66
+ Quick checks:
66
67
  ```bash
67
- claude mcp add devlens -- npx devlens-mcp@latest
68
+ node -v # Should print v18+
69
+ adb devices # Should list your emulator
70
+ xcrun simctl list devices | grep Booted # (iOS) Should list simulator
68
71
  ```
69
72
 
70
- ### Option 3: Claude Desktop
71
- Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
73
+ ---
74
+
75
+ ## Environment Variables
76
+
77
+ Add any of these to the `"env"` block in your MCP config:
78
+
79
+ | Variable | Required | Default | Description |
80
+ |----------|----------|---------|-------------|
81
+ | `METRO_PORT` | No | `8081` | Port where Metro bundler is running |
82
+ | `FIGMA_TOKEN` | For Figma compare | — | Figma personal access token. [How to get one](#figma-token-setup). |
83
+ | `DEVLENS_CONFIG` | For DS context | — | Absolute path to `devlens.config.json`. [Details](#design-system-configuration). |
84
+ | `ANDROID_HOME` | No | auto-detect | Android SDK path |
85
+ | `DEVICE_ID` | No | first available | Target a specific device by ID |
86
+
87
+ Full example with all optional vars:
72
88
  ```json
73
89
  {
74
90
  "mcpServers": {
@@ -78,46 +94,60 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
78
94
  "env": {
79
95
  "METRO_PORT": "8081",
80
96
  "FIGMA_TOKEN": "figd_xxxxx",
81
- "DEVLENS_CONFIG": "/path/to/your-app/devlens.config.json"
97
+ "DEVLENS_CONFIG": "/Users/you/your-app/devlens.config.json"
82
98
  }
83
99
  }
84
100
  }
85
101
  }
86
102
  ```
87
103
 
88
- > **Note:** `npx` downloads and runs DevLens automatically on first use. No clone or build step needed.
89
-
90
104
  ---
91
105
 
92
- ## Configuration
106
+ ## Verify It Works
93
107
 
94
- ### Environment Variables
108
+ Start your emulator/simulator and Metro, then ask your AI:
95
109
 
96
- Set these in the `env` section of your MCP config, or export them in your shell:
110
+ | Step | What to say | Expected |
111
+ |------|-------------|----------|
112
+ | 1 | "List running devices" | Your emulator/simulator listed |
113
+ | 2 | "Take a screenshot" | Device screenshot as inline image |
114
+ | 3 | "Take a snapshot with validation" | Accessibility tree with `ref=eN` IDs |
115
+ | 4 | "Show Metro logs" | Console output from your app |
97
116
 
98
- | Variable | Default | Description |
99
- |----------|---------|-------------|
100
- | `FIGMA_TOKEN` | — | Figma personal access token. Required for `devlens_compare_with_figma`. Generate at [figma.com/developers](https://www.figma.com/developers/api#access-tokens). Required scope: **File content: Read**. |
101
- | `DEVLENS_CONFIG` | — | Absolute path to your `devlens.config.json`. Enables the `devlens_ds_context` tool. |
102
- | `METRO_PORT` | `8081` | Port where Metro bundler is running |
103
- | `ANDROID_HOME` | auto-detect | Path to Android SDK (e.g., `/Users/you/Library/Android/sdk`) |
104
- | `ANDROID_SDK_ROOT` | auto-detect | Alternative to `ANDROID_HOME` |
105
- | `DEVICE_ID` | first available | Target a specific device by ID |
117
+ If step 1 works, DevLens is running correctly.
106
118
 
107
- ### Multiple Devices
119
+ ---
108
120
 
109
- If you have multiple emulators/simulators running, DevLens auto-selects the first one. To target a specific device:
121
+ ## Figma Token Setup
110
122
 
111
- 1. Run `devlens_list_devices` to see all available devices
112
- 2. Pass `deviceId` to any tool: `devlens_device_info(deviceId: "emulator-5554")`
123
+ Required only for `devlens_compare_with_figma`.
113
124
 
114
- Or set `DEVICE_ID=emulator-5554` in your environment.
125
+ 1. Go to [figma.com/settings](https://www.figma.com/settings)
126
+ 2. Scroll to **Personal access tokens** → **Generate new token**
127
+ 3. Name: `devlens` (or anything)
128
+ 4. Scope: **File content → Read** (only scope needed)
129
+ 5. Copy the token (starts with `figd_`)
130
+
131
+ Verify it works:
132
+ ```bash
133
+ curl -H "X-Figma-Token: figd_yourtoken" "https://api.figma.com/v1/me"
134
+ # Should return your account info
135
+ ```
136
+
137
+ Add to your MCP config:
138
+ ```json
139
+ "env": {
140
+ "FIGMA_TOKEN": "figd_yourtoken"
141
+ }
142
+ ```
143
+
144
+ > **Security:** Never paste your PAT in chat messages or commit it to git.
115
145
 
116
146
  ---
117
147
 
118
148
  ## Design System Configuration
119
149
 
120
- DevLens can read your design tokens and component interfaces to give the AI accurate context when writing or fixing UI code. This is configured via a `devlens.config.json` file in your app root.
150
+ Optional. Enables `devlens_ds_context` for design-token-aware code generation.
121
151
 
122
152
  ### 1. Create `devlens.config.json` in your app root
123
153
 
@@ -135,22 +165,20 @@ DevLens can read your design tokens and component interfaces to give the AI accu
135
165
 
136
166
  | Field | Required | Description |
137
167
  |-------|----------|-------------|
138
- | `name` | Yes | Design system identifier (e.g. `"jds3"`, `"my-ds"`) |
139
- | `projectRoot` | Yes | Absolute path to your app root |
140
- | `tokensFile` | Yes | Path to your token constants file, relative to `projectRoot` |
141
- | `componentsDir` | No | Path to generated component interface directory, relative to `projectRoot` |
168
+ | `name` | Yes | Design system identifier (e.g. `"jds3"`) |
169
+ | `projectRoot` | Yes | **Absolute** path to your app root |
170
+ | `tokensFile` | Yes | Token file, relative to `projectRoot` |
171
+ | `componentsDir` | No | Generated component interfaces directory |
142
172
  | `componentsGlob` | No | Glob for component source files (default: `"src/**/*.tsx"`) |
143
173
 
144
- ### 2. Point DevLens to the config via the MCP env block
145
-
146
- Add `DEVLENS_CONFIG` to your `~/.cursor/mcp.json` (or equivalent):
174
+ ### 2. Point to it in your MCP config
147
175
 
148
176
  ```json
149
177
  {
150
178
  "mcpServers": {
151
179
  "devlens": {
152
- "command": "node",
153
- "args": ["/path/to/devlens/dist/bin/cli.js"],
180
+ "command": "npx",
181
+ "args": ["devlens-mcp@latest"],
154
182
  "env": {
155
183
  "METRO_PORT": "8081",
156
184
  "FIGMA_TOKEN": "figd_xxxxx",
@@ -161,189 +189,92 @@ Add `DEVLENS_CONFIG` to your `~/.cursor/mcp.json` (or equivalent):
161
189
  }
162
190
  ```
163
191
 
164
- The `devlens.config.json` file lives in your consumer app repository so it stays version-controlled alongside the app it describes.
165
-
166
- ### 3. Verify with `devlens_ds_context`
192
+ ### 3. Verify
167
193
 
168
- After restarting your AI client, ask:
169
-
170
- > *"Load the design system context"*
171
-
172
- `devlens_ds_context` will return:
173
- - All token names and values from your tokens file (colors, spacing, typography, etc.)
174
- - Component prop interfaces from `componentsDir`
175
- - Real usage patterns scanned from your `.tsx` files
194
+ Ask your AI: *"Load the design system context"* — it should return token names, component interfaces, and usage patterns.
176
195
 
177
196
  ---
178
197
 
179
- ## Figma Token Setup
180
-
181
- `devlens_compare_with_figma` requires a Figma personal access token (PAT).
182
-
183
- ### Generate a PAT
198
+ ## Troubleshooting
184
199
 
185
- 1. Go to [figma.com](https://www.figma.com) your profile icon **Settings**
186
- 2. Scroll to **Personal access tokens** → **Generate new token**
187
- 3. Give it a name (e.g. `devlens`)
188
- 4. Set scope: **File content → Read** (this is the only scope needed)
189
- 5. Copy the token — it starts with `figd_`
200
+ ### Fix: nvm/PATH issue (`env: node: No such file or directory`)
190
201
 
191
- ### Verify the token works
202
+ **This is the most common issue on macOS.** It happens because Cursor (and other GUI apps) don't load your shell profile, so `node` isn't in their PATH even though `npx` works in your terminal.
192
203
 
193
- ```bash
194
- curl -H "X-Figma-Token: figd_yourtoken" "https://api.figma.com/v1/me"
195
- # Expected: {"id":"...","email":"you@example.com","handle":"..."}
196
- ```
204
+ **Fix — use the full path to `npx`:**
197
205
 
198
- ### Add to MCP config
206
+ 1. Open **Terminal** and run:
207
+ ```bash
208
+ which npx
209
+ ```
210
+ This prints something like:
211
+ ```
212
+ /Users/yourname/.nvm/versions/node/v20.12.2/bin/npx
213
+ ```
199
214
 
200
- ```json
201
- "env": {
202
- "FIGMA_TOKEN": "figd_yourtoken"
203
- }
204
- ```
215
+ 2. Copy that full path and replace `"command": "npx"` in `~/.cursor/mcp.json`:
216
+ ```json
217
+ {
218
+ "mcpServers": {
219
+ "devlens": {
220
+ "command": "/Users/yourname/.nvm/versions/node/v20.12.2/bin/npx",
221
+ "args": ["devlens-mcp@latest"],
222
+ "env": {
223
+ "METRO_PORT": "8081"
224
+ }
225
+ }
226
+ }
227
+ }
228
+ ```
205
229
 
206
- > **Security note:** Never paste your PAT in a chat or commit it to source control. Use environment variables or a secrets manager.
230
+ 3. **Restart Cursor.** This fixes it permanently.
207
231
 
208
232
  ---
209
233
 
210
- ## Verifying Setup
211
-
212
- After configuration, start a conversation with your AI assistant and try these commands in order:
213
-
214
- ### 1. Check Metro Health
215
-
216
- > **Say:** *"Check if Metro is running"*
217
- >
218
- > **Tool called:** `devlens_metro_status`
219
- >
220
- > **Expected:** Running: `true`, Port: `8081`
221
-
222
- ### 2. List Devices
223
-
224
- > **Say:** *"List my devices"*
225
- >
226
- > **Tool called:** `devlens_list_devices`
227
- >
228
- > **Expected:** Your running emulators/simulators listed with IDs
234
+ ### Fix: "No server info found" / DevLens tools not showing
229
235
 
230
- ### 3. Take a Screenshot
236
+ This means Cursor couldn't start the MCP server. Check these in order:
231
237
 
232
- > **Say:** *"Take a screenshot of the device"*
233
- >
234
- > **Tool called:** `devlens_screenshot`
235
- >
236
- > **Expected:** Device screenshot returned as an inline image
238
+ 1. **Is the JSON valid?** Paste your `~/.cursor/mcp.json` into [jsonlint.com](https://jsonlint.com) to check for syntax errors (trailing commas, missing quotes, etc.)
237
239
 
238
- ### 4. Take a Snapshot
240
+ 2. **Is it `"command": "npx"`?** Not `"command": "node"`. Using `"node"` makes it look for a local file instead of downloading the package.
239
241
 
240
- > **Say:** *"Take a snapshot of the screen with validation"*
241
- >
242
- > **Tool called:** `devlens_snapshot(validate: true)`
243
- >
244
- > **Expected:** Accessibility tree with `ref=eN` IDs + validation report
245
-
246
- ### 5. Test Metro Logs
247
-
248
- > **Say:** *"Show me the Metro logs"*
249
- >
250
- > **Tool called:** `devlens_metro_logs`
251
- >
252
- > **Expected:** Console output from your React Native app
253
-
254
- ### 6. Compare with Figma (optional — requires FIGMA_TOKEN)
255
-
256
- > **Say:** *"Compare the current screen with this Figma frame: [your Figma URL]"*
257
- >
258
- > **Tool called:** `devlens_compare_with_figma`
259
- >
260
- > **Expected:** Three images (device, Figma reference, diff) + layout region report
261
-
262
- ### 7. Design System Context (optional — requires DEVLENS_CONFIG)
263
-
264
- > **Say:** *"Load the design system context"*
265
- >
266
- > **Tool called:** `devlens_ds_context`
267
- >
268
- > **Expected:** Token list, component interfaces, and usage patterns
242
+ 3. **Does `npx devlens-mcp@latest` work in Terminal?**
243
+ ```bash
244
+ npx devlens-mcp@latest
245
+ ```
246
+ - If this hangs (no output) that's correct, it's waiting for MCP input via stdin. Press `Ctrl+C`.
247
+ - If it errors with `env: node: No such file` — see the [nvm/PATH fix](#fix-nvmpath-issue-env-node-no-such-file-or-directory) above.
248
+ - If it errors with `Cannot find module` — clear the npx cache: `rm -rf ~/.npm/_npx/*devlens*` and try again.
269
249
 
270
- If steps 1–5 succeed, DevLens is fully operational. Steps 6–7 require the optional env vars.
250
+ 4. **Restart Cursor completely** (quit and reopen, not just reload window).
271
251
 
272
252
  ---
273
253
 
274
- ## Troubleshooting
275
-
276
- ### "No running simulators or emulators found"
277
- - Start an Android emulator from Android Studio, or boot an iOS Simulator from Xcode
278
- - Verify with `adb devices` (Android) or `xcrun simctl list devices | grep Booted` (iOS)
279
- - If the device was recently started, DevLens may have a stale cache — the retry system will auto-reconnect
280
-
281
- ### "Could not connect to Metro bundler"
282
- - Ensure Metro is running: `npx react-native start` or `npx expo start`
283
- - Check the port: default is 8081, set `METRO_PORT` if different
284
- - Metro must be running on the same machine as DevLens
285
- - Use `devlens_metro_status` to diagnose — it gives actionable error messages
286
-
287
- ### "ADB command not found"
288
- - Set `ANDROID_HOME` to your Android SDK path
289
- - Or add `$ANDROID_HOME/platform-tools` to your PATH
290
-
291
- ### iOS "simctl not found"
292
- - Install Xcode Command Line Tools: `xcode-select --install`
293
- - Ensure Xcode is installed (not just CLT)
294
-
295
- ### Screenshots return empty or black
296
- - The app might not be in the foreground; use `devlens_launch_app` first
297
- - Wait a moment after navigation for the screen to render
298
- - Use `devlens_wait_for_screen(stableMs: 2000)` to wait for screen stability
299
-
300
- ### "Invalid token" when using Figma comparison
301
- - Make sure you're using a **personal access token** (`figd_...`), not an OAuth token
302
- - Verify it has the **File content: Read** scope
303
- - Test with: `curl -H "X-Figma-Token: YOUR_TOKEN" "https://api.figma.com/v1/me"`
304
-
305
- ### "File not exportable" when using Figma comparison
306
- - The Figma file has export restrictions enabled
307
- - Ask the file owner to go to **Share → Anyone with link → Uncheck "Prevent viewers from copying and exporting"**
254
+ ### Fix: Stale npx cache after update
308
255
 
309
- ### Layout report is empty or missing in Figma comparison
310
- - Run `devlens_snapshot` on the current screen before `devlens_compare_with_figma` — the layout report uses element bounds from the snapshot
311
- - If refs are stale (screen changed), take a fresh snapshot first
256
+ If you were on an older version and get `Cannot find module` errors:
312
257
 
313
- ### `devlens_ds_context` returns empty or fails
314
- - Check that `DEVLENS_CONFIG` points to a valid `devlens.config.json` with an absolute `projectRoot`
315
- - Verify the `tokensFile` path is correct relative to `projectRoot`
316
- - The tool logs warnings to stderr — check your MCP server logs
258
+ ```bash
259
+ rm -rf ~/.npm/_npx/*devlens*
260
+ ```
317
261
 
318
- ### "env: node: No such file or directory" when using npx
319
- This happens on macOS when Node.js is installed via `nvm`, `fnm`, or a version manager. Cursor (and other GUI apps) don't load shell profiles, so `node` isn't in their PATH even though `npx` is found.
262
+ Then restart Cursor. npx will re-download the latest version.
320
263
 
321
- **Fix:** Use the full absolute path to `npx` instead of just `npx`.
264
+ ---
322
265
 
323
- 1. Open Terminal and run:
324
- ```bash
325
- which npx
326
- # e.g. /Users/yourname/.nvm/versions/node/v23.10.0/bin/npx
327
- ```
328
- 2. Replace `"command": "npx"` in `~/.cursor/mcp.json` with that full path:
329
- ```json
330
- {
331
- "mcpServers": {
332
- "devlens": {
333
- "command": "/Users/yourname/.nvm/versions/node/v23.10.0/bin/npx",
334
- "args": ["devlens-mcp@latest"],
335
- "env": { "METRO_PORT": "8081", "FIGMA_TOKEN": "figd_xxxxx" }
336
- }
337
- }
338
- }
339
- ```
340
- 3. Restart Cursor.
266
+ ### Other Issues
341
267
 
342
- ### DevLens tools not available in AI assistant
343
- - Verify `"command": "npx"` (not `"command": "node"`) in your MCP config
344
- - If you see `env: node: No such file or directory`, see the section above
345
- - Restart your AI client after any config change
346
- - Check `~/.cursor/mcp.json` or your IDE's MCP config for a `devlens` entry
268
+ | Problem | Solution |
269
+ |---------|----------|
270
+ | "No running simulators or emulators" | Start a device from Android Studio or Xcode |
271
+ | "Could not connect to Metro bundler" | Run `npx react-native start` and check `METRO_PORT` |
272
+ | "ADB command not found" | Set `ANDROID_HOME` or add `platform-tools` to PATH |
273
+ | "simctl not found" (iOS) | Run `xcode-select --install` |
274
+ | "Invalid token" on Figma compare | Use a personal access token (`figd_...`) with **File content: Read** scope |
275
+ | "File not exportable" on Figma compare | Ask file owner to uncheck "Prevent copying and exporting" in Figma share settings |
276
+ | Layout report empty in Figma compare | Run `devlens_snapshot` first — layout report needs element bounds from the snapshot |
277
+ | `devlens_ds_context` returns empty | Verify `DEVLENS_CONFIG` path and that `projectRoot` is absolute |
347
278
 
348
279
  ---
349
280
 
@@ -362,4 +293,4 @@ DevLens provides **34 tools** across 8 categories:
362
293
  | Navigation | open_url, go_back | 2 |
363
294
  | Design System | ds_context | 1 |
364
295
 
365
- See the [Tool Reference](./tool-reference.md) for detailed documentation of every tool and parameter.
296
+ See the [Tool Reference](./tool-reference.md) for detailed parameter docs.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devlens-mcp",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "DevLens — Playwright-style MCP server for mobile development. Take screenshots, compare with Figma designs, interact with iOS Simulators & Android Emulators, and access Metro bundler logs.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",