metro-mcp 0.1.0

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 (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +143 -0
  3. package/dist/bin/metro-mcp.js +3726 -0
  4. package/dist/client/client-buffer.d.ts +14 -0
  5. package/dist/client/client-buffer.d.ts.map +1 -0
  6. package/dist/client/index.cjs +346 -0
  7. package/dist/client/index.d.ts +80 -0
  8. package/dist/client/index.d.ts.map +1 -0
  9. package/dist/client/index.js +307 -0
  10. package/dist/client/lifecycle.d.ts +17 -0
  11. package/dist/client/lifecycle.d.ts.map +1 -0
  12. package/dist/client/logger.d.ts +17 -0
  13. package/dist/client/logger.d.ts.map +1 -0
  14. package/dist/client/middleware/navigation.d.ts +22 -0
  15. package/dist/client/middleware/navigation.d.ts.map +1 -0
  16. package/dist/client/middleware/redux.d.ts +22 -0
  17. package/dist/client/middleware/redux.d.ts.map +1 -0
  18. package/dist/client/performance.d.ts +18 -0
  19. package/dist/client/performance.d.ts.map +1 -0
  20. package/dist/client/state.d.ts +13 -0
  21. package/dist/client/state.d.ts.map +1 -0
  22. package/dist/config.d.ts +6 -0
  23. package/dist/config.d.ts.map +1 -0
  24. package/dist/index.d.ts +3 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +3746 -0
  27. package/dist/metro/connection.d.ts +66 -0
  28. package/dist/metro/connection.d.ts.map +1 -0
  29. package/dist/metro/discovery.d.ts +19 -0
  30. package/dist/metro/discovery.d.ts.map +1 -0
  31. package/dist/metro/types.d.ts +49 -0
  32. package/dist/metro/types.d.ts.map +1 -0
  33. package/dist/plugin.cjs +51 -0
  34. package/dist/plugin.d.ts +97 -0
  35. package/dist/plugin.d.ts.map +1 -0
  36. package/dist/plugin.js +14 -0
  37. package/dist/plugins/accessibility.d.ts +2 -0
  38. package/dist/plugins/accessibility.d.ts.map +1 -0
  39. package/dist/plugins/appium.d.ts +2 -0
  40. package/dist/plugins/appium.d.ts.map +1 -0
  41. package/dist/plugins/bundle.d.ts +2 -0
  42. package/dist/plugins/bundle.d.ts.map +1 -0
  43. package/dist/plugins/commands.d.ts +2 -0
  44. package/dist/plugins/commands.d.ts.map +1 -0
  45. package/dist/plugins/components.d.ts +2 -0
  46. package/dist/plugins/components.d.ts.map +1 -0
  47. package/dist/plugins/console.d.ts +2 -0
  48. package/dist/plugins/console.d.ts.map +1 -0
  49. package/dist/plugins/deeplink.d.ts +2 -0
  50. package/dist/plugins/deeplink.d.ts.map +1 -0
  51. package/dist/plugins/device.d.ts +2 -0
  52. package/dist/plugins/device.d.ts.map +1 -0
  53. package/dist/plugins/errors.d.ts +2 -0
  54. package/dist/plugins/errors.d.ts.map +1 -0
  55. package/dist/plugins/evaluate.d.ts +2 -0
  56. package/dist/plugins/evaluate.d.ts.map +1 -0
  57. package/dist/plugins/maestro.d.ts +2 -0
  58. package/dist/plugins/maestro.d.ts.map +1 -0
  59. package/dist/plugins/navigation.d.ts +2 -0
  60. package/dist/plugins/navigation.d.ts.map +1 -0
  61. package/dist/plugins/network.d.ts +2 -0
  62. package/dist/plugins/network.d.ts.map +1 -0
  63. package/dist/plugins/prompts.d.ts +2 -0
  64. package/dist/plugins/prompts.d.ts.map +1 -0
  65. package/dist/plugins/redux.d.ts +2 -0
  66. package/dist/plugins/redux.d.ts.map +1 -0
  67. package/dist/plugins/simulator.d.ts +2 -0
  68. package/dist/plugins/simulator.d.ts.map +1 -0
  69. package/dist/plugins/source.d.ts +2 -0
  70. package/dist/plugins/source.d.ts.map +1 -0
  71. package/dist/plugins/storage.d.ts +2 -0
  72. package/dist/plugins/storage.d.ts.map +1 -0
  73. package/dist/plugins/ui-interact.d.ts +2 -0
  74. package/dist/plugins/ui-interact.d.ts.map +1 -0
  75. package/dist/server.d.ts +3 -0
  76. package/dist/server.d.ts.map +1 -0
  77. package/dist/utils/buffer.d.ts +19 -0
  78. package/dist/utils/buffer.d.ts.map +1 -0
  79. package/dist/utils/cdp.d.ts +6 -0
  80. package/dist/utils/cdp.d.ts.map +1 -0
  81. package/dist/utils/fiber.d.ts +33 -0
  82. package/dist/utils/fiber.d.ts.map +1 -0
  83. package/dist/utils/format.d.ts +34 -0
  84. package/dist/utils/format.d.ts.map +1 -0
  85. package/dist/utils/logger.d.ts +3 -0
  86. package/dist/utils/logger.d.ts.map +1 -0
  87. package/package.json +65 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Stephen Radford
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.
package/README.md ADDED
@@ -0,0 +1,143 @@
1
+ # metro-mcp
2
+
3
+ [![Install in VS Code](https://img.shields.io/badge/Install_in-VS_Code-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect/mcp/install?name=metro-mcp&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22metro-mcp%22%5D%2C%22env%22%3A%7B%7D%7D)
4
+ [![Install in Cursor](https://img.shields.io/badge/Install_in-Cursor-000000?style=flat-square&logoColor=white)](https://cursor.com/en/install-mcp?name=metro-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIm1ldHJvLW1jcCJdLCJlbnYiOnt9fQ==)
5
+
6
+ A plugin-based MCP server for React Native runtime debugging, inspection, and automation. Connects to Metro bundler via Chrome DevTools Protocol — **no app code changes needed** for most features.
7
+
8
+ Works with **Expo**, **bare React Native**, and any project using **Metro + Hermes**.
9
+
10
+ ## Quick Start
11
+
12
+ ### Claude Code
13
+
14
+ ```bash
15
+ claude mcp add metro-mcp -- npx -y metro-mcp
16
+ # or with Bun
17
+ claude mcp add metro-mcp -- bunx metro-mcp
18
+ ```
19
+
20
+ ### Cursor / VS Code
21
+
22
+ ```json
23
+ {
24
+ "mcpServers": {
25
+ "metro-mcp": {
26
+ "command": "npx",
27
+ "args": ["-y", "metro-mcp"]
28
+ }
29
+ }
30
+ }
31
+ ```
32
+
33
+ Or with Bun:
34
+
35
+ ```json
36
+ {
37
+ "mcpServers": {
38
+ "metro-mcp": {
39
+ "command": "bunx",
40
+ "args": ["metro-mcp"]
41
+ }
42
+ }
43
+ }
44
+ ```
45
+
46
+ ### With custom Metro port
47
+
48
+ ```bash
49
+ claude mcp add metro-mcp -- npx -y metro-mcp --port 19000
50
+ ```
51
+
52
+ ## Requirements
53
+
54
+ - **Node.js** 18+ or **Bun** 1.0+
55
+ - **iOS**: Xcode 14+ with Simulator (`xcrun simctl` is used for most operations)
56
+ - **Android**: Android SDK with `adb` on your PATH
57
+ - **IDB** *(optional)*: Some iOS operations fall back to [IDB (idb-companion)](https://github.com/facebook/idb) — install with `brew install idb-companion`. Tools will tell you when IDB is needed.
58
+
59
+ ## How It Works
60
+
61
+ metro-mcp connects to your running Metro dev server the same way Chrome DevTools does:
62
+
63
+ 1. Discovers Metro via port scanning (8081, 8082, 19000-19002)
64
+ 2. Connects to Hermes via Chrome DevTools Protocol (CDP)
65
+ 3. Streams console logs, network requests, errors into buffers
66
+ 4. Exposes everything as MCP tools, resources, and prompts
67
+
68
+ **No app modifications required** for core debugging features.
69
+
70
+ ## Features
71
+
72
+ | Plugin | Tools | Description |
73
+ |--------|-------|-------------|
74
+ | **console** | 2 | Console log collection with filtering |
75
+ | **network** | 3 | Network request tracking and search |
76
+ | **errors** | 2 | Exception collection with auto-symbolication |
77
+ | **evaluate** | 1 | Execute JavaScript in app runtime |
78
+ | **device** | 3 | Device and connection management |
79
+ | **source** | 1 | Stack trace symbolication |
80
+ | **redux** | 3 | Redux state inspection and action dispatch |
81
+ | **components** | 4 | React component tree inspection |
82
+ | **storage** | 3 | AsyncStorage reading |
83
+ | **bundle** | 2 | Metro bundle diagnostics |
84
+ | **simulator** | 6 | iOS simulator / Android device control |
85
+ | **deeplink** | 2 | Cross-platform deep link testing |
86
+ | **ui-interact** | 6 | UI automation (tap, swipe, type) |
87
+ | **navigation** | 4 | React Navigation / Expo Router state |
88
+ | **accessibility** | 3 | Accessibility auditing |
89
+ | **commands** | 2 | Custom app commands |
90
+ | **maestro** | 2 | Maestro test flow generation |
91
+ | **appium** | 3 | Appium/WebdriverIO Jest test generation |
92
+
93
+ **Total: 50 tools, 7 resources, 7 prompts** — see the [full tools reference](docs/tools.md).
94
+
95
+ ## App Integration (Optional)
96
+
97
+ Register custom commands and expose state to the MCP server — no package needed. Add this to your app entry point in dev mode:
98
+
99
+ ```typescript
100
+ if (__DEV__) {
101
+ global.__METRO_MCP__ = {
102
+ commands: {
103
+ // Run custom actions from the MCP client
104
+ login: async ({ email, password }) => {
105
+ return await authService.login(email, password);
106
+ },
107
+ resetOnboarding: () => {
108
+ AsyncStorage.removeItem('onboarding_completed');
109
+ },
110
+ switchUser: ({ userId }) => {
111
+ store.dispatch(switchUser(userId));
112
+ },
113
+ },
114
+ state: {
115
+ // Expose state snapshots readable via get_redux_state
116
+ userStore: () => useUserStore.getState(),
117
+ },
118
+ };
119
+ }
120
+ ```
121
+
122
+ Use `list_commands` and `run_command` to call these from the MCP client.
123
+
124
+ For enhanced features like real-time Redux action tracking, navigation events, and performance marks, see the [optional client SDK](docs/sdk.md).
125
+
126
+ ## Configuration
127
+
128
+ See [configuration docs](docs/configuration.md) for environment variables, CLI arguments, and config file options.
129
+
130
+ ## Custom Plugins
131
+
132
+ metro-mcp is fully extensible. See the [plugins guide](docs/plugins.md) to build your own tools and resources.
133
+
134
+ ## Compatibility
135
+
136
+ - **React Native**: 0.70+ (Hermes required)
137
+ - **Expo**: SDK 49+
138
+ - **Runtime**: Node.js 18+ or Bun 1.0+
139
+ - **Platforms**: iOS Simulator, Android Emulator, physical devices via USB
140
+
141
+ ## License
142
+
143
+ MIT