react-native-mcp-kit 1.0.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 (271) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +868 -0
  3. package/dist/babel/index.d.ts +3 -0
  4. package/dist/babel/index.d.ts.map +1 -0
  5. package/dist/babel/index.js +11 -0
  6. package/dist/babel/index.js.map +1 -0
  7. package/dist/babel/stripPlugin.d.ts +5 -0
  8. package/dist/babel/stripPlugin.d.ts.map +1 -0
  9. package/dist/babel/stripPlugin.js +100 -0
  10. package/dist/babel/stripPlugin.js.map +1 -0
  11. package/dist/babel/testIdPlugin.d.ts +5 -0
  12. package/dist/babel/testIdPlugin.d.ts.map +1 -0
  13. package/dist/babel/testIdPlugin.js +69 -0
  14. package/dist/babel/testIdPlugin.js.map +1 -0
  15. package/dist/client/contexts/McpContext/McpContext.d.ts +3 -0
  16. package/dist/client/contexts/McpContext/McpContext.d.ts.map +1 -0
  17. package/dist/client/contexts/McpContext/McpContext.js +6 -0
  18. package/dist/client/contexts/McpContext/McpContext.js.map +1 -0
  19. package/dist/client/contexts/McpContext/McpProvider.d.ts +3 -0
  20. package/dist/client/contexts/McpContext/McpProvider.d.ts.map +1 -0
  21. package/dist/client/contexts/McpContext/McpProvider.js +28 -0
  22. package/dist/client/contexts/McpContext/McpProvider.js.map +1 -0
  23. package/dist/client/contexts/McpContext/index.d.ts +4 -0
  24. package/dist/client/contexts/McpContext/index.d.ts.map +1 -0
  25. package/dist/client/contexts/McpContext/index.js +8 -0
  26. package/dist/client/contexts/McpContext/index.js.map +1 -0
  27. package/dist/client/contexts/McpContext/types.d.ts +12 -0
  28. package/dist/client/contexts/McpContext/types.d.ts.map +1 -0
  29. package/dist/client/contexts/McpContext/types.js +3 -0
  30. package/dist/client/contexts/McpContext/types.js.map +1 -0
  31. package/dist/client/contexts/McpTreeContext/McpTracker.d.ts +10 -0
  32. package/dist/client/contexts/McpTreeContext/McpTracker.d.ts.map +1 -0
  33. package/dist/client/contexts/McpTreeContext/McpTracker.js +101 -0
  34. package/dist/client/contexts/McpTreeContext/McpTracker.js.map +1 -0
  35. package/dist/client/contexts/McpTreeContext/McpTreeContext.d.ts +2 -0
  36. package/dist/client/contexts/McpTreeContext/McpTreeContext.d.ts.map +1 -0
  37. package/dist/client/contexts/McpTreeContext/McpTreeContext.js +6 -0
  38. package/dist/client/contexts/McpTreeContext/McpTreeContext.js.map +1 -0
  39. package/dist/client/contexts/McpTreeContext/McpTreeRegistry.d.ts +16 -0
  40. package/dist/client/contexts/McpTreeContext/McpTreeRegistry.d.ts.map +1 -0
  41. package/dist/client/contexts/McpTreeContext/McpTreeRegistry.js +96 -0
  42. package/dist/client/contexts/McpTreeContext/McpTreeRegistry.js.map +1 -0
  43. package/dist/client/contexts/McpTreeContext/index.d.ts +5 -0
  44. package/dist/client/contexts/McpTreeContext/index.d.ts.map +1 -0
  45. package/dist/client/contexts/McpTreeContext/index.js +10 -0
  46. package/dist/client/contexts/McpTreeContext/index.js.map +1 -0
  47. package/dist/client/contexts/McpTreeContext/types.d.ts +14 -0
  48. package/dist/client/contexts/McpTreeContext/types.d.ts.map +1 -0
  49. package/dist/client/contexts/McpTreeContext/types.js +3 -0
  50. package/dist/client/contexts/McpTreeContext/types.js.map +1 -0
  51. package/dist/client/core/McpClient.d.ts +25 -0
  52. package/dist/client/core/McpClient.d.ts.map +1 -0
  53. package/dist/client/core/McpClient.js +183 -0
  54. package/dist/client/core/McpClient.js.map +1 -0
  55. package/dist/client/hooks/useMcpModule.d.ts +4 -0
  56. package/dist/client/hooks/useMcpModule.d.ts.map +1 -0
  57. package/dist/client/hooks/useMcpModule.js +17 -0
  58. package/dist/client/hooks/useMcpModule.js.map +1 -0
  59. package/dist/client/hooks/useMcpState.d.ts +3 -0
  60. package/dist/client/hooks/useMcpState.d.ts.map +1 -0
  61. package/dist/client/hooks/useMcpState.js +20 -0
  62. package/dist/client/hooks/useMcpState.js.map +1 -0
  63. package/dist/client/hooks/useMcpTool.d.ts +4 -0
  64. package/dist/client/hooks/useMcpTool.d.ts.map +1 -0
  65. package/dist/client/hooks/useMcpTool.js +20 -0
  66. package/dist/client/hooks/useMcpTool.js.map +1 -0
  67. package/dist/client/index.d.ts +8 -0
  68. package/dist/client/index.d.ts.map +1 -0
  69. package/dist/client/index.js +15 -0
  70. package/dist/client/index.js.map +1 -0
  71. package/dist/client/models/types.d.ts +12 -0
  72. package/dist/client/models/types.d.ts.map +1 -0
  73. package/dist/client/models/types.js +3 -0
  74. package/dist/client/models/types.js.map +1 -0
  75. package/dist/client/utils/connection.d.ts +17 -0
  76. package/dist/client/utils/connection.d.ts.map +1 -0
  77. package/dist/client/utils/connection.js +71 -0
  78. package/dist/client/utils/connection.js.map +1 -0
  79. package/dist/client/utils/moduleRunner.d.ts +13 -0
  80. package/dist/client/utils/moduleRunner.d.ts.map +1 -0
  81. package/dist/client/utils/moduleRunner.js +59 -0
  82. package/dist/client/utils/moduleRunner.js.map +1 -0
  83. package/dist/index.d.ts +5 -0
  84. package/dist/index.d.ts.map +1 -0
  85. package/dist/index.js +25 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/modules/alert/alert.d.ts +3 -0
  88. package/dist/modules/alert/alert.d.ts.map +1 -0
  89. package/dist/modules/alert/alert.js +50 -0
  90. package/dist/modules/alert/alert.js.map +1 -0
  91. package/dist/modules/alert/index.d.ts +2 -0
  92. package/dist/modules/alert/index.d.ts.map +1 -0
  93. package/dist/modules/alert/index.js +6 -0
  94. package/dist/modules/alert/index.js.map +1 -0
  95. package/dist/modules/components/components.d.ts +8 -0
  96. package/dist/modules/components/components.d.ts.map +1 -0
  97. package/dist/modules/components/components.js +315 -0
  98. package/dist/modules/components/components.js.map +1 -0
  99. package/dist/modules/components/index.d.ts +3 -0
  100. package/dist/modules/components/index.d.ts.map +1 -0
  101. package/dist/modules/components/index.js +6 -0
  102. package/dist/modules/components/index.js.map +1 -0
  103. package/dist/modules/components/types.d.ts +18 -0
  104. package/dist/modules/components/types.d.ts.map +1 -0
  105. package/dist/modules/components/types.js +3 -0
  106. package/dist/modules/components/types.js.map +1 -0
  107. package/dist/modules/components/utils.d.ts +18 -0
  108. package/dist/modules/components/utils.d.ts.map +1 -0
  109. package/dist/modules/components/utils.js +386 -0
  110. package/dist/modules/components/utils.js.map +1 -0
  111. package/dist/modules/console/console.d.ts +4 -0
  112. package/dist/modules/console/console.d.ts.map +1 -0
  113. package/dist/modules/console/console.js +176 -0
  114. package/dist/modules/console/console.js.map +1 -0
  115. package/dist/modules/console/index.d.ts +3 -0
  116. package/dist/modules/console/index.d.ts.map +1 -0
  117. package/dist/modules/console/index.js +6 -0
  118. package/dist/modules/console/index.js.map +1 -0
  119. package/dist/modules/console/types.d.ts +13 -0
  120. package/dist/modules/console/types.d.ts.map +1 -0
  121. package/dist/modules/console/types.js +3 -0
  122. package/dist/modules/console/types.js.map +1 -0
  123. package/dist/modules/device/device.d.ts +3 -0
  124. package/dist/modules/device/device.d.ts.map +1 -0
  125. package/dist/modules/device/device.js +182 -0
  126. package/dist/modules/device/device.js.map +1 -0
  127. package/dist/modules/device/index.d.ts +3 -0
  128. package/dist/modules/device/index.d.ts.map +1 -0
  129. package/dist/modules/device/index.js +6 -0
  130. package/dist/modules/device/index.js.map +1 -0
  131. package/dist/modules/device/types.d.ts +24 -0
  132. package/dist/modules/device/types.d.ts.map +1 -0
  133. package/dist/modules/device/types.js +3 -0
  134. package/dist/modules/device/types.js.map +1 -0
  135. package/dist/modules/errors/errors.d.ts +4 -0
  136. package/dist/modules/errors/errors.d.ts.map +1 -0
  137. package/dist/modules/errors/errors.js +133 -0
  138. package/dist/modules/errors/errors.js.map +1 -0
  139. package/dist/modules/errors/index.d.ts +3 -0
  140. package/dist/modules/errors/index.d.ts.map +1 -0
  141. package/dist/modules/errors/index.js +6 -0
  142. package/dist/modules/errors/index.js.map +1 -0
  143. package/dist/modules/errors/types.d.ts +12 -0
  144. package/dist/modules/errors/types.d.ts.map +1 -0
  145. package/dist/modules/errors/types.js +3 -0
  146. package/dist/modules/errors/types.js.map +1 -0
  147. package/dist/modules/fiberTree/fiberTree.d.ts +8 -0
  148. package/dist/modules/fiberTree/fiberTree.d.ts.map +1 -0
  149. package/dist/modules/fiberTree/fiberTree.js +337 -0
  150. package/dist/modules/fiberTree/fiberTree.js.map +1 -0
  151. package/dist/modules/fiberTree/index.d.ts +3 -0
  152. package/dist/modules/fiberTree/index.d.ts.map +1 -0
  153. package/dist/modules/fiberTree/index.js +6 -0
  154. package/dist/modules/fiberTree/index.js.map +1 -0
  155. package/dist/modules/fiberTree/types.d.ts +18 -0
  156. package/dist/modules/fiberTree/types.d.ts.map +1 -0
  157. package/dist/modules/fiberTree/types.js +3 -0
  158. package/dist/modules/fiberTree/types.js.map +1 -0
  159. package/dist/modules/fiberTree/utils.d.ts +18 -0
  160. package/dist/modules/fiberTree/utils.d.ts.map +1 -0
  161. package/dist/modules/fiberTree/utils.js +386 -0
  162. package/dist/modules/fiberTree/utils.js.map +1 -0
  163. package/dist/modules/i18next/i18next.d.ts +4 -0
  164. package/dist/modules/i18next/i18next.d.ts.map +1 -0
  165. package/dist/modules/i18next/i18next.js +133 -0
  166. package/dist/modules/i18next/i18next.js.map +1 -0
  167. package/dist/modules/i18next/index.d.ts +3 -0
  168. package/dist/modules/i18next/index.d.ts.map +1 -0
  169. package/dist/modules/i18next/index.js +6 -0
  170. package/dist/modules/i18next/index.js.map +1 -0
  171. package/dist/modules/i18next/types.d.ts +12 -0
  172. package/dist/modules/i18next/types.d.ts.map +1 -0
  173. package/dist/modules/i18next/types.js +3 -0
  174. package/dist/modules/i18next/types.js.map +1 -0
  175. package/dist/modules/index.d.ts +12 -0
  176. package/dist/modules/index.d.ts.map +1 -0
  177. package/dist/modules/index.js +26 -0
  178. package/dist/modules/index.js.map +1 -0
  179. package/dist/modules/navigation/index.d.ts +3 -0
  180. package/dist/modules/navigation/index.d.ts.map +1 -0
  181. package/dist/modules/navigation/index.js +6 -0
  182. package/dist/modules/navigation/index.js.map +1 -0
  183. package/dist/modules/navigation/navigation.d.ts +4 -0
  184. package/dist/modules/navigation/navigation.d.ts.map +1 -0
  185. package/dist/modules/navigation/navigation.js +240 -0
  186. package/dist/modules/navigation/navigation.js.map +1 -0
  187. package/dist/modules/navigation/types.d.ts +34 -0
  188. package/dist/modules/navigation/types.d.ts.map +1 -0
  189. package/dist/modules/navigation/types.js +3 -0
  190. package/dist/modules/navigation/types.js.map +1 -0
  191. package/dist/modules/network/index.d.ts +3 -0
  192. package/dist/modules/network/index.d.ts.map +1 -0
  193. package/dist/modules/network/index.js +6 -0
  194. package/dist/modules/network/index.js.map +1 -0
  195. package/dist/modules/network/network.d.ts +4 -0
  196. package/dist/modules/network/network.d.ts.map +1 -0
  197. package/dist/modules/network/network.js +276 -0
  198. package/dist/modules/network/network.js.map +1 -0
  199. package/dist/modules/network/types.d.ts +26 -0
  200. package/dist/modules/network/types.d.ts.map +1 -0
  201. package/dist/modules/network/types.js +3 -0
  202. package/dist/modules/network/types.js.map +1 -0
  203. package/dist/modules/reactQuery/index.d.ts +3 -0
  204. package/dist/modules/reactQuery/index.d.ts.map +1 -0
  205. package/dist/modules/reactQuery/index.js +6 -0
  206. package/dist/modules/reactQuery/index.js.map +1 -0
  207. package/dist/modules/reactQuery/reactQuery.d.ts +4 -0
  208. package/dist/modules/reactQuery/reactQuery.d.ts.map +1 -0
  209. package/dist/modules/reactQuery/reactQuery.js +160 -0
  210. package/dist/modules/reactQuery/reactQuery.js.map +1 -0
  211. package/dist/modules/reactQuery/types.d.ts +29 -0
  212. package/dist/modules/reactQuery/types.d.ts.map +1 -0
  213. package/dist/modules/reactQuery/types.js +3 -0
  214. package/dist/modules/reactQuery/types.js.map +1 -0
  215. package/dist/modules/screenshot/index.d.ts +3 -0
  216. package/dist/modules/screenshot/index.d.ts.map +1 -0
  217. package/dist/modules/screenshot/index.js +6 -0
  218. package/dist/modules/screenshot/index.js.map +1 -0
  219. package/dist/modules/screenshot/screenshot.d.ts +4 -0
  220. package/dist/modules/screenshot/screenshot.d.ts.map +1 -0
  221. package/dist/modules/screenshot/screenshot.js +89 -0
  222. package/dist/modules/screenshot/screenshot.js.map +1 -0
  223. package/dist/modules/screenshot/types.d.ts +5 -0
  224. package/dist/modules/screenshot/types.d.ts.map +1 -0
  225. package/dist/modules/screenshot/types.js +3 -0
  226. package/dist/modules/screenshot/types.js.map +1 -0
  227. package/dist/modules/storage/index.d.ts +3 -0
  228. package/dist/modules/storage/index.d.ts.map +1 -0
  229. package/dist/modules/storage/index.js +6 -0
  230. package/dist/modules/storage/index.js.map +1 -0
  231. package/dist/modules/storage/storage.d.ts +4 -0
  232. package/dist/modules/storage/storage.d.ts.map +1 -0
  233. package/dist/modules/storage/storage.js +124 -0
  234. package/dist/modules/storage/storage.js.map +1 -0
  235. package/dist/modules/storage/types.d.ts +11 -0
  236. package/dist/modules/storage/types.d.ts.map +1 -0
  237. package/dist/modules/storage/types.js +3 -0
  238. package/dist/modules/storage/types.js.map +1 -0
  239. package/dist/modules/tree/index.d.ts +2 -0
  240. package/dist/modules/tree/index.d.ts.map +1 -0
  241. package/dist/modules/tree/index.js +6 -0
  242. package/dist/modules/tree/index.js.map +1 -0
  243. package/dist/modules/tree/tree.d.ts +3 -0
  244. package/dist/modules/tree/tree.d.ts.map +1 -0
  245. package/dist/modules/tree/tree.js +274 -0
  246. package/dist/modules/tree/tree.js.map +1 -0
  247. package/dist/server/bridge.d.ts +24 -0
  248. package/dist/server/bridge.d.ts.map +1 -0
  249. package/dist/server/bridge.js +152 -0
  250. package/dist/server/bridge.js.map +1 -0
  251. package/dist/server/cli.d.ts +3 -0
  252. package/dist/server/cli.d.ts.map +1 -0
  253. package/dist/server/cli.js +17 -0
  254. package/dist/server/cli.js.map +1 -0
  255. package/dist/server/index.d.ts +4 -0
  256. package/dist/server/index.d.ts.map +1 -0
  257. package/dist/server/index.js +30 -0
  258. package/dist/server/index.js.map +1 -0
  259. package/dist/server/mcpServer.d.ts +19 -0
  260. package/dist/server/mcpServer.d.ts.map +1 -0
  261. package/dist/server/mcpServer.js +303 -0
  262. package/dist/server/mcpServer.js.map +1 -0
  263. package/dist/server/types.d.ts +12 -0
  264. package/dist/server/types.d.ts.map +1 -0
  265. package/dist/server/types.js +3 -0
  266. package/dist/server/types.js.map +1 -0
  267. package/dist/shared/protocol.d.ts +54 -0
  268. package/dist/shared/protocol.d.ts.map +1 -0
  269. package/dist/shared/protocol.js +8 -0
  270. package/dist/shared/protocol.js.map +1 -0
  271. package/package.json +95 -0
@@ -0,0 +1,337 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fiberTreeModule = void 0;
4
+ const utils_1 = require("./utils");
5
+ const DEFAULT_DEPTH = 10;
6
+ const FIND_SCHEMA = {
7
+ index: {
8
+ description: 'Zero-based index when multiple components match (default: 0, i.e. first match)',
9
+ type: 'number',
10
+ },
11
+ mcpId: { description: 'data-mcp-id to search for', type: 'string' },
12
+ name: { description: 'Component name to search for', type: 'string' },
13
+ testID: { description: 'testID to search for', type: 'string' },
14
+ text: { description: 'Text content to search for', type: 'string' },
15
+ within: {
16
+ description: 'Search within a parent component path. Use "/" for nesting, ":N" for index. E.g. "Checkbox/Pressable", "Button:1/View"',
17
+ type: 'string',
18
+ },
19
+ };
20
+ const fiberTreeModule = (options) => {
21
+ if (options?.rootRef) {
22
+ (0, utils_1.setRootRef)(options.rootRef);
23
+ }
24
+ const findInRoot = (root, segment) => {
25
+ if (!root)
26
+ return null;
27
+ // Support "Name:index" format, e.g. "Button:1"
28
+ const [name, indexStr] = segment.split(':');
29
+ if (!name)
30
+ return null;
31
+ const idx = indexStr ? parseInt(indexStr, 10) : 0;
32
+ const allByMcpId = (0, utils_1.findAllByQuery)(root, { mcpId: name });
33
+ if (allByMcpId.length > 0)
34
+ return allByMcpId[idx] ?? null;
35
+ const allByTestID = (0, utils_1.findAllByQuery)(root, { testID: name });
36
+ if (allByTestID.length > 0)
37
+ return allByTestID[idx] ?? null;
38
+ const allByName = (0, utils_1.findAllByQuery)(root, { name });
39
+ return allByName[idx] ?? null;
40
+ };
41
+ const findComponent = (args) => {
42
+ let root = (0, utils_1.getFiberRoot)();
43
+ if (!root)
44
+ return null;
45
+ // "within" supports recursive path with index: "Parent/Child:1/GrandChild"
46
+ if (args.within) {
47
+ const path = args.within.split('/');
48
+ for (const segment of path) {
49
+ root = findInRoot(root, segment);
50
+ if (!root)
51
+ return null;
52
+ }
53
+ }
54
+ const index = args.index ?? 0;
55
+ if (args.mcpId) {
56
+ const all = (0, utils_1.findAllByQuery)(root, { mcpId: args.mcpId });
57
+ return all[index] ?? null;
58
+ }
59
+ if (args.testID) {
60
+ const all = (0, utils_1.findAllByQuery)(root, { testID: args.testID });
61
+ return all[index] ?? null;
62
+ }
63
+ if (args.name) {
64
+ const all = (0, utils_1.findAllByQuery)(root, { name: args.name });
65
+ return all[index] ?? null;
66
+ }
67
+ if (args.text) {
68
+ const all = (0, utils_1.findAllByQuery)(root, { text: args.text });
69
+ return all[index] ?? null;
70
+ }
71
+ return null;
72
+ };
73
+ const requireRoot = () => {
74
+ const root = (0, utils_1.getFiberRoot)();
75
+ if (!root) {
76
+ return { error: 'Fiber root not available. The app may not have rendered yet.' };
77
+ }
78
+ return null;
79
+ };
80
+ return {
81
+ description: `React component tree inspection and interaction.
82
+
83
+ ## Finding components
84
+ - find_all with hasProps: ["onPress"] — find all pressable elements
85
+ - find_all with hasProps: ["onChangeText"] — find all text inputs
86
+ - find_all with name: "Button" — find by component name
87
+ - get_component with mcpId: "Button:screens/Login:42" — find by stable ID
88
+
89
+ ## Interacting
90
+ - invoke with callback: "onPress" — press a button
91
+ - invoke with callback: "onChangeText", args: ["text"] — type into input
92
+ - invoke with callback: "onPress", args: [true] — toggle checkbox
93
+ - call_ref with method: "focus" — focus an input
94
+
95
+ ## Scoping with "within"
96
+ - within: "LoginForm" — search only inside LoginForm
97
+ - within: "Button:1/Pressable" — nested path with index
98
+
99
+ ## Tips
100
+ - mcpId is stable across renders (format: ComponentName:file:line)
101
+ - Use find_all first to discover available components, then invoke on them
102
+ - Use screenshot after interactions to verify results`,
103
+ name: 'fiber_tree',
104
+ tools: {
105
+ call_ref: {
106
+ description: 'Call a method on the native ref/instance of a component (e.g. focus, blur, measure). Use get_ref_methods first to see available methods.',
107
+ handler: (args) => {
108
+ const rootError = requireRoot();
109
+ if (rootError)
110
+ return rootError;
111
+ const fiber = findComponent(args);
112
+ if (!fiber)
113
+ return { error: 'Component not found' };
114
+ const instance = (0, utils_1.getNativeInstance)(fiber);
115
+ if (!instance) {
116
+ return { error: `Component "${(0, utils_1.getComponentName)(fiber)}" has no native instance` };
117
+ }
118
+ const methodName = args.method;
119
+ const methodArgs = args.args;
120
+ const method = instance[methodName];
121
+ if (typeof method !== 'function') {
122
+ return {
123
+ availableMethods: (0, utils_1.getAvailableMethods)(instance),
124
+ error: `No method "${methodName}" on native instance`,
125
+ };
126
+ }
127
+ try {
128
+ const bound = method.bind(instance);
129
+ const result = bound(...(methodArgs ?? []));
130
+ return {
131
+ component: (0, utils_1.getComponentName)(fiber),
132
+ method: methodName,
133
+ result,
134
+ success: true,
135
+ };
136
+ }
137
+ catch (e) {
138
+ return {
139
+ error: `Method "${methodName}" threw: ${e instanceof Error ? e.message : String(e)}`,
140
+ };
141
+ }
142
+ },
143
+ inputSchema: {
144
+ ...FIND_SCHEMA,
145
+ args: { description: 'Arguments to pass to the method as array', type: 'array' },
146
+ method: {
147
+ description: 'Method name to call (e.g. "focus", "blur", "measure")',
148
+ type: 'string',
149
+ },
150
+ },
151
+ },
152
+ find_all: {
153
+ description: 'Find all components matching a query (by testID, name, text, or props presence). Supports within for scoped search.',
154
+ handler: (args) => {
155
+ const rootError = requireRoot();
156
+ if (rootError)
157
+ return rootError;
158
+ let root = (0, utils_1.getFiberRoot)();
159
+ if (args.within) {
160
+ const path = args.within.split('/');
161
+ for (const segment of path) {
162
+ root = findInRoot(root, segment);
163
+ if (!root)
164
+ return { error: `Parent "${args.within}" not found` };
165
+ }
166
+ }
167
+ const query = {
168
+ hasProps: args.hasProps,
169
+ mcpId: args.mcpId,
170
+ name: args.name,
171
+ testID: args.testID,
172
+ text: args.text,
173
+ };
174
+ const fibers = (0, utils_1.findAllByQuery)(root, query);
175
+ return fibers.map((fiber) => {
176
+ return {
177
+ mcpId: fiber.memoizedProps?.['data-mcp-id'],
178
+ name: (0, utils_1.getComponentName)(fiber),
179
+ props: (0, utils_1.serializeProps)(fiber.memoizedProps),
180
+ testID: fiber.memoizedProps?.testID,
181
+ };
182
+ });
183
+ },
184
+ inputSchema: {
185
+ hasProps: {
186
+ description: 'Filter by props presence (array of prop names)',
187
+ type: 'array',
188
+ },
189
+ mcpId: { description: 'data-mcp-id to match', type: 'string' },
190
+ name: { description: 'Component name to match', type: 'string' },
191
+ testID: { description: 'testID to match', type: 'string' },
192
+ text: { description: 'Text content to match (substring)', type: 'string' },
193
+ within: FIND_SCHEMA.within,
194
+ },
195
+ },
196
+ get_children: {
197
+ description: 'Get children of a component found by testID, name, or text',
198
+ handler: (args) => {
199
+ const rootError = requireRoot();
200
+ if (rootError)
201
+ return rootError;
202
+ const fiber = findComponent(args);
203
+ if (!fiber)
204
+ return { error: 'Component not found' };
205
+ const depth = args.depth || DEFAULT_DEPTH;
206
+ const serialized = (0, utils_1.serializeFiber)(fiber, depth);
207
+ return serialized?.children ?? [];
208
+ },
209
+ inputSchema: {
210
+ ...FIND_SCHEMA,
211
+ depth: { description: 'Max depth to traverse (default: 10)', type: 'number' },
212
+ },
213
+ },
214
+ get_component: {
215
+ description: 'Find a component by testID, name, or text and return its details',
216
+ handler: (args) => {
217
+ const rootError = requireRoot();
218
+ if (rootError)
219
+ return rootError;
220
+ const root = (0, utils_1.getFiberRoot)();
221
+ let fiber = null;
222
+ if (args.mcpId) {
223
+ fiber = (0, utils_1.findByMcpId)(root, args.mcpId);
224
+ }
225
+ else if (args.testID) {
226
+ fiber = (0, utils_1.findByTestID)(root, args.testID);
227
+ }
228
+ else if (args.name) {
229
+ fiber = (0, utils_1.findByName)(root, args.name);
230
+ }
231
+ else if (args.text) {
232
+ fiber = (0, utils_1.findByText)(root, args.text);
233
+ }
234
+ if (!fiber)
235
+ return { error: 'Component not found' };
236
+ const depth = args.depth || DEFAULT_DEPTH;
237
+ return (0, utils_1.serializeFiber)(fiber, depth);
238
+ },
239
+ inputSchema: {
240
+ depth: { description: 'Max depth to traverse children (default: 3)', type: 'number' },
241
+ mcpId: { description: 'data-mcp-id to search for', type: 'string' },
242
+ name: { description: 'Component name to search for', type: 'string' },
243
+ testID: { description: 'testID to search for', type: 'string' },
244
+ text: { description: 'Text content to search for', type: 'string' },
245
+ },
246
+ },
247
+ get_props: {
248
+ description: 'Get all props of a component found by testID, name, or text',
249
+ handler: (args) => {
250
+ const rootError = requireRoot();
251
+ if (rootError)
252
+ return rootError;
253
+ const fiber = findComponent(args);
254
+ if (!fiber)
255
+ return { error: 'Component not found' };
256
+ return {
257
+ name: (0, utils_1.getComponentName)(fiber),
258
+ props: (0, utils_1.serializeProps)(fiber.memoizedProps),
259
+ };
260
+ },
261
+ inputSchema: FIND_SCHEMA,
262
+ },
263
+ get_ref_methods: {
264
+ description: 'List available methods on the native ref/instance of a component',
265
+ handler: (args) => {
266
+ const rootError = requireRoot();
267
+ if (rootError)
268
+ return rootError;
269
+ const fiber = findComponent(args);
270
+ if (!fiber)
271
+ return { error: 'Component not found' };
272
+ const instance = (0, utils_1.getNativeInstance)(fiber);
273
+ if (!instance) {
274
+ return { error: `Component "${(0, utils_1.getComponentName)(fiber)}" has no native instance` };
275
+ }
276
+ return {
277
+ component: (0, utils_1.getComponentName)(fiber),
278
+ methods: (0, utils_1.getAvailableMethods)(instance),
279
+ };
280
+ },
281
+ inputSchema: FIND_SCHEMA,
282
+ },
283
+ get_tree: {
284
+ description: 'Get the React component tree. Returns component names, types, props, and testIDs.',
285
+ handler: (args) => {
286
+ const rootError = requireRoot();
287
+ if (rootError)
288
+ return rootError;
289
+ const root = (0, utils_1.getFiberRoot)();
290
+ const depth = args.depth || DEFAULT_DEPTH;
291
+ return (0, utils_1.serializeFiber)(root, depth);
292
+ },
293
+ inputSchema: {
294
+ depth: { description: 'Max depth to traverse (default: 3)', type: 'number' },
295
+ },
296
+ },
297
+ invoke: {
298
+ description: 'Call any callback prop on a component found by testID, name, or text. Use this to simulate press, scroll, text input, or any other interaction.',
299
+ handler: (args) => {
300
+ const rootError = requireRoot();
301
+ if (rootError)
302
+ return rootError;
303
+ const fiber = findComponent(args);
304
+ if (!fiber)
305
+ return { error: 'Component not found' };
306
+ const callbackName = args.callback;
307
+ const callbackArgs = args.args;
308
+ const callback = fiber.memoizedProps?.[callbackName];
309
+ if (typeof callback !== 'function') {
310
+ const availableCallbacks = Object.keys(fiber.memoizedProps ?? {}).filter((key) => {
311
+ return typeof fiber.memoizedProps[key] === 'function';
312
+ });
313
+ return {
314
+ availableCallbacks,
315
+ error: `Component "${(0, utils_1.getComponentName)(fiber)}" has no "${callbackName}" callback`,
316
+ };
317
+ }
318
+ const result = callback(...(callbackArgs ?? []));
319
+ return { component: (0, utils_1.getComponentName)(fiber), result, success: true };
320
+ },
321
+ inputSchema: {
322
+ ...FIND_SCHEMA,
323
+ args: {
324
+ description: 'Arguments to pass to the callback as array (e.g. [true] or ["text"])',
325
+ type: 'array',
326
+ },
327
+ callback: {
328
+ description: 'Name of the callback prop to call (e.g. "onPress", "onChangeText")',
329
+ type: 'string',
330
+ },
331
+ },
332
+ },
333
+ },
334
+ };
335
+ };
336
+ exports.fiberTreeModule = fiberTreeModule;
337
+ //# sourceMappingURL=fiberTree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fiberTree.js","sourceRoot":"","sources":["../../../src/modules/fiberTree/fiberTree.ts"],"names":[],"mappings":";;;AAIA,mCAaiB;AAEjB,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE;QACL,WAAW,EAAE,gFAAgF;QAC7F,I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BACH,OAAO;4BACL,kBAAkB;4BAClB,KAAK,EAAE,cAAc,IAAA,wBAAgB,EAAC,KAAK,CAAC,aAAa,YAAY,YAAY;yBAClF,CAAC;oBACJ,CAAC;oBAED,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,CAAC;oBACjD,OAAO,EAAE,SAAS,EAAE,IAAA,wBAAgB,EAAC,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gBACvE,CAAC;gBACD,WAAW,EAAE;oBACX,GAAG,WAAW;oBACd,IAAI,EAAE;wBACJ,WAAW,EAAE,sEAAsE;wBACnF,IAAI,EAAE,OAAO;qBACd;oBACD,QAAQ,EAAE;wBACR,WAAW,EAAE,oEAAoE;wBACjF,IAAI,EAAE,QAAQ;qBACf;iBACF;aACF;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAvUW,QAAA,eAAe,mBAuU1B"}
@@ -0,0 +1,3 @@
1
+ export { fiberTreeModule } from './fiberTree';
2
+ export { type ComponentQuery, type ComponentType, type SerializedComponent } from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/fiberTree/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fiberTreeModule = void 0;
4
+ var fiberTree_1 = require("./fiberTree");
5
+ Object.defineProperty(exports, "fiberTreeModule", { enumerable: true, get: function () { return fiberTree_1.fiberTreeModule; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/fiberTree/index.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAArC,4GAAA,eAAe,OAAA"}
@@ -0,0 +1,18 @@
1
+ export type ComponentType = 'composite' | 'host' | 'other' | 'text';
2
+ export interface SerializedComponent {
3
+ children: SerializedComponent[];
4
+ name: string;
5
+ props: Record<string, unknown>;
6
+ type: ComponentType;
7
+ mcpId?: string;
8
+ testID?: string;
9
+ text?: string;
10
+ }
11
+ export interface ComponentQuery {
12
+ hasProps?: string[];
13
+ mcpId?: string;
14
+ name?: string;
15
+ testID?: string;
16
+ text?: string;
17
+ }
18
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/fiberTree/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAEpE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,EAAE,aAAa,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/modules/fiberTree/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ import { type ComponentQuery, type SerializedComponent } from './types';
2
+ type Fiber = any;
3
+ export declare const setRootRef: (ref: unknown) => void;
4
+ export declare const getFiberRoot: () => Fiber | null;
5
+ export declare const getComponentName: (fiber: Fiber) => string;
6
+ export declare const serializeProps: (props: Record<string, unknown> | null) => Record<string, unknown>;
7
+ export declare const serializeFiber: (fiber: Fiber, maxDepth: number, currentDepth?: number) => SerializedComponent | null;
8
+ export declare const findFiber: (root: Fiber, predicate: (fiber: Fiber) => boolean) => Fiber | null;
9
+ export declare const findAllFibers: (root: Fiber, predicate: (fiber: Fiber) => boolean) => Fiber[];
10
+ export declare const findByMcpId: (root: Fiber, mcpId: string) => Fiber | null;
11
+ export declare const findByTestID: (root: Fiber, testID: string) => Fiber | null;
12
+ export declare const findByName: (root: Fiber, name: string) => Fiber | null;
13
+ export declare const findByText: (root: Fiber, text: string) => Fiber | null;
14
+ export declare const findAllByQuery: (root: Fiber, query: ComponentQuery) => Fiber[];
15
+ export declare const getNativeInstance: (fiber: Fiber) => unknown;
16
+ export declare const getAvailableMethods: (instance: unknown) => string[];
17
+ export {};
18
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/modules/fiberTree/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAsB,KAAK,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAY5F,KAAK,KAAK,GAAG,GAAG,CAAC;AAKjB,eAAO,MAAM,UAAU,QAAS,OAAO,KAAG,IAEzC,CAAC;AAeF,eAAO,MAAM,YAAY,QAAO,KAAK,GAAG,IAKvC,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAAW,KAAK,KAAG,MA+B/C,CAAC;AAkFF,eAAO,MAAM,cAAc,UAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG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