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.
- package/LICENSE +202 -0
- package/README.md +802 -0
- package/build/src/DevToolsConnectionAdapter.js +69 -0
- package/build/src/DevtoolsUtils.js +294 -0
- package/build/src/McpContext.js +676 -0
- package/build/src/McpPage.js +108 -0
- package/build/src/McpResponse.js +718 -0
- package/build/src/Mutex.js +37 -0
- package/build/src/PageCollector.js +310 -0
- package/build/src/SlimMcpResponse.js +18 -0
- package/build/src/WaitForHelper.js +153 -0
- package/build/src/bin/brave-devtools-cli-options.js +651 -0
- package/build/src/bin/brave-devtools-mcp-cli-options.js +312 -0
- package/build/src/bin/brave-devtools-mcp-main.js +35 -0
- package/build/src/bin/brave-devtools-mcp.js +22 -0
- package/build/src/bin/brave-devtools.js +190 -0
- package/build/src/bin/check-latest-version.js +25 -0
- package/build/src/bin/cliDefinitions.js +615 -0
- package/build/src/browser.js +295 -0
- package/build/src/daemon/client.js +152 -0
- package/build/src/daemon/daemon.js +202 -0
- package/build/src/daemon/types.js +6 -0
- package/build/src/daemon/utils.js +109 -0
- package/build/src/formatters/ConsoleFormatter.js +241 -0
- package/build/src/formatters/IssueFormatter.js +192 -0
- package/build/src/formatters/NetworkFormatter.js +218 -0
- package/build/src/formatters/SnapshotFormatter.js +134 -0
- package/build/src/index.js +216 -0
- package/build/src/issue-descriptions.js +39 -0
- package/build/src/logger.js +36 -0
- package/build/src/polyfill.js +7 -0
- package/build/src/telemetry/ClearcutLogger.js +234 -0
- package/build/src/telemetry/WatchdogClient.js +60 -0
- package/build/src/telemetry/flagUtils.js +45 -0
- package/build/src/telemetry/metricUtils.js +14 -0
- package/build/src/telemetry/persistence.js +53 -0
- package/build/src/telemetry/toolMetricsUtils.js +88 -0
- package/build/src/telemetry/types.js +38 -0
- package/build/src/telemetry/watchdog/ClearcutSender.js +203 -0
- package/build/src/telemetry/watchdog/main.js +127 -0
- package/build/src/third_party/devtools-formatter-worker.js +7 -0
- package/build/src/third_party/index.js +28 -0
- package/build/src/third_party/issue-descriptions/CoepCoopSandboxedIframeCannotNavigateToCoopPage.md +4 -0
- package/build/src/third_party/issue-descriptions/CoepCorpNotSameOrigin.md +8 -0
- package/build/src/third_party/issue-descriptions/CoepCorpNotSameOriginAfterDefaultedToSameOriginByCoep.md +18 -0
- package/build/src/third_party/issue-descriptions/CoepCorpNotSameSite.md +7 -0
- package/build/src/third_party/issue-descriptions/CoepFrameResourceNeedsCoepHeader.md +10 -0
- package/build/src/third_party/issue-descriptions/CompatibilityModeQuirks.md +5 -0
- package/build/src/third_party/issue-descriptions/CookieAttributeValueExceedsMaxSize.md +5 -0
- package/build/src/third_party/issue-descriptions/LowTextContrast.md +5 -0
- package/build/src/third_party/issue-descriptions/SameSiteExcludeContextDowngradeRead.md +8 -0
- package/build/src/third_party/issue-descriptions/SameSiteExcludeContextDowngradeSet.md +8 -0
- package/build/src/third_party/issue-descriptions/SameSiteExcludeNavigationContextDowngrade.md +8 -0
- package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorRead.md +8 -0
- package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorSet.md +8 -0
- package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnRead.md +8 -0
- package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnSet.md +8 -0
- package/build/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeRead.md +9 -0
- package/build/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeSet.md +9 -0
- package/build/src/third_party/issue-descriptions/SameSiteWarnCrossDowngradeRead.md +8 -0
- package/build/src/third_party/issue-descriptions/SameSiteWarnCrossDowngradeSet.md +8 -0
- package/build/src/third_party/issue-descriptions/SameSiteWarnStrictLaxDowngradeStrict.md +8 -0
- package/build/src/third_party/issue-descriptions/arInsecureContext.md +7 -0
- package/build/src/third_party/issue-descriptions/arInvalidInfoHeader.md +5 -0
- package/build/src/third_party/issue-descriptions/arInvalidRegisterOsSourceHeader.md +5 -0
- package/build/src/third_party/issue-descriptions/arInvalidRegisterOsTriggerHeader.md +5 -0
- package/build/src/third_party/issue-descriptions/arInvalidRegisterSourceHeader.md +5 -0
- package/build/src/third_party/issue-descriptions/arInvalidRegisterTriggerHeader.md +5 -0
- package/build/src/third_party/issue-descriptions/arNavigationRegistrationUniqueScopeAlreadySet.md +5 -0
- package/build/src/third_party/issue-descriptions/arNavigationRegistrationWithoutTransientUserActivation.md +6 -0
- package/build/src/third_party/issue-descriptions/arNoRegisterOsSourceHeader.md +5 -0
- package/build/src/third_party/issue-descriptions/arNoRegisterOsTriggerHeader.md +5 -0
- package/build/src/third_party/issue-descriptions/arNoRegisterSourceHeader.md +5 -0
- package/build/src/third_party/issue-descriptions/arNoRegisterTriggerHeader.md +5 -0
- package/build/src/third_party/issue-descriptions/arNoWebOrOsSupport.md +4 -0
- package/build/src/third_party/issue-descriptions/arOsSourceIgnored.md +18 -0
- package/build/src/third_party/issue-descriptions/arOsTriggerIgnored.md +19 -0
- package/build/src/third_party/issue-descriptions/arPermissionPolicyDisabled.md +8 -0
- package/build/src/third_party/issue-descriptions/arSourceAndTriggerHeaders.md +9 -0
- package/build/src/third_party/issue-descriptions/arSourceIgnored.md +13 -0
- package/build/src/third_party/issue-descriptions/arTriggerIgnored.md +12 -0
- package/build/src/third_party/issue-descriptions/arUntrustworthyReportingOrigin.md +10 -0
- package/build/src/third_party/issue-descriptions/arWebAndOsHeaders.md +11 -0
- package/build/src/third_party/issue-descriptions/bounceTrackingMitigations.md +3 -0
- package/build/src/third_party/issue-descriptions/clientHintMetaTagAllowListInvalidOrigin.md +4 -0
- package/build/src/third_party/issue-descriptions/clientHintMetaTagModifiedHTML.md +4 -0
- package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowlistItemType.md +12 -0
- package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidHeader.md +12 -0
- package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidUrlPattern.md +8 -0
- package/build/src/third_party/issue-descriptions/connectionAllowlistItemNotInnerList.md +12 -0
- package/build/src/third_party/issue-descriptions/connectionAllowlistMoreThanOneList.md +7 -0
- package/build/src/third_party/issue-descriptions/connectionAllowlistReportingEndpointNotToken.md +10 -0
- package/build/src/third_party/issue-descriptions/cookieCrossSiteRedirectDowngrade.md +12 -0
- package/build/src/third_party/issue-descriptions/cookieExcludeBlockedWithinRelatedWebsiteSet.md +4 -0
- package/build/src/third_party/issue-descriptions/cookieExcludeDomainNonAscii.md +11 -0
- package/build/src/third_party/issue-descriptions/cookieExcludePortMismatch.md +8 -0
- package/build/src/third_party/issue-descriptions/cookieExcludeSchemeMismatch.md +7 -0
- package/build/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutRead.md +6 -0
- package/build/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutSet.md +6 -0
- package/build/src/third_party/issue-descriptions/cookieWarnDomainNonAscii.md +11 -0
- package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantRead.md +4 -0
- package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantSet.md +4 -0
- package/build/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutRead.md +6 -0
- package/build/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutSet.md +6 -0
- package/build/src/third_party/issue-descriptions/corsAllowCredentialsRequired.md +6 -0
- package/build/src/third_party/issue-descriptions/corsDisabledScheme.md +7 -0
- package/build/src/third_party/issue-descriptions/corsDisallowedByMode.md +7 -0
- package/build/src/third_party/issue-descriptions/corsHeaderDisallowedByPreflightResponse.md +5 -0
- package/build/src/third_party/issue-descriptions/corsInvalidHeaderValues.md +7 -0
- package/build/src/third_party/issue-descriptions/corsLocalNetworkAccessPermissionDenied.md +19 -0
- package/build/src/third_party/issue-descriptions/corsMethodDisallowedByPreflightResponse.md +5 -0
- package/build/src/third_party/issue-descriptions/corsNoCorsRedirectModeNotFollow.md +5 -0
- package/build/src/third_party/issue-descriptions/corsOriginMismatch.md +6 -0
- package/build/src/third_party/issue-descriptions/corsPreflightResponseInvalid.md +5 -0
- package/build/src/third_party/issue-descriptions/corsRedirectContainsCredentials.md +5 -0
- package/build/src/third_party/issue-descriptions/corsWildcardOriginNotAllowed.md +8 -0
- package/build/src/third_party/issue-descriptions/cspEvalViolation.md +9 -0
- package/build/src/third_party/issue-descriptions/cspInlineViolation.md +10 -0
- package/build/src/third_party/issue-descriptions/cspTrustedTypesPolicyViolation.md +5 -0
- package/build/src/third_party/issue-descriptions/cspTrustedTypesSinkViolation.md +8 -0
- package/build/src/third_party/issue-descriptions/cspURLViolation.md +10 -0
- package/build/src/third_party/issue-descriptions/deprecation.md +3 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsHttpNotFound.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsInvalidResponse.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsNoResponse.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestApprovalDeclined.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestCanceled.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestErrorFetchingSignin.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestErrorIdToken.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenHttpNotFound.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidRequest.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidResponse.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenNoResponse.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestInvalidSigninResponse.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestHttpNotFound.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestInvalidResponse.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestNoResponse.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestTooManyRequests.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidAccountsResponse.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidConfigOrWellKnown.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoAccountSharingPermission.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoApiPermission.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoReturningUserFromFetchedAccounts.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotIframe.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotPotentiallyTrustworthy.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSameOrigin.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSignedInWithIdp.md +1 -0
- package/build/src/third_party/issue-descriptions/fetchingPartitionedBlobURL.md +7 -0
- package/build/src/third_party/issue-descriptions/genericFormAriaLabelledByToNonExistingIdError.md +8 -0
- package/build/src/third_party/issue-descriptions/genericFormAutocompleteAttributeEmptyError.md +5 -0
- package/build/src/third_party/issue-descriptions/genericFormDuplicateIdForInputError.md +5 -0
- package/build/src/third_party/issue-descriptions/genericFormEmptyIdAndNameAttributesForInputError.md +5 -0
- package/build/src/third_party/issue-descriptions/genericFormInputAssignedAutocompleteValueToIdOrNameAttributeError.md +5 -0
- package/build/src/third_party/issue-descriptions/genericFormInputHasWrongButWellIntendedAutocompleteValueError.md +5 -0
- package/build/src/third_party/issue-descriptions/genericFormInputWithNoLabelError.md +5 -0
- package/build/src/third_party/issue-descriptions/genericFormLabelForMatchesNonExistingIdError.md +5 -0
- package/build/src/third_party/issue-descriptions/genericFormLabelForNameError.md +5 -0
- package/build/src/third_party/issue-descriptions/genericFormLabelHasNeitherForNorNestedInputError.md +5 -0
- package/build/src/third_party/issue-descriptions/genericNavigationEntryMarkedSkippable.md +7 -0
- package/build/src/third_party/issue-descriptions/genericResponseWasBlockedByORB.md +4 -0
- package/build/src/third_party/issue-descriptions/heavyAd.md +10 -0
- package/build/src/third_party/issue-descriptions/mixedContent.md +5 -0
- package/build/src/third_party/issue-descriptions/navigatingPartitionedBlobURL.md +5 -0
- package/build/src/third_party/issue-descriptions/permissionElementActivationDisabled.md +7 -0
- package/build/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluder.md +9 -0
- package/build/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluderParent.md +9 -0
- package/build/src/third_party/issue-descriptions/permissionElementCspFrameAncestorsMissing.md +5 -0
- package/build/src/third_party/issue-descriptions/permissionElementFencedFrameDisallowed.md +5 -0
- package/build/src/third_party/issue-descriptions/permissionElementFontSizeTooLarge.md +5 -0
- package/build/src/third_party/issue-descriptions/permissionElementFontSizeTooSmall.md +5 -0
- package/build/src/third_party/issue-descriptions/permissionElementGeolocationDeprecated.md +5 -0
- package/build/src/third_party/issue-descriptions/permissionElementInsetBoxShadowUnsupported.md +5 -0
- package/build/src/third_party/issue-descriptions/permissionElementInvalidDisplayStyle.md +5 -0
- package/build/src/third_party/issue-descriptions/permissionElementInvalidSizeValue.md +5 -0
- package/build/src/third_party/issue-descriptions/permissionElementInvalidType.md +5 -0
- package/build/src/third_party/issue-descriptions/permissionElementInvalidTypeActivation.md +5 -0
- package/build/src/third_party/issue-descriptions/permissionElementLowContrast.md +5 -0
- package/build/src/third_party/issue-descriptions/permissionElementNonOpaqueColor.md +5 -0
- package/build/src/third_party/issue-descriptions/permissionElementPaddingBottomUnsupported.md +6 -0
- package/build/src/third_party/issue-descriptions/permissionElementPaddingRightUnsupported.md +6 -0
- package/build/src/third_party/issue-descriptions/permissionElementPermissionsPolicyBlocked.md +5 -0
- package/build/src/third_party/issue-descriptions/permissionElementRegistrationFailed.md +5 -0
- package/build/src/third_party/issue-descriptions/permissionElementRequestInProgress.md +5 -0
- package/build/src/third_party/issue-descriptions/permissionElementSecurityChecksFailed.md +5 -0
- package/build/src/third_party/issue-descriptions/permissionElementTypeNotSupported.md +5 -0
- package/build/src/third_party/issue-descriptions/permissionElementUntrustedEvent.md +7 -0
- package/build/src/third_party/issue-descriptions/placeholderDescriptionForInvisibleIssues.md +3 -0
- package/build/src/third_party/issue-descriptions/propertyRuleInvalidNameIssue.md +3 -0
- package/build/src/third_party/issue-descriptions/propertyRuleIssue.md +7 -0
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedOptGroupChild.md +7 -0
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedSelectChild.md +7 -0
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentAttributesSelectDescendant.md +3 -0
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentLegendChild.md +3 -0
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentOptionChild.md +3 -0
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityNonPhrasingContentOptionChild.md +3 -0
- package/build/src/third_party/issue-descriptions/selectivePermissionsIntervention.md +7 -0
- package/build/src/third_party/issue-descriptions/sharedArrayBuffer.md +7 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorCrossOriginNoCorsRequest.md +1 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorDictionaryLoadFailure.md +3 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorMatchingDictionaryNotUsed.md +3 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorUnexpectedContentDictionaryHeader.md +1 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorCossOriginNoCorsRequest.md +1 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorDisallowedBySettings.md +1 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorExpiredResponse.md +3 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorFeatureDisabled.md +3 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInsufficientResources.md +1 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidMatchField.md +1 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidStructuredHeader.md +1 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidTTLField.md +1 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNavigationRequest.md +3 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNoMatchField.md +1 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonIntegerTTLField.md +1 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonListMatchDestField.md +1 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonSecureContext.md +3 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringIdField.md +1 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringInMatchDestList.md +1 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringMatchField.md +1 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonTokenTypeField.md +1 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorRequestAborted.md +1 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorShuttingDown.md +1 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorTooLongIdField.md +3 -0
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorUnsupportedType.md +3 -0
- package/build/src/third_party/issue-descriptions/sriInvalidSignatureHeader.md +14 -0
- package/build/src/third_party/issue-descriptions/sriInvalidSignatureInputHeader.md +15 -0
- package/build/src/third_party/issue-descriptions/sriMissingSignatureHeader.md +8 -0
- package/build/src/third_party/issue-descriptions/sriMissingSignatureInputHeader.md +7 -0
- package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsIncorrectLength.md +11 -0
- package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsNotByteSequence.md +14 -0
- package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsParameterized.md +15 -0
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentName.md +8 -0
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentType.md +13 -0
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidDerivedComponentParameter.md +4 -0
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidHeaderComponentParameter.md +5 -0
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidParameter.md +11 -0
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderKeyIdLength.md +12 -0
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingLabel.md +6 -0
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingRequiredParameters.md +8 -0
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderValueMissingComponents.md +11 -0
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderValueNotInnerList.md +11 -0
- package/build/src/third_party/issue-descriptions/sriValidationFailedIntegrityMismatch.md +10 -0
- package/build/src/third_party/issue-descriptions/sriValidationFailedInvalidLength.md +5 -0
- package/build/src/third_party/issue-descriptions/sriValidationFailedSignatureExpired.md +6 -0
- package/build/src/third_party/issue-descriptions/sriValidationFailedSignatureMismatch.md +11 -0
- package/build/src/third_party/issue-descriptions/stylesheetLateImport.md +4 -0
- package/build/src/third_party/issue-descriptions/stylesheetRequestFailed.md +3 -0
- package/build/src/third_party/issue-descriptions/summaryElementAccessibilityInteractiveContentSummaryDescendant.md +3 -0
- package/build/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestLength.md +12 -0
- package/build/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestType.md +17 -0
- package/build/src/third_party/issue-descriptions/unencodedDigestMalformedDictionary.md +14 -0
- package/build/src/third_party/issue-descriptions/unencodedDigestUnknownAlgorithm.md +15 -0
- package/build/src/third_party/lighthouse-devtools-mcp-bundle.js +59418 -0
- package/build/src/tools/ToolDefinition.js +72 -0
- package/build/src/tools/categories.js +26 -0
- package/build/src/tools/console.js +85 -0
- package/build/src/tools/emulation.js +55 -0
- package/build/src/tools/extensions.js +96 -0
- package/build/src/tools/inPage.js +105 -0
- package/build/src/tools/input.js +376 -0
- package/build/src/tools/lighthouse.js +123 -0
- package/build/src/tools/memory.js +28 -0
- package/build/src/tools/network.js +120 -0
- package/build/src/tools/pages.js +336 -0
- package/build/src/tools/performance.js +190 -0
- package/build/src/tools/screencast.js +79 -0
- package/build/src/tools/screenshot.js +84 -0
- package/build/src/tools/script.js +125 -0
- package/build/src/tools/slim/tools.js +81 -0
- package/build/src/tools/snapshot.js +56 -0
- package/build/src/tools/tools.js +53 -0
- package/build/src/trace-processing/parse.js +84 -0
- package/build/src/types.js +6 -0
- package/build/src/utils/ExtensionRegistry.js +35 -0
- package/build/src/utils/check-for-updates.js +72 -0
- package/build/src/utils/files.js +19 -0
- package/build/src/utils/keyboard.js +296 -0
- package/build/src/utils/pagination.js +49 -0
- package/build/src/utils/string.js +36 -0
- package/build/src/utils/types.js +6 -0
- package/build/src/version.js +6 -0
- package/package.json +87 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { yargs, hideBin } from '../third_party/index.js';
|
|
7
|
+
export const cliOptions = {
|
|
8
|
+
autoConnect: {
|
|
9
|
+
type: 'boolean',
|
|
10
|
+
description: 'If specified, automatically connects to a Brave instance running locally from the user data directory identified by the channel param (default channel is release). Requires the remote debugging server to be started in the Brave instance via brave://inspect/#remote-debugging.',
|
|
11
|
+
conflicts: ['isolated', 'executablePath', 'categoryExtensions'],
|
|
12
|
+
default: false,
|
|
13
|
+
coerce: (value) => {
|
|
14
|
+
if (!value) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
return value;
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
browserUrl: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
description: 'Connect to a running, debuggable Brave instance (e.g. `http://127.0.0.1:9222`).',
|
|
23
|
+
alias: 'u',
|
|
24
|
+
conflicts: ['wsEndpoint', 'categoryExtensions'],
|
|
25
|
+
coerce: (url) => {
|
|
26
|
+
if (!url) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
new URL(url);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
throw new Error(`Provided browserUrl ${url} is not valid URL.`);
|
|
34
|
+
}
|
|
35
|
+
return url;
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
wsEndpoint: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
description: 'WebSocket endpoint to connect to a running Brave instance (e.g., ws://127.0.0.1:9222/devtools/browser/<id>). Alternative to --browserUrl.',
|
|
41
|
+
alias: 'w',
|
|
42
|
+
conflicts: ['browserUrl', 'categoryExtensions'],
|
|
43
|
+
coerce: (url) => {
|
|
44
|
+
if (!url) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const parsed = new URL(url);
|
|
49
|
+
if (parsed.protocol !== 'ws:' && parsed.protocol !== 'wss:') {
|
|
50
|
+
throw new Error(`Provided wsEndpoint ${url} must use ws:// or wss:// protocol.`);
|
|
51
|
+
}
|
|
52
|
+
return url;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (error.message.includes('ws://')) {
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
throw new Error(`Provided wsEndpoint ${url} is not valid URL.`);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
wsHeaders: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
description: 'Custom headers for WebSocket connection in JSON format (e.g., \'{"Authorization":"Bearer token"}\'). Only works with --wsEndpoint.',
|
|
65
|
+
implies: 'wsEndpoint',
|
|
66
|
+
coerce: (val) => {
|
|
67
|
+
if (!val) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
const parsed = JSON.parse(val);
|
|
72
|
+
if (typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
73
|
+
throw new Error('Headers must be a JSON object');
|
|
74
|
+
}
|
|
75
|
+
return parsed;
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
throw new Error(`Invalid JSON for wsHeaders: ${error.message}`);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
headless: {
|
|
83
|
+
type: 'boolean',
|
|
84
|
+
description: 'Whether to run in headless (no UI) mode.',
|
|
85
|
+
default: false,
|
|
86
|
+
},
|
|
87
|
+
executablePath: {
|
|
88
|
+
type: 'string',
|
|
89
|
+
description: 'Path to custom Brave executable. Can also be set via BRAVE_PATH environment variable.',
|
|
90
|
+
conflicts: ['browserUrl', 'wsEndpoint'],
|
|
91
|
+
alias: 'e',
|
|
92
|
+
},
|
|
93
|
+
isolated: {
|
|
94
|
+
type: 'boolean',
|
|
95
|
+
description: 'If specified, creates a temporary user-data-dir that is automatically cleaned up after the browser is closed. Defaults to false.',
|
|
96
|
+
},
|
|
97
|
+
userDataDir: {
|
|
98
|
+
type: 'string',
|
|
99
|
+
description: 'Path to the user data directory for Brave. Default is $HOME/.cache/brave-devtools-mcp/brave-profile$CHANNEL_SUFFIX_IF_NON_RELEASE',
|
|
100
|
+
conflicts: ['browserUrl', 'wsEndpoint', 'isolated'],
|
|
101
|
+
},
|
|
102
|
+
channel: {
|
|
103
|
+
type: 'string',
|
|
104
|
+
description: 'Specify a different Brave channel that should be used. The default is the release channel.',
|
|
105
|
+
choices: ['release', 'beta', 'nightly', 'dev'],
|
|
106
|
+
conflicts: ['browserUrl', 'wsEndpoint', 'executablePath'],
|
|
107
|
+
},
|
|
108
|
+
logFile: {
|
|
109
|
+
type: 'string',
|
|
110
|
+
describe: 'Path to a file to write debug logs to. Set the env variable `DEBUG` to `*` to enable verbose logs. Useful for submitting bug reports.',
|
|
111
|
+
},
|
|
112
|
+
viewport: {
|
|
113
|
+
type: 'string',
|
|
114
|
+
describe: 'Initial viewport size for the Brave instances started by the server. For example, `1280x720`. In headless mode, max size is 3840x2160px.',
|
|
115
|
+
coerce: (arg) => {
|
|
116
|
+
if (arg === undefined) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const [width, height] = arg.split('x').map(Number);
|
|
120
|
+
if (!width || !height || Number.isNaN(width) || Number.isNaN(height)) {
|
|
121
|
+
throw new Error('Invalid viewport. Expected format is `1280x720`.');
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
width,
|
|
125
|
+
height,
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
proxyServer: {
|
|
130
|
+
type: 'string',
|
|
131
|
+
description: `Proxy server configuration for Brave passed as --proxy-server when launching the browser. See https://www.chromium.org/developers/design-documents/network-settings/ for details.`,
|
|
132
|
+
},
|
|
133
|
+
acceptInsecureCerts: {
|
|
134
|
+
type: 'boolean',
|
|
135
|
+
description: `If enabled, ignores errors relative to self-signed and expired certificates. Use with caution.`,
|
|
136
|
+
},
|
|
137
|
+
experimentalPageIdRouting: {
|
|
138
|
+
type: 'boolean',
|
|
139
|
+
describe: 'Whether to expose pageId on page-scoped tools and route requests by page ID.',
|
|
140
|
+
hidden: true,
|
|
141
|
+
},
|
|
142
|
+
experimentalDevtools: {
|
|
143
|
+
type: 'boolean',
|
|
144
|
+
describe: 'Whether to enable automation over DevTools targets',
|
|
145
|
+
hidden: true,
|
|
146
|
+
},
|
|
147
|
+
experimentalVision: {
|
|
148
|
+
type: 'boolean',
|
|
149
|
+
describe: 'Whether to enable coordinate-based tools such as click_at(x,y). Usually requires a computer-use model able to produce accurate coordinates by looking at screenshots.',
|
|
150
|
+
hidden: false,
|
|
151
|
+
},
|
|
152
|
+
experimentalStructuredContent: {
|
|
153
|
+
type: 'boolean',
|
|
154
|
+
describe: 'Whether to output structured formatted content.',
|
|
155
|
+
hidden: true,
|
|
156
|
+
},
|
|
157
|
+
experimentalIncludeAllPages: {
|
|
158
|
+
type: 'boolean',
|
|
159
|
+
describe: 'Whether to include all kinds of pages such as webviews or background pages as pages.',
|
|
160
|
+
hidden: true,
|
|
161
|
+
},
|
|
162
|
+
experimentalInteropTools: {
|
|
163
|
+
type: 'boolean',
|
|
164
|
+
describe: 'Whether to enable interoperability tools',
|
|
165
|
+
hidden: true,
|
|
166
|
+
},
|
|
167
|
+
experimentalScreencast: {
|
|
168
|
+
type: 'boolean',
|
|
169
|
+
describe: 'Exposes experimental screencast tools (requires ffmpeg). Install ffmpeg https://www.ffmpeg.org/download.html and ensure it is available in the MCP server PATH.',
|
|
170
|
+
},
|
|
171
|
+
braveArg: {
|
|
172
|
+
type: 'array',
|
|
173
|
+
describe: 'Additional arguments for Brave. Only applies when Brave is launched by brave-devtools-mcp.',
|
|
174
|
+
},
|
|
175
|
+
ignoreDefaultBraveArg: {
|
|
176
|
+
type: 'array',
|
|
177
|
+
describe: 'Explicitly disable default arguments for Brave. Only applies when Brave is launched by brave-devtools-mcp.',
|
|
178
|
+
},
|
|
179
|
+
categoryEmulation: {
|
|
180
|
+
type: 'boolean',
|
|
181
|
+
default: true,
|
|
182
|
+
describe: 'Set to false to exclude tools related to emulation.',
|
|
183
|
+
},
|
|
184
|
+
categoryPerformance: {
|
|
185
|
+
type: 'boolean',
|
|
186
|
+
default: true,
|
|
187
|
+
describe: 'Set to false to exclude tools related to performance.',
|
|
188
|
+
},
|
|
189
|
+
categoryNetwork: {
|
|
190
|
+
type: 'boolean',
|
|
191
|
+
default: true,
|
|
192
|
+
describe: 'Set to false to exclude tools related to network.',
|
|
193
|
+
},
|
|
194
|
+
categoryExtensions: {
|
|
195
|
+
type: 'boolean',
|
|
196
|
+
hidden: true,
|
|
197
|
+
conflicts: ['browserUrl', 'autoConnect', 'wsEndpoint'],
|
|
198
|
+
describe: 'Set to true to include tools related to extensions. Note: This feature is only supported with a pipe connection. autoConnect is not supported.',
|
|
199
|
+
},
|
|
200
|
+
categoryInPageTools: {
|
|
201
|
+
type: 'boolean',
|
|
202
|
+
hidden: true,
|
|
203
|
+
describe: 'Set to true to enable tools exposed by the inspected page itself',
|
|
204
|
+
},
|
|
205
|
+
performanceCrux: {
|
|
206
|
+
type: 'boolean',
|
|
207
|
+
default: true,
|
|
208
|
+
describe: 'Set to false to disable sending URLs from performance traces to CrUX API to get field performance data.',
|
|
209
|
+
},
|
|
210
|
+
usageStatistics: {
|
|
211
|
+
type: 'boolean',
|
|
212
|
+
default: false,
|
|
213
|
+
describe: 'Usage statistics collection (disabled by default in this fork).',
|
|
214
|
+
},
|
|
215
|
+
clearcutEndpoint: {
|
|
216
|
+
type: 'string',
|
|
217
|
+
hidden: true,
|
|
218
|
+
describe: 'Endpoint for Clearcut telemetry.',
|
|
219
|
+
},
|
|
220
|
+
clearcutForceFlushIntervalMs: {
|
|
221
|
+
type: 'number',
|
|
222
|
+
hidden: true,
|
|
223
|
+
describe: 'Force flush interval in milliseconds (for testing).',
|
|
224
|
+
},
|
|
225
|
+
clearcutIncludePidHeader: {
|
|
226
|
+
type: 'boolean',
|
|
227
|
+
hidden: true,
|
|
228
|
+
describe: 'Include watchdog PID in Clearcut request headers (for testing).',
|
|
229
|
+
},
|
|
230
|
+
slim: {
|
|
231
|
+
type: 'boolean',
|
|
232
|
+
describe: 'Exposes a "slim" set of 3 tools covering navigation, script execution and screenshots only. Useful for basic browser tasks.',
|
|
233
|
+
},
|
|
234
|
+
viaCli: {
|
|
235
|
+
type: 'boolean',
|
|
236
|
+
describe: 'Set by Brave DevTools CLI if the MCP server is started via the CLI client (this arg exists for usage stats)',
|
|
237
|
+
hidden: true,
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
export function parseArguments(version, argv = process.argv) {
|
|
241
|
+
const yargsInstance = yargs(hideBin(argv))
|
|
242
|
+
.scriptName('npx brave-devtools-mcp@latest')
|
|
243
|
+
.options(cliOptions)
|
|
244
|
+
.check(args => {
|
|
245
|
+
if (!args.channel &&
|
|
246
|
+
!args.browserUrl &&
|
|
247
|
+
!args.wsEndpoint &&
|
|
248
|
+
!args.executablePath) {
|
|
249
|
+
args.channel = 'release';
|
|
250
|
+
}
|
|
251
|
+
return true;
|
|
252
|
+
})
|
|
253
|
+
.example([
|
|
254
|
+
[
|
|
255
|
+
'$0 --browserUrl http://127.0.0.1:9222',
|
|
256
|
+
'Connect to an existing Brave instance via HTTP',
|
|
257
|
+
],
|
|
258
|
+
[
|
|
259
|
+
'$0 --wsEndpoint ws://127.0.0.1:9222/devtools/browser/abc123',
|
|
260
|
+
'Connect to an existing Brave instance via WebSocket',
|
|
261
|
+
],
|
|
262
|
+
[
|
|
263
|
+
`$0 --wsEndpoint ws://127.0.0.1:9222/devtools/browser/abc123 --wsHeaders '{"Authorization":"Bearer token"}'`,
|
|
264
|
+
'Connect via WebSocket with custom headers',
|
|
265
|
+
],
|
|
266
|
+
['$0 --channel beta', 'Use Brave Beta installed on this system'],
|
|
267
|
+
['$0 --channel nightly', 'Use Brave Nightly installed on this system'],
|
|
268
|
+
['$0 --channel dev', 'Use Brave Dev installed on this system'],
|
|
269
|
+
['$0 --channel release', 'Use release Brave installed on this system'],
|
|
270
|
+
['$0 --logFile /tmp/log.txt', 'Save logs to a file'],
|
|
271
|
+
['$0 --help', 'Print CLI options'],
|
|
272
|
+
[
|
|
273
|
+
'$0 --viewport 1280x720',
|
|
274
|
+
'Launch Brave with the initial viewport size of 1280x720px',
|
|
275
|
+
],
|
|
276
|
+
[
|
|
277
|
+
`$0 --brave-arg='--no-sandbox' --brave-arg='--disable-setuid-sandbox'`,
|
|
278
|
+
'Launch Brave without sandboxes. Use with caution.',
|
|
279
|
+
],
|
|
280
|
+
[
|
|
281
|
+
`$0 --ignore-default-brave-arg='--disable-extensions'`,
|
|
282
|
+
'Disable the default arguments provided by Puppeteer. Use with caution.',
|
|
283
|
+
],
|
|
284
|
+
['$0 --no-category-emulation', 'Disable tools in the emulation category'],
|
|
285
|
+
[
|
|
286
|
+
'$0 --no-category-performance',
|
|
287
|
+
'Disable tools in the performance category',
|
|
288
|
+
],
|
|
289
|
+
['$0 --no-category-network', 'Disable tools in the network category'],
|
|
290
|
+
[
|
|
291
|
+
'$0 --user-data-dir=/tmp/user-data-dir',
|
|
292
|
+
'Use a custom user data directory',
|
|
293
|
+
],
|
|
294
|
+
[
|
|
295
|
+
'$0 --auto-connect',
|
|
296
|
+
'Connect to a release Brave instance running instead of launching a new instance',
|
|
297
|
+
],
|
|
298
|
+
[
|
|
299
|
+
'$0 --auto-connect --channel=nightly',
|
|
300
|
+
'Connect to a nightly Brave instance running instead of launching a new instance',
|
|
301
|
+
],
|
|
302
|
+
[
|
|
303
|
+
'$0 --slim',
|
|
304
|
+
'Only 3 tools: navigation, JavaScript execution and screenshot',
|
|
305
|
+
],
|
|
306
|
+
]);
|
|
307
|
+
return yargsInstance
|
|
308
|
+
.wrap(Math.min(120, yargsInstance.terminalWidth()))
|
|
309
|
+
.help()
|
|
310
|
+
.version(version)
|
|
311
|
+
.parseSync();
|
|
312
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import '../polyfill.js';
|
|
7
|
+
import process from 'node:process';
|
|
8
|
+
import { createMcpServer, logDisclaimers } from '../index.js';
|
|
9
|
+
import { logger, saveLogsToFile } from '../logger.js';
|
|
10
|
+
import { computeFlagUsage } from '../telemetry/flagUtils.js';
|
|
11
|
+
import { StdioServerTransport } from '../third_party/index.js';
|
|
12
|
+
import { VERSION } from '../version.js';
|
|
13
|
+
import { cliOptions, parseArguments } from './brave-devtools-mcp-cli-options.js';
|
|
14
|
+
export const args = parseArguments(VERSION);
|
|
15
|
+
const logFile = args.logFile ? saveLogsToFile(args.logFile) : undefined;
|
|
16
|
+
if (process.env['CI'] ||
|
|
17
|
+
process.env['BRAVE_DEVTOOLS_MCP_NO_USAGE_STATISTICS']) {
|
|
18
|
+
console.error("turning off usage statistics. process.env['CI'] || process.env['BRAVE_DEVTOOLS_MCP_NO_USAGE_STATISTICS'] is set.");
|
|
19
|
+
args.usageStatistics = false;
|
|
20
|
+
}
|
|
21
|
+
if (process.env['BRAVE_DEVTOOLS_MCP_CRASH_ON_UNCAUGHT'] !== 'true') {
|
|
22
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
23
|
+
logger('Unhandled promise rejection', promise, reason);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
logger(`Starting Brave DevTools MCP Server v${VERSION}`);
|
|
27
|
+
const { server, clearcutLogger } = await createMcpServer(args, {
|
|
28
|
+
logFile,
|
|
29
|
+
});
|
|
30
|
+
const transport = new StdioServerTransport();
|
|
31
|
+
await server.connect(transport);
|
|
32
|
+
logger('Brave DevTools MCP Server connected');
|
|
33
|
+
logDisclaimers(args);
|
|
34
|
+
void clearcutLogger?.logDailyActiveIfNeeded();
|
|
35
|
+
void clearcutLogger?.logServerStart(computeFlagUsage(args, cliOptions));
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2025 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*/
|
|
7
|
+
process.title = 'brave-devtools-mcp';
|
|
8
|
+
import { version } from 'node:process';
|
|
9
|
+
const [major, minor] = version.substring(1).split('.').map(Number);
|
|
10
|
+
if (major === 20 && minor < 19) {
|
|
11
|
+
console.error(`ERROR: \`brave-devtools-mcp\` does not support Node ${process.version}. Please upgrade to Node 20.19.0 LTS or a newer LTS.`);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
if (major === 22 && minor < 12) {
|
|
15
|
+
console.error(`ERROR: \`brave-devtools-mcp\` does not support Node ${process.version}. Please upgrade to Node 22.12.0 LTS or a newer LTS.`);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
if (major < 20) {
|
|
19
|
+
console.error(`ERROR: \`brave-devtools-mcp\` does not support Node ${process.version}. Please upgrade to Node 20.19.0 LTS or a newer LTS.`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
await import('./brave-devtools-mcp-main.js');
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2026 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*/
|
|
7
|
+
process.title = 'brave-devtools';
|
|
8
|
+
import process from 'node:process';
|
|
9
|
+
import { startDaemon, stopDaemon, sendCommand, handleResponse, } from '../daemon/client.js';
|
|
10
|
+
import { isDaemonRunning, serializeArgs } from '../daemon/utils.js';
|
|
11
|
+
import { logDisclaimers } from '../index.js';
|
|
12
|
+
import { hideBin, yargs } from '../third_party/index.js';
|
|
13
|
+
import { checkForUpdates } from '../utils/check-for-updates.js';
|
|
14
|
+
import { VERSION } from '../version.js';
|
|
15
|
+
import { commands } from './brave-devtools-cli-options.js';
|
|
16
|
+
import { cliOptions, parseArguments } from './brave-devtools-mcp-cli-options.js';
|
|
17
|
+
await checkForUpdates('Run `npm install -g brave-devtools-mcp@latest` and `brave-devtools start` to update and restart the daemon.');
|
|
18
|
+
async function start(args) {
|
|
19
|
+
const combinedArgs = [...args, ...defaultArgs];
|
|
20
|
+
await startDaemon(combinedArgs);
|
|
21
|
+
logDisclaimers(parseArguments(VERSION, combinedArgs));
|
|
22
|
+
}
|
|
23
|
+
const defaultArgs = ['--viaCli', '--experimentalStructuredContent'];
|
|
24
|
+
const startCliOptions = {
|
|
25
|
+
...cliOptions,
|
|
26
|
+
};
|
|
27
|
+
// Not supported in CLI on purpose.
|
|
28
|
+
delete startCliOptions.autoConnect;
|
|
29
|
+
// Missing CLI serialization.
|
|
30
|
+
delete startCliOptions.viewport;
|
|
31
|
+
// CLI is generated based on the default tool definitions. To enable conditional
|
|
32
|
+
// tools, they need to be enabled during CLI generation.
|
|
33
|
+
delete startCliOptions.experimentalPageIdRouting;
|
|
34
|
+
delete startCliOptions.experimentalVision;
|
|
35
|
+
delete startCliOptions.experimentalInteropTools;
|
|
36
|
+
delete startCliOptions.experimentalScreencast;
|
|
37
|
+
delete startCliOptions.categoryEmulation;
|
|
38
|
+
delete startCliOptions.categoryPerformance;
|
|
39
|
+
delete startCliOptions.categoryNetwork;
|
|
40
|
+
delete startCliOptions.categoryExtensions;
|
|
41
|
+
// Always on in CLI.
|
|
42
|
+
delete startCliOptions.experimentalStructuredContent;
|
|
43
|
+
// Change the defaults.
|
|
44
|
+
if (!('default' in cliOptions.headless)) {
|
|
45
|
+
throw new Error('headless cli option unexpectedly does not have a default');
|
|
46
|
+
}
|
|
47
|
+
if ('default' in cliOptions.isolated) {
|
|
48
|
+
throw new Error('isolated cli option unexpectedly has a default');
|
|
49
|
+
}
|
|
50
|
+
startCliOptions.headless.default = true;
|
|
51
|
+
startCliOptions.isolated.description =
|
|
52
|
+
'If specified, creates a temporary user-data-dir that is automatically cleaned up after the browser is closed. Defaults to true unless userDataDir is provided.';
|
|
53
|
+
const y = yargs(hideBin(process.argv))
|
|
54
|
+
.scriptName('brave-devtools')
|
|
55
|
+
.showHelpOnFail(true)
|
|
56
|
+
.usage('brave-devtools <command> [...args] --flags')
|
|
57
|
+
.usage(`Run 'brave-devtools <command> --help' for help on the specific command.`)
|
|
58
|
+
.demandCommand()
|
|
59
|
+
.version(VERSION)
|
|
60
|
+
.strict()
|
|
61
|
+
.help(true)
|
|
62
|
+
.wrap(120);
|
|
63
|
+
y.command('start', 'Start or restart brave-devtools-mcp', y => y
|
|
64
|
+
.options(startCliOptions)
|
|
65
|
+
.example('$0 start --browserUrl http://localhost:9222', 'Start the server connecting to an existing browser')
|
|
66
|
+
.strict(), async (argv) => {
|
|
67
|
+
if (isDaemonRunning()) {
|
|
68
|
+
await stopDaemon();
|
|
69
|
+
}
|
|
70
|
+
// Defaults but we do not want to affect the yargs conflict resolution.
|
|
71
|
+
if (argv.isolated === undefined && argv.userDataDir === undefined) {
|
|
72
|
+
argv.isolated = true;
|
|
73
|
+
}
|
|
74
|
+
if (argv.headless === undefined) {
|
|
75
|
+
argv.headless = true;
|
|
76
|
+
}
|
|
77
|
+
const args = serializeArgs(cliOptions, argv);
|
|
78
|
+
await start(args);
|
|
79
|
+
process.exit(0);
|
|
80
|
+
}).strict(); // Re-enable strict validation for other commands; this is applied to the yargs instance itself
|
|
81
|
+
y.command('status', 'Checks if brave-devtools-mcp is running', async () => {
|
|
82
|
+
if (isDaemonRunning()) {
|
|
83
|
+
console.log('brave-devtools-mcp daemon is running.');
|
|
84
|
+
const response = await sendCommand({
|
|
85
|
+
method: 'status',
|
|
86
|
+
});
|
|
87
|
+
if (response.success) {
|
|
88
|
+
const data = JSON.parse(response.result);
|
|
89
|
+
console.log(`pid=${data.pid} socket=${data.socketPath} start-date=${data.startDate} version=${data.version}`);
|
|
90
|
+
console.log(`args=${JSON.stringify(data.args)}`);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
console.error('Error:', response.error);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
console.log('brave-devtools-mcp daemon is not running.');
|
|
99
|
+
}
|
|
100
|
+
process.exit(0);
|
|
101
|
+
});
|
|
102
|
+
y.command('stop', 'Stop brave-devtools-mcp if any', async () => {
|
|
103
|
+
if (!isDaemonRunning()) {
|
|
104
|
+
process.exit(0);
|
|
105
|
+
}
|
|
106
|
+
await stopDaemon();
|
|
107
|
+
process.exit(0);
|
|
108
|
+
});
|
|
109
|
+
for (const [commandName, commandDef] of Object.entries(commands)) {
|
|
110
|
+
const args = commandDef.args;
|
|
111
|
+
const requiredArgNames = Object.keys(args).filter(name => args[name].required);
|
|
112
|
+
const optionalArgNames = Object.keys(args).filter(name => !args[name].required);
|
|
113
|
+
let commandStr = commandName;
|
|
114
|
+
for (const arg of requiredArgNames) {
|
|
115
|
+
commandStr += ` <${arg}>`;
|
|
116
|
+
}
|
|
117
|
+
for (const arg of optionalArgNames) {
|
|
118
|
+
commandStr += ` [--${arg}]`;
|
|
119
|
+
}
|
|
120
|
+
y.command(commandStr, commandDef.description, y => {
|
|
121
|
+
y.option('output-format', {
|
|
122
|
+
choices: ['md', 'json'],
|
|
123
|
+
default: 'md',
|
|
124
|
+
});
|
|
125
|
+
for (const [argName, opt] of Object.entries(args)) {
|
|
126
|
+
const type = opt.type === 'integer' || opt.type === 'number'
|
|
127
|
+
? 'number'
|
|
128
|
+
: opt.type === 'boolean'
|
|
129
|
+
? 'boolean'
|
|
130
|
+
: opt.type === 'array'
|
|
131
|
+
? 'array'
|
|
132
|
+
: 'string';
|
|
133
|
+
if (opt.required) {
|
|
134
|
+
const options = {
|
|
135
|
+
describe: opt.description,
|
|
136
|
+
type: type,
|
|
137
|
+
};
|
|
138
|
+
if (opt.default !== undefined) {
|
|
139
|
+
options.default = opt.default;
|
|
140
|
+
}
|
|
141
|
+
if (opt.enum) {
|
|
142
|
+
options.choices = opt.enum;
|
|
143
|
+
}
|
|
144
|
+
y.positional(argName, options);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
const options = {
|
|
148
|
+
describe: opt.description,
|
|
149
|
+
type: type,
|
|
150
|
+
};
|
|
151
|
+
if (opt.default !== undefined) {
|
|
152
|
+
options.default = opt.default;
|
|
153
|
+
}
|
|
154
|
+
if (opt.enum) {
|
|
155
|
+
options.choices = opt.enum;
|
|
156
|
+
}
|
|
157
|
+
y.option(argName, options);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}, async (argv) => {
|
|
161
|
+
try {
|
|
162
|
+
if (!isDaemonRunning()) {
|
|
163
|
+
await start([]);
|
|
164
|
+
}
|
|
165
|
+
const commandArgs = {};
|
|
166
|
+
for (const argName of Object.keys(args)) {
|
|
167
|
+
if (argName in argv) {
|
|
168
|
+
commandArgs[argName] = argv[argName];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const response = await sendCommand({
|
|
172
|
+
method: 'invoke_tool',
|
|
173
|
+
tool: commandName,
|
|
174
|
+
args: commandArgs,
|
|
175
|
+
});
|
|
176
|
+
if (response.success) {
|
|
177
|
+
console.log(await handleResponse(JSON.parse(response.result), argv['output-format']));
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
console.error('Error:', response.error);
|
|
181
|
+
process.exit(1);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
console.error('Failed to execute command:', error);
|
|
186
|
+
process.exit(1);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
await y.parse();
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import fs from 'node:fs/promises';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import process from 'node:process';
|
|
9
|
+
const cachePath = process.argv[2];
|
|
10
|
+
if (cachePath) {
|
|
11
|
+
try {
|
|
12
|
+
const response = await fetch('https://registry.npmjs.org/brave-mcp/latest');
|
|
13
|
+
const data = response.ok ? await response.json() : null;
|
|
14
|
+
if (data &&
|
|
15
|
+
typeof data === 'object' &&
|
|
16
|
+
'version' in data &&
|
|
17
|
+
typeof data.version === 'string') {
|
|
18
|
+
await fs.mkdir(path.dirname(cachePath), { recursive: true });
|
|
19
|
+
await fs.writeFile(cachePath, JSON.stringify({ version: data.version }));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// Ignore errors.
|
|
24
|
+
}
|
|
25
|
+
}
|