ios-webkit-mcp 0.18.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.
Files changed (171) hide show
  1. package/CONTRIBUTING.md +61 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +16 -0
  4. package/README.md +187 -0
  5. package/build/src/bin/ios-webkit-mcp.d.ts +2 -0
  6. package/build/src/bin/ios-webkit-mcp.js +14 -0
  7. package/build/src/bin/ios-webkit-mcp.js.map +1 -0
  8. package/build/src/capability.d.ts +61 -0
  9. package/build/src/capability.js +146 -0
  10. package/build/src/capability.js.map +1 -0
  11. package/build/src/index.d.ts +1 -0
  12. package/build/src/index.js +2 -0
  13. package/build/src/index.js.map +1 -0
  14. package/build/src/page-session.d.ts +108 -0
  15. package/build/src/page-session.js +331 -0
  16. package/build/src/page-session.js.map +1 -0
  17. package/build/src/server.d.ts +11 -0
  18. package/build/src/server.js +144 -0
  19. package/build/src/server.js.map +1 -0
  20. package/build/src/tools/analyze_performance.d.ts +40 -0
  21. package/build/src/tools/analyze_performance.js +112 -0
  22. package/build/src/tools/analyze_performance.js.map +1 -0
  23. package/build/src/tools/breakpoints.d.ts +80 -0
  24. package/build/src/tools/breakpoints.js +167 -0
  25. package/build/src/tools/breakpoints.js.map +1 -0
  26. package/build/src/tools/clear_console.d.ts +11 -0
  27. package/build/src/tools/clear_console.js +32 -0
  28. package/build/src/tools/clear_console.js.map +1 -0
  29. package/build/src/tools/click.d.ts +20 -0
  30. package/build/src/tools/click.js +88 -0
  31. package/build/src/tools/click.js.map +1 -0
  32. package/build/src/tools/debug_element.d.ts +36 -0
  33. package/build/src/tools/debug_element.js +66 -0
  34. package/build/src/tools/debug_element.js.map +1 -0
  35. package/build/src/tools/debugger.d.ts +44 -0
  36. package/build/src/tools/debugger.js +117 -0
  37. package/build/src/tools/debugger.js.map +1 -0
  38. package/build/src/tools/delete_cookie.d.ts +18 -0
  39. package/build/src/tools/delete_cookie.js +33 -0
  40. package/build/src/tools/delete_cookie.js.map +1 -0
  41. package/build/src/tools/drag.d.ts +40 -0
  42. package/build/src/tools/drag.js +202 -0
  43. package/build/src/tools/drag.js.map +1 -0
  44. package/build/src/tools/evaluate_script.d.ts +24 -0
  45. package/build/src/tools/evaluate_script.js +172 -0
  46. package/build/src/tools/evaluate_script.js.map +1 -0
  47. package/build/src/tools/fill.d.ts +22 -0
  48. package/build/src/tools/fill.js +104 -0
  49. package/build/src/tools/fill.js.map +1 -0
  50. package/build/src/tools/fill_form.d.ts +34 -0
  51. package/build/src/tools/fill_form.js +110 -0
  52. package/build/src/tools/fill_form.js.map +1 -0
  53. package/build/src/tools/gc_heap.d.ts +16 -0
  54. package/build/src/tools/gc_heap.js +66 -0
  55. package/build/src/tools/gc_heap.js.map +1 -0
  56. package/build/src/tools/get_capability_snapshot.d.ts +17 -0
  57. package/build/src/tools/get_capability_snapshot.js +50 -0
  58. package/build/src/tools/get_capability_snapshot.js.map +1 -0
  59. package/build/src/tools/get_console_message.d.ts +18 -0
  60. package/build/src/tools/get_console_message.js +92 -0
  61. package/build/src/tools/get_console_message.js.map +1 -0
  62. package/build/src/tools/get_cookies.d.ts +20 -0
  63. package/build/src/tools/get_cookies.js +59 -0
  64. package/build/src/tools/get_cookies.js.map +1 -0
  65. package/build/src/tools/get_event_listeners.d.ts +29 -0
  66. package/build/src/tools/get_event_listeners.js +129 -0
  67. package/build/src/tools/get_event_listeners.js.map +1 -0
  68. package/build/src/tools/get_network_request.d.ts +22 -0
  69. package/build/src/tools/get_network_request.js +121 -0
  70. package/build/src/tools/get_network_request.js.map +1 -0
  71. package/build/src/tools/get_performance_metrics.d.ts +27 -0
  72. package/build/src/tools/get_performance_metrics.js +185 -0
  73. package/build/src/tools/get_performance_metrics.js.map +1 -0
  74. package/build/src/tools/get_resource_tree.d.ts +18 -0
  75. package/build/src/tools/get_resource_tree.js +82 -0
  76. package/build/src/tools/get_resource_tree.js.map +1 -0
  77. package/build/src/tools/handle_dialog.d.ts +39 -0
  78. package/build/src/tools/handle_dialog.js +182 -0
  79. package/build/src/tools/handle_dialog.js.map +1 -0
  80. package/build/src/tools/highlight_node.d.ts +41 -0
  81. package/build/src/tools/highlight_node.js +95 -0
  82. package/build/src/tools/highlight_node.js.map +1 -0
  83. package/build/src/tools/hover.d.ts +20 -0
  84. package/build/src/tools/hover.js +89 -0
  85. package/build/src/tools/hover.js.map +1 -0
  86. package/build/src/tools/intercept.d.ts +81 -0
  87. package/build/src/tools/intercept.js +161 -0
  88. package/build/src/tools/intercept.js.map +1 -0
  89. package/build/src/tools/list_console_messages.d.ts +20 -0
  90. package/build/src/tools/list_console_messages.js +105 -0
  91. package/build/src/tools/list_console_messages.js.map +1 -0
  92. package/build/src/tools/list_indexeddb.d.ts +16 -0
  93. package/build/src/tools/list_indexeddb.js +55 -0
  94. package/build/src/tools/list_indexeddb.js.map +1 -0
  95. package/build/src/tools/list_network_requests.d.ts +25 -0
  96. package/build/src/tools/list_network_requests.js +108 -0
  97. package/build/src/tools/list_network_requests.js.map +1 -0
  98. package/build/src/tools/list_pages.d.ts +17 -0
  99. package/build/src/tools/list_pages.js +113 -0
  100. package/build/src/tools/list_pages.js.map +1 -0
  101. package/build/src/tools/navigate_page.d.ts +18 -0
  102. package/build/src/tools/navigate_page.js +73 -0
  103. package/build/src/tools/navigate_page.js.map +1 -0
  104. package/build/src/tools/network_runtime.d.ts +51 -0
  105. package/build/src/tools/network_runtime.js +101 -0
  106. package/build/src/tools/network_runtime.js.map +1 -0
  107. package/build/src/tools/press_key.d.ts +32 -0
  108. package/build/src/tools/press_key.js +108 -0
  109. package/build/src/tools/press_key.js.map +1 -0
  110. package/build/src/tools/query_dom_node.d.ts +22 -0
  111. package/build/src/tools/query_dom_node.js +103 -0
  112. package/build/src/tools/query_dom_node.js.map +1 -0
  113. package/build/src/tools/record_cpu_profile.d.ts +38 -0
  114. package/build/src/tools/record_cpu_profile.js +174 -0
  115. package/build/src/tools/record_cpu_profile.js.map +1 -0
  116. package/build/src/tools/record_memory_tracking.d.ts +32 -0
  117. package/build/src/tools/record_memory_tracking.js +103 -0
  118. package/build/src/tools/record_memory_tracking.js.map +1 -0
  119. package/build/src/tools/record_timeline.d.ts +20 -0
  120. package/build/src/tools/record_timeline.js +110 -0
  121. package/build/src/tools/record_timeline.js.map +1 -0
  122. package/build/src/tools/reload_page.d.ts +18 -0
  123. package/build/src/tools/reload_page.js +59 -0
  124. package/build/src/tools/reload_page.js.map +1 -0
  125. package/build/src/tools/select_page.d.ts +18 -0
  126. package/build/src/tools/select_page.js +54 -0
  127. package/build/src/tools/select_page.js.map +1 -0
  128. package/build/src/tools/set_extra_http_headers.d.ts +16 -0
  129. package/build/src/tools/set_extra_http_headers.js +55 -0
  130. package/build/src/tools/set_extra_http_headers.js.map +1 -0
  131. package/build/src/tools/set_init_script.d.ts +16 -0
  132. package/build/src/tools/set_init_script.js +43 -0
  133. package/build/src/tools/set_init_script.js.map +1 -0
  134. package/build/src/tools/set_outer_html.d.ts +18 -0
  135. package/build/src/tools/set_outer_html.js +52 -0
  136. package/build/src/tools/set_outer_html.js.map +1 -0
  137. package/build/src/tools/set_user_agent.d.ts +40 -0
  138. package/build/src/tools/set_user_agent.js +83 -0
  139. package/build/src/tools/set_user_agent.js.map +1 -0
  140. package/build/src/tools/summarize_console_errors.d.ts +40 -0
  141. package/build/src/tools/summarize_console_errors.js +131 -0
  142. package/build/src/tools/summarize_console_errors.js.map +1 -0
  143. package/build/src/tools/take_memory_snapshot.d.ts +18 -0
  144. package/build/src/tools/take_memory_snapshot.js +88 -0
  145. package/build/src/tools/take_memory_snapshot.js.map +1 -0
  146. package/build/src/tools/take_node_screenshot.d.ts +29 -0
  147. package/build/src/tools/take_node_screenshot.js +57 -0
  148. package/build/src/tools/take_node_screenshot.js.map +1 -0
  149. package/build/src/tools/take_screenshot.d.ts +51 -0
  150. package/build/src/tools/take_screenshot.js +108 -0
  151. package/build/src/tools/take_screenshot.js.map +1 -0
  152. package/build/src/tools/take_snapshot.d.ts +22 -0
  153. package/build/src/tools/take_snapshot.js +142 -0
  154. package/build/src/tools/take_snapshot.js.map +1 -0
  155. package/build/src/tools/type_text.d.ts +34 -0
  156. package/build/src/tools/type_text.js +203 -0
  157. package/build/src/tools/type_text.js.map +1 -0
  158. package/build/src/tools/wait_for.d.ts +24 -0
  159. package/build/src/tools/wait_for.js +93 -0
  160. package/build/src/tools/wait_for.js.map +1 -0
  161. package/build/src/tools/wip_send.d.ts +22 -0
  162. package/build/src/tools/wip_send.js +81 -0
  163. package/build/src/tools/wip_send.js.map +1 -0
  164. package/build/src/wip-client/iwdp-http.d.ts +17 -0
  165. package/build/src/wip-client/iwdp-http.js +98 -0
  166. package/build/src/wip-client/iwdp-http.js.map +1 -0
  167. package/build/src/wip-client/ws-session.d.ts +41 -0
  168. package/build/src/wip-client/ws-session.js +290 -0
  169. package/build/src/wip-client/ws-session.js.map +1 -0
  170. package/docs/spec.md +689 -0
  171. package/package.json +77 -0
@@ -0,0 +1,61 @@
1
+ # Contributing to ios-webkit-mcp
2
+
3
+ Thanks for your interest. This is a small open-source project maintained by a single author in personal time; PRs and issues are responded to on a best-effort basis.
4
+
5
+ ## Developer Certificate of Origin (DCO)
6
+
7
+ All contributions must be made under the Apache-2.0 license and must be your own work (or work you have the right to submit under that license).
8
+
9
+ Every commit must be signed off using the `-s` / `--signoff` flag:
10
+
11
+ ```bash
12
+ git commit -s -m "fix: tighten capability probe timeout"
13
+ ```
14
+
15
+ This appends a `Signed-off-by: Your Name <you@example.com>` trailer to the commit message, which constitutes your agreement to the [Developer Certificate of Origin v1.1](https://developercertificate.org/):
16
+
17
+ > By making a contribution to this project, I certify that:
18
+ >
19
+ > (a) The contribution was created in whole or in part by me and I have
20
+ > the right to submit it under the open source license indicated in
21
+ > the file; or
22
+ >
23
+ > (b) The contribution is based upon previous work that, to the best of
24
+ > my knowledge, is covered under an appropriate open source license
25
+ > and I have the right under that license to submit that work with
26
+ > modifications, whether created in whole or in part by me, under
27
+ > the same open source license (unless I am permitted to submit
28
+ > under a different license), as indicated in the file; or
29
+ >
30
+ > (c) The contribution was provided directly to me by some other person
31
+ > who certified (a), (b) or (c) and I have not modified it.
32
+ >
33
+ > (d) I understand and agree that this project and the contribution are
34
+ > public and that a record of the contribution (including all
35
+ > personal information I submit with it, including my sign-off) is
36
+ > maintained indefinitely and may be redistributed consistent with
37
+ > this project or the open source license(s) involved.
38
+
39
+ PRs without a sign-off will be asked to amend before merge.
40
+
41
+ ## Scope and triage
42
+
43
+ This project tracks the [`chrome-devtools/chrome-devtools-mcp`](https://github.com/chrome-devtools/chrome-devtools-mcp) tool surface on the Apple Web Inspector Protocol (WIP) side. Out-of-scope:
44
+
45
+ - Android WebView debugging — use upstream `chrome-devtools-mcp` directly.
46
+ - Desktop Safari WIP — should work but is not actively tested.
47
+ - Bug reports that are actually iOS WKWebView platform limitations already covered in [`README.md` § Known limitations](README.md#known-limitations).
48
+
49
+ For new tool requests, please reference the corresponding CDP method in the chrome-devtools-mcp upstream catalog, and confirm the WIP equivalent exists via [`npm run probe`](README.md) before filing.
50
+
51
+ ## Test
52
+
53
+ ```bash
54
+ npm test # builds and runs the 41 node:test cases
55
+ ```
56
+
57
+ If your change affects WIP-touching code paths (not just type/format), please add or update a unit test in `tests/`.
58
+
59
+ ## License of contributions
60
+
61
+ By submitting a PR, you license your contribution under the [Apache License 2.0](LICENSE).
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of tracking or improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not use or grant permission to use the
139
+ trade names, trademarks, service marks, or product names of the
140
+ Licensor, except as required for describing the origin of the Work
141
+ and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing the Work or
166
+ Derivative Works thereof, You may accept support, warranty,
167
+ indemnity, or other liability obligations and/or rights consistent
168
+ with this License. However, in accepting such obligations, You may
169
+ act only on Your own behalf and on Your sole responsibility, not on
170
+ behalf of any other Contributor, and only if You agree to indemnify,
171
+ defend, and hold each Contributor harmless for any liability
172
+ incurred by, or claims asserted against, such Contributor by reason
173
+ of your accepting any such warranty or support.
174
+
175
+ END OF TERMS AND CONDITIONS
176
+
177
+ APPENDIX: How to apply the Apache License to your work.
178
+
179
+ To apply the Apache License to your work, attach the following
180
+ boilerplate notice, with the fields enclosed by brackets "[]"
181
+ replaced with your own identifying information. (Don't include
182
+ the brackets!) The text should be enclosed in the appropriate
183
+ comment syntax for the file format. We also recommend that you
184
+ include a copyright notice as well as a file comment identifying
185
+ the original copyright owner.
186
+
187
+ Copyright 2026 echopi
188
+
189
+ Licensed under the Apache License, Version 2.0 (the "License");
190
+ you may not use this file except in compliance with the License.
191
+ You may obtain a copy of the License at
192
+
193
+ http://www.apache.org/licenses/LICENSE-2.0
194
+
195
+ Unless required by applicable law or agreed to in writing, software
196
+ distributed under the License is distributed on an "AS IS" BASIS,
197
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
198
+ implied, including, without limitation, any warranties or conditions
199
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
200
+ PARTICULAR PURPOSE. You are solely responsible for determining the
201
+ appropriateness of using or redistributing the Work and assume any
202
+ risks associated with Your exercise of permissions under this License.
package/NOTICE ADDED
@@ -0,0 +1,16 @@
1
+ ios-webkit-mcp
2
+ Copyright 2026 echopi
3
+
4
+ This product is an independent open-source project licensed under the
5
+ Apache License, Version 2.0 (see LICENSE).
6
+
7
+ It is an independent implementation of an iOS WebView debugging bridge
8
+ based on the publicly available WebKit Inspector protocol definitions
9
+ (https://github.com/WebKit/WebKit/tree/main/Source/JavaScriptCore/inspector/protocol).
10
+
11
+ Not affiliated with, endorsed by, or sponsored by Apple Inc. or any
12
+ other organization. All product names, logos, and brands are property
13
+ of their respective owners.
14
+
15
+ "echopi" is the author's public pseudonym; correspondence is via the
16
+ email address listed in package.json.
package/README.md ADDED
@@ -0,0 +1,187 @@
1
+ # ios-webkit-mcp
2
+
3
+ iOS WebView debugging MCP server. Bridges LLM agents (Claude Code, Cursor, etc.) to iPhone WKWebView pages via Apple's **Web Inspector Protocol (WIP)**, transported by `ios_webkit_debug_proxy`.
4
+
5
+ **57 tools** (54 ✅ end-to-end verified + 3 ⚠ coded but blocked by documented iOS WKWebView runtime limitations). Targets parity with [`chrome-devtools/chrome-devtools-mcp`](https://github.com/chrome-devtools/chrome-devtools-mcp) on the upstream-overlapping surface, plus Apple-specific extensions and composite tools.
6
+
7
+ > **Spec**: [`docs/spec.md`](docs/spec.md) — full design, WIP capability matrix, 11 decision records, complete tool table with smoke receipts.
8
+
9
+ ## Quick start
10
+
11
+ ```bash
12
+ # 1. Install ios_webkit_debug_proxy (macOS, one-time)
13
+ brew install ios-webkit-debug-proxy libimobiledevice
14
+
15
+ # 2. Connect iPhone via USB + trust this Mac
16
+ # On iPhone: Settings → Safari → Advanced → Web Inspector = ON
17
+ # On the app: WKWebView must have isInspectable = true (iOS 16.4+ requirement)
18
+
19
+ # 3. Start the proxy
20
+ ios_webkit_debug_proxy --no-frontend
21
+
22
+ # 4. Install & build
23
+ git clone https://github.com/echopi/ios-webkit-mcp.git
24
+ cd ios-webkit-mcp
25
+ npm install
26
+ npm run build
27
+
28
+ # 5. Register with Claude Code
29
+ claude mcp add ios-webkit --scope user -- \
30
+ node "$PWD/build/src/bin/ios-webkit-mcp.js"
31
+ ```
32
+
33
+ Restart Claude Code, then ask the agent to call `list_pages` — it should enumerate inspectable WKWebView pages on the connected iPhone.
34
+
35
+ ## Tool catalog (57)
36
+
37
+ **chrome-devtools-mcp upstream parity (20)**
38
+ `list_pages` / `evaluate_script` / `list_console_messages` / `list_network_requests` / `get_console_message` / `get_network_request` / `take_snapshot` / `take_screenshot` / `navigate_page` / `click` / `fill` / `fill_form` / `type_text` / `press_key` / `hover` / `drag` / `wait_for` / `select_page` / `reload_page` / `handle_dialog`
39
+
40
+ **Apple WIP-specific extensions (18)**
41
+ `query_dom_node` / `take_node_screenshot` / `get_resource_tree` / `get_cookies` / `delete_cookie` / `set_extra_http_headers` / `set_init_script` / `set_outer_html` / `list_indexeddb` / `get_performance_metrics` / `record_timeline` / `pause_debugger` / `resume_debugger` / `set_breakpoint_by_url` / `gc_heap` / `clear_console` / `take_memory_snapshot` / `set_user_agent`
42
+
43
+ **Advanced debugger / interception (10)**
44
+ `set_pause_on_exceptions` / `set_event_breakpoint` / `set_url_breakpoint` / `set_blackbox_url` / `get_event_listeners` / `record_cpu_profile` / `record_memory_tracking` / `highlight_node` / `hide_highlight` / `set_resource_caching_disabled`
45
+
46
+ **Composite (3)**
47
+ `analyze_performance` (Timeline + CPU + memory in one shot) / `debug_element` (DOM + listeners + screenshot + highlight) / `summarize_console_errors` (grouped error summary)
48
+
49
+ **Capability / interception state machine (5)**
50
+ `get_capability_snapshot` / `set_request_interception` / `list_intercepted_requests` / `intercept_continue` / `intercept_respond` (⚠ last 3 are iOS-blocked — see Known Limitations)
51
+
52
+ **Escape hatch (1)**
53
+ `wip_send` — raw WIP method/params passthrough
54
+
55
+ Full descriptions + parameter schemas + smoke receipts: [`docs/spec.md`](docs/spec.md).
56
+
57
+ ## Known limitations (iOS WKWebView)
58
+
59
+ These are **iOS-platform constraints**, not implementation bugs. Tools are coded correctly per the WIP spec; the runtime behavior is the issue.
60
+
61
+ ### 1. CSS.* domain hangs (no `CSS.*` tools exposed)
62
+
63
+ Apple WIP protocol declares CSS as always available, but iOS 26.5.0 WKWebView's WebKit runtime does not respond to `CSS.enable` / `CSS.getMatchedStylesForNode` / etc. — calls hang ≥ 2.5s with no response. Root cause is in `WebCore/inspector/agents/InspectorCSSAgent.cpp` runtime layer on iOS, not the protocol.
64
+
65
+ **Workaround**: use `evaluate_script` with `getComputedStyle()` / inline style mutation. Example:
66
+
67
+ ```js
68
+ // "Get computed color of .foo"
69
+ evaluate_script({ expression: 'getComputedStyle(document.querySelector(".foo")).color' })
70
+
71
+ // "Change .foo background-color"
72
+ evaluate_script({ expression: 'document.querySelector(".foo").style.backgroundColor = "red"' })
73
+ ```
74
+
75
+ ### 2. `Network.requestIntercepted` runtime is a no-op (3 tools blocked)
76
+
77
+ Protocol declares `Network.setInterceptionEnabled` + `Network.addInterception` + `Network.interceptContinue` + `Network.interceptWithResponse` as always available. All return `{}` success on iOS. **But** `Network.requestIntercepted` event is never fired for matching requests — iOS WKWebView's network loader (CFNetwork/NSURLSession) does not call back into the WebCore inspector hook.
78
+
79
+ Affected tools: `set_request_interception` / `list_intercepted_requests` / `intercept_continue` / `intercept_respond`. They are kept in the catalog because they work on macOS Safari WIP (validated by [`iwdp-mcp`](https://github.com/nnemirovsky/iwdp-mcp)) and would Just Work the day Apple ships iOS interception runtime.
80
+
81
+ **Workaround for mocking responses**: monkey-patch `fetch` / `XMLHttpRequest.prototype.open` via `set_init_script` (a `Page.setBootstrapScript` wrapper):
82
+
83
+ ```js
84
+ set_init_script({
85
+ source: `
86
+ const _fetch = window.fetch;
87
+ window.fetch = (url, opts) => {
88
+ if (url.includes('/api/foo')) {
89
+ return Promise.resolve(new Response(JSON.stringify({mocked:true}), {
90
+ status: 200,
91
+ headers: {'Content-Type': 'application/json'},
92
+ }));
93
+ }
94
+ return _fetch(url, opts);
95
+ };
96
+ `
97
+ })
98
+ ```
99
+
100
+ ### 3. `Schema.getDomains` not exposed on iOS (graceful fallback)
101
+
102
+ Apple's iOS WebKit WIP does not expose the `Schema` domain. Capability discovery falls back to optimistic mode — tool calls go through; failures surface as `WipError` with `DOMAIN_UNAVAILABLE` / `METHOD_NOT_FOUND` / `TIMEOUT` codes.
103
+
104
+ ### 4. `Page.navigate` removed upstream (workaround built in)
105
+
106
+ The WebKit team removed `Page.navigate` from WIP in commit [`5871ac5`](https://github.com/WebKit/WebKit/commit/5871ac5) (2025-11-13). The `navigate_page` tool here automatically falls back to `Runtime.evaluate('location.href = ...')`.
107
+
108
+ ### 5. `Page.setScreenSizeOverride` not on Cocoa (no viewport tool)
109
+
110
+ Per [WebKit upstream](https://github.com/WebKit/WebKit/blob/main/Source/JavaScriptCore/inspector/protocol/Page.json), `Page.setScreenSizeOverride` is gated `!PLATFORM_COCOA` — neither iOS nor macOS Safari supports it. Viewport emulation would require a native bridge.
111
+
112
+ ## Capability discovery
113
+
114
+ `get_capability_snapshot` returns the runtime probe result for the connected device — which domains the WebKit build claims to support, which sentinel methods responded, and any platform-specific notes. The MCP server runs this probe asynchronously after page attach (non-blocking, ~5–10ms when Schema is available).
115
+
116
+ When `Schema.getDomains` is unavailable (current iOS), `supportedDomains` is `null` and tool dispatch is **optimistic** — calls go through and surface real errors as structured `WipError` instances with one of these codes:
117
+
118
+ | Code | Meaning |
119
+ |---|---|
120
+ | `DOMAIN_UNAVAILABLE` | `'<X>' domain was not found` (-32601 at domain level) |
121
+ | `METHOD_NOT_FOUND` | `'<X>.<method>'` not found (-32601 at method level) |
122
+ | `INVALID_PARAMS` | `-32602` schema mismatch |
123
+ | `TIMEOUT` | WIP round-trip exceeded SLA (default 3-15s) |
124
+ | `TRANSPORT_ERROR` | ws connection error / peer close |
125
+ | `INTERNAL` | unclassified — see message for raw WIP error |
126
+
127
+ ## Runtime kill switch
128
+
129
+ Disable specific tools at startup via `WDM_DISABLE_TOOLS` (comma-separated list):
130
+
131
+ ```bash
132
+ WDM_DISABLE_TOOLS=set_init_script,record_timeline node build/src/bin/ios-webkit-mcp.js
133
+ ```
134
+
135
+ Useful for hotfixing a tool that misbehaves on a particular device without rebuilding.
136
+
137
+ ## Troubleshooting
138
+
139
+ ### iwdp's internal HTTP/WS server gets stuck
140
+
141
+ After an abrupt ws disconnect (e.g. killing a probe process with SIGKILL), `ios_webkit_debug_proxy` v1.9.2's internal CDP HTTP server (`/json/version` and per-page wsURLs) can lock up. Symptoms: `curl http://127.0.0.1:9222/json` hangs, or pages exist in the list but ws connect never receives `Target.targetCreated`.
142
+
143
+ **Fix**: terminate + relaunch the app holding the WKWebView, then retry. From a Mac:
144
+
145
+ ```bash
146
+ DEV='<your-device-udid>'
147
+ # Find the app PID
148
+ xcrun devicectl device info processes -d "$DEV" | grep -i <app-name>
149
+ # Force-terminate
150
+ xcrun devicectl device process terminate -d "$DEV" -p <PID> --kill
151
+ # Relaunch
152
+ xcrun devicectl device process launch -d "$DEV" '<bundle-id>'
153
+ ```
154
+
155
+ Or just close the app from the iPhone's app switcher and reopen.
156
+
157
+ ### DOM operations fail with "Missing node for given nodeId"
158
+
159
+ Apple WIP `DOM.getDocument` bumps the node generation, invalidating prior nodeIds. If you're chaining your own DOM operations via `wip_send`, do them **serially** (not via `Promise.all`).
160
+
161
+ This MCP's composite tools (e.g. `debug_element`) already serialize DOM ops internally.
162
+
163
+ ### Tests
164
+
165
+ ```bash
166
+ npm test # builds and runs 41 node:test cases
167
+ ```
168
+
169
+ Foundation covers `capability.ts` (WipError + classifyWipError + probeCapabilities + assertDomainAvailable), env-var parsing (`_parseDisabledTools`), and `summarize_console_errors` grouping helpers.
170
+
171
+ ## Why a separate package from `chrome-devtools-mcp`
172
+
173
+ Different protocol (WIP, not CDP), different transport (ws-via-iwdp, not direct), different runtime (WebKit, not Blink). Tool schemas are intentionally aligned with [`chrome-devtools/chrome-devtools-mcp`](https://github.com/chrome-devtools/chrome-devtools-mcp) so LLMs see a uniform surface when an agent's session targets both Android and iOS devices.
174
+
175
+ For Android WebView debugging, use upstream `chrome-devtools-mcp` directly — it speaks CDP, which Android WebView (Chromium fork) supports natively.
176
+
177
+ ## Legal & compliance
178
+
179
+ Independent open-source implementation based on the publicly available WebKit Inspector protocol definitions: [`Source/JavaScriptCore/inspector/protocol/*.json`](https://github.com/WebKit/WebKit/tree/main/Source/JavaScriptCore/inspector/protocol). No private SDKs are imported or redistributed.
180
+
181
+ Not affiliated with, endorsed by, or sponsored by Apple Inc. All product names, logos, and brands are the property of their respective owners.
182
+
183
+ This project is provided for research, debugging, and educational use under the Apache-2.0 license. No warranty, no commercial support is implied. Issues filed in this repository are best-effort responses from the author.
184
+
185
+ ## License
186
+
187
+ Apache-2.0 (see [`LICENSE`](LICENSE) and [`NOTICE`](NOTICE)).
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import { createServer } from '../server.js';
4
+ async function main() {
5
+ const server = createServer();
6
+ const transport = new StdioServerTransport();
7
+ await server.connect(transport);
8
+ }
9
+ main().catch(err => {
10
+ // stderr only; stdout is the MCP transport
11
+ process.stderr.write(`[ios-webkit-mcp] fatal: ${err instanceof Error ? err.stack ?? err.message : String(err)}\n`);
12
+ process.exit(1);
13
+ });
14
+ //# sourceMappingURL=ios-webkit-mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ios-webkit-mcp.js","sourceRoot":"","sources":["../../../src/bin/ios-webkit-mcp.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;IACjB,2CAA2C;IAC3C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Capability discovery — runtime detection of which WIP domains the
3
+ * connected WebKit build actually supports.
4
+ *
5
+ * Motivated by iOS WKWebView (tested on iOS 26.5.0) hanging on `CSS.*`
6
+ * (TIMEOUT, not -32601 NOT_FOUND). The WIP protocol declares CSS as always
7
+ * available, but iOS WebKit runtime does not respond to CSS domain calls.
8
+ * spec: docs/spec.md §"Capability discovery architecture".
9
+ *
10
+ * Strategy:
11
+ * 1. Try `Schema.getDomains` first — canonical Apple WIP discovery method.
12
+ * 2. If that fails (-32601), probe a curated CSS sentinel (CSS.enable with
13
+ * a short timeout) — TIMEOUT means the fork omitted the domain even if
14
+ * it would respond -32601 to other calls.
15
+ *
16
+ * The probe runs async after page attach so tool calls are not blocked. Tool
17
+ * handlers may consult `PageSession.capability()` to fail-fast with a
18
+ * structured `WipError` instead of waiting for a 15s timeout.
19
+ */
20
+ import type { WipSession } from './wip-client/ws-session.js';
21
+ export type WipErrorCode = 'DOMAIN_UNAVAILABLE' | 'METHOD_NOT_FOUND' | 'INVALID_PARAMS' | 'TIMEOUT' | 'TRANSPORT_ERROR' | 'INTERNAL';
22
+ export declare class WipError extends Error {
23
+ readonly code: WipErrorCode;
24
+ readonly domain?: string;
25
+ readonly rawCode?: number;
26
+ readonly fallback?: string;
27
+ constructor(code: WipErrorCode, message: string, opts?: {
28
+ domain?: string;
29
+ rawCode?: number;
30
+ fallback?: string;
31
+ });
32
+ toStructured(): Record<string, unknown>;
33
+ }
34
+ /**
35
+ * Map a raw WIP error response (or thrown Error) to a WipError with code.
36
+ * `code === -32601` → METHOD_NOT_FOUND (or DOMAIN_UNAVAILABLE if message
37
+ * contains "domain was not found"). `-32602` → INVALID_PARAMS. Plain timeout
38
+ * messages from `WipSession.send` → TIMEOUT.
39
+ */
40
+ export declare function classifyWipError(err: unknown, method: string): WipError;
41
+ export interface CapabilitySnapshot {
42
+ /** ISO timestamp of probe completion. */
43
+ probedAt: string;
44
+ /** ms it took to complete all probes. */
45
+ probeDurationMs: number;
46
+ /** Domains reported by Schema.getDomains, lowercased to set membership. undefined if Schema unavailable. */
47
+ supportedDomains?: Set<string>;
48
+ /** True iff Schema.getDomains succeeded. False if probe fell back to sentinels. */
49
+ schemaProbeSucceeded: boolean;
50
+ /** Curated sentinel results: domain → 'ok' | 'timeout' | 'not-found' | 'invalid-params'. */
51
+ sentinels: Record<string, 'ok' | 'timeout' | 'not-found' | 'invalid-params' | 'error'>;
52
+ /** Free-form notes (e.g. "CSS.enable hung after 3s — iOS WKWebView runtime no-op on CSS domain"). */
53
+ notes: string[];
54
+ }
55
+ export declare function probeCapabilities(session: WipSession): Promise<CapabilitySnapshot>;
56
+ /**
57
+ * Convenience: throw a structured WipError if the snapshot tells us the
58
+ * required domain is unavailable. No-op if `supportedDomains` is undefined
59
+ * (Schema probe failed → assume optimistic).
60
+ */
61
+ export declare function assertDomainAvailable(snap: CapabilitySnapshot | undefined, domain: string): void;