@gabrielbryk/arc-devtools-mcp 1.3.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 (367) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +977 -0
  3. package/build/src/HeapSnapshotManager.js +148 -0
  4. package/build/src/McpContext.js +737 -0
  5. package/build/src/McpPage.js +315 -0
  6. package/build/src/McpResponse.js +990 -0
  7. package/build/src/Mutex.js +38 -0
  8. package/build/src/PageCollector.js +297 -0
  9. package/build/src/ServiceWorkerCollector.js +171 -0
  10. package/build/src/SlimMcpResponse.js +19 -0
  11. package/build/src/TextSnapshot.js +236 -0
  12. package/build/src/ToolHandler.js +223 -0
  13. package/build/src/WaitForHelper.js +190 -0
  14. package/build/src/bin/check-latest-version.js +50 -0
  15. package/build/src/bin/chrome-devtools-cli-options.js +978 -0
  16. package/build/src/bin/chrome-devtools-mcp-cli-options.js +412 -0
  17. package/build/src/bin/chrome-devtools-mcp-main.js +72 -0
  18. package/build/src/bin/chrome-devtools-mcp.js +23 -0
  19. package/build/src/bin/chrome-devtools.js +189 -0
  20. package/build/src/browser.js +253 -0
  21. package/build/src/daemon/client.js +160 -0
  22. package/build/src/daemon/daemon.js +261 -0
  23. package/build/src/daemon/types.js +7 -0
  24. package/build/src/daemon/utils.js +115 -0
  25. package/build/src/devtools/DevToolsConnectionAdapter.js +70 -0
  26. package/build/src/devtools/DevtoolsUtils.js +369 -0
  27. package/build/src/devtools/McpHostBindingAdapter.js +165 -0
  28. package/build/src/formatters/ConsoleFormatter.js +288 -0
  29. package/build/src/formatters/HeapSnapshotFormatter.js +97 -0
  30. package/build/src/formatters/IssueFormatter.js +193 -0
  31. package/build/src/formatters/NetworkFormatter.js +238 -0
  32. package/build/src/formatters/SnapshotFormatter.js +135 -0
  33. package/build/src/index.js +153 -0
  34. package/build/src/issue-descriptions.js +40 -0
  35. package/build/src/logger.js +37 -0
  36. package/build/src/polyfill.js +8 -0
  37. package/build/src/telemetry/ClearcutLogger.js +169 -0
  38. package/build/src/telemetry/WatchdogClient.js +61 -0
  39. package/build/src/telemetry/errors.js +18 -0
  40. package/build/src/telemetry/flagUtils.js +89 -0
  41. package/build/src/telemetry/metricsRegistry.js +89 -0
  42. package/build/src/telemetry/persistence.js +72 -0
  43. package/build/src/telemetry/transformation.js +134 -0
  44. package/build/src/telemetry/types.js +31 -0
  45. package/build/src/telemetry/watchdog/ClearcutSender.js +205 -0
  46. package/build/src/telemetry/watchdog/main.js +128 -0
  47. package/build/src/third_party/THIRD_PARTY_NOTICES +3637 -0
  48. package/build/src/third_party/bundled-packages.json +12 -0
  49. package/build/src/third_party/devtools-formatter-worker.js +15301 -0
  50. package/build/src/third_party/devtools-heap-snapshot-worker.js +9870 -0
  51. package/build/src/third_party/index.js +159597 -0
  52. package/build/src/third_party/issue-descriptions/CoepCoopSandboxedIframeCannotNavigateToCoopPage.md +4 -0
  53. package/build/src/third_party/issue-descriptions/CoepCorpNotSameOrigin.md +8 -0
  54. package/build/src/third_party/issue-descriptions/CoepCorpNotSameOriginAfterDefaultedToSameOriginByCoep.md +18 -0
  55. package/build/src/third_party/issue-descriptions/CoepCorpNotSameSite.md +7 -0
  56. package/build/src/third_party/issue-descriptions/CoepFrameResourceNeedsCoepHeader.md +10 -0
  57. package/build/src/third_party/issue-descriptions/CompatibilityModeQuirks.md +5 -0
  58. package/build/src/third_party/issue-descriptions/CookieAttributeValueExceedsMaxSize.md +5 -0
  59. package/build/src/third_party/issue-descriptions/LowTextContrast.md +5 -0
  60. package/build/src/third_party/issue-descriptions/SameSiteExcludeContextDowngradeRead.md +8 -0
  61. package/build/src/third_party/issue-descriptions/SameSiteExcludeContextDowngradeSet.md +8 -0
  62. package/build/src/third_party/issue-descriptions/SameSiteExcludeNavigationContextDowngrade.md +8 -0
  63. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorRead.md +8 -0
  64. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorSet.md +8 -0
  65. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnRead.md +8 -0
  66. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnSet.md +8 -0
  67. package/build/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeRead.md +9 -0
  68. package/build/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeSet.md +9 -0
  69. package/build/src/third_party/issue-descriptions/SameSiteWarnCrossDowngradeRead.md +8 -0
  70. package/build/src/third_party/issue-descriptions/SameSiteWarnCrossDowngradeSet.md +8 -0
  71. package/build/src/third_party/issue-descriptions/SameSiteWarnStrictLaxDowngradeStrict.md +8 -0
  72. package/build/src/third_party/issue-descriptions/arInsecureContext.md +7 -0
  73. package/build/src/third_party/issue-descriptions/arInvalidInfoHeader.md +5 -0
  74. package/build/src/third_party/issue-descriptions/arInvalidRegisterOsSourceHeader.md +5 -0
  75. package/build/src/third_party/issue-descriptions/arInvalidRegisterOsTriggerHeader.md +5 -0
  76. package/build/src/third_party/issue-descriptions/arInvalidRegisterSourceHeader.md +5 -0
  77. package/build/src/third_party/issue-descriptions/arInvalidRegisterTriggerHeader.md +5 -0
  78. package/build/src/third_party/issue-descriptions/arNavigationRegistrationUniqueScopeAlreadySet.md +5 -0
  79. package/build/src/third_party/issue-descriptions/arNavigationRegistrationWithoutTransientUserActivation.md +6 -0
  80. package/build/src/third_party/issue-descriptions/arNoRegisterOsSourceHeader.md +5 -0
  81. package/build/src/third_party/issue-descriptions/arNoRegisterOsTriggerHeader.md +5 -0
  82. package/build/src/third_party/issue-descriptions/arNoRegisterSourceHeader.md +5 -0
  83. package/build/src/third_party/issue-descriptions/arNoRegisterTriggerHeader.md +5 -0
  84. package/build/src/third_party/issue-descriptions/arNoWebOrOsSupport.md +4 -0
  85. package/build/src/third_party/issue-descriptions/arOsSourceIgnored.md +18 -0
  86. package/build/src/third_party/issue-descriptions/arOsTriggerIgnored.md +19 -0
  87. package/build/src/third_party/issue-descriptions/arPermissionPolicyDisabled.md +8 -0
  88. package/build/src/third_party/issue-descriptions/arSourceAndTriggerHeaders.md +9 -0
  89. package/build/src/third_party/issue-descriptions/arSourceIgnored.md +13 -0
  90. package/build/src/third_party/issue-descriptions/arTriggerIgnored.md +12 -0
  91. package/build/src/third_party/issue-descriptions/arUntrustworthyReportingOrigin.md +10 -0
  92. package/build/src/third_party/issue-descriptions/arWebAndOsHeaders.md +11 -0
  93. package/build/src/third_party/issue-descriptions/bounceTrackingMitigations.md +3 -0
  94. package/build/src/third_party/issue-descriptions/clientHintMetaTagAllowListInvalidOrigin.md +4 -0
  95. package/build/src/third_party/issue-descriptions/clientHintMetaTagModifiedHTML.md +4 -0
  96. package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowlistItemType.md +12 -0
  97. package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidHeader.md +12 -0
  98. package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidUrlPattern.md +8 -0
  99. package/build/src/third_party/issue-descriptions/connectionAllowlistItemNotInnerList.md +12 -0
  100. package/build/src/third_party/issue-descriptions/connectionAllowlistMoreThanOneList.md +7 -0
  101. package/build/src/third_party/issue-descriptions/connectionAllowlistReportingEndpointNotToken.md +10 -0
  102. package/build/src/third_party/issue-descriptions/cookieCrossSiteRedirectDowngrade.md +12 -0
  103. package/build/src/third_party/issue-descriptions/cookieExcludeBlockedWithinRelatedWebsiteSet.md +4 -0
  104. package/build/src/third_party/issue-descriptions/cookieExcludeDomainNonAscii.md +11 -0
  105. package/build/src/third_party/issue-descriptions/cookieExcludePortMismatch.md +8 -0
  106. package/build/src/third_party/issue-descriptions/cookieExcludeSchemeMismatch.md +7 -0
  107. package/build/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutRead.md +6 -0
  108. package/build/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutSet.md +6 -0
  109. package/build/src/third_party/issue-descriptions/cookieWarnDomainNonAscii.md +11 -0
  110. package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantRead.md +4 -0
  111. package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantSet.md +4 -0
  112. package/build/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutRead.md +6 -0
  113. package/build/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutSet.md +6 -0
  114. package/build/src/third_party/issue-descriptions/corsAllowCredentialsRequired.md +6 -0
  115. package/build/src/third_party/issue-descriptions/corsDisabledScheme.md +7 -0
  116. package/build/src/third_party/issue-descriptions/corsDisallowedByMode.md +7 -0
  117. package/build/src/third_party/issue-descriptions/corsHeaderDisallowedByPreflightResponse.md +5 -0
  118. package/build/src/third_party/issue-descriptions/corsInvalidHeaderValues.md +7 -0
  119. package/build/src/third_party/issue-descriptions/corsLocalNetworkAccessPermissionDenied.md +19 -0
  120. package/build/src/third_party/issue-descriptions/corsMethodDisallowedByPreflightResponse.md +5 -0
  121. package/build/src/third_party/issue-descriptions/corsNoCorsRedirectModeNotFollow.md +5 -0
  122. package/build/src/third_party/issue-descriptions/corsOriginMismatch.md +6 -0
  123. package/build/src/third_party/issue-descriptions/corsPreflightResponseInvalid.md +5 -0
  124. package/build/src/third_party/issue-descriptions/corsRedirectContainsCredentials.md +5 -0
  125. package/build/src/third_party/issue-descriptions/corsWildcardOriginNotAllowed.md +8 -0
  126. package/build/src/third_party/issue-descriptions/cspEvalViolation.md +9 -0
  127. package/build/src/third_party/issue-descriptions/cspInlineViolation.md +10 -0
  128. package/build/src/third_party/issue-descriptions/cspTrustedTypesPolicyViolation.md +5 -0
  129. package/build/src/third_party/issue-descriptions/cspTrustedTypesSinkViolation.md +8 -0
  130. package/build/src/third_party/issue-descriptions/cspURLViolation.md +10 -0
  131. package/build/src/third_party/issue-descriptions/deprecation.md +3 -0
  132. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsEmptyList.md +1 -0
  133. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsHttpNotFound.md +1 -0
  134. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidContentType.md +1 -0
  135. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidResponse.md +1 -0
  136. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsNoResponse.md +1 -0
  137. package/build/src/third_party/issue-descriptions/emailVerificationRequestDnsFetchFailed.md +1 -0
  138. package/build/src/third_party/issue-descriptions/emailVerificationRequestDnsInvalidRecord.md +1 -0
  139. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownHttpNotFound.md +1 -0
  140. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidContentType.md +1 -0
  141. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidResponse.md +1 -0
  142. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownNoResponse.md +1 -0
  143. package/build/src/third_party/issue-descriptions/emailVerificationRequestInvalidEmail.md +1 -0
  144. package/build/src/third_party/issue-descriptions/emailVerificationRequestJwksHttpNotFound.md +1 -0
  145. package/build/src/third_party/issue-descriptions/emailVerificationRequestJwksInvalidResponse.md +1 -0
  146. package/build/src/third_party/issue-descriptions/emailVerificationRequestKeyBindingSigningFailed.md +1 -0
  147. package/build/src/third_party/issue-descriptions/emailVerificationRequestRpOriginIsOpaque.md +1 -0
  148. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenHttpNotFound.md +1 -0
  149. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidContentType.md +1 -0
  150. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidResponse.md +1 -0
  151. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidSdJwt.md +1 -0
  152. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenMalformedSdJwt.md +1 -0
  153. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenNoResponse.md +1 -0
  154. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidAudience.md +1 -0
  155. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidIssuedAt.md +1 -0
  156. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidNonce.md +1 -0
  157. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidSdHash.md +1 -0
  158. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidTyp.md +1 -0
  159. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingAud.md +1 -0
  160. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingCnf.md +1 -0
  161. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingIat.md +1 -0
  162. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingNonce.md +1 -0
  163. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingSdHash.md +1 -0
  164. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbSignatureFailed.md +1 -0
  165. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmail.md +1 -0
  166. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmailVerified.md +1 -0
  167. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidHolderKey.md +1 -0
  168. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuedAt.md +1 -0
  169. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuer.md +1 -0
  170. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtJwksMissingKeys.md +1 -0
  171. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingCnf.md +1 -0
  172. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingEmail.md +1 -0
  173. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIat.md +1 -0
  174. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIss.md +1 -0
  175. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtSignatureFailed.md +1 -0
  176. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtUnsupportedHeaderAlg.md +1 -0
  177. package/build/src/third_party/issue-descriptions/emailVerificationRequestUserLoggedOut.md +1 -0
  178. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownAccountsEndpointCrossOrigin.md +1 -0
  179. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownHttpNotFound.md +1 -0
  180. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidContentType.md +1 -0
  181. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidResponse.md +1 -0
  182. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownIssuanceEndpointCrossOrigin.md +1 -0
  183. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownListEmpty.md +1 -0
  184. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingAccountsEndpoint.md +1 -0
  185. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingIssuanceEndpoint.md +1 -0
  186. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownNoResponse.md +1 -0
  187. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownUnsupportedSigningAlgorithm.md +1 -0
  188. package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsHttpNotFound.md +1 -0
  189. package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsInvalidResponse.md +1 -0
  190. package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsNoResponse.md +1 -0
  191. package/build/src/third_party/issue-descriptions/federatedAuthRequestApprovalDeclined.md +1 -0
  192. package/build/src/third_party/issue-descriptions/federatedAuthRequestCanceled.md +1 -0
  193. package/build/src/third_party/issue-descriptions/federatedAuthRequestErrorFetchingSignin.md +1 -0
  194. package/build/src/third_party/issue-descriptions/federatedAuthRequestErrorIdToken.md +1 -0
  195. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenHttpNotFound.md +1 -0
  196. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidRequest.md +1 -0
  197. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidResponse.md +1 -0
  198. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenNoResponse.md +1 -0
  199. package/build/src/third_party/issue-descriptions/federatedAuthRequestInvalidSigninResponse.md +1 -0
  200. package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestHttpNotFound.md +1 -0
  201. package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestInvalidResponse.md +1 -0
  202. package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestNoResponse.md +1 -0
  203. package/build/src/third_party/issue-descriptions/federatedAuthRequestTooManyRequests.md +1 -0
  204. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidAccountsResponse.md +1 -0
  205. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidConfigOrWellKnown.md +1 -0
  206. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoAccountSharingPermission.md +1 -0
  207. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoApiPermission.md +1 -0
  208. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoReturningUserFromFetchedAccounts.md +1 -0
  209. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotIframe.md +1 -0
  210. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotPotentiallyTrustworthy.md +1 -0
  211. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSameOrigin.md +1 -0
  212. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSignedInWithIdp.md +1 -0
  213. package/build/src/third_party/issue-descriptions/fetchingPartitionedBlobURL.md +7 -0
  214. package/build/src/third_party/issue-descriptions/genericBackUINavigationWouldSkipAd.md +4 -0
  215. package/build/src/third_party/issue-descriptions/genericFormAriaLabelledByToNonExistingIdError.md +8 -0
  216. package/build/src/third_party/issue-descriptions/genericFormAutocompleteAttributeEmptyError.md +5 -0
  217. package/build/src/third_party/issue-descriptions/genericFormDuplicateIdForInputError.md +5 -0
  218. package/build/src/third_party/issue-descriptions/genericFormEmptyIdAndNameAttributesForInputError.md +5 -0
  219. package/build/src/third_party/issue-descriptions/genericFormInputAssignedAutocompleteValueToIdOrNameAttributeError.md +5 -0
  220. package/build/src/third_party/issue-descriptions/genericFormInputHasWrongButWellIntendedAutocompleteValueError.md +5 -0
  221. package/build/src/third_party/issue-descriptions/genericFormInputWithNoLabelError.md +5 -0
  222. package/build/src/third_party/issue-descriptions/genericFormLabelForMatchesNonExistingIdError.md +5 -0
  223. package/build/src/third_party/issue-descriptions/genericFormLabelForNameError.md +5 -0
  224. package/build/src/third_party/issue-descriptions/genericFormLabelHasNeitherForNorNestedInputError.md +5 -0
  225. package/build/src/third_party/issue-descriptions/genericFormModelContextMissingToolDescription.md +5 -0
  226. package/build/src/third_party/issue-descriptions/genericFormModelContextMissingToolName.md +5 -0
  227. package/build/src/third_party/issue-descriptions/genericFormModelContextParameterMissingName.md +5 -0
  228. package/build/src/third_party/issue-descriptions/genericFormModelContextParameterMissingTitleAndDescription.md +5 -0
  229. package/build/src/third_party/issue-descriptions/genericFormModelContextRequiredParameterMissingName.md +5 -0
  230. package/build/src/third_party/issue-descriptions/genericNavigationEntryMarkedSkippable.md +7 -0
  231. package/build/src/third_party/issue-descriptions/genericResponseWasBlockedByORB.md +4 -0
  232. package/build/src/third_party/issue-descriptions/heavyAd.md +10 -0
  233. package/build/src/third_party/issue-descriptions/mixedContent.md +5 -0
  234. package/build/src/third_party/issue-descriptions/navigatingPartitionedBlobURL.md +5 -0
  235. package/build/src/third_party/issue-descriptions/permissionElementActivationDisabled.md +7 -0
  236. package/build/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluder.md +9 -0
  237. package/build/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluderParent.md +9 -0
  238. package/build/src/third_party/issue-descriptions/permissionElementCspFrameAncestorsMissing.md +5 -0
  239. package/build/src/third_party/issue-descriptions/permissionElementFencedFrameDisallowed.md +5 -0
  240. package/build/src/third_party/issue-descriptions/permissionElementFontSizeTooLarge.md +5 -0
  241. package/build/src/third_party/issue-descriptions/permissionElementFontSizeTooSmall.md +5 -0
  242. package/build/src/third_party/issue-descriptions/permissionElementGeolocationDeprecated.md +5 -0
  243. package/build/src/third_party/issue-descriptions/permissionElementInsetBoxShadowUnsupported.md +5 -0
  244. package/build/src/third_party/issue-descriptions/permissionElementInvalidDisplayStyle.md +5 -0
  245. package/build/src/third_party/issue-descriptions/permissionElementInvalidSizeValue.md +5 -0
  246. package/build/src/third_party/issue-descriptions/permissionElementInvalidType.md +5 -0
  247. package/build/src/third_party/issue-descriptions/permissionElementInvalidTypeActivation.md +5 -0
  248. package/build/src/third_party/issue-descriptions/permissionElementLowContrast.md +5 -0
  249. package/build/src/third_party/issue-descriptions/permissionElementNonOpaqueColor.md +5 -0
  250. package/build/src/third_party/issue-descriptions/permissionElementPaddingBottomUnsupported.md +6 -0
  251. package/build/src/third_party/issue-descriptions/permissionElementPaddingRightUnsupported.md +6 -0
  252. package/build/src/third_party/issue-descriptions/permissionElementPermissionsPolicyBlocked.md +5 -0
  253. package/build/src/third_party/issue-descriptions/permissionElementRegistrationFailed.md +5 -0
  254. package/build/src/third_party/issue-descriptions/permissionElementRequestInProgress.md +5 -0
  255. package/build/src/third_party/issue-descriptions/permissionElementSecurityChecksFailed.md +5 -0
  256. package/build/src/third_party/issue-descriptions/permissionElementTypeNotSupported.md +5 -0
  257. package/build/src/third_party/issue-descriptions/permissionElementUntrustedEvent.md +7 -0
  258. package/build/src/third_party/issue-descriptions/placeholderDescriptionForInvisibleIssues.md +3 -0
  259. package/build/src/third_party/issue-descriptions/propertyRuleInvalidNameIssue.md +3 -0
  260. package/build/src/third_party/issue-descriptions/propertyRuleIssue.md +7 -0
  261. package/build/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedOptGroupChild.md +7 -0
  262. package/build/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedSelectChild.md +7 -0
  263. package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentAttributesSelectDescendant.md +3 -0
  264. package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentLegendChild.md +3 -0
  265. package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentOptionChild.md +3 -0
  266. package/build/src/third_party/issue-descriptions/selectElementAccessibilityNonPhrasingContentOptionChild.md +3 -0
  267. package/build/src/third_party/issue-descriptions/selectivePermissionsIntervention.md +7 -0
  268. package/build/src/third_party/issue-descriptions/sharedArrayBuffer.md +7 -0
  269. package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorCrossOriginNoCorsRequest.md +1 -0
  270. package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorDictionaryLoadFailure.md +3 -0
  271. package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorMatchingDictionaryNotUsed.md +3 -0
  272. package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorUnexpectedContentDictionaryHeader.md +1 -0
  273. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorCossOriginNoCorsRequest.md +1 -0
  274. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorDisallowedBySettings.md +1 -0
  275. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorExpiredResponse.md +3 -0
  276. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorFeatureDisabled.md +3 -0
  277. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInsufficientResources.md +1 -0
  278. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidMatchField.md +1 -0
  279. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidStructuredHeader.md +1 -0
  280. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidTTLField.md +1 -0
  281. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNavigationRequest.md +3 -0
  282. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNoMatchField.md +1 -0
  283. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonIntegerTTLField.md +1 -0
  284. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonListMatchDestField.md +1 -0
  285. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonSecureContext.md +3 -0
  286. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringIdField.md +1 -0
  287. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringInMatchDestList.md +1 -0
  288. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringMatchField.md +1 -0
  289. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonTokenTypeField.md +1 -0
  290. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorRequestAborted.md +1 -0
  291. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorShuttingDown.md +1 -0
  292. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorTooLongIdField.md +3 -0
  293. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorUnsupportedType.md +3 -0
  294. package/build/src/third_party/issue-descriptions/sriInvalidSignatureHeader.md +14 -0
  295. package/build/src/third_party/issue-descriptions/sriInvalidSignatureInputHeader.md +15 -0
  296. package/build/src/third_party/issue-descriptions/sriMissingSignatureHeader.md +8 -0
  297. package/build/src/third_party/issue-descriptions/sriMissingSignatureInputHeader.md +7 -0
  298. package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsIncorrectLength.md +11 -0
  299. package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsNotByteSequence.md +14 -0
  300. package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsParameterized.md +15 -0
  301. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentName.md +8 -0
  302. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentType.md +13 -0
  303. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidDerivedComponentParameter.md +4 -0
  304. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidHeaderComponentParameter.md +5 -0
  305. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidParameter.md +11 -0
  306. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderKeyIdLength.md +12 -0
  307. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingLabel.md +6 -0
  308. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingRequiredParameters.md +8 -0
  309. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderValueMissingComponents.md +11 -0
  310. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderValueNotInnerList.md +11 -0
  311. package/build/src/third_party/issue-descriptions/sriValidationFailedIntegrityMismatch.md +10 -0
  312. package/build/src/third_party/issue-descriptions/sriValidationFailedInvalidLength.md +5 -0
  313. package/build/src/third_party/issue-descriptions/sriValidationFailedSignatureExpired.md +6 -0
  314. package/build/src/third_party/issue-descriptions/sriValidationFailedSignatureMismatch.md +11 -0
  315. package/build/src/third_party/issue-descriptions/stylesheetLateImport.md +4 -0
  316. package/build/src/third_party/issue-descriptions/stylesheetRequestFailed.md +3 -0
  317. package/build/src/third_party/issue-descriptions/summaryElementAccessibilityInteractiveContentSummaryDescendant.md +3 -0
  318. package/build/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestLength.md +12 -0
  319. package/build/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestType.md +17 -0
  320. package/build/src/third_party/issue-descriptions/unencodedDigestMalformedDictionary.md +14 -0
  321. package/build/src/third_party/issue-descriptions/unencodedDigestUnknownAlgorithm.md +15 -0
  322. package/build/src/third_party/lighthouse-devtools-mcp-bundle.js +61598 -0
  323. package/build/src/tools/ToolDefinition.js +73 -0
  324. package/build/src/tools/categories.js +36 -0
  325. package/build/src/tools/console.js +98 -0
  326. package/build/src/tools/emulation.js +84 -0
  327. package/build/src/tools/extensions.js +101 -0
  328. package/build/src/tools/input.js +469 -0
  329. package/build/src/tools/lighthouse.js +136 -0
  330. package/build/src/tools/memory.js +227 -0
  331. package/build/src/tools/network.js +125 -0
  332. package/build/src/tools/pages.js +419 -0
  333. package/build/src/tools/performance.js +200 -0
  334. package/build/src/tools/screencast.js +117 -0
  335. package/build/src/tools/screenshot.js +169 -0
  336. package/build/src/tools/script.js +151 -0
  337. package/build/src/tools/slim/tools.js +88 -0
  338. package/build/src/tools/snapshot.js +61 -0
  339. package/build/src/tools/thirdPartyDeveloper.js +85 -0
  340. package/build/src/tools/tools.js +56 -0
  341. package/build/src/tools/webmcp.js +66 -0
  342. package/build/src/trace-processing/parse.js +85 -0
  343. package/build/src/types.js +7 -0
  344. package/build/src/utils/check-for-updates.js +74 -0
  345. package/build/src/utils/files.js +61 -0
  346. package/build/src/utils/id.js +16 -0
  347. package/build/src/utils/keyboard.js +297 -0
  348. package/build/src/utils/pagination.js +50 -0
  349. package/build/src/utils/string.js +37 -0
  350. package/build/src/utils/types.js +7 -0
  351. package/build/src/version.js +10 -0
  352. package/package.json +100 -0
  353. package/skills/a11y-debugging/SKILL.md +89 -0
  354. package/skills/a11y-debugging/references/a11y-snippets.md +92 -0
  355. package/skills/chrome-devtools/SKILL.md +72 -0
  356. package/skills/chrome-devtools-cli/SKILL.md +153 -0
  357. package/skills/chrome-devtools-cli/references/installation.md +14 -0
  358. package/skills/debug-optimize-lcp/SKILL.md +121 -0
  359. package/skills/debug-optimize-lcp/references/elements-and-size.md +27 -0
  360. package/skills/debug-optimize-lcp/references/lcp-breakdown.md +23 -0
  361. package/skills/debug-optimize-lcp/references/lcp-snippets.md +79 -0
  362. package/skills/debug-optimize-lcp/references/optimization-strategies.md +38 -0
  363. package/skills/memory-leak-debugging/SKILL.md +50 -0
  364. package/skills/memory-leak-debugging/references/common-leaks.md +33 -0
  365. package/skills/memory-leak-debugging/references/compare_snapshots.js +109 -0
  366. package/skills/memory-leak-debugging/references/memlab.md +29 -0
  367. package/skills/troubleshooting/SKILL.md +98 -0
@@ -0,0 +1,419 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { logger } from '../logger.js';
7
+ import { zod } from '../third_party/index.js';
8
+ import { ToolCategory } from './categories.js';
9
+ import { CLOSE_PAGE_ERROR, definePageTool, defineTool, timeoutSchema, } from './ToolDefinition.js';
10
+ async function navigateWithInterception(page, action, allowListString, timeout) {
11
+ const allowList = allowListString
12
+ ? allowListString.split(',').map((p) => new URLPattern(p.trim()))
13
+ : undefined;
14
+ const requestHandler = (interceptedRequest) => {
15
+ if (!interceptedRequest.isNavigationRequest()) {
16
+ void interceptedRequest.continue();
17
+ return;
18
+ }
19
+ const requestUrl = interceptedRequest.url();
20
+ const isAllowed = allowList.some((pattern) => pattern.test(requestUrl));
21
+ if (isAllowed) {
22
+ void interceptedRequest.continue();
23
+ }
24
+ else {
25
+ logger?.(`Blocking request to: ${requestUrl}`);
26
+ void interceptedRequest.abort('blockedbyclient');
27
+ }
28
+ };
29
+ const cleanupInterception = async () => {
30
+ if (allowList) {
31
+ page.pptrPage.off('request', requestHandler);
32
+ await page.pptrPage.setRequestInterception(false).catch(error => {
33
+ logger?.(`Failed to disable request interception`, error);
34
+ });
35
+ }
36
+ };
37
+ if (allowList) {
38
+ await page.pptrPage.setRequestInterception(true);
39
+ page.pptrPage.on('request', requestHandler);
40
+ }
41
+ try {
42
+ await page.waitForEventsAfterAction(async () => {
43
+ try {
44
+ await action();
45
+ }
46
+ finally {
47
+ await cleanupInterception();
48
+ }
49
+ }, { timeout });
50
+ }
51
+ finally {
52
+ await cleanupInterception();
53
+ }
54
+ }
55
+ export const listPages = defineTool(args => {
56
+ return {
57
+ name: 'list_pages',
58
+ description: `Get a list of pages${args?.categoryExtensions ? ' including extension service workers' : ''} open in the browser.`,
59
+ annotations: {
60
+ category: ToolCategory.NAVIGATION,
61
+ readOnlyHint: true,
62
+ },
63
+ schema: {},
64
+ blockedByDialog: false,
65
+ verifyFilesSchema: [],
66
+ handler: async (_request, response) => {
67
+ response.setIncludePages(true);
68
+ response.setListThirdPartyDeveloperTools();
69
+ response.setListWebMcpTools();
70
+ },
71
+ };
72
+ });
73
+ export const selectPage = defineTool({
74
+ name: 'select_page',
75
+ description: `Select a page as a context for future tool calls.`,
76
+ annotations: {
77
+ category: ToolCategory.NAVIGATION,
78
+ readOnlyHint: true,
79
+ },
80
+ schema: {
81
+ pageId: zod
82
+ .number()
83
+ .describe(`The ID of the page to select. Call ${listPages().name} to get available pages.`),
84
+ bringToFront: zod
85
+ .boolean()
86
+ .optional()
87
+ .describe('Whether to focus the page and bring it to the top.'),
88
+ },
89
+ blockedByDialog: false,
90
+ verifyFilesSchema: [],
91
+ handler: async (request, response, context) => {
92
+ const page = context.getPageById(request.params.pageId);
93
+ context.selectPage(page);
94
+ response.setIncludePages(true);
95
+ response.setListThirdPartyDeveloperTools();
96
+ response.setListWebMcpTools();
97
+ if (request.params.bringToFront) {
98
+ await page.pptrPage.bringToFront();
99
+ }
100
+ },
101
+ });
102
+ export const closePage = defineTool({
103
+ name: 'close_page',
104
+ description: `Closes the page by its index. The last open page cannot be closed.`,
105
+ annotations: {
106
+ category: ToolCategory.NAVIGATION,
107
+ readOnlyHint: false,
108
+ },
109
+ schema: {
110
+ pageId: zod
111
+ .number()
112
+ .describe('The ID of the page to close. Call list_pages to list pages.'),
113
+ },
114
+ blockedByDialog: false,
115
+ verifyFilesSchema: [],
116
+ handler: async (request, response, context) => {
117
+ try {
118
+ await context.closePage(request.params.pageId);
119
+ }
120
+ catch (err) {
121
+ if (err.message === CLOSE_PAGE_ERROR) {
122
+ response.appendResponseLine(err.message);
123
+ }
124
+ else {
125
+ throw err;
126
+ }
127
+ }
128
+ response.setIncludePages(true);
129
+ response.setListThirdPartyDeveloperTools();
130
+ },
131
+ });
132
+ export const newPage = defineTool(args => {
133
+ return {
134
+ name: 'new_page',
135
+ description: `Open a new tab and load a URL. Use project URL if not specified otherwise.`,
136
+ annotations: {
137
+ category: ToolCategory.NAVIGATION,
138
+ readOnlyHint: false,
139
+ },
140
+ schema: {
141
+ url: zod.string().describe('URL to load in a new page.'),
142
+ background: zod
143
+ .boolean()
144
+ .optional()
145
+ .describe('Whether to open the page in the background without bringing it to the front. Default is false (foreground).'),
146
+ isolatedContext: zod
147
+ .string()
148
+ .optional()
149
+ .describe('If specified, the page is created in an isolated browser context with the given name. ' +
150
+ 'Pages in the same browser context share cookies and storage. ' +
151
+ 'Pages in different browser contexts are fully isolated.'),
152
+ ...(args?.experimentalNavigationAllowlist
153
+ ? {
154
+ allowList: zod
155
+ .string()
156
+ .optional()
157
+ .describe('Optional comma-separated list of URL patterns to allow. If provided, all other navigations will be blocked.'),
158
+ }
159
+ : {}),
160
+ ...timeoutSchema,
161
+ },
162
+ blockedByDialog: false,
163
+ verifyFilesSchema: [],
164
+ handler: async (request, response, context) => {
165
+ const page = await context.newPage(request.params.background, request.params.isolatedContext);
166
+ await navigateWithInterception(page, () => page.pptrPage.goto(request.params.url, {
167
+ timeout: request.params.timeout,
168
+ }), request.params.allowList, request.params.timeout);
169
+ response.setIncludePages(true);
170
+ response.setListThirdPartyDeveloperTools();
171
+ },
172
+ };
173
+ });
174
+ export const navigatePage = definePageTool(args => {
175
+ return {
176
+ name: 'navigate_page',
177
+ description: `Go to a URL, or back, forward, or reload. Use project URL if not specified otherwise.`,
178
+ annotations: {
179
+ category: ToolCategory.NAVIGATION,
180
+ readOnlyHint: false,
181
+ },
182
+ schema: {
183
+ type: zod
184
+ .enum(['url', 'back', 'forward', 'reload'])
185
+ .optional()
186
+ .describe('Navigate the page by URL, back or forward in history, or reload.'),
187
+ url: zod.string().optional().describe('Target URL (only type=url)'),
188
+ ignoreCache: zod
189
+ .boolean()
190
+ .optional()
191
+ .describe('Whether to ignore cache on reload.'),
192
+ handleBeforeUnload: zod
193
+ .enum(['accept', 'decline'])
194
+ .optional()
195
+ .describe('Whether to auto accept or beforeunload dialogs triggered by this navigation. Default is accept.'),
196
+ initScript: zod
197
+ .string()
198
+ .optional()
199
+ .describe('A JavaScript script to be executed on each new document before any other scripts for the next navigation.'),
200
+ ...(args?.experimentalNavigationAllowlist
201
+ ? {
202
+ allowList: zod
203
+ .string()
204
+ .optional()
205
+ .describe('Optional comma-separated list of URL patterns to allow. If provided, all other navigations will be blocked.'),
206
+ }
207
+ : {}),
208
+ ...timeoutSchema,
209
+ },
210
+ blockedByDialog: false,
211
+ verifyFilesSchema: [],
212
+ handler: async (request, response) => {
213
+ const page = request.page;
214
+ const options = {
215
+ timeout: request.params.timeout,
216
+ };
217
+ if (!request.params.type && !request.params.url) {
218
+ throw new Error('Either URL or a type is required.');
219
+ }
220
+ if (!request.params.type) {
221
+ request.params.type = 'url';
222
+ }
223
+ const handleBeforeUnload = request.params.handleBeforeUnload ?? 'accept';
224
+ const dialogHandler = (dialog) => {
225
+ if (dialog.type() === 'beforeunload') {
226
+ if (handleBeforeUnload === 'accept') {
227
+ response.appendResponseLine(`Accepted a beforeunload dialog.`);
228
+ void dialog.accept();
229
+ }
230
+ else {
231
+ response.appendResponseLine(`Declined a beforeunload dialog.`);
232
+ void dialog.dismiss();
233
+ }
234
+ // We are not going to report the dialog like regular dialogs.
235
+ page.clearDialog();
236
+ }
237
+ };
238
+ let initScriptId;
239
+ if (request.params.initScript) {
240
+ const { identifier } = await page.pptrPage.evaluateOnNewDocument(request.params.initScript);
241
+ initScriptId = identifier;
242
+ }
243
+ page.pptrPage.on('dialog', dialogHandler);
244
+ try {
245
+ await navigateWithInterception(page, async () => {
246
+ switch (request.params.type) {
247
+ case 'url':
248
+ if (!request.params.url) {
249
+ throw new Error('A URL is required for navigation of type=url.');
250
+ }
251
+ try {
252
+ await page.pptrPage.goto(request.params.url, options);
253
+ response.appendResponseLine(`Successfully navigated to ${request.params.url}.`);
254
+ }
255
+ catch (error) {
256
+ response.appendResponseLine(`Unable to navigate in the selected page: ${error.message}.`);
257
+ }
258
+ break;
259
+ case 'back':
260
+ try {
261
+ await page.pptrPage.goBack(options);
262
+ response.appendResponseLine(`Successfully navigated back to ${page.pptrPage.url()}.`);
263
+ }
264
+ catch (error) {
265
+ response.appendResponseLine(`Unable to navigate back in the selected page: ${error.message}.`);
266
+ }
267
+ break;
268
+ case 'forward':
269
+ try {
270
+ await page.pptrPage.goForward(options);
271
+ response.appendResponseLine(`Successfully navigated forward to ${page.pptrPage.url()}.`);
272
+ }
273
+ catch (error) {
274
+ response.appendResponseLine(`Unable to navigate forward in the selected page: ${error.message}.`);
275
+ }
276
+ break;
277
+ case 'reload':
278
+ try {
279
+ await page.pptrPage.reload({
280
+ ...options,
281
+ ignoreCache: request.params.ignoreCache,
282
+ });
283
+ response.appendResponseLine(`Successfully reloaded the page.`);
284
+ }
285
+ catch (error) {
286
+ response.appendResponseLine(`Unable to reload the selected page: ${error.message}.`);
287
+ }
288
+ break;
289
+ }
290
+ }, request.params.allowList, request.params.timeout);
291
+ }
292
+ finally {
293
+ page.pptrPage.off('dialog', dialogHandler);
294
+ if (initScriptId) {
295
+ await page.pptrPage
296
+ .removeScriptToEvaluateOnNewDocument(initScriptId)
297
+ .catch(error => {
298
+ logger?.(`Failed to remove init script`, error);
299
+ });
300
+ }
301
+ }
302
+ response.setIncludePages(true);
303
+ response.setListThirdPartyDeveloperTools();
304
+ response.setListWebMcpTools();
305
+ },
306
+ };
307
+ });
308
+ export const resizePage = definePageTool({
309
+ name: 'resize_page',
310
+ description: `Resizes the selected page's window so that the page has specified dimension`,
311
+ annotations: {
312
+ category: ToolCategory.EMULATION,
313
+ readOnlyHint: false,
314
+ },
315
+ schema: {
316
+ width: zod.number().describe('Page width'),
317
+ height: zod.number().describe('Page height'),
318
+ },
319
+ blockedByDialog: false,
320
+ verifyFilesSchema: [],
321
+ handler: async (request, response, _context) => {
322
+ const page = request.page;
323
+ try {
324
+ const browser = page.pptrPage.browser();
325
+ const windowId = await page.pptrPage.windowId();
326
+ const bounds = await browser.getWindowBounds(windowId);
327
+ if (bounds.windowState === 'fullscreen') {
328
+ // Have to call this twice on Ubuntu when the window is in fullscreen mode.
329
+ await browser.setWindowBounds(windowId, { windowState: 'normal' });
330
+ await browser.setWindowBounds(windowId, { windowState: 'normal' });
331
+ }
332
+ else if (bounds.windowState !== 'normal') {
333
+ await browser.setWindowBounds(windowId, { windowState: 'normal' });
334
+ }
335
+ }
336
+ catch {
337
+ // Window APIs are not supported on all platforms
338
+ }
339
+ await page.pptrPage.resize({
340
+ contentWidth: request.params.width,
341
+ contentHeight: request.params.height,
342
+ });
343
+ response.setIncludePages(true);
344
+ },
345
+ });
346
+ export const handleDialog = definePageTool({
347
+ name: 'handle_dialog',
348
+ description: `If a browser dialog was opened, use this command to handle it`,
349
+ annotations: {
350
+ category: ToolCategory.INPUT,
351
+ readOnlyHint: false,
352
+ },
353
+ schema: {
354
+ action: zod
355
+ .enum(['accept', 'dismiss'])
356
+ .describe('Whether to dismiss or accept the dialog'),
357
+ promptText: zod
358
+ .string()
359
+ .optional()
360
+ .describe('Optional prompt text to enter into the dialog.'),
361
+ },
362
+ blockedByDialog: false,
363
+ verifyFilesSchema: [],
364
+ handler: async (request, response, _context) => {
365
+ const page = request.page;
366
+ const dialog = page.getDialog();
367
+ if (!dialog) {
368
+ throw new Error('No open dialog found');
369
+ }
370
+ switch (request.params.action) {
371
+ case 'accept': {
372
+ try {
373
+ await dialog.accept(request.params.promptText);
374
+ }
375
+ catch (err) {
376
+ // Likely already handled by the user outside of MCP.
377
+ logger?.(err);
378
+ }
379
+ response.appendResponseLine('Successfully accepted the dialog');
380
+ break;
381
+ }
382
+ case 'dismiss': {
383
+ try {
384
+ await dialog.dismiss();
385
+ }
386
+ catch (err) {
387
+ // Likely already handled.
388
+ logger?.(err);
389
+ }
390
+ response.appendResponseLine('Successfully dismissed the dialog');
391
+ break;
392
+ }
393
+ }
394
+ page.clearDialog();
395
+ response.setIncludePages(true);
396
+ },
397
+ });
398
+ export const getTabId = definePageTool({
399
+ name: 'get_tab_id',
400
+ description: `Get the tab ID of the page`,
401
+ annotations: {
402
+ category: ToolCategory.NAVIGATION,
403
+ readOnlyHint: true,
404
+ conditions: ['experimentalInteropTools'],
405
+ },
406
+ schema: {
407
+ pageId: zod
408
+ .number()
409
+ .describe(`The ID of the page to get the tab ID for. Call ${listPages().name} to get available pages.`),
410
+ },
411
+ blockedByDialog: false,
412
+ verifyFilesSchema: [],
413
+ handler: async (request, response, context) => {
414
+ const page = context.getPageById(request.params.pageId);
415
+ const tabId = page.pptrPage._tabId;
416
+ response.setTabId(tabId);
417
+ },
418
+ });
419
+ //# sourceMappingURL=pages.js.map
@@ -0,0 +1,200 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import zlib from 'node:zlib';
7
+ import { logger } from '../logger.js';
8
+ import { zod, DevTools } from '../third_party/index.js';
9
+ import { parseRawTraceBuffer, traceResultIsSuccess, } from '../trace-processing/parse.js';
10
+ import { ToolCategory } from './categories.js';
11
+ import { definePageTool } from './ToolDefinition.js';
12
+ const filePathSchema = zod
13
+ .string()
14
+ .optional()
15
+ .describe('The absolute file path, or a file path relative to the current working directory, to save the raw trace data. For example, trace.json.gz (compressed) or trace.json (uncompressed).');
16
+ export const startTrace = definePageTool({
17
+ name: 'performance_start_trace',
18
+ description: `Start a performance trace on the selected webpage. Use to find frontend performance issues, Core Web Vitals (LCP, INP, CLS), and improve page load speed.`,
19
+ annotations: {
20
+ category: ToolCategory.PERFORMANCE,
21
+ readOnlyHint: false,
22
+ },
23
+ schema: {
24
+ reload: zod
25
+ .boolean()
26
+ .default(true)
27
+ .describe('Determines if, once tracing has started, the current selected page should be automatically reloaded. Navigate the page to the right URL using the navigate_page tool BEFORE starting the trace if reload or autoStop is set to true.'),
28
+ autoStop: zod
29
+ .boolean()
30
+ .default(true)
31
+ .describe('Determines if the trace recording should be automatically stopped.'),
32
+ filePath: filePathSchema,
33
+ },
34
+ blockedByDialog: true,
35
+ verifyFilesSchema: ['filePath'],
36
+ handler: async (request, response, context) => {
37
+ if (context.isRunningPerformanceTrace()) {
38
+ response.appendResponseLine('Error: a performance trace is already running. Use performance_stop_trace to stop it. Only one trace can be running at any given time.');
39
+ return;
40
+ }
41
+ context.setIsRunningPerformanceTrace(true);
42
+ const page = request.page;
43
+ const pageUrlForTracing = page.pptrPage.url();
44
+ if (request.params.reload) {
45
+ // Before starting the recording, navigate to about:blank to clear out any state.
46
+ await page.pptrPage.goto('about:blank', {
47
+ waitUntil: ['networkidle0'],
48
+ });
49
+ }
50
+ // Keep in sync with the categories arrays in:
51
+ // https://source.chromium.org/chromium/chromium/src/+/main:third_party/devtools-frontend/src/front_end/panels/timeline/TimelineController.ts
52
+ // https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/gather/gatherers/trace.js
53
+ const categories = [
54
+ '-*',
55
+ 'blink.console',
56
+ 'blink.user_timing',
57
+ 'devtools.timeline',
58
+ 'disabled-by-default-devtools.screenshot',
59
+ 'disabled-by-default-devtools.timeline',
60
+ 'disabled-by-default-devtools.timeline.invalidationTracking',
61
+ 'disabled-by-default-devtools.timeline.frame',
62
+ 'disabled-by-default-devtools.timeline.stack',
63
+ 'disabled-by-default-v8.cpu_profiler',
64
+ 'disabled-by-default-v8.cpu_profiler.hires',
65
+ 'latencyInfo',
66
+ 'loading',
67
+ 'disabled-by-default-lighthouse',
68
+ 'v8.execute',
69
+ 'v8',
70
+ ];
71
+ await page.pptrPage.tracing.start({
72
+ categories,
73
+ });
74
+ if (request.params.reload) {
75
+ await page.pptrPage.goto(pageUrlForTracing, {
76
+ waitUntil: ['load'],
77
+ });
78
+ }
79
+ if (request.params.autoStop) {
80
+ await new Promise(resolve => setTimeout(resolve, 5_000));
81
+ await stopTracingAndAppendOutput(page, response, context, request.params.filePath);
82
+ }
83
+ else {
84
+ response.appendResponseLine(`The performance trace is being recorded. Use performance_stop_trace to stop it.`);
85
+ }
86
+ },
87
+ });
88
+ export const stopTrace = definePageTool({
89
+ name: 'performance_stop_trace',
90
+ description: 'Stop the active performance trace recording on the selected webpage.',
91
+ annotations: {
92
+ category: ToolCategory.PERFORMANCE,
93
+ readOnlyHint: false,
94
+ },
95
+ schema: {
96
+ filePath: filePathSchema,
97
+ },
98
+ blockedByDialog: true,
99
+ verifyFilesSchema: ['filePath'],
100
+ handler: async (request, response, context) => {
101
+ if (!context.isRunningPerformanceTrace()) {
102
+ return;
103
+ }
104
+ const page = request.page;
105
+ await stopTracingAndAppendOutput(page, response, context, request.params.filePath);
106
+ },
107
+ });
108
+ export const analyzeInsight = definePageTool({
109
+ name: 'performance_analyze_insight',
110
+ description: 'Provides more detailed information on a specific Performance Insight of an insight set that was highlighted in the results of a trace recording.',
111
+ annotations: {
112
+ category: ToolCategory.PERFORMANCE,
113
+ readOnlyHint: true,
114
+ },
115
+ schema: {
116
+ insightSetId: zod
117
+ .string()
118
+ .describe('The id for the specific insight set. Only use the ids given in the "Available insight sets" list.'),
119
+ insightName: zod
120
+ .string()
121
+ .describe('The name of the Insight you want more information on. For example: "DocumentLatency" or "LCPBreakdown"'),
122
+ },
123
+ blockedByDialog: false,
124
+ verifyFilesSchema: [],
125
+ handler: async (request, response, context) => {
126
+ const lastRecording = context.recordedTraces().at(-1);
127
+ if (!lastRecording) {
128
+ response.appendResponseLine('No recorded traces found. Record a performance trace so you have Insights to analyze.');
129
+ return;
130
+ }
131
+ response.attachTraceInsight(lastRecording, request.params.insightSetId, request.params.insightName);
132
+ },
133
+ });
134
+ async function stopTracingAndAppendOutput(page, response, context, filePath) {
135
+ try {
136
+ const traceEventsBuffer = await page.pptrPage.tracing.stop();
137
+ if (filePath && traceEventsBuffer) {
138
+ let dataToWrite = traceEventsBuffer;
139
+ if (filePath.endsWith('.gz')) {
140
+ dataToWrite = await new Promise((resolve, reject) => {
141
+ zlib.gzip(traceEventsBuffer, (error, result) => {
142
+ if (error) {
143
+ reject(error);
144
+ }
145
+ else {
146
+ resolve(result);
147
+ }
148
+ });
149
+ });
150
+ }
151
+ const file = await context.saveFile(dataToWrite, filePath, filePath.endsWith('.gz') ? '.json.gz' : '.json');
152
+ response.appendResponseLine(`The raw trace data was saved to ${file.filename}.`);
153
+ }
154
+ const result = await parseRawTraceBuffer(traceEventsBuffer, {
155
+ cpuThrottling: page.cpuThrottlingRate,
156
+ networkThrottling: page.networkConditions ?? undefined,
157
+ });
158
+ response.appendResponseLine('The performance trace has been stopped.');
159
+ if (traceResultIsSuccess(result)) {
160
+ if (context.isCruxEnabled()) {
161
+ await populateCruxData(result);
162
+ }
163
+ context.storeTraceRecording(result);
164
+ response.attachTraceSummary(result);
165
+ }
166
+ else {
167
+ throw new Error(`There was an unexpected error parsing the trace: ${result.error}`);
168
+ }
169
+ }
170
+ finally {
171
+ context.setIsRunningPerformanceTrace(false);
172
+ }
173
+ }
174
+ /** We tell CrUXManager to fetch data so it's available when DevTools.PerformanceTraceFormatter is invoked */
175
+ async function populateCruxData(result) {
176
+ logger?.('populateCruxData called');
177
+ const cruxManager = DevTools.CrUXManager.CrUXManager.instance();
178
+ // go/jtfbx. Yes, we're aware this API key is public. ;)
179
+ cruxManager.setEndpointForTesting('https://chromeuxreport.googleapis.com/v1/records:queryRecord?key=AIzaSyBn5gimNjhiEyA_euicSKko6IlD3HdgUfk');
180
+ const cruxSetting = DevTools.Common.Settings.Settings.instance().createSetting('field-data', {
181
+ enabled: true,
182
+ });
183
+ cruxSetting.set({ enabled: true });
184
+ // Gather URLs to fetch CrUX data for
185
+ const urls = [...(result.parsedTrace.insights?.values() ?? [])].map(c => c.url.toString());
186
+ urls.push(result.parsedTrace.data.Meta.mainFrameURL);
187
+ const urlSet = new Set(urls);
188
+ if (urlSet.size === 0) {
189
+ logger?.('No URLs found for CrUX data');
190
+ return;
191
+ }
192
+ logger?.(`Fetching CrUX data for ${urlSet.size} URLs: ${Array.from(urlSet).join(', ')}`);
193
+ const cruxData = await Promise.all(Array.from(urlSet).map(async (url) => {
194
+ const data = await cruxManager.getFieldDataForPage(url);
195
+ logger?.(`CrUX data for ${url}: ${data ? 'found' : 'not found'}`);
196
+ return data;
197
+ }));
198
+ result.parsedTrace.metadata.cruxFieldData = cruxData;
199
+ }
200
+ //# sourceMappingURL=performance.js.map