@vibebrowser/chrome-devtools-mcp 0.26.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 +873 -0
- package/build/src/DevToolsConnectionAdapter.js +70 -0
- package/build/src/DevtoolsUtils.js +295 -0
- package/build/src/HeapSnapshotManager.js +110 -0
- package/build/src/McpContext.js +605 -0
- package/build/src/McpPage.js +315 -0
- package/build/src/McpResponse.js +858 -0
- package/build/src/Mutex.js +38 -0
- package/build/src/PageCollector.js +297 -0
- package/build/src/SlimMcpResponse.js +19 -0
- package/build/src/TextSnapshot.js +236 -0
- package/build/src/ToolHandler.js +217 -0
- package/build/src/WaitForHelper.js +190 -0
- package/build/src/bin/check-latest-version.js +50 -0
- package/build/src/bin/chrome-devtools-cli-options.js +840 -0
- package/build/src/bin/chrome-devtools-mcp-cli-options.js +350 -0
- package/build/src/bin/chrome-devtools-mcp-main.js +94 -0
- package/build/src/bin/chrome-devtools-mcp.js +31 -0
- package/build/src/bin/chrome-devtools.js +189 -0
- package/build/src/bin/install-service.js +246 -0
- package/build/src/bin/service/chrome-devtools-mcp.service.template +17 -0
- package/build/src/bin/service/com.vibebrowser.chrome-devtools-mcp.plist.template +37 -0
- package/build/src/browser.js +204 -0
- package/build/src/daemon/client.js +154 -0
- package/build/src/daemon/daemon.js +204 -0
- package/build/src/daemon/types.js +7 -0
- package/build/src/daemon/utils.js +115 -0
- package/build/src/formatters/ConsoleFormatter.js +288 -0
- package/build/src/formatters/HeapSnapshotFormatter.js +54 -0
- package/build/src/formatters/IssueFormatter.js +193 -0
- package/build/src/formatters/NetworkFormatter.js +236 -0
- package/build/src/formatters/SnapshotFormatter.js +135 -0
- package/build/src/index.js +140 -0
- package/build/src/issue-descriptions.js +40 -0
- package/build/src/logger.js +37 -0
- package/build/src/polyfill.js +8 -0
- package/build/src/telemetry/ClearcutLogger.js +169 -0
- package/build/src/telemetry/WatchdogClient.js +61 -0
- package/build/src/telemetry/errors.js +18 -0
- package/build/src/telemetry/flagUtils.js +89 -0
- package/build/src/telemetry/metricsRegistry.js +89 -0
- package/build/src/telemetry/persistence.js +72 -0
- package/build/src/telemetry/transformation.js +134 -0
- package/build/src/telemetry/types.js +31 -0
- package/build/src/telemetry/watchdog/ClearcutSender.js +205 -0
- package/build/src/telemetry/watchdog/main.js +128 -0
- package/build/src/third_party/devtools-formatter-worker.js +8 -0
- package/build/src/third_party/devtools-heap-snapshot-worker.js +8 -0
- package/build/src/third_party/index.js +32 -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/genericFormModelContextMissingToolDescription.md +5 -0
- package/build/src/third_party/issue-descriptions/genericFormModelContextMissingToolName.md +5 -0
- package/build/src/third_party/issue-descriptions/genericFormModelContextParameterMissingName.md +5 -0
- package/build/src/third_party/issue-descriptions/genericFormModelContextParameterMissingTitleAndDescription.md +5 -0
- package/build/src/third_party/issue-descriptions/genericFormModelContextRequiredParameterMissingName.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 +61598 -0
- package/build/src/tools/ToolDefinition.js +73 -0
- package/build/src/tools/categories.js +36 -0
- package/build/src/tools/console.js +91 -0
- package/build/src/tools/emulation.js +57 -0
- package/build/src/tools/extensions.js +96 -0
- package/build/src/tools/input.js +461 -0
- package/build/src/tools/lighthouse.js +131 -0
- package/build/src/tools/memory.js +106 -0
- package/build/src/tools/network.js +125 -0
- package/build/src/tools/pages.js +411 -0
- package/build/src/tools/performance.js +196 -0
- package/build/src/tools/screencast.js +95 -0
- package/build/src/tools/screenshot.js +87 -0
- package/build/src/tools/script.js +151 -0
- package/build/src/tools/slim/tools.js +85 -0
- package/build/src/tools/snapshot.js +60 -0
- package/build/src/tools/thirdPartyDeveloper.js +75 -0
- package/build/src/tools/tools.js +56 -0
- package/build/src/tools/webmcp.js +64 -0
- package/build/src/trace-processing/parse.js +85 -0
- package/build/src/types.js +7 -0
- package/build/src/utils/check-for-updates.js +74 -0
- package/build/src/utils/files.js +18 -0
- package/build/src/utils/id.js +16 -0
- package/build/src/utils/keyboard.js +297 -0
- package/build/src/utils/pagination.js +50 -0
- package/build/src/utils/string.js +37 -0
- package/build/src/utils/types.js +7 -0
- package/build/src/version.js +10 -0
- package/package.json +93 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import zlib from 'node:zlib';
|
|
7
|
+
import { logger } from '../logger.js';
|
|
8
|
+
import { zod, DevTools } from '../third_party/index.js';
|
|
9
|
+
import { parseRawTraceBuffer, traceResultIsSuccess, } from '../trace-processing/parse.js';
|
|
10
|
+
import { ToolCategory } from './categories.js';
|
|
11
|
+
import { definePageTool } from './ToolDefinition.js';
|
|
12
|
+
const filePathSchema = zod
|
|
13
|
+
.string()
|
|
14
|
+
.optional()
|
|
15
|
+
.describe('The absolute file path, or a file path relative to the current working directory, to save the raw trace data. For example, trace.json.gz (compressed) or trace.json (uncompressed).');
|
|
16
|
+
export const startTrace = definePageTool({
|
|
17
|
+
name: 'performance_start_trace',
|
|
18
|
+
description: `Start a performance trace on the selected webpage. Use to find frontend performance issues, Core Web Vitals (LCP, INP, CLS), and improve page load speed.`,
|
|
19
|
+
annotations: {
|
|
20
|
+
category: ToolCategory.PERFORMANCE,
|
|
21
|
+
readOnlyHint: false,
|
|
22
|
+
},
|
|
23
|
+
schema: {
|
|
24
|
+
reload: zod
|
|
25
|
+
.boolean()
|
|
26
|
+
.default(true)
|
|
27
|
+
.describe('Determines if, once tracing has started, the current selected page should be automatically reloaded. Navigate the page to the right URL using the navigate_page tool BEFORE starting the trace if reload or autoStop is set to true.'),
|
|
28
|
+
autoStop: zod
|
|
29
|
+
.boolean()
|
|
30
|
+
.default(true)
|
|
31
|
+
.describe('Determines if the trace recording should be automatically stopped.'),
|
|
32
|
+
filePath: filePathSchema,
|
|
33
|
+
},
|
|
34
|
+
blockedByDialog: true,
|
|
35
|
+
handler: async (request, response, context) => {
|
|
36
|
+
context.validatePath(request.params.filePath);
|
|
37
|
+
if (context.isRunningPerformanceTrace()) {
|
|
38
|
+
response.appendResponseLine('Error: a performance trace is already running. Use performance_stop_trace to stop it. Only one trace can be running at any given time.');
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
context.setIsRunningPerformanceTrace(true);
|
|
42
|
+
const page = request.page;
|
|
43
|
+
const pageUrlForTracing = page.pptrPage.url();
|
|
44
|
+
if (request.params.reload) {
|
|
45
|
+
// Before starting the recording, navigate to about:blank to clear out any state.
|
|
46
|
+
await page.pptrPage.goto('about:blank', {
|
|
47
|
+
waitUntil: ['networkidle0'],
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
// Keep in sync with the categories arrays in:
|
|
51
|
+
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/devtools-frontend/src/front_end/panels/timeline/TimelineController.ts
|
|
52
|
+
// https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/gather/gatherers/trace.js
|
|
53
|
+
const categories = [
|
|
54
|
+
'-*',
|
|
55
|
+
'blink.console',
|
|
56
|
+
'blink.user_timing',
|
|
57
|
+
'devtools.timeline',
|
|
58
|
+
'disabled-by-default-devtools.screenshot',
|
|
59
|
+
'disabled-by-default-devtools.timeline',
|
|
60
|
+
'disabled-by-default-devtools.timeline.invalidationTracking',
|
|
61
|
+
'disabled-by-default-devtools.timeline.frame',
|
|
62
|
+
'disabled-by-default-devtools.timeline.stack',
|
|
63
|
+
'disabled-by-default-v8.cpu_profiler',
|
|
64
|
+
'disabled-by-default-v8.cpu_profiler.hires',
|
|
65
|
+
'latencyInfo',
|
|
66
|
+
'loading',
|
|
67
|
+
'disabled-by-default-lighthouse',
|
|
68
|
+
'v8.execute',
|
|
69
|
+
'v8',
|
|
70
|
+
];
|
|
71
|
+
await page.pptrPage.tracing.start({
|
|
72
|
+
categories,
|
|
73
|
+
});
|
|
74
|
+
if (request.params.reload) {
|
|
75
|
+
await page.pptrPage.goto(pageUrlForTracing, {
|
|
76
|
+
waitUntil: ['load'],
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (request.params.autoStop) {
|
|
80
|
+
await new Promise(resolve => setTimeout(resolve, 5_000));
|
|
81
|
+
await stopTracingAndAppendOutput(page.pptrPage, response, context, request.params.filePath);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
response.appendResponseLine(`The performance trace is being recorded. Use performance_stop_trace to stop it.`);
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
export const stopTrace = definePageTool({
|
|
89
|
+
name: 'performance_stop_trace',
|
|
90
|
+
description: 'Stop the active performance trace recording on the selected webpage.',
|
|
91
|
+
annotations: {
|
|
92
|
+
category: ToolCategory.PERFORMANCE,
|
|
93
|
+
readOnlyHint: false,
|
|
94
|
+
},
|
|
95
|
+
schema: {
|
|
96
|
+
filePath: filePathSchema,
|
|
97
|
+
},
|
|
98
|
+
blockedByDialog: true,
|
|
99
|
+
handler: async (request, response, context) => {
|
|
100
|
+
context.validatePath(request.params.filePath);
|
|
101
|
+
if (!context.isRunningPerformanceTrace()) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const page = request.page;
|
|
105
|
+
await stopTracingAndAppendOutput(page.pptrPage, response, context, request.params.filePath);
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
export const analyzeInsight = definePageTool({
|
|
109
|
+
name: 'performance_analyze_insight',
|
|
110
|
+
description: 'Provides more detailed information on a specific Performance Insight of an insight set that was highlighted in the results of a trace recording.',
|
|
111
|
+
annotations: {
|
|
112
|
+
category: ToolCategory.PERFORMANCE,
|
|
113
|
+
readOnlyHint: true,
|
|
114
|
+
},
|
|
115
|
+
schema: {
|
|
116
|
+
insightSetId: zod
|
|
117
|
+
.string()
|
|
118
|
+
.describe('The id for the specific insight set. Only use the ids given in the "Available insight sets" list.'),
|
|
119
|
+
insightName: zod
|
|
120
|
+
.string()
|
|
121
|
+
.describe('The name of the Insight you want more information on. For example: "DocumentLatency" or "LCPBreakdown"'),
|
|
122
|
+
},
|
|
123
|
+
blockedByDialog: false,
|
|
124
|
+
handler: async (request, response, context) => {
|
|
125
|
+
const lastRecording = context.recordedTraces().at(-1);
|
|
126
|
+
if (!lastRecording) {
|
|
127
|
+
response.appendResponseLine('No recorded traces found. Record a performance trace so you have Insights to analyze.');
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
response.attachTraceInsight(lastRecording, request.params.insightSetId, request.params.insightName);
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
async function stopTracingAndAppendOutput(page, response, context, filePath) {
|
|
134
|
+
try {
|
|
135
|
+
const traceEventsBuffer = await page.tracing.stop();
|
|
136
|
+
if (filePath && traceEventsBuffer) {
|
|
137
|
+
let dataToWrite = traceEventsBuffer;
|
|
138
|
+
if (filePath.endsWith('.gz')) {
|
|
139
|
+
dataToWrite = await new Promise((resolve, reject) => {
|
|
140
|
+
zlib.gzip(traceEventsBuffer, (error, result) => {
|
|
141
|
+
if (error) {
|
|
142
|
+
reject(error);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
resolve(result);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const file = await context.saveFile(dataToWrite, filePath, filePath.endsWith('.gz') ? '.json.gz' : '.json');
|
|
151
|
+
response.appendResponseLine(`The raw trace data was saved to ${file.filename}.`);
|
|
152
|
+
}
|
|
153
|
+
const result = await parseRawTraceBuffer(traceEventsBuffer);
|
|
154
|
+
response.appendResponseLine('The performance trace has been stopped.');
|
|
155
|
+
if (traceResultIsSuccess(result)) {
|
|
156
|
+
if (context.isCruxEnabled()) {
|
|
157
|
+
await populateCruxData(result);
|
|
158
|
+
}
|
|
159
|
+
context.storeTraceRecording(result);
|
|
160
|
+
response.attachTraceSummary(result);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
throw new Error(`There was an unexpected error parsing the trace: ${result.error}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
finally {
|
|
167
|
+
context.setIsRunningPerformanceTrace(false);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/** We tell CrUXManager to fetch data so it's available when DevTools.PerformanceTraceFormatter is invoked */
|
|
171
|
+
async function populateCruxData(result) {
|
|
172
|
+
logger('populateCruxData called');
|
|
173
|
+
const cruxManager = DevTools.CrUXManager.instance();
|
|
174
|
+
// go/jtfbx. Yes, we're aware this API key is public. ;)
|
|
175
|
+
cruxManager.setEndpointForTesting('https://chromeuxreport.googleapis.com/v1/records:queryRecord?key=AIzaSyBn5gimNjhiEyA_euicSKko6IlD3HdgUfk');
|
|
176
|
+
const cruxSetting = DevTools.Common.Settings.Settings.instance().createSetting('field-data', {
|
|
177
|
+
enabled: true,
|
|
178
|
+
});
|
|
179
|
+
cruxSetting.set({ enabled: true });
|
|
180
|
+
// Gather URLs to fetch CrUX data for
|
|
181
|
+
const urls = [...(result.parsedTrace.insights?.values() ?? [])].map(c => c.url.toString());
|
|
182
|
+
urls.push(result.parsedTrace.data.Meta.mainFrameURL);
|
|
183
|
+
const urlSet = new Set(urls);
|
|
184
|
+
if (urlSet.size === 0) {
|
|
185
|
+
logger('No URLs found for CrUX data');
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
logger(`Fetching CrUX data for ${urlSet.size} URLs: ${Array.from(urlSet).join(', ')}`);
|
|
189
|
+
const cruxData = await Promise.all(Array.from(urlSet).map(async (url) => {
|
|
190
|
+
const data = await cruxManager.getFieldDataForPage(url);
|
|
191
|
+
logger(`CrUX data for ${url}: ${data ? 'found' : 'not found'}`);
|
|
192
|
+
return data;
|
|
193
|
+
}));
|
|
194
|
+
result.parsedTrace.metadata.cruxFieldData = cruxData;
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=performance.js.map
|
|
@@ -0,0 +1,95 @@
|
|
|
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 os from 'node:os';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { zod } from '../third_party/index.js';
|
|
10
|
+
import { ensureExtension } from '../utils/files.js';
|
|
11
|
+
import { ToolCategory } from './categories.js';
|
|
12
|
+
import { definePageTool } from './ToolDefinition.js';
|
|
13
|
+
async function generateTempFilePath() {
|
|
14
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'chrome-devtools-mcp-'));
|
|
15
|
+
return path.join(dir, `screencast.mp4`);
|
|
16
|
+
}
|
|
17
|
+
const supportedExtensions = ['.webm', '.mp4'];
|
|
18
|
+
export const startScreencast = definePageTool(args => ({
|
|
19
|
+
name: 'screencast_start',
|
|
20
|
+
description: `Starts recording a screencast (video) of the selected page in specified format.`,
|
|
21
|
+
annotations: {
|
|
22
|
+
category: ToolCategory.DEBUGGING,
|
|
23
|
+
readOnlyHint: false,
|
|
24
|
+
conditions: ['experimentalScreencast'],
|
|
25
|
+
},
|
|
26
|
+
schema: {
|
|
27
|
+
filePath: zod
|
|
28
|
+
.string()
|
|
29
|
+
.optional()
|
|
30
|
+
.describe(`Output file path (${supportedExtensions.join(',')} are supported). Uses mkdtemp to generate a unique path if not provided.`),
|
|
31
|
+
},
|
|
32
|
+
blockedByDialog: false,
|
|
33
|
+
handler: async (request, response, context) => {
|
|
34
|
+
context.validatePath(request.params.filePath);
|
|
35
|
+
if (context.getScreenRecorder() !== null) {
|
|
36
|
+
response.appendResponseLine('Error: a screencast recording is already in progress. Use screencast_stop to stop it before starting a new one.');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const filePath = request.params.filePath ?? (await generateTempFilePath());
|
|
40
|
+
let enforcedExtension = '.mp4';
|
|
41
|
+
let format = 'mp4';
|
|
42
|
+
for (const supportedExtension of supportedExtensions) {
|
|
43
|
+
if (filePath.endsWith(supportedExtension)) {
|
|
44
|
+
enforcedExtension = supportedExtension;
|
|
45
|
+
format = supportedExtension.substring(1);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const resolvedPath = ensureExtension(path.resolve(filePath), enforcedExtension);
|
|
50
|
+
const page = request.page;
|
|
51
|
+
let recorder;
|
|
52
|
+
try {
|
|
53
|
+
recorder = await page.pptrPage.screencast({
|
|
54
|
+
path: resolvedPath,
|
|
55
|
+
format: format,
|
|
56
|
+
ffmpegPath: args?.experimentalFfmpegPath,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
61
|
+
if (message.includes('ENOENT') && message.includes('ffmpeg')) {
|
|
62
|
+
throw new Error('ffmpeg is required for screencast recording but was not found. ' +
|
|
63
|
+
'Install ffmpeg (https://ffmpeg.org/) and ensure it is available in your PATH.');
|
|
64
|
+
}
|
|
65
|
+
throw err;
|
|
66
|
+
}
|
|
67
|
+
context.setScreenRecorder({ recorder, filePath: resolvedPath });
|
|
68
|
+
response.appendResponseLine(`Screencast recording started. The recording will be saved to ${resolvedPath}. Use ${stopScreencast.name} to stop recording.`);
|
|
69
|
+
},
|
|
70
|
+
}));
|
|
71
|
+
export const stopScreencast = definePageTool({
|
|
72
|
+
name: 'screencast_stop',
|
|
73
|
+
description: 'Stops the active screencast recording on the selected page.',
|
|
74
|
+
annotations: {
|
|
75
|
+
category: ToolCategory.DEBUGGING,
|
|
76
|
+
readOnlyHint: false,
|
|
77
|
+
conditions: ['experimentalScreencast'],
|
|
78
|
+
},
|
|
79
|
+
schema: {},
|
|
80
|
+
blockedByDialog: false,
|
|
81
|
+
handler: async (_request, response, context) => {
|
|
82
|
+
const data = context.getScreenRecorder();
|
|
83
|
+
if (!data) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
await data.recorder.stop();
|
|
88
|
+
response.appendResponseLine(`The screencast recording has been stopped and saved to ${data.filePath}.`);
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
context.setScreenRecorder(null);
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=screencast.js.map
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { zod } from '../third_party/index.js';
|
|
7
|
+
import { ToolCategory } from './categories.js';
|
|
8
|
+
import { definePageTool } from './ToolDefinition.js';
|
|
9
|
+
export const screenshot = definePageTool({
|
|
10
|
+
name: 'take_screenshot',
|
|
11
|
+
description: `Take a screenshot of the page or element.`,
|
|
12
|
+
annotations: {
|
|
13
|
+
category: ToolCategory.DEBUGGING,
|
|
14
|
+
// Not read-only due to filePath param.
|
|
15
|
+
readOnlyHint: false,
|
|
16
|
+
},
|
|
17
|
+
schema: {
|
|
18
|
+
format: zod
|
|
19
|
+
.enum(['png', 'jpeg', 'webp'])
|
|
20
|
+
.default('png')
|
|
21
|
+
.describe('Type of format to save the screenshot as. Default is "png"'),
|
|
22
|
+
quality: zod
|
|
23
|
+
.number()
|
|
24
|
+
.min(0)
|
|
25
|
+
.max(100)
|
|
26
|
+
.optional()
|
|
27
|
+
.describe('Compression quality for JPEG and WebP formats (0-100). Higher values mean better quality but larger file sizes. Ignored for PNG format.'),
|
|
28
|
+
uid: zod
|
|
29
|
+
.string()
|
|
30
|
+
.optional()
|
|
31
|
+
.describe('The uid of an element on the page from the page content snapshot. If omitted, takes a page screenshot.'),
|
|
32
|
+
fullPage: zod
|
|
33
|
+
.boolean()
|
|
34
|
+
.optional()
|
|
35
|
+
.describe('If set to true takes a screenshot of the full page instead of the currently visible viewport. Incompatible with uid.'),
|
|
36
|
+
filePath: zod
|
|
37
|
+
.string()
|
|
38
|
+
.optional()
|
|
39
|
+
.describe('The absolute path, or a path relative to the current working directory, to save the screenshot to instead of attaching it to the response.'),
|
|
40
|
+
},
|
|
41
|
+
blockedByDialog: true,
|
|
42
|
+
handler: async (request, response, context) => {
|
|
43
|
+
context.validatePath(request.params.filePath);
|
|
44
|
+
if (request.params.uid && request.params.fullPage) {
|
|
45
|
+
throw new Error('Providing both "uid" and "fullPage" is not allowed.');
|
|
46
|
+
}
|
|
47
|
+
let pageOrHandle;
|
|
48
|
+
if (request.params.uid) {
|
|
49
|
+
pageOrHandle = await request.page.getElementByUid(request.params.uid);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
pageOrHandle = request.page.pptrPage;
|
|
53
|
+
}
|
|
54
|
+
const format = request.params.format;
|
|
55
|
+
const quality = format === 'png' ? undefined : request.params.quality;
|
|
56
|
+
const screenshot = await pageOrHandle.screenshot({
|
|
57
|
+
type: format,
|
|
58
|
+
fullPage: request.params.fullPage,
|
|
59
|
+
quality,
|
|
60
|
+
optimizeForSpeed: true, // Bonus: optimize encoding for speed
|
|
61
|
+
});
|
|
62
|
+
if (request.params.uid) {
|
|
63
|
+
response.appendResponseLine(`Took a screenshot of node with uid "${request.params.uid}".`);
|
|
64
|
+
}
|
|
65
|
+
else if (request.params.fullPage) {
|
|
66
|
+
response.appendResponseLine('Took a screenshot of the full current page.');
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
response.appendResponseLine("Took a screenshot of the current page's viewport.");
|
|
70
|
+
}
|
|
71
|
+
if (request.params.filePath) {
|
|
72
|
+
const result = await context.saveFile(screenshot, request.params.filePath, `.${format}`);
|
|
73
|
+
response.appendResponseLine(`Saved screenshot to ${result.filename}.`);
|
|
74
|
+
}
|
|
75
|
+
else if (screenshot.length >= 2_000_000) {
|
|
76
|
+
const { filepath } = await context.saveTemporaryFile(screenshot, `screenshot.${request.params.format}`);
|
|
77
|
+
response.appendResponseLine(`Saved screenshot to ${filepath}.`);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
response.attachImage({
|
|
81
|
+
mimeType: `image/${request.params.format}`,
|
|
82
|
+
data: Buffer.from(screenshot).toString('base64'),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=screenshot.js.map
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { zod } from '../third_party/index.js';
|
|
7
|
+
import { ToolCategory } from './categories.js';
|
|
8
|
+
import { defineTool, pageIdSchema } from './ToolDefinition.js';
|
|
9
|
+
export const evaluateScript = defineTool(cliArgs => {
|
|
10
|
+
return {
|
|
11
|
+
name: 'evaluate_script',
|
|
12
|
+
description: `Evaluate a JavaScript function inside the currently selected page${cliArgs?.categoryExtensions ? ' or service worker' : ''}. Returns the response as JSON,
|
|
13
|
+
so returned values have to be JSON-serializable.`,
|
|
14
|
+
annotations: {
|
|
15
|
+
category: ToolCategory.DEBUGGING,
|
|
16
|
+
readOnlyHint: false,
|
|
17
|
+
},
|
|
18
|
+
schema: {
|
|
19
|
+
function: zod.string().describe(`A JavaScript function declaration to be executed by the tool in the currently selected page.
|
|
20
|
+
Example without arguments: \`() => {
|
|
21
|
+
return document.title
|
|
22
|
+
}\` or \`async () => {
|
|
23
|
+
return await fetch("example.com")
|
|
24
|
+
}\`.
|
|
25
|
+
Example with arguments: \`(el) => {
|
|
26
|
+
return el.innerText;
|
|
27
|
+
}\`
|
|
28
|
+
`),
|
|
29
|
+
args: zod
|
|
30
|
+
.array(zod
|
|
31
|
+
.string()
|
|
32
|
+
.describe('The uid of an element on the page from the page content snapshot'))
|
|
33
|
+
.optional()
|
|
34
|
+
.describe(`An optional list of arguments to pass to the function.`),
|
|
35
|
+
filePath: zod
|
|
36
|
+
.string()
|
|
37
|
+
.optional()
|
|
38
|
+
.describe('The absolute or relative path to a file to save the script output to. If omitted, the output is returned inline.'),
|
|
39
|
+
dialogAction: zod
|
|
40
|
+
.string()
|
|
41
|
+
.optional()
|
|
42
|
+
.describe('Handle dialogs while execution. "accept", "dismiss", or string for response of window.prompt. Defaults to accept.'),
|
|
43
|
+
...(cliArgs?.experimentalPageIdRouting ? pageIdSchema : {}),
|
|
44
|
+
...(cliArgs?.categoryExtensions
|
|
45
|
+
? {
|
|
46
|
+
serviceWorkerId: zod
|
|
47
|
+
.string()
|
|
48
|
+
.optional()
|
|
49
|
+
.describe(`The optional service worker id to evaluate the script in. If provided, 'pageId' should be omitted. Note: 'args' (element UIDs) cannot be used when evaluating in a service worker.`),
|
|
50
|
+
}
|
|
51
|
+
: {}),
|
|
52
|
+
},
|
|
53
|
+
blockedByDialog: true,
|
|
54
|
+
handler: async (request, response, context) => {
|
|
55
|
+
const { serviceWorkerId, args: uidArgs, function: fnString, pageId, dialogAction, filePath, } = request.params;
|
|
56
|
+
context.validatePath(filePath);
|
|
57
|
+
if (cliArgs?.categoryExtensions && serviceWorkerId) {
|
|
58
|
+
if (uidArgs && uidArgs.length > 0) {
|
|
59
|
+
throw new Error('args (element uids) cannot be used when evaluating in a service worker.');
|
|
60
|
+
}
|
|
61
|
+
if (pageId) {
|
|
62
|
+
throw new Error('specify either a pageId or a serviceWorkerId.');
|
|
63
|
+
}
|
|
64
|
+
const worker = await getWebWorker(context, serviceWorkerId);
|
|
65
|
+
const result = await context
|
|
66
|
+
.getSelectedMcpPage()
|
|
67
|
+
.waitForEventsAfterAction(async () => {
|
|
68
|
+
await performEvaluation(worker, fnString, [], response, {
|
|
69
|
+
filePath,
|
|
70
|
+
context,
|
|
71
|
+
});
|
|
72
|
+
}, { handleDialog: dialogAction ?? 'accept' });
|
|
73
|
+
response.attachWaitForResult(result);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const mcpPage = cliArgs?.experimentalPageIdRouting
|
|
77
|
+
? context.getPageById(request.params.pageId)
|
|
78
|
+
: context.getSelectedMcpPage();
|
|
79
|
+
const page = mcpPage.pptrPage;
|
|
80
|
+
const args = [];
|
|
81
|
+
try {
|
|
82
|
+
const frames = new Set();
|
|
83
|
+
for (const uid of uidArgs ?? []) {
|
|
84
|
+
const handle = await mcpPage.getElementByUid(uid);
|
|
85
|
+
frames.add(handle.frame);
|
|
86
|
+
args.push(handle);
|
|
87
|
+
}
|
|
88
|
+
const evaluatable = await getPageOrFrame(page, frames);
|
|
89
|
+
const result = await mcpPage.waitForEventsAfterAction(async () => {
|
|
90
|
+
await performEvaluation(evaluatable, fnString, args, response, {
|
|
91
|
+
filePath,
|
|
92
|
+
context,
|
|
93
|
+
});
|
|
94
|
+
}, { handleDialog: dialogAction ?? 'accept' });
|
|
95
|
+
response.attachWaitForResult(result);
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
void Promise.allSettled(args.map(arg => arg.dispose()));
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
const performEvaluation = async (evaluatable, fnString, args, response, options) => {
|
|
104
|
+
const fn = await evaluatable.evaluateHandle(`(${fnString})`);
|
|
105
|
+
try {
|
|
106
|
+
const result = await evaluatable.evaluate(async (fn, ...args) => {
|
|
107
|
+
// @ts-expect-error no types for function fn
|
|
108
|
+
return JSON.stringify(await fn(...args));
|
|
109
|
+
}, fn, ...args);
|
|
110
|
+
if (options?.filePath) {
|
|
111
|
+
const data = new TextEncoder().encode(result ?? 'undefined');
|
|
112
|
+
const { filename } = await options.context.saveFile(data, options.filePath, '.json');
|
|
113
|
+
response.appendResponseLine(`Script ran on page. Output saved to ${filename}.`);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
response.appendResponseLine('Script ran on page and returned:');
|
|
117
|
+
response.appendResponseLine('```json');
|
|
118
|
+
response.appendResponseLine(`${result}`);
|
|
119
|
+
response.appendResponseLine('```');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
finally {
|
|
123
|
+
void fn.dispose();
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const getPageOrFrame = async (page, frames) => {
|
|
127
|
+
let pageOrFrame;
|
|
128
|
+
// We can't evaluate the element handle across frames
|
|
129
|
+
if (frames.size > 1) {
|
|
130
|
+
throw new Error("Elements from different frames can't be evaluated together.");
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
pageOrFrame = [...frames.values()][0] ?? page;
|
|
134
|
+
}
|
|
135
|
+
return pageOrFrame;
|
|
136
|
+
};
|
|
137
|
+
const getWebWorker = async (context, serviceWorkerId) => {
|
|
138
|
+
const serviceWorkers = context.getExtensionServiceWorkers();
|
|
139
|
+
const serviceWorker = serviceWorkers.find((sw) => context.getExtensionServiceWorkerId(sw) === serviceWorkerId);
|
|
140
|
+
if (serviceWorker && serviceWorker.target) {
|
|
141
|
+
const worker = await serviceWorker.target.worker();
|
|
142
|
+
if (!worker) {
|
|
143
|
+
throw new Error('Service worker target not found.');
|
|
144
|
+
}
|
|
145
|
+
return worker;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
throw new Error('Service worker not found.');
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=script.js.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { zod } from '../../third_party/index.js';
|
|
7
|
+
import { ToolCategory } from '../categories.js';
|
|
8
|
+
import { definePageTool } from '../ToolDefinition.js';
|
|
9
|
+
export const screenshot = definePageTool({
|
|
10
|
+
name: 'screenshot',
|
|
11
|
+
description: `Takes a screenshot`,
|
|
12
|
+
annotations: {
|
|
13
|
+
category: ToolCategory.DEBUGGING,
|
|
14
|
+
// Not read-only due to filePath param.
|
|
15
|
+
readOnlyHint: false,
|
|
16
|
+
},
|
|
17
|
+
schema: {},
|
|
18
|
+
blockedByDialog: true,
|
|
19
|
+
handler: async (request, response, context) => {
|
|
20
|
+
const page = request.page;
|
|
21
|
+
const screenshot = await page.pptrPage.screenshot({
|
|
22
|
+
type: 'png',
|
|
23
|
+
optimizeForSpeed: true,
|
|
24
|
+
});
|
|
25
|
+
const { filepath } = await context.saveTemporaryFile(screenshot, `screenshot.png`);
|
|
26
|
+
response.appendResponseLine(filepath);
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
export const navigate = definePageTool({
|
|
30
|
+
name: 'navigate',
|
|
31
|
+
description: `Loads a URL`,
|
|
32
|
+
annotations: {
|
|
33
|
+
category: ToolCategory.NAVIGATION,
|
|
34
|
+
readOnlyHint: false,
|
|
35
|
+
},
|
|
36
|
+
schema: {
|
|
37
|
+
url: zod.string().describe('URL to navigate to'),
|
|
38
|
+
},
|
|
39
|
+
blockedByDialog: false,
|
|
40
|
+
handler: async (request, response) => {
|
|
41
|
+
const page = request.page;
|
|
42
|
+
const options = {
|
|
43
|
+
timeout: 30_000,
|
|
44
|
+
};
|
|
45
|
+
const dialogHandler = (dialog) => {
|
|
46
|
+
if (dialog.type() === 'beforeunload') {
|
|
47
|
+
response.appendResponseLine(`Accepted a beforeunload dialog.`);
|
|
48
|
+
void dialog.accept();
|
|
49
|
+
// We are not going to report the dialog like regular dialogs.
|
|
50
|
+
page.clearDialog();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
page.pptrPage.on('dialog', dialogHandler);
|
|
54
|
+
try {
|
|
55
|
+
await page.pptrPage.goto(request.params.url, options);
|
|
56
|
+
response.appendResponseLine(`Navigated to ${page.pptrPage.url()}.`);
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
page.pptrPage.off('dialog', dialogHandler);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
export const evaluate = definePageTool({
|
|
64
|
+
name: 'evaluate',
|
|
65
|
+
description: `Evaluates a JavaScript script`,
|
|
66
|
+
annotations: {
|
|
67
|
+
category: ToolCategory.DEBUGGING,
|
|
68
|
+
readOnlyHint: false,
|
|
69
|
+
},
|
|
70
|
+
schema: {
|
|
71
|
+
script: zod.string().describe(`JS script to run on the page`),
|
|
72
|
+
},
|
|
73
|
+
blockedByDialog: true,
|
|
74
|
+
handler: async (request, response) => {
|
|
75
|
+
const page = request.page;
|
|
76
|
+
try {
|
|
77
|
+
const result = await page.pptrPage.evaluate(request.params.script);
|
|
78
|
+
response.appendResponseLine(JSON.stringify(result));
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
response.appendResponseLine(String(err.message));
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { zod } from '../third_party/index.js';
|
|
7
|
+
import { ToolCategory } from './categories.js';
|
|
8
|
+
import { definePageTool, timeoutSchema } from './ToolDefinition.js';
|
|
9
|
+
export const takeSnapshot = definePageTool({
|
|
10
|
+
name: 'take_snapshot',
|
|
11
|
+
description: `Take a text snapshot of the currently selected page based on the a11y tree. The snapshot lists page elements along with a unique
|
|
12
|
+
identifier (uid). Always use the latest snapshot. Prefer taking a snapshot over taking a screenshot. The snapshot indicates the element selected
|
|
13
|
+
in the DevTools Elements panel (if any).`,
|
|
14
|
+
annotations: {
|
|
15
|
+
category: ToolCategory.DEBUGGING,
|
|
16
|
+
// Not read-only due to filePath param.
|
|
17
|
+
readOnlyHint: false,
|
|
18
|
+
},
|
|
19
|
+
schema: {
|
|
20
|
+
verbose: zod
|
|
21
|
+
.boolean()
|
|
22
|
+
.optional()
|
|
23
|
+
.describe('Whether to include all possible information available in the full a11y tree. Default is false.'),
|
|
24
|
+
filePath: zod
|
|
25
|
+
.string()
|
|
26
|
+
.optional()
|
|
27
|
+
.describe('The absolute path, or a path relative to the current working directory, to save the snapshot to instead of attaching it to the response.'),
|
|
28
|
+
},
|
|
29
|
+
blockedByDialog: true,
|
|
30
|
+
handler: async (request, response, context) => {
|
|
31
|
+
context.validatePath(request.params.filePath);
|
|
32
|
+
response.includeSnapshot({
|
|
33
|
+
verbose: request.params.verbose ?? false,
|
|
34
|
+
filePath: request.params.filePath,
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
export const waitFor = definePageTool({
|
|
39
|
+
name: 'wait_for',
|
|
40
|
+
description: `Wait for the specified text to appear on the selected page.`,
|
|
41
|
+
annotations: {
|
|
42
|
+
category: ToolCategory.NAVIGATION,
|
|
43
|
+
readOnlyHint: true,
|
|
44
|
+
},
|
|
45
|
+
schema: {
|
|
46
|
+
text: zod
|
|
47
|
+
.array(zod.string())
|
|
48
|
+
.min(1)
|
|
49
|
+
.describe('Non-empty list of texts. Resolves when any value appears on the page.'),
|
|
50
|
+
...timeoutSchema,
|
|
51
|
+
},
|
|
52
|
+
blockedByDialog: true,
|
|
53
|
+
handler: async (request, response, context) => {
|
|
54
|
+
const page = request.page;
|
|
55
|
+
await context.waitForTextOnPage(request.params.text, request.params.timeout, page.pptrPage);
|
|
56
|
+
response.appendResponseLine(`Element matching one of ${JSON.stringify(request.params.text)} found.`);
|
|
57
|
+
response.includeSnapshot();
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=snapshot.js.map
|