brave-mcp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +802 -0
  3. package/build/src/DevToolsConnectionAdapter.js +69 -0
  4. package/build/src/DevtoolsUtils.js +294 -0
  5. package/build/src/McpContext.js +676 -0
  6. package/build/src/McpPage.js +108 -0
  7. package/build/src/McpResponse.js +718 -0
  8. package/build/src/Mutex.js +37 -0
  9. package/build/src/PageCollector.js +310 -0
  10. package/build/src/SlimMcpResponse.js +18 -0
  11. package/build/src/WaitForHelper.js +153 -0
  12. package/build/src/bin/brave-devtools-cli-options.js +651 -0
  13. package/build/src/bin/brave-devtools-mcp-cli-options.js +312 -0
  14. package/build/src/bin/brave-devtools-mcp-main.js +35 -0
  15. package/build/src/bin/brave-devtools-mcp.js +22 -0
  16. package/build/src/bin/brave-devtools.js +190 -0
  17. package/build/src/bin/check-latest-version.js +25 -0
  18. package/build/src/bin/cliDefinitions.js +615 -0
  19. package/build/src/browser.js +295 -0
  20. package/build/src/daemon/client.js +152 -0
  21. package/build/src/daemon/daemon.js +202 -0
  22. package/build/src/daemon/types.js +6 -0
  23. package/build/src/daemon/utils.js +109 -0
  24. package/build/src/formatters/ConsoleFormatter.js +241 -0
  25. package/build/src/formatters/IssueFormatter.js +192 -0
  26. package/build/src/formatters/NetworkFormatter.js +218 -0
  27. package/build/src/formatters/SnapshotFormatter.js +134 -0
  28. package/build/src/index.js +216 -0
  29. package/build/src/issue-descriptions.js +39 -0
  30. package/build/src/logger.js +36 -0
  31. package/build/src/polyfill.js +7 -0
  32. package/build/src/telemetry/ClearcutLogger.js +234 -0
  33. package/build/src/telemetry/WatchdogClient.js +60 -0
  34. package/build/src/telemetry/flagUtils.js +45 -0
  35. package/build/src/telemetry/metricUtils.js +14 -0
  36. package/build/src/telemetry/persistence.js +53 -0
  37. package/build/src/telemetry/toolMetricsUtils.js +88 -0
  38. package/build/src/telemetry/types.js +38 -0
  39. package/build/src/telemetry/watchdog/ClearcutSender.js +203 -0
  40. package/build/src/telemetry/watchdog/main.js +127 -0
  41. package/build/src/third_party/devtools-formatter-worker.js +7 -0
  42. package/build/src/third_party/index.js +28 -0
  43. package/build/src/third_party/issue-descriptions/CoepCoopSandboxedIframeCannotNavigateToCoopPage.md +4 -0
  44. package/build/src/third_party/issue-descriptions/CoepCorpNotSameOrigin.md +8 -0
  45. package/build/src/third_party/issue-descriptions/CoepCorpNotSameOriginAfterDefaultedToSameOriginByCoep.md +18 -0
  46. package/build/src/third_party/issue-descriptions/CoepCorpNotSameSite.md +7 -0
  47. package/build/src/third_party/issue-descriptions/CoepFrameResourceNeedsCoepHeader.md +10 -0
  48. package/build/src/third_party/issue-descriptions/CompatibilityModeQuirks.md +5 -0
  49. package/build/src/third_party/issue-descriptions/CookieAttributeValueExceedsMaxSize.md +5 -0
  50. package/build/src/third_party/issue-descriptions/LowTextContrast.md +5 -0
  51. package/build/src/third_party/issue-descriptions/SameSiteExcludeContextDowngradeRead.md +8 -0
  52. package/build/src/third_party/issue-descriptions/SameSiteExcludeContextDowngradeSet.md +8 -0
  53. package/build/src/third_party/issue-descriptions/SameSiteExcludeNavigationContextDowngrade.md +8 -0
  54. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorRead.md +8 -0
  55. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorSet.md +8 -0
  56. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnRead.md +8 -0
  57. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnSet.md +8 -0
  58. package/build/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeRead.md +9 -0
  59. package/build/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeSet.md +9 -0
  60. package/build/src/third_party/issue-descriptions/SameSiteWarnCrossDowngradeRead.md +8 -0
  61. package/build/src/third_party/issue-descriptions/SameSiteWarnCrossDowngradeSet.md +8 -0
  62. package/build/src/third_party/issue-descriptions/SameSiteWarnStrictLaxDowngradeStrict.md +8 -0
  63. package/build/src/third_party/issue-descriptions/arInsecureContext.md +7 -0
  64. package/build/src/third_party/issue-descriptions/arInvalidInfoHeader.md +5 -0
  65. package/build/src/third_party/issue-descriptions/arInvalidRegisterOsSourceHeader.md +5 -0
  66. package/build/src/third_party/issue-descriptions/arInvalidRegisterOsTriggerHeader.md +5 -0
  67. package/build/src/third_party/issue-descriptions/arInvalidRegisterSourceHeader.md +5 -0
  68. package/build/src/third_party/issue-descriptions/arInvalidRegisterTriggerHeader.md +5 -0
  69. package/build/src/third_party/issue-descriptions/arNavigationRegistrationUniqueScopeAlreadySet.md +5 -0
  70. package/build/src/third_party/issue-descriptions/arNavigationRegistrationWithoutTransientUserActivation.md +6 -0
  71. package/build/src/third_party/issue-descriptions/arNoRegisterOsSourceHeader.md +5 -0
  72. package/build/src/third_party/issue-descriptions/arNoRegisterOsTriggerHeader.md +5 -0
  73. package/build/src/third_party/issue-descriptions/arNoRegisterSourceHeader.md +5 -0
  74. package/build/src/third_party/issue-descriptions/arNoRegisterTriggerHeader.md +5 -0
  75. package/build/src/third_party/issue-descriptions/arNoWebOrOsSupport.md +4 -0
  76. package/build/src/third_party/issue-descriptions/arOsSourceIgnored.md +18 -0
  77. package/build/src/third_party/issue-descriptions/arOsTriggerIgnored.md +19 -0
  78. package/build/src/third_party/issue-descriptions/arPermissionPolicyDisabled.md +8 -0
  79. package/build/src/third_party/issue-descriptions/arSourceAndTriggerHeaders.md +9 -0
  80. package/build/src/third_party/issue-descriptions/arSourceIgnored.md +13 -0
  81. package/build/src/third_party/issue-descriptions/arTriggerIgnored.md +12 -0
  82. package/build/src/third_party/issue-descriptions/arUntrustworthyReportingOrigin.md +10 -0
  83. package/build/src/third_party/issue-descriptions/arWebAndOsHeaders.md +11 -0
  84. package/build/src/third_party/issue-descriptions/bounceTrackingMitigations.md +3 -0
  85. package/build/src/third_party/issue-descriptions/clientHintMetaTagAllowListInvalidOrigin.md +4 -0
  86. package/build/src/third_party/issue-descriptions/clientHintMetaTagModifiedHTML.md +4 -0
  87. package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowlistItemType.md +12 -0
  88. package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidHeader.md +12 -0
  89. package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidUrlPattern.md +8 -0
  90. package/build/src/third_party/issue-descriptions/connectionAllowlistItemNotInnerList.md +12 -0
  91. package/build/src/third_party/issue-descriptions/connectionAllowlistMoreThanOneList.md +7 -0
  92. package/build/src/third_party/issue-descriptions/connectionAllowlistReportingEndpointNotToken.md +10 -0
  93. package/build/src/third_party/issue-descriptions/cookieCrossSiteRedirectDowngrade.md +12 -0
  94. package/build/src/third_party/issue-descriptions/cookieExcludeBlockedWithinRelatedWebsiteSet.md +4 -0
  95. package/build/src/third_party/issue-descriptions/cookieExcludeDomainNonAscii.md +11 -0
  96. package/build/src/third_party/issue-descriptions/cookieExcludePortMismatch.md +8 -0
  97. package/build/src/third_party/issue-descriptions/cookieExcludeSchemeMismatch.md +7 -0
  98. package/build/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutRead.md +6 -0
  99. package/build/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutSet.md +6 -0
  100. package/build/src/third_party/issue-descriptions/cookieWarnDomainNonAscii.md +11 -0
  101. package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantRead.md +4 -0
  102. package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantSet.md +4 -0
  103. package/build/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutRead.md +6 -0
  104. package/build/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutSet.md +6 -0
  105. package/build/src/third_party/issue-descriptions/corsAllowCredentialsRequired.md +6 -0
  106. package/build/src/third_party/issue-descriptions/corsDisabledScheme.md +7 -0
  107. package/build/src/third_party/issue-descriptions/corsDisallowedByMode.md +7 -0
  108. package/build/src/third_party/issue-descriptions/corsHeaderDisallowedByPreflightResponse.md +5 -0
  109. package/build/src/third_party/issue-descriptions/corsInvalidHeaderValues.md +7 -0
  110. package/build/src/third_party/issue-descriptions/corsLocalNetworkAccessPermissionDenied.md +19 -0
  111. package/build/src/third_party/issue-descriptions/corsMethodDisallowedByPreflightResponse.md +5 -0
  112. package/build/src/third_party/issue-descriptions/corsNoCorsRedirectModeNotFollow.md +5 -0
  113. package/build/src/third_party/issue-descriptions/corsOriginMismatch.md +6 -0
  114. package/build/src/third_party/issue-descriptions/corsPreflightResponseInvalid.md +5 -0
  115. package/build/src/third_party/issue-descriptions/corsRedirectContainsCredentials.md +5 -0
  116. package/build/src/third_party/issue-descriptions/corsWildcardOriginNotAllowed.md +8 -0
  117. package/build/src/third_party/issue-descriptions/cspEvalViolation.md +9 -0
  118. package/build/src/third_party/issue-descriptions/cspInlineViolation.md +10 -0
  119. package/build/src/third_party/issue-descriptions/cspTrustedTypesPolicyViolation.md +5 -0
  120. package/build/src/third_party/issue-descriptions/cspTrustedTypesSinkViolation.md +8 -0
  121. package/build/src/third_party/issue-descriptions/cspURLViolation.md +10 -0
  122. package/build/src/third_party/issue-descriptions/deprecation.md +3 -0
  123. package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsHttpNotFound.md +1 -0
  124. package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsInvalidResponse.md +1 -0
  125. package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsNoResponse.md +1 -0
  126. package/build/src/third_party/issue-descriptions/federatedAuthRequestApprovalDeclined.md +1 -0
  127. package/build/src/third_party/issue-descriptions/federatedAuthRequestCanceled.md +1 -0
  128. package/build/src/third_party/issue-descriptions/federatedAuthRequestErrorFetchingSignin.md +1 -0
  129. package/build/src/third_party/issue-descriptions/federatedAuthRequestErrorIdToken.md +1 -0
  130. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenHttpNotFound.md +1 -0
  131. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidRequest.md +1 -0
  132. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidResponse.md +1 -0
  133. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenNoResponse.md +1 -0
  134. package/build/src/third_party/issue-descriptions/federatedAuthRequestInvalidSigninResponse.md +1 -0
  135. package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestHttpNotFound.md +1 -0
  136. package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestInvalidResponse.md +1 -0
  137. package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestNoResponse.md +1 -0
  138. package/build/src/third_party/issue-descriptions/federatedAuthRequestTooManyRequests.md +1 -0
  139. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidAccountsResponse.md +1 -0
  140. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidConfigOrWellKnown.md +1 -0
  141. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoAccountSharingPermission.md +1 -0
  142. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoApiPermission.md +1 -0
  143. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoReturningUserFromFetchedAccounts.md +1 -0
  144. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotIframe.md +1 -0
  145. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotPotentiallyTrustworthy.md +1 -0
  146. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSameOrigin.md +1 -0
  147. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSignedInWithIdp.md +1 -0
  148. package/build/src/third_party/issue-descriptions/fetchingPartitionedBlobURL.md +7 -0
  149. package/build/src/third_party/issue-descriptions/genericFormAriaLabelledByToNonExistingIdError.md +8 -0
  150. package/build/src/third_party/issue-descriptions/genericFormAutocompleteAttributeEmptyError.md +5 -0
  151. package/build/src/third_party/issue-descriptions/genericFormDuplicateIdForInputError.md +5 -0
  152. package/build/src/third_party/issue-descriptions/genericFormEmptyIdAndNameAttributesForInputError.md +5 -0
  153. package/build/src/third_party/issue-descriptions/genericFormInputAssignedAutocompleteValueToIdOrNameAttributeError.md +5 -0
  154. package/build/src/third_party/issue-descriptions/genericFormInputHasWrongButWellIntendedAutocompleteValueError.md +5 -0
  155. package/build/src/third_party/issue-descriptions/genericFormInputWithNoLabelError.md +5 -0
  156. package/build/src/third_party/issue-descriptions/genericFormLabelForMatchesNonExistingIdError.md +5 -0
  157. package/build/src/third_party/issue-descriptions/genericFormLabelForNameError.md +5 -0
  158. package/build/src/third_party/issue-descriptions/genericFormLabelHasNeitherForNorNestedInputError.md +5 -0
  159. package/build/src/third_party/issue-descriptions/genericNavigationEntryMarkedSkippable.md +7 -0
  160. package/build/src/third_party/issue-descriptions/genericResponseWasBlockedByORB.md +4 -0
  161. package/build/src/third_party/issue-descriptions/heavyAd.md +10 -0
  162. package/build/src/third_party/issue-descriptions/mixedContent.md +5 -0
  163. package/build/src/third_party/issue-descriptions/navigatingPartitionedBlobURL.md +5 -0
  164. package/build/src/third_party/issue-descriptions/permissionElementActivationDisabled.md +7 -0
  165. package/build/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluder.md +9 -0
  166. package/build/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluderParent.md +9 -0
  167. package/build/src/third_party/issue-descriptions/permissionElementCspFrameAncestorsMissing.md +5 -0
  168. package/build/src/third_party/issue-descriptions/permissionElementFencedFrameDisallowed.md +5 -0
  169. package/build/src/third_party/issue-descriptions/permissionElementFontSizeTooLarge.md +5 -0
  170. package/build/src/third_party/issue-descriptions/permissionElementFontSizeTooSmall.md +5 -0
  171. package/build/src/third_party/issue-descriptions/permissionElementGeolocationDeprecated.md +5 -0
  172. package/build/src/third_party/issue-descriptions/permissionElementInsetBoxShadowUnsupported.md +5 -0
  173. package/build/src/third_party/issue-descriptions/permissionElementInvalidDisplayStyle.md +5 -0
  174. package/build/src/third_party/issue-descriptions/permissionElementInvalidSizeValue.md +5 -0
  175. package/build/src/third_party/issue-descriptions/permissionElementInvalidType.md +5 -0
  176. package/build/src/third_party/issue-descriptions/permissionElementInvalidTypeActivation.md +5 -0
  177. package/build/src/third_party/issue-descriptions/permissionElementLowContrast.md +5 -0
  178. package/build/src/third_party/issue-descriptions/permissionElementNonOpaqueColor.md +5 -0
  179. package/build/src/third_party/issue-descriptions/permissionElementPaddingBottomUnsupported.md +6 -0
  180. package/build/src/third_party/issue-descriptions/permissionElementPaddingRightUnsupported.md +6 -0
  181. package/build/src/third_party/issue-descriptions/permissionElementPermissionsPolicyBlocked.md +5 -0
  182. package/build/src/third_party/issue-descriptions/permissionElementRegistrationFailed.md +5 -0
  183. package/build/src/third_party/issue-descriptions/permissionElementRequestInProgress.md +5 -0
  184. package/build/src/third_party/issue-descriptions/permissionElementSecurityChecksFailed.md +5 -0
  185. package/build/src/third_party/issue-descriptions/permissionElementTypeNotSupported.md +5 -0
  186. package/build/src/third_party/issue-descriptions/permissionElementUntrustedEvent.md +7 -0
  187. package/build/src/third_party/issue-descriptions/placeholderDescriptionForInvisibleIssues.md +3 -0
  188. package/build/src/third_party/issue-descriptions/propertyRuleInvalidNameIssue.md +3 -0
  189. package/build/src/third_party/issue-descriptions/propertyRuleIssue.md +7 -0
  190. package/build/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedOptGroupChild.md +7 -0
  191. package/build/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedSelectChild.md +7 -0
  192. package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentAttributesSelectDescendant.md +3 -0
  193. package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentLegendChild.md +3 -0
  194. package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentOptionChild.md +3 -0
  195. package/build/src/third_party/issue-descriptions/selectElementAccessibilityNonPhrasingContentOptionChild.md +3 -0
  196. package/build/src/third_party/issue-descriptions/selectivePermissionsIntervention.md +7 -0
  197. package/build/src/third_party/issue-descriptions/sharedArrayBuffer.md +7 -0
  198. package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorCrossOriginNoCorsRequest.md +1 -0
  199. package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorDictionaryLoadFailure.md +3 -0
  200. package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorMatchingDictionaryNotUsed.md +3 -0
  201. package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorUnexpectedContentDictionaryHeader.md +1 -0
  202. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorCossOriginNoCorsRequest.md +1 -0
  203. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorDisallowedBySettings.md +1 -0
  204. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorExpiredResponse.md +3 -0
  205. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorFeatureDisabled.md +3 -0
  206. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInsufficientResources.md +1 -0
  207. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidMatchField.md +1 -0
  208. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidStructuredHeader.md +1 -0
  209. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidTTLField.md +1 -0
  210. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNavigationRequest.md +3 -0
  211. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNoMatchField.md +1 -0
  212. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonIntegerTTLField.md +1 -0
  213. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonListMatchDestField.md +1 -0
  214. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonSecureContext.md +3 -0
  215. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringIdField.md +1 -0
  216. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringInMatchDestList.md +1 -0
  217. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringMatchField.md +1 -0
  218. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonTokenTypeField.md +1 -0
  219. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorRequestAborted.md +1 -0
  220. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorShuttingDown.md +1 -0
  221. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorTooLongIdField.md +3 -0
  222. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorUnsupportedType.md +3 -0
  223. package/build/src/third_party/issue-descriptions/sriInvalidSignatureHeader.md +14 -0
  224. package/build/src/third_party/issue-descriptions/sriInvalidSignatureInputHeader.md +15 -0
  225. package/build/src/third_party/issue-descriptions/sriMissingSignatureHeader.md +8 -0
  226. package/build/src/third_party/issue-descriptions/sriMissingSignatureInputHeader.md +7 -0
  227. package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsIncorrectLength.md +11 -0
  228. package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsNotByteSequence.md +14 -0
  229. package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsParameterized.md +15 -0
  230. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentName.md +8 -0
  231. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentType.md +13 -0
  232. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidDerivedComponentParameter.md +4 -0
  233. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidHeaderComponentParameter.md +5 -0
  234. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidParameter.md +11 -0
  235. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderKeyIdLength.md +12 -0
  236. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingLabel.md +6 -0
  237. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingRequiredParameters.md +8 -0
  238. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderValueMissingComponents.md +11 -0
  239. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderValueNotInnerList.md +11 -0
  240. package/build/src/third_party/issue-descriptions/sriValidationFailedIntegrityMismatch.md +10 -0
  241. package/build/src/third_party/issue-descriptions/sriValidationFailedInvalidLength.md +5 -0
  242. package/build/src/third_party/issue-descriptions/sriValidationFailedSignatureExpired.md +6 -0
  243. package/build/src/third_party/issue-descriptions/sriValidationFailedSignatureMismatch.md +11 -0
  244. package/build/src/third_party/issue-descriptions/stylesheetLateImport.md +4 -0
  245. package/build/src/third_party/issue-descriptions/stylesheetRequestFailed.md +3 -0
  246. package/build/src/third_party/issue-descriptions/summaryElementAccessibilityInteractiveContentSummaryDescendant.md +3 -0
  247. package/build/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestLength.md +12 -0
  248. package/build/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestType.md +17 -0
  249. package/build/src/third_party/issue-descriptions/unencodedDigestMalformedDictionary.md +14 -0
  250. package/build/src/third_party/issue-descriptions/unencodedDigestUnknownAlgorithm.md +15 -0
  251. package/build/src/third_party/lighthouse-devtools-mcp-bundle.js +59418 -0
  252. package/build/src/tools/ToolDefinition.js +72 -0
  253. package/build/src/tools/categories.js +26 -0
  254. package/build/src/tools/console.js +85 -0
  255. package/build/src/tools/emulation.js +55 -0
  256. package/build/src/tools/extensions.js +96 -0
  257. package/build/src/tools/inPage.js +105 -0
  258. package/build/src/tools/input.js +376 -0
  259. package/build/src/tools/lighthouse.js +123 -0
  260. package/build/src/tools/memory.js +28 -0
  261. package/build/src/tools/network.js +120 -0
  262. package/build/src/tools/pages.js +336 -0
  263. package/build/src/tools/performance.js +190 -0
  264. package/build/src/tools/screencast.js +79 -0
  265. package/build/src/tools/screenshot.js +84 -0
  266. package/build/src/tools/script.js +125 -0
  267. package/build/src/tools/slim/tools.js +81 -0
  268. package/build/src/tools/snapshot.js +56 -0
  269. package/build/src/tools/tools.js +53 -0
  270. package/build/src/trace-processing/parse.js +84 -0
  271. package/build/src/types.js +6 -0
  272. package/build/src/utils/ExtensionRegistry.js +35 -0
  273. package/build/src/utils/check-for-updates.js +72 -0
  274. package/build/src/utils/files.js +19 -0
  275. package/build/src/utils/keyboard.js +296 -0
  276. package/build/src/utils/pagination.js +49 -0
  277. package/build/src/utils/string.js +36 -0
  278. package/build/src/utils/types.js +6 -0
  279. package/build/src/version.js +6 -0
  280. package/package.json +87 -0
@@ -0,0 +1,218 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ * */
6
+ import { isUtf8 } from 'node:buffer';
7
+ const BODY_CONTEXT_SIZE_LIMIT = 10000;
8
+ export class NetworkFormatter {
9
+ #request;
10
+ #options;
11
+ #requestBody;
12
+ #responseBody;
13
+ #requestBodyFilePath;
14
+ #responseBodyFilePath;
15
+ constructor(request, options) {
16
+ this.#request = request;
17
+ this.#options = options;
18
+ }
19
+ static async from(request, options) {
20
+ const instance = new NetworkFormatter(request, options);
21
+ if (options.fetchData) {
22
+ await instance.#loadDetailedData();
23
+ }
24
+ return instance;
25
+ }
26
+ async #loadDetailedData() {
27
+ // Load Request Body
28
+ if (this.#request.hasPostData()) {
29
+ let data;
30
+ try {
31
+ data =
32
+ this.#request.postData() ?? (await this.#request.fetchPostData());
33
+ }
34
+ catch {
35
+ // Ignore parsing errors
36
+ }
37
+ const requestBodyNotAvailableMessage = '<Request body not available anymore>';
38
+ if (this.#options.requestFilePath) {
39
+ if (!this.#options.saveFile) {
40
+ throw new Error('saveFile is not provided');
41
+ }
42
+ if (data) {
43
+ await this.#options.saveFile(Buffer.from(data), this.#options.requestFilePath);
44
+ this.#requestBodyFilePath = this.#options.requestFilePath;
45
+ }
46
+ else {
47
+ this.#requestBody = requestBodyNotAvailableMessage;
48
+ }
49
+ }
50
+ else {
51
+ if (data) {
52
+ this.#requestBody = getSizeLimitedString(data, BODY_CONTEXT_SIZE_LIMIT);
53
+ }
54
+ else {
55
+ this.#requestBody = requestBodyNotAvailableMessage;
56
+ }
57
+ }
58
+ }
59
+ // Load Response Body
60
+ const response = this.#request.response();
61
+ if (response) {
62
+ const responseBodyNotAvailableMessage = '<Response body not available anymore>';
63
+ if (this.#options.responseFilePath) {
64
+ try {
65
+ const buffer = await response.buffer();
66
+ if (!this.#options.saveFile) {
67
+ throw new Error('saveFile is not provided');
68
+ }
69
+ await this.#options.saveFile(buffer, this.#options.responseFilePath);
70
+ this.#responseBodyFilePath = this.#options.responseFilePath;
71
+ }
72
+ catch {
73
+ // Flatten error handling for buffer() failure and save failure
74
+ }
75
+ if (!this.#responseBodyFilePath) {
76
+ this.#responseBody = responseBodyNotAvailableMessage;
77
+ }
78
+ }
79
+ else {
80
+ this.#responseBody = await this.#getFormattedResponseBody(response, BODY_CONTEXT_SIZE_LIMIT);
81
+ }
82
+ }
83
+ }
84
+ toString() {
85
+ return convertNetworkRequestConciseToString(this.toJSON());
86
+ }
87
+ toStringDetailed() {
88
+ return converNetworkRequestDetailedToStringDetailed(this.toJSONDetailed());
89
+ }
90
+ toJSON() {
91
+ return {
92
+ requestId: this.#options.requestId,
93
+ method: this.#request.method(),
94
+ url: this.#request.url(),
95
+ status: this.#getStatusFromRequest(this.#request),
96
+ selectedInDevToolsUI: this.#options.selectedInDevToolsUI,
97
+ };
98
+ }
99
+ toJSONDetailed() {
100
+ const redirectChain = this.#request.redirectChain();
101
+ const formattedRedirectChain = redirectChain.reverse().map(request => {
102
+ const id = this.#options.requestIdResolver
103
+ ? this.#options.requestIdResolver(request)
104
+ : undefined;
105
+ const formatter = new NetworkFormatter(request, {
106
+ requestId: id,
107
+ saveFile: this.#options.saveFile,
108
+ });
109
+ return formatter.toJSON();
110
+ });
111
+ return {
112
+ ...this.toJSON(),
113
+ requestHeaders: this.#request.headers(),
114
+ requestBody: this.#requestBody,
115
+ requestBodyFilePath: this.#requestBodyFilePath,
116
+ responseHeaders: this.#request.response()?.headers(),
117
+ responseBody: this.#responseBody,
118
+ responseBodyFilePath: this.#responseBodyFilePath,
119
+ failure: this.#request.failure()?.errorText,
120
+ redirectChain: formattedRedirectChain.length
121
+ ? formattedRedirectChain
122
+ : undefined,
123
+ };
124
+ }
125
+ #getStatusFromRequest(request) {
126
+ const httpResponse = request.response();
127
+ const failure = request.failure();
128
+ let status;
129
+ if (httpResponse) {
130
+ status = httpResponse.status().toString();
131
+ }
132
+ else if (failure) {
133
+ status = failure.errorText;
134
+ }
135
+ else {
136
+ status = 'pending';
137
+ }
138
+ return status;
139
+ }
140
+ async #getFormattedResponseBody(httpResponse, sizeLimit = BODY_CONTEXT_SIZE_LIMIT) {
141
+ try {
142
+ const responseBuffer = await httpResponse.buffer();
143
+ if (isUtf8(responseBuffer)) {
144
+ const responseAsTest = responseBuffer.toString('utf-8');
145
+ if (responseAsTest.length === 0) {
146
+ return '<empty response>';
147
+ }
148
+ return getSizeLimitedString(responseAsTest, sizeLimit);
149
+ }
150
+ return '<binary data>';
151
+ }
152
+ catch {
153
+ return '<not available anymore>';
154
+ }
155
+ }
156
+ }
157
+ function getSizeLimitedString(text, sizeLimit) {
158
+ if (text.length > sizeLimit) {
159
+ return text.substring(0, sizeLimit) + '... <truncated>';
160
+ }
161
+ return text;
162
+ }
163
+ function convertNetworkRequestConciseToString(data) {
164
+ // TODO truncate the URL
165
+ return `reqid=${data.requestId} ${data.method} ${data.url} [${data.status}]${data.selectedInDevToolsUI ? ` [selected in the DevTools Network panel]` : ''}`;
166
+ }
167
+ function formatHeadlers(headers) {
168
+ const response = [];
169
+ for (const [name, value] of Object.entries(headers)) {
170
+ response.push(`- ${name}:${value}`);
171
+ }
172
+ return response;
173
+ }
174
+ function converNetworkRequestDetailedToStringDetailed(data) {
175
+ const response = [];
176
+ response.push(`## Request ${data.url}`);
177
+ response.push(`Status: ${data.status}`);
178
+ response.push(`### Request Headers`);
179
+ for (const line of formatHeadlers(data.requestHeaders)) {
180
+ response.push(line);
181
+ }
182
+ if (data.requestBody) {
183
+ response.push(`### Request Body`);
184
+ response.push(data.requestBody);
185
+ }
186
+ else if (data.requestBodyFilePath) {
187
+ response.push(`### Request Body`);
188
+ response.push(`Saved to ${data.requestBodyFilePath}.`);
189
+ }
190
+ if (data.responseHeaders) {
191
+ response.push(`### Response Headers`);
192
+ for (const line of formatHeadlers(data.responseHeaders)) {
193
+ response.push(line);
194
+ }
195
+ }
196
+ if (data.responseBody) {
197
+ response.push(`### Response Body`);
198
+ response.push(data.responseBody);
199
+ }
200
+ else if (data.responseBodyFilePath) {
201
+ response.push(`### Response Body`);
202
+ response.push(`Saved to ${data.responseBodyFilePath}.`);
203
+ }
204
+ if (data.failure) {
205
+ response.push(`### Request failed with`);
206
+ response.push(data.failure);
207
+ }
208
+ const redirectChain = data.redirectChain;
209
+ if (redirectChain?.length) {
210
+ response.push(`### Redirect chain`);
211
+ let indent = 0;
212
+ for (const request of redirectChain.reverse()) {
213
+ response.push(`${' '.repeat(indent)}${convertNetworkRequestConciseToString(request)})}`);
214
+ indent++;
215
+ }
216
+ }
217
+ return response.join('\n');
218
+ }
@@ -0,0 +1,134 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export class SnapshotFormatter {
7
+ #snapshot;
8
+ constructor(snapshot) {
9
+ this.#snapshot = snapshot;
10
+ }
11
+ toString() {
12
+ const chunks = [];
13
+ const root = this.#snapshot.root;
14
+ // Top-level content of the snapshot.
15
+ if (this.#snapshot.verbose &&
16
+ this.#snapshot.hasSelectedElement &&
17
+ !this.#snapshot.selectedElementUid) {
18
+ chunks.push(`Note: there is a selected element in the DevTools Elements panel but it is not included into the current a11y tree snapshot.
19
+ Get a verbose snapshot to include all elements if you are interested in the selected element.\n\n`);
20
+ }
21
+ chunks.push(this.#formatNode(root, 0));
22
+ return chunks.join('');
23
+ }
24
+ toJSON() {
25
+ return this.#nodeToJSON(this.#snapshot.root);
26
+ }
27
+ #formatNode(node, depth = 0) {
28
+ const chunks = [];
29
+ const attributes = this.#getAttributes(node);
30
+ const line = ' '.repeat(depth * 2) +
31
+ attributes.join(' ') +
32
+ (node.id === this.#snapshot.selectedElementUid
33
+ ? ' [selected in the DevTools Elements panel]'
34
+ : '') +
35
+ '\n';
36
+ chunks.push(line);
37
+ for (const child of node.children) {
38
+ chunks.push(this.#formatNode(child, depth + 1));
39
+ }
40
+ return chunks.join('');
41
+ }
42
+ #nodeToJSON(node) {
43
+ const rawAttrs = this.#getAttributesMap(node);
44
+ const children = node.children.map(child => this.#nodeToJSON(child));
45
+ const result = structuredClone(rawAttrs);
46
+ if (children.length > 0) {
47
+ result.children = children;
48
+ }
49
+ return result;
50
+ }
51
+ #getAttributes(serializedAXNodeRoot) {
52
+ const attributes = [`uid=${serializedAXNodeRoot.id}`];
53
+ if (serializedAXNodeRoot.role) {
54
+ attributes.push(serializedAXNodeRoot.role === 'none'
55
+ ? 'ignored'
56
+ : serializedAXNodeRoot.role);
57
+ }
58
+ if (serializedAXNodeRoot.name) {
59
+ attributes.push(`"${serializedAXNodeRoot.name}"`);
60
+ }
61
+ const simpleAttrs = this.#getAttributesMap(serializedAXNodeRoot,
62
+ /* excludeSpecial */ true);
63
+ for (const attr of Object.keys(serializedAXNodeRoot).sort()) {
64
+ if (excludedAttributes.has(attr)) {
65
+ continue;
66
+ }
67
+ const mapped = booleanPropertyMap[attr];
68
+ if (mapped && simpleAttrs[mapped]) {
69
+ attributes.push(mapped);
70
+ }
71
+ const val = simpleAttrs[attr];
72
+ if (val === true) {
73
+ attributes.push(attr);
74
+ }
75
+ else if (typeof val === 'string' || typeof val === 'number') {
76
+ attributes.push(`${attr}="${val}"`);
77
+ }
78
+ }
79
+ return attributes;
80
+ }
81
+ #getAttributesMap(node, excludeSpecial = false) {
82
+ const result = {};
83
+ if (!excludeSpecial) {
84
+ result.id = node.id;
85
+ if (node.role) {
86
+ result.role = node.role;
87
+ }
88
+ if (node.name) {
89
+ result.name = node.name;
90
+ }
91
+ }
92
+ // Re-implementing the exact logic from original function for #getAttributes to be safe:
93
+ return {
94
+ ...result,
95
+ ...this.#extractedAttributes(node),
96
+ };
97
+ }
98
+ #extractedAttributes(node) {
99
+ const result = {};
100
+ for (const attr of Object.keys(node).sort()) {
101
+ if (excludedAttributes.has(attr)) {
102
+ continue;
103
+ }
104
+ const value = node[attr];
105
+ if (typeof value === 'boolean') {
106
+ if (booleanPropertyMap[attr]) {
107
+ result[booleanPropertyMap[attr]] = true;
108
+ }
109
+ if (value) {
110
+ result[attr] = true;
111
+ }
112
+ }
113
+ else if (typeof value === 'string' || typeof value === 'number') {
114
+ result[attr] = value;
115
+ }
116
+ }
117
+ return result;
118
+ }
119
+ }
120
+ const booleanPropertyMap = {
121
+ disabled: 'disableable',
122
+ expanded: 'expandable',
123
+ focused: 'focusable',
124
+ selected: 'selectable',
125
+ };
126
+ const excludedAttributes = new Set([
127
+ 'id',
128
+ 'role',
129
+ 'name',
130
+ 'elementHandle',
131
+ 'children',
132
+ 'backendNodeId',
133
+ 'loaderId',
134
+ ]);
@@ -0,0 +1,216 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { ensureBrowserConnected, ensureBrowserLaunched } from './browser.js';
7
+ import { loadIssueDescriptions } from './issue-descriptions.js';
8
+ import { logger } from './logger.js';
9
+ import { McpContext } from './McpContext.js';
10
+ import { McpResponse } from './McpResponse.js';
11
+ import { Mutex } from './Mutex.js';
12
+ import { SlimMcpResponse } from './SlimMcpResponse.js';
13
+ import { ClearcutLogger } from './telemetry/ClearcutLogger.js';
14
+ import { bucketizeLatency } from './telemetry/metricUtils.js';
15
+ import { McpServer, SetLevelRequestSchema, } from './third_party/index.js';
16
+ import { ToolCategory } from './tools/categories.js';
17
+ import { pageIdSchema } from './tools/ToolDefinition.js';
18
+ import { createTools } from './tools/tools.js';
19
+ import { VERSION } from './version.js';
20
+ export async function createMcpServer(serverArgs, options) {
21
+ let clearcutLogger;
22
+ if (serverArgs.usageStatistics) {
23
+ clearcutLogger = new ClearcutLogger({
24
+ logFile: serverArgs.logFile,
25
+ appVersion: VERSION,
26
+ clearcutEndpoint: serverArgs.clearcutEndpoint,
27
+ clearcutForceFlushIntervalMs: serverArgs.clearcutForceFlushIntervalMs,
28
+ clearcutIncludePidHeader: serverArgs.clearcutIncludePidHeader,
29
+ });
30
+ }
31
+ const server = new McpServer({
32
+ name: 'brave_devtools',
33
+ title: 'Brave DevTools MCP server',
34
+ version: VERSION,
35
+ }, { capabilities: { logging: {} } });
36
+ server.server.setRequestHandler(SetLevelRequestSchema, () => {
37
+ return {};
38
+ });
39
+ server.server.oninitialized = () => {
40
+ const clientName = server.server.getClientVersion()?.name;
41
+ if (clientName) {
42
+ clearcutLogger?.setClientName(clientName);
43
+ }
44
+ };
45
+ let context;
46
+ async function getContext() {
47
+ const braveArgs = (serverArgs.braveArg ?? []).map(String);
48
+ const ignoreDefaultBraveArgs = (serverArgs.ignoreDefaultBraveArg ?? []).map(String);
49
+ if (serverArgs.proxyServer) {
50
+ braveArgs.push(`--proxy-server=${serverArgs.proxyServer}`);
51
+ }
52
+ const devtools = serverArgs.experimentalDevtools ?? false;
53
+ const browser = serverArgs.browserUrl || serverArgs.wsEndpoint || serverArgs.autoConnect
54
+ ? await ensureBrowserConnected({
55
+ browserURL: serverArgs.browserUrl,
56
+ wsEndpoint: serverArgs.wsEndpoint,
57
+ wsHeaders: serverArgs.wsHeaders,
58
+ channel: serverArgs.autoConnect
59
+ ? serverArgs.channel
60
+ : undefined,
61
+ userDataDir: serverArgs.userDataDir,
62
+ devtools,
63
+ })
64
+ : await ensureBrowserLaunched({
65
+ headless: serverArgs.headless,
66
+ executablePath: serverArgs.executablePath,
67
+ channel: serverArgs.channel,
68
+ isolated: serverArgs.isolated ?? false,
69
+ userDataDir: serverArgs.userDataDir,
70
+ logFile: options.logFile,
71
+ viewport: serverArgs.viewport,
72
+ braveArgs,
73
+ ignoreDefaultBraveArgs,
74
+ acceptInsecureCerts: serverArgs.acceptInsecureCerts,
75
+ devtools,
76
+ enableExtensions: serverArgs.categoryExtensions,
77
+ viaCli: serverArgs.viaCli,
78
+ });
79
+ if (context?.browser !== browser) {
80
+ context = await McpContext.from(browser, logger, {
81
+ experimentalDevToolsDebugging: devtools,
82
+ experimentalIncludeAllPages: serverArgs.experimentalIncludeAllPages,
83
+ performanceCrux: serverArgs.performanceCrux,
84
+ });
85
+ }
86
+ return context;
87
+ }
88
+ const toolMutex = new Mutex();
89
+ function registerTool(tool) {
90
+ if (tool.annotations.category === ToolCategory.EMULATION &&
91
+ serverArgs.categoryEmulation === false) {
92
+ return;
93
+ }
94
+ if (tool.annotations.category === ToolCategory.PERFORMANCE &&
95
+ serverArgs.categoryPerformance === false) {
96
+ return;
97
+ }
98
+ if (tool.annotations.category === ToolCategory.NETWORK &&
99
+ serverArgs.categoryNetwork === false) {
100
+ return;
101
+ }
102
+ if (tool.annotations.category === ToolCategory.EXTENSIONS &&
103
+ !serverArgs.categoryExtensions) {
104
+ return;
105
+ }
106
+ if (tool.annotations.category === ToolCategory.IN_PAGE &&
107
+ !serverArgs.categoryInPageTools) {
108
+ return;
109
+ }
110
+ if (tool.annotations.conditions?.includes('computerVision') &&
111
+ !serverArgs.experimentalVision) {
112
+ return;
113
+ }
114
+ if (tool.annotations.conditions?.includes('experimentalInteropTools') &&
115
+ !serverArgs.experimentalInteropTools) {
116
+ return;
117
+ }
118
+ if (tool.annotations.conditions?.includes('screencast') &&
119
+ !serverArgs.experimentalScreencast) {
120
+ return;
121
+ }
122
+ const schema = 'pageScoped' in tool &&
123
+ tool.pageScoped &&
124
+ serverArgs.experimentalPageIdRouting &&
125
+ !serverArgs.slim
126
+ ? { ...tool.schema, ...pageIdSchema }
127
+ : tool.schema;
128
+ server.registerTool(tool.name, {
129
+ description: tool.description,
130
+ inputSchema: schema,
131
+ annotations: tool.annotations,
132
+ }, async (params) => {
133
+ const guard = await toolMutex.acquire();
134
+ const startTime = Date.now();
135
+ let success = false;
136
+ try {
137
+ logger(`${tool.name} request: ${JSON.stringify(params, null, ' ')}`);
138
+ const context = await getContext();
139
+ logger(`${tool.name} context: resolved`);
140
+ await context.detectOpenDevToolsWindows();
141
+ const response = serverArgs.slim
142
+ ? new SlimMcpResponse(serverArgs)
143
+ : new McpResponse(serverArgs);
144
+ if ('pageScoped' in tool && tool.pageScoped) {
145
+ const page = serverArgs.experimentalPageIdRouting &&
146
+ params.pageId &&
147
+ !serverArgs.slim
148
+ ? context.getPageById(params.pageId)
149
+ : context.getSelectedMcpPage();
150
+ response.setPage(page);
151
+ await tool.handler({
152
+ params,
153
+ page,
154
+ }, response, context);
155
+ }
156
+ else {
157
+ await tool.handler(
158
+ // @ts-expect-error types do not match.
159
+ {
160
+ params,
161
+ }, response, context);
162
+ }
163
+ const { content, structuredContent } = await response.handle(tool.name, context);
164
+ const result = {
165
+ content,
166
+ };
167
+ success = true;
168
+ if (serverArgs.experimentalStructuredContent) {
169
+ result.structuredContent = structuredContent;
170
+ }
171
+ return result;
172
+ }
173
+ catch (err) {
174
+ logger(`${tool.name} error:`, err, err?.stack);
175
+ let errorText = err && 'message' in err ? err.message : String(err);
176
+ if ('cause' in err && err.cause) {
177
+ errorText += `\nCause: ${err.cause.message}`;
178
+ }
179
+ return {
180
+ content: [
181
+ {
182
+ type: 'text',
183
+ text: errorText,
184
+ },
185
+ ],
186
+ isError: true,
187
+ };
188
+ }
189
+ finally {
190
+ void clearcutLogger?.logToolInvocation({
191
+ toolName: tool.name,
192
+ success,
193
+ latencyMs: bucketizeLatency(Date.now() - startTime),
194
+ });
195
+ guard.dispose();
196
+ }
197
+ });
198
+ }
199
+ const tools = createTools(serverArgs);
200
+ for (const tool of tools) {
201
+ registerTool(tool);
202
+ }
203
+ await loadIssueDescriptions();
204
+ return { server, clearcutLogger };
205
+ }
206
+ export const logDisclaimers = (args) => {
207
+ console.error(`brave-devtools-mcp exposes content of the browser instance to the MCP clients allowing them to inspect,
208
+ debug, and modify any data in the browser or DevTools.
209
+ Avoid sharing sensitive or personal information that you do not want to share with MCP clients.`);
210
+ if (!args.slim && args.performanceCrux) {
211
+ console.error(`Performance tools may send trace URLs to the Google CrUX API to fetch real-user experience data. To disable, run with --no-performance-crux.`);
212
+ }
213
+ if (!args.slim && args.usageStatistics) {
214
+ console.error(`Usage statistics are enabled. To opt-out, run with --no-usage-statistics.`);
215
+ }
216
+ };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import * as fs from 'node:fs';
7
+ import * as path from 'node:path';
8
+ const DESCRIPTIONS_PATH = path.join(import.meta.dirname, 'third_party/issue-descriptions');
9
+ let issueDescriptions = {};
10
+ /**
11
+ * Reads all issue descriptions from the filesystem into memory.
12
+ */
13
+ export async function loadIssueDescriptions() {
14
+ if (Object.keys(issueDescriptions).length > 0) {
15
+ return;
16
+ }
17
+ const files = await fs.promises.readdir(DESCRIPTIONS_PATH);
18
+ const descriptions = {};
19
+ for (const file of files) {
20
+ if (!file.endsWith('.md')) {
21
+ continue;
22
+ }
23
+ const content = await fs.promises.readFile(path.join(DESCRIPTIONS_PATH, file), 'utf-8');
24
+ descriptions[file] = content;
25
+ }
26
+ issueDescriptions = descriptions;
27
+ }
28
+ /**
29
+ * Gets an issue description from the in-memory cache.
30
+ * @param fileName The file name of the issue description.
31
+ * @returns The description of the issue, or null if it doesn't exist.
32
+ */
33
+ export function getIssueDescription(fileName) {
34
+ return issueDescriptions[fileName] ?? null;
35
+ }
36
+ export const ISSUE_UTILS = {
37
+ loadIssueDescriptions,
38
+ getIssueDescription,
39
+ };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import fs from 'node:fs';
7
+ import { debug } from './third_party/index.js';
8
+ const mcpDebugNamespace = 'mcp:log';
9
+ const namespacesToEnable = [
10
+ mcpDebugNamespace,
11
+ ...(process.env['DEBUG'] ? [process.env['DEBUG']] : []),
12
+ ];
13
+ export function saveLogsToFile(fileName) {
14
+ // Enable overrides everything so we need to add them
15
+ debug.enable(namespacesToEnable.join(','));
16
+ const logFile = fs.createWriteStream(fileName, { flags: 'a+' });
17
+ debug.log = function (...chunks) {
18
+ logFile.write(`${chunks.join(' ')}\n`);
19
+ };
20
+ logFile.on('error', function (error) {
21
+ console.error(`Error when opening/writing to log file: ${error.message}`);
22
+ logFile.end();
23
+ process.exit(1);
24
+ });
25
+ return logFile;
26
+ }
27
+ export function flushLogs(logFile, timeoutMs = 2000) {
28
+ return new Promise((resolve, reject) => {
29
+ const timeout = setTimeout(reject, timeoutMs);
30
+ logFile.end(() => {
31
+ clearTimeout(timeout);
32
+ resolve();
33
+ });
34
+ });
35
+ }
36
+ export const logger = debug(mcpDebugNamespace);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google Inc.
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ // polyfills are now bundled with all other dependencies
7
+ import './third_party/index.js';