@chenpx976/chrome-devtools-mcp 0.0.0-stage → 1.13.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 +223 -2
- package/out/Default/gen/src/ArcBrowser.js +128 -0
- package/out/Default/gen/src/BrowserManager.js +562 -0
- package/out/Default/gen/src/LogpointManager.js +287 -0
- package/out/Default/gen/src/McpContext.js +1031 -0
- package/out/Default/gen/src/McpPage.js +1427 -0
- package/out/Default/gen/src/McpResponse.js +1350 -0
- package/out/Default/gen/src/McpWorker.js +66 -0
- package/out/Default/gen/src/NetworkOverrideManager.js +447 -0
- package/out/Default/gen/src/SlimMcpResponse.js +23 -0
- package/out/Default/gen/src/TextSnapshot.js +336 -0
- package/out/Default/gen/src/ToolHandler.js +531 -0
- package/out/Default/gen/src/bin/check-latest-version.js +53 -0
- package/out/Default/gen/src/bin/chrome-devtools-mcp-main.js +80 -0
- package/out/Default/gen/src/bin/chrome-devtools-mcp.js +23 -0
- package/out/Default/gen/src/bin/chrome-devtools.js +213 -0
- package/out/Default/gen/src/collectors/PageCollector.js +325 -0
- package/out/Default/gen/src/collectors/ServiceWorkerCollector.js +198 -0
- package/out/Default/gen/src/collectors/constants.js +7 -0
- package/out/Default/gen/src/config/ConfigLocator.js +70 -0
- package/out/Default/gen/src/config/ConfigParser.js +163 -0
- package/out/Default/gen/src/config/ConfigWatcher.js +94 -0
- package/out/Default/gen/src/config/ServerConfig.js +284 -0
- package/out/Default/gen/src/config/browser-options.js +135 -0
- package/out/Default/gen/src/config/category-options.js +84 -0
- package/out/Default/gen/src/config/cli-commands.js +208 -0
- package/out/Default/gen/src/config/cli-options.js +2090 -0
- package/out/Default/gen/src/config/mcp-options.js +371 -0
- package/out/Default/gen/src/config/puppeteer-options.js +69 -0
- package/out/Default/gen/src/config/tool-options.js +60 -0
- package/out/Default/gen/src/daemon/client.js +281 -0
- package/out/Default/gen/src/daemon/daemon.js +280 -0
- package/out/Default/gen/src/daemon/types.js +7 -0
- package/out/Default/gen/src/daemon/utils.js +173 -0
- package/out/Default/gen/src/devtools/DevToolsCommentBridge.js +151 -0
- package/out/Default/gen/src/devtools/DevtoolsUtils.js +413 -0
- package/out/Default/gen/src/devtools/McpHostBindingAdapter.js +164 -0
- package/out/Default/gen/src/devtools/issueDescriptions.js +42 -0
- package/out/Default/gen/src/formatters/CommentFormatter.js +73 -0
- package/out/Default/gen/src/formatters/ConsoleFormatter.js +363 -0
- package/out/Default/gen/src/formatters/CssFormatter.js +883 -0
- package/out/Default/gen/src/formatters/HeapSnapshotFormatter.js +239 -0
- package/out/Default/gen/src/formatters/IssueFormatter.js +194 -0
- package/out/Default/gen/src/formatters/LogpointFormatter.js +62 -0
- package/out/Default/gen/src/formatters/NetworkFormatter.js +295 -0
- package/out/Default/gen/src/formatters/NetworkOverridesFormatter.js +57 -0
- package/out/Default/gen/src/formatters/RemoteObjectFormatter.js +231 -0
- package/out/Default/gen/src/formatters/SnapshotFormatter.js +172 -0
- package/out/Default/gen/src/formatters/WebAuthnFormatter.js +56 -0
- package/out/Default/gen/src/formatters/constants.js +8 -0
- package/out/Default/gen/src/index.js +434 -0
- package/out/Default/gen/src/processors/ChunkedTraceParser.js +361 -0
- package/out/Default/gen/src/processors/HeapSnapshotManager.js +595 -0
- package/out/Default/gen/src/processors/PerformanceTrace.js +132 -0
- package/out/Default/gen/src/telemetry/ClearcutLogger.js +271 -0
- package/out/Default/gen/src/telemetry/WatchdogClient.js +60 -0
- package/out/Default/gen/src/telemetry/errors.js +18 -0
- package/out/Default/gen/src/telemetry/flagUtils.js +89 -0
- package/out/Default/gen/src/telemetry/metricsRegistry.js +85 -0
- package/out/Default/gen/src/telemetry/persistence.js +82 -0
- package/out/Default/gen/src/telemetry/transformation.js +229 -0
- package/out/Default/gen/src/telemetry/types.js +36 -0
- package/out/Default/gen/src/telemetry/watchdog/ClearcutSender.js +213 -0
- package/out/Default/gen/src/telemetry/watchdog/main.js +142 -0
- package/out/Default/gen/src/third_party/THIRD_PARTY_NOTICES +3774 -0
- package/out/Default/gen/src/third_party/browser.js +808 -0
- package/out/Default/gen/src/third_party/bundled-packages.json +11 -0
- package/out/Default/gen/src/third_party/cli.js +139 -0
- package/out/Default/gen/src/third_party/devtools-formatter-worker.js +125 -0
- package/out/Default/gen/src/third_party/devtools-heap-snapshot-worker.js +111 -0
- package/out/Default/gen/src/third_party/index.js +128 -0
- package/out/Default/gen/src/third_party/issue-descriptions/CoepCoopSandboxedIframeCannotNavigateToCoopPage.md +4 -0
- package/out/Default/gen/src/third_party/issue-descriptions/CoepCorpNotSameOrigin.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/CoepCorpNotSameOriginAfterDefaultedToSameOriginByCoep.md +18 -0
- package/out/Default/gen/src/third_party/issue-descriptions/CoepCorpNotSameSite.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/CoepFrameResourceNeedsCoepHeader.md +10 -0
- package/out/Default/gen/src/third_party/issue-descriptions/CompatibilityModeQuirks.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/CookieAttributeValueExceedsMaxSize.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/LowTextContrast.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorRead.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorSet.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnRead.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnSet.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeRead.md +9 -0
- package/out/Default/gen/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeSet.md +9 -0
- package/out/Default/gen/src/third_party/issue-descriptions/bounceTrackingMitigations.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/clientHintMetaTagAllowListInvalidOrigin.md +4 -0
- package/out/Default/gen/src/third_party/issue-descriptions/clientHintMetaTagModifiedHTML.md +4 -0
- package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistEmbeddingRequirementNotSatisfied.md +26 -0
- package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistIFrameAttributeLoosensEmbeddingRequirement.md +19 -0
- package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowConnectionAllowlistFrom.md +21 -0
- package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowlistItemType.md +12 -0
- package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistInvalidHeader.md +12 -0
- package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistInvalidUrlPattern.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistItemNotInnerList.md +12 -0
- package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistMoreThanOneList.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistReportingEndpointNotToken.md +10 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieCrossSiteRedirectDowngrade.md +12 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieExcludeDomainNonAscii.md +11 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieExcludePortMismatch.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieExcludeSchemeMismatch.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutRead.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutSet.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnDomainNonAscii.md +11 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnMetadataGrantRead.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnMetadataGrantReadOptOut.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnMetadataGrantSet.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnMetadataGrantSetOptOut.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutRead.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutSet.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsAllowCredentialsRequired.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsDisabledScheme.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsDisallowedByMode.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsHeaderDisallowedByPreflightResponse.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsInvalidHeaderValues.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsLocalNetworkAccessPermissionDenied.md +19 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsMethodDisallowedByPreflightResponse.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsNoCorsRedirectModeNotFollow.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsOriginMismatch.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsPreflightResponseInvalid.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsRedirectContainsCredentials.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsWildcardOriginNotAllowed.md +9 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cspEvalViolation.md +9 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cspInlineViolation.md +10 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cspTrustedTypesPolicyViolation.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cspTrustedTypesSinkViolation.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cspURLViolation.md +10 -0
- package/out/Default/gen/src/third_party/issue-descriptions/deprecation.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestAccountsEmptyList.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestAccountsHttpNotFound.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidContentType.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestAccountsNoResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestDnsFetchFailed.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestDnsInvalidRecord.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownHttpNotFound.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidContentType.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownNoResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestInvalidEmail.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestJwksHttpNotFound.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestJwksInvalidResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestKeyBindingSigningFailed.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestRpOriginIsOpaque.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenHttpNotFound.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidContentType.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidSdJwt.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenMalformedSdJwt.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenNoResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidAudience.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidIssuedAt.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidNonce.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidSdHash.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidTyp.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingAud.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingCnf.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingIat.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingNonce.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingSdHash.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbSignatureFailed.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmail.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmailVerified.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidHolderKey.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuedAt.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuer.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtJwksMissingKeys.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingCnf.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingEmail.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIat.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIss.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtSignatureFailed.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtUnsupportedHeaderAlg.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestUserLoggedOut.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownAccountsEndpointCrossOrigin.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownHttpNotFound.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidContentType.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownIssuanceEndpointCrossOrigin.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownListEmpty.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingAccountsEndpoint.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingIssuanceEndpoint.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownNoResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownUnsupportedSigningAlgorithm.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestAccountsBlockedByConnectionAllowlist.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestAccountsHttpNotFound.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestAccountsInvalidResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestAccountsNoResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestApprovalDeclined.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestCanceled.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestConfigBlockedByConnectionAllowlist.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestErrorFetchingSignin.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestErrorIdToken.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestIdTokenBlockedByConnectionAllowlist.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestIdTokenHttpNotFound.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidRequest.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestIdTokenNoResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestInvalidSigninResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestManifestHttpNotFound.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestManifestInvalidResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestManifestNoResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestTooManyRequests.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestWellKnownBlockedByConnectionAllowlist.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidAccountsResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidConfigOrWellKnown.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoAccountSharingPermission.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoApiPermission.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoReturningUserFromFetchedAccounts.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotIframe.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotPotentiallyTrustworthy.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSameOrigin.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSignedInWithIdp.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/fetchingPartitionedBlobURL.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericBackUINavigationWouldSkipAd.md +4 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormAriaLabelledByToNonExistingIdError.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormAutocompleteAttributeEmptyError.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormDuplicateIdForInputError.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormEmptyIdAndNameAttributesForInputError.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormInputAssignedAutocompleteValueToIdOrNameAttributeError.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormInputHasWrongButWellIntendedAutocompleteValueError.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormInputWithNoLabelError.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormLabelForMatchesNonExistingIdError.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormLabelForNameError.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormLabelHasNeitherForNorNestedInputError.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormModelContextMissingToolDescription.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormModelContextMissingToolName.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormModelContextParameterMissingName.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormModelContextParameterMissingTitleAndDescription.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormModelContextRequiredParameterMissingName.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericGeolocationPromptWithoutUserGesture.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericNavigationEntryMarkedSkippable.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericResponseWasBlockedByORB.md +4 -0
- package/out/Default/gen/src/third_party/issue-descriptions/heavyAd.md +10 -0
- package/out/Default/gen/src/third_party/issue-descriptions/lazyLoadImageZeroSize.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/mixedContent.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/navigatingPartitionedBlobURL.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementActivationDisabled.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluder.md +9 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluderParent.md +9 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementCspFrameAncestorsMissing.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementFencedFrameDisallowed.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementFontSizeTooLarge.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementFontSizeTooSmall.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementGeolocationDeprecated.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementInsetBoxShadowUnsupported.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementInvalidDisplayStyle.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementInvalidSizeValue.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementInvalidType.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementInvalidTypeActivation.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementLowContrast.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementNonOpaqueColor.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementPaddingBottomUnsupported.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementPaddingRightUnsupported.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementPermissionsPolicyBlocked.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementRegistrationFailed.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementRequestInProgress.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementSecurityChecksFailed.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementTypeNotSupported.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementUntrustedEvent.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/placeholderDescriptionForInvisibleIssues.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/propertyRuleInvalidNameIssue.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/propertyRuleIssue.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedOptGroupChild.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedSelectChild.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentAttributesSelectDescendant.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentLegendChild.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentOptionChild.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/selectElementAccessibilityNonPhrasingContentOptionChild.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/selectivePermissionsIntervention.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedArrayBuffer.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryUseErrorCrossOriginNoCorsRequest.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryUseErrorDictionaryLoadFailure.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryUseErrorMatchingDictionaryNotUsed.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryUseErrorUnexpectedContentDictionaryHeader.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorCossOriginNoCorsRequest.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorDisallowedBySettings.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorExpiredResponse.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorFeatureDisabled.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInsufficientResources.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidMatchField.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidStructuredHeader.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidTTLField.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNavigationRequest.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNoMatchField.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonIntegerTTLField.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonListMatchDestField.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonSecureContext.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringIdField.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringInMatchDestList.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringMatchField.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonTokenTypeField.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorRequestAborted.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorShuttingDown.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorTooLongIdField.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorUnsupportedType.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriInvalidSignatureHeader.md +14 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriInvalidSignatureInputHeader.md +15 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriMissingSignatureHeader.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriMissingSignatureInputHeader.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureHeaderValueIsIncorrectLength.md +11 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureHeaderValueIsNotByteSequence.md +14 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureHeaderValueIsParameterized.md +15 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentName.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentType.md +13 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidDerivedComponentParameter.md +4 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidHeaderComponentParameter.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidParameter.md +11 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderKeyIdLength.md +12 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingLabel.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingRequiredParameters.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderValueMissingComponents.md +11 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderValueNotInnerList.md +11 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriValidationFailedIntegrityMismatch.md +12 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriValidationFailedInvalidLength.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriValidationFailedSignatureExpired.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriValidationFailedSignatureMismatch.md +11 -0
- package/out/Default/gen/src/third_party/issue-descriptions/stylesheetLateImport.md +4 -0
- package/out/Default/gen/src/third_party/issue-descriptions/stylesheetRequestFailed.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/summaryElementAccessibilityInteractiveContentSummaryDescendant.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestLength.md +12 -0
- package/out/Default/gen/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestType.md +17 -0
- package/out/Default/gen/src/third_party/issue-descriptions/unencodedDigestMalformedDictionary.md +14 -0
- package/out/Default/gen/src/third_party/issue-descriptions/unencodedDigestUnknownAlgorithm.md +15 -0
- package/out/Default/gen/src/third_party/issue-descriptions/webInstallManifestMissingId.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/webInstallManifestMissingNameOrShortName.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/webInstallManifestParsingOrNetworkError.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/webInstallNoManifest.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/webInstallStartUrlInvalid.md +3 -0
- package/out/Default/gen/src/third_party/lighthouse-devtools-mcp-bundle.js +60395 -0
- package/out/Default/gen/src/tools/ToolDefinition.js +180 -0
- package/out/Default/gen/src/tools/categories.js +37 -0
- package/out/Default/gen/src/tools/comments.js +230 -0
- package/out/Default/gen/src/tools/console.js +122 -0
- package/out/Default/gen/src/tools/css.js +54 -0
- package/out/Default/gen/src/tools/emulation.js +98 -0
- package/out/Default/gen/src/tools/extensions.js +108 -0
- package/out/Default/gen/src/tools/input.js +658 -0
- package/out/Default/gen/src/tools/lighthouse.js +279 -0
- package/out/Default/gen/src/tools/logpoints.js +51 -0
- package/out/Default/gen/src/tools/memory.js +531 -0
- package/out/Default/gen/src/tools/network.js +325 -0
- package/out/Default/gen/src/tools/pages.js +420 -0
- package/out/Default/gen/src/tools/performance.js +258 -0
- package/out/Default/gen/src/tools/pwa.js +152 -0
- package/out/Default/gen/src/tools/screencast.js +160 -0
- package/out/Default/gen/src/tools/screenshot.js +315 -0
- package/out/Default/gen/src/tools/script.js +319 -0
- package/out/Default/gen/src/tools/slim/tools.js +110 -0
- package/out/Default/gen/src/tools/snapshot.js +88 -0
- package/out/Default/gen/src/tools/thirdPartyDeveloper.js +73 -0
- package/out/Default/gen/src/tools/toolNames.js +10 -0
- package/out/Default/gen/src/tools/tools.js +72 -0
- package/out/Default/gen/src/tools/webauthn.js +51 -0
- package/out/Default/gen/src/tools/webmcp.js +55 -0
- package/out/Default/gen/src/types.js +21 -0
- package/out/Default/gen/src/utils/TaskRunner.js +151 -0
- package/out/Default/gen/src/utils/WaitForHelper.js +343 -0
- package/out/Default/gen/src/utils/bytes.js +95 -0
- package/out/Default/gen/src/utils/check-for-updates.js +81 -0
- package/out/Default/gen/src/utils/disclaimers.js +27 -0
- package/out/Default/gen/src/utils/errorHandling.js +23 -0
- package/out/Default/gen/src/utils/files.js +81 -0
- package/out/Default/gen/src/utils/id.js +16 -0
- package/out/Default/gen/src/utils/keyboard.js +307 -0
- package/out/Default/gen/src/utils/logger.js +145 -0
- package/out/Default/gen/src/utils/logpoint.js +44 -0
- package/out/Default/gen/src/utils/network.js +81 -0
- package/out/Default/gen/src/utils/pagination.js +50 -0
- package/out/Default/gen/src/utils/polyfill.js +11 -0
- package/out/Default/gen/src/utils/raceWithSignal.js +26 -0
- package/out/Default/gen/src/utils/resourceType.js +27 -0
- package/out/Default/gen/src/utils/text.js +43 -0
- package/out/Default/gen/src/utils/timeout.js +14 -0
- package/out/Default/gen/src/utils/url.js +311 -0
- package/out/Default/gen/src/version.js +11 -0
- package/package.json +125 -4
- package/skills/a11y-debugging/SKILL.md +86 -0
- package/skills/a11y-debugging/references/a11y-snippets.md +92 -0
- package/skills/arc-compatibility/SKILL.md +168 -0
- package/skills/arc-compatibility/SOURCES.md +216 -0
- package/skills/arc-compatibility/references/compatibility.md +113 -0
- package/skills/arc-compatibility/references/output-contract.md +62 -0
- package/skills/arc-compatibility/references/workflows.md +105 -0
- package/skills/chrome-devtools/SKILL.md +80 -0
- package/skills/chrome-devtools-cli/SKILL.md +208 -0
- package/skills/chrome-devtools-cli/references/installation.md +24 -0
- package/skills/cookie-debugging/SKILL.md +152 -0
- package/skills/debug-optimize-lcp/SKILL.md +121 -0
- package/skills/debug-optimize-lcp/references/elements-and-size.md +27 -0
- package/skills/debug-optimize-lcp/references/lcp-breakdown.md +23 -0
- package/skills/debug-optimize-lcp/references/lcp-snippets.md +79 -0
- package/skills/debug-optimize-lcp/references/optimization-strategies.md +38 -0
- package/skills/inspect-in-devtools/SKILL.md +82 -0
- package/skills/memory-leak-debugging/SKILL.md +58 -0
- package/skills/memory-leak-debugging/references/common-leaks.md +33 -0
- package/skills/troubleshooting/SKILL.md +107 -0
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
7
|
+
if (value !== null && value !== void 0) {
|
|
8
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
9
|
+
var dispose, inner;
|
|
10
|
+
if (async) {
|
|
11
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
12
|
+
dispose = value[Symbol.asyncDispose];
|
|
13
|
+
}
|
|
14
|
+
if (dispose === void 0) {
|
|
15
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
16
|
+
dispose = value[Symbol.dispose];
|
|
17
|
+
if (async) inner = dispose;
|
|
18
|
+
}
|
|
19
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
20
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
21
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
22
|
+
}
|
|
23
|
+
else if (async) {
|
|
24
|
+
env.stack.push({ async: true });
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
28
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
29
|
+
return function (env) {
|
|
30
|
+
function fail(e) {
|
|
31
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
32
|
+
env.hasError = true;
|
|
33
|
+
}
|
|
34
|
+
var r, s = 0;
|
|
35
|
+
function next() {
|
|
36
|
+
while (r = env.stack.pop()) {
|
|
37
|
+
try {
|
|
38
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
39
|
+
if (r.dispose) {
|
|
40
|
+
var result = r.dispose.call(r.value);
|
|
41
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
42
|
+
}
|
|
43
|
+
else s |= 1;
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
fail(e);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
50
|
+
if (env.hasError) throw env.error;
|
|
51
|
+
}
|
|
52
|
+
return next();
|
|
53
|
+
};
|
|
54
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
55
|
+
var e = new Error(message);
|
|
56
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
57
|
+
});
|
|
58
|
+
import { ClearcutLogger } from './telemetry/ClearcutLogger.js';
|
|
59
|
+
import { DisposableStack, ProtocolError, ProtocolErrorCode, zod, } from './third_party/index.js';
|
|
60
|
+
import { labels } from './tools/categories.js';
|
|
61
|
+
import { categoryToFlagName } from './config/category-options.js';
|
|
62
|
+
import { isAvailableInMode, isBrowserlessTool, isPageScopedTool, isSlimTool, } from './tools/ToolDefinition.js';
|
|
63
|
+
import { getErrorMessage, toError } from './utils/errorHandling.js';
|
|
64
|
+
import { fileUrlToPathWithPosixFallback } from './utils/files.js';
|
|
65
|
+
import { logger } from './utils/logger.js';
|
|
66
|
+
import { raceWithSignal } from './utils/raceWithSignal.js';
|
|
67
|
+
import { pathToFileURL } from 'node:url';
|
|
68
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
69
|
+
import { isLocalBrowserEndpoint } from './utils/url.js';
|
|
70
|
+
/**
|
|
71
|
+
* Upper bound on how long a tool call may wait to acquire the browser
|
|
72
|
+
* (connect/launch and McpContext initialization). A connect attempt on a
|
|
73
|
+
* half-open socket can hang without ever failing; this bound turns that into
|
|
74
|
+
* a clear error and abandons the attempt so the next call starts fresh.
|
|
75
|
+
*
|
|
76
|
+
* This does not bound the tool's own work. A slow but valid call (a long
|
|
77
|
+
* `wait_for` timeout, an `evaluate_script` awaiting a slow promise, a
|
|
78
|
+
* Lighthouse audit) must finish on its own terms without the browser being
|
|
79
|
+
* closed underneath it. A transport that dies mid-call is detected by the
|
|
80
|
+
* WebSocket keep-alive configured in BrowserManager#connect(), which rejects
|
|
81
|
+
* the in-flight CDP calls and fires `disconnected`.
|
|
82
|
+
*/
|
|
83
|
+
export const TOOL_CALL_TIMEOUT_MS = 60_000;
|
|
84
|
+
class ToolCallTimeoutError extends Error {
|
|
85
|
+
}
|
|
86
|
+
let responseFactory;
|
|
87
|
+
/**
|
|
88
|
+
* Loads the response classes on first use, because they import the browser
|
|
89
|
+
* bundle through the formatters.
|
|
90
|
+
*/
|
|
91
|
+
function loadResponseFactory() {
|
|
92
|
+
responseFactory ??= Promise.all([
|
|
93
|
+
import('./McpResponse.js'),
|
|
94
|
+
import('./SlimMcpResponse.js'),
|
|
95
|
+
]).then(([mcpResponseModule, slimMcpResponseModule]) => (slim, config) => {
|
|
96
|
+
return slim
|
|
97
|
+
? new slimMcpResponseModule.SlimMcpResponse(config)
|
|
98
|
+
: new mcpResponseModule.McpResponse(config);
|
|
99
|
+
});
|
|
100
|
+
return responseFactory;
|
|
101
|
+
}
|
|
102
|
+
function buildDisabledMessage(toolName, flag, categoryLabel) {
|
|
103
|
+
const reason = categoryLabel
|
|
104
|
+
? `is in category ${categoryLabel} which`
|
|
105
|
+
: `requires ${flag.startsWith('--experimental') ? 'experimental feature' : 'flag'} ${flag} and`;
|
|
106
|
+
return `Tool ${toolName} ${reason} is currently disabled. Enable it by running chrome-devtools start ${flag}=true. For more information check the README.`;
|
|
107
|
+
}
|
|
108
|
+
function getDisabledReason(tool, serverArgs) {
|
|
109
|
+
if (!isAvailableInMode(tool, serverArgs)) {
|
|
110
|
+
return isSlimTool(tool)
|
|
111
|
+
? `Tool ${tool.name} is only available with --slim.`
|
|
112
|
+
: `Tool ${tool.name} is not available with --slim.`;
|
|
113
|
+
}
|
|
114
|
+
const category = tool.annotations.category;
|
|
115
|
+
if (category) {
|
|
116
|
+
const flag = categoryToFlagName(category);
|
|
117
|
+
if (!serverArgs[flag]) {
|
|
118
|
+
return buildDisabledMessage(tool.name, `--${flag}`, labels[category]);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
for (const condition of tool.annotations.conditions || []) {
|
|
122
|
+
if (!serverArgs[condition]) {
|
|
123
|
+
return buildDisabledMessage(tool.name, `--${condition}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
async function validateAndResolvePathOrUrl(filePathOrUrl, context, allowUrl) {
|
|
129
|
+
if (filePathOrUrl.trim().length === 0) {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
let url;
|
|
133
|
+
try {
|
|
134
|
+
url = new URL(filePathOrUrl);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
// Not a URL; fall through and validate it as a regular file path.
|
|
138
|
+
}
|
|
139
|
+
if (url) {
|
|
140
|
+
if (url.protocol === 'file:') {
|
|
141
|
+
return pathToFileURL(await context.validatePath(fileUrlToPathWithPosixFallback(url))).href;
|
|
142
|
+
}
|
|
143
|
+
if (['http:', 'https:', 'ws:', 'wss:'].includes(url.protocol)) {
|
|
144
|
+
// Only pass a remote URL through unchanged for parameters whose sink
|
|
145
|
+
// actually fetches the URL or hands it to the browser (allowUrl). For a
|
|
146
|
+
// filesystem-path parameter, a value that merely looks like an http/ws
|
|
147
|
+
// URL must still be rejected outright: `new URL()` accepts
|
|
148
|
+
// `http://x/../../etc/passwd`, and the downstream filesystem API (e.g.
|
|
149
|
+
// Puppeteer's uploadFile) path.resolve()s that non-absolute string into
|
|
150
|
+
// an absolute host path, which would bypass validatePath (workspace
|
|
151
|
+
// roots and the temp-dir fallback) if it fell through to it unchanged.
|
|
152
|
+
if (allowUrl) {
|
|
153
|
+
return filePathOrUrl;
|
|
154
|
+
}
|
|
155
|
+
throw new Error('This parameter expects a file path, not a URL.');
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return await context.validatePath(filePathOrUrl);
|
|
159
|
+
}
|
|
160
|
+
function isLocalBrowser(browser) {
|
|
161
|
+
if (browser.process()) {
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
const wsEndpoint = browser.wsEndpoint();
|
|
165
|
+
if (wsEndpoint && isLocalBrowserEndpoint(wsEndpoint)) {
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
function shouldValidateFile(option, isLocal) {
|
|
171
|
+
if (option === true) {
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
if (typeof option === 'object' && option !== null) {
|
|
175
|
+
if (isLocal) {
|
|
176
|
+
return Boolean(option.local);
|
|
177
|
+
}
|
|
178
|
+
return Boolean(option.remote);
|
|
179
|
+
}
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* `isLocal` tells whether files are accessed on the machine the server runs on,
|
|
184
|
+
* which is always the case for browserless tools.
|
|
185
|
+
*/
|
|
186
|
+
async function validateToolFiles(tool, params, context, isLocal) {
|
|
187
|
+
for (const [key, option] of Object.entries(tool.verifyFilesSchema)) {
|
|
188
|
+
if (shouldValidateFile(option, isLocal)) {
|
|
189
|
+
const allowUrl = option !== true && option.allowUrl === true;
|
|
190
|
+
const val = params[key];
|
|
191
|
+
if (typeof val === 'string') {
|
|
192
|
+
params[key] = await validateAndResolvePathOrUrl(val, context, allowUrl);
|
|
193
|
+
}
|
|
194
|
+
else if (Array.isArray(val)) {
|
|
195
|
+
const updated = [];
|
|
196
|
+
for (const item of val) {
|
|
197
|
+
if (typeof item === 'string') {
|
|
198
|
+
const resolved = await validateAndResolvePathOrUrl(item, context, allowUrl);
|
|
199
|
+
if (resolved !== undefined) {
|
|
200
|
+
updated.push(resolved);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
throw new Error('Unexpected non-string value as a file path or URL');
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
params[key] = updated;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function toInputJsonSchema(schema) {
|
|
213
|
+
return zod.toJSONSchema(schema, { io: 'input', unrepresentable: 'any' });
|
|
214
|
+
}
|
|
215
|
+
function formatValidationError(toolName, error) {
|
|
216
|
+
const details = error.issues
|
|
217
|
+
.map(issue => `${issue.path.length > 0 ? `${issue.path.join('.')}: ` : ''}${issue.message}`)
|
|
218
|
+
.join(', ');
|
|
219
|
+
return `Input validation error: Invalid arguments for tool ${toolName}: ${details}`;
|
|
220
|
+
}
|
|
221
|
+
function errorResult(text) {
|
|
222
|
+
return {
|
|
223
|
+
content: [{ type: 'text', text }],
|
|
224
|
+
isError: true,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* The page id a page tool call targets, or `undefined` when the call targets
|
|
229
|
+
* the selected page. `args` can be the raw or the parsed arguments.
|
|
230
|
+
*/
|
|
231
|
+
function routedPageId(tool, serverArgs, args) {
|
|
232
|
+
if (!serverArgs.pageIdRouting || isSlimTool(tool)) {
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
const { pageId } = args;
|
|
236
|
+
return typeof pageId === 'number' && Number.isInteger(pageId)
|
|
237
|
+
? pageId
|
|
238
|
+
: undefined;
|
|
239
|
+
}
|
|
240
|
+
export class ToolHandler {
|
|
241
|
+
getContext;
|
|
242
|
+
abandonPendingBrowserAttemptOnTimeout;
|
|
243
|
+
#tool;
|
|
244
|
+
#config;
|
|
245
|
+
#registeredInputSchema;
|
|
246
|
+
#disabled = false;
|
|
247
|
+
#disabledReason;
|
|
248
|
+
constructor(tool, config, getContext, abandonPendingBrowserAttemptOnTimeout) {
|
|
249
|
+
this.getContext = getContext;
|
|
250
|
+
this.abandonPendingBrowserAttemptOnTimeout = abandonPendingBrowserAttemptOnTimeout;
|
|
251
|
+
this.#tool = tool;
|
|
252
|
+
this.#config = config;
|
|
253
|
+
this.#registeredInputSchema = zod.object(tool.schema).strict();
|
|
254
|
+
this.#updateStatus(tool);
|
|
255
|
+
}
|
|
256
|
+
get registeredInputSchema() {
|
|
257
|
+
return this.#registeredInputSchema;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Whether the tool is hidden from the client.
|
|
261
|
+
*/
|
|
262
|
+
get disabled() {
|
|
263
|
+
return this.#disabled;
|
|
264
|
+
}
|
|
265
|
+
#updateStatus(tool) {
|
|
266
|
+
const serverArgs = this.#config.resolved;
|
|
267
|
+
this.#disabledReason = getDisabledReason(tool, serverArgs);
|
|
268
|
+
this.#disabled =
|
|
269
|
+
Boolean(this.#disabledReason) &&
|
|
270
|
+
(!isAvailableInMode(tool, serverArgs) || !serverArgs.viaCli);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Replaces the tool definition and re-evaluates its status against the
|
|
274
|
+
* current server config. Callers must pause the task runner, so calls that
|
|
275
|
+
* are already waiting run with the new state. Returns true if the tool
|
|
276
|
+
* listing visible to the client changed.
|
|
277
|
+
*/
|
|
278
|
+
update(tool) {
|
|
279
|
+
const previousTool = this.#tool;
|
|
280
|
+
const previousDisabled = this.#disabled;
|
|
281
|
+
const previousInputSchema = this.#registeredInputSchema;
|
|
282
|
+
const nextInputSchema = zod.object(tool.schema).strict();
|
|
283
|
+
this.#tool = tool;
|
|
284
|
+
this.#registeredInputSchema = nextInputSchema;
|
|
285
|
+
this.#updateStatus(tool);
|
|
286
|
+
if (previousDisabled !== this.#disabled) {
|
|
287
|
+
return true;
|
|
288
|
+
}
|
|
289
|
+
if (this.#disabled) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
return (previousTool.description !== tool.description ||
|
|
293
|
+
!isDeepStrictEqual(previousTool.annotations, tool.annotations) ||
|
|
294
|
+
!isDeepStrictEqual(toInputJsonSchema(previousInputSchema), toInputJsonSchema(nextInputSchema)));
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Races a promise against TOOL_CALL_TIMEOUT_MS and signal abort, calling
|
|
298
|
+
* onTimeout() only if the timer wins, never on abort.
|
|
299
|
+
* The loser of the race is left running — there is no way to
|
|
300
|
+
* cancel a pending connect/launch — but since nothing is left awaiting it,
|
|
301
|
+
* it cannot block subsequent tool calls.
|
|
302
|
+
*/
|
|
303
|
+
async #raceWithTimeout(promise, onTimeout, signal) {
|
|
304
|
+
const timeoutError = new ToolCallTimeoutError(`Tool "${this.#tool.name}" timed out after ${TOOL_CALL_TIMEOUT_MS}ms waiting for the browser connection to be established. The connection attempt will be retried automatically on the next tool call.`);
|
|
305
|
+
let timer;
|
|
306
|
+
const timeout = new Promise((_, reject) => {
|
|
307
|
+
timer = setTimeout(() => reject(timeoutError), TOOL_CALL_TIMEOUT_MS);
|
|
308
|
+
timer.unref?.();
|
|
309
|
+
});
|
|
310
|
+
try {
|
|
311
|
+
return await raceWithSignal(Promise.race([promise, timeout]), signal);
|
|
312
|
+
}
|
|
313
|
+
catch (err) {
|
|
314
|
+
if (err === timeoutError) {
|
|
315
|
+
onTimeout();
|
|
316
|
+
}
|
|
317
|
+
throw err;
|
|
318
|
+
}
|
|
319
|
+
finally {
|
|
320
|
+
clearTimeout(timer);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
#dataFormat(serverArgs) {
|
|
324
|
+
// --experimentalDataFormat takes precedence over the legacy
|
|
325
|
+
// --experimentalToonFormat.
|
|
326
|
+
return (serverArgs.experimentalDataFormat ??
|
|
327
|
+
(serverArgs.experimentalToonFormat ? 'toon' : 'default'));
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Browserless tools never establish a browser connection, so they also never
|
|
331
|
+
* wait for one under TOOL_CALL_TIMEOUT_MS.
|
|
332
|
+
*/
|
|
333
|
+
async #runBrowserlessTool(tool, params, response, context, signal) {
|
|
334
|
+
try {
|
|
335
|
+
await validateToolFiles(tool, params, context, true);
|
|
336
|
+
signal.throwIfAborted();
|
|
337
|
+
await tool.handler({ params }, response, context);
|
|
338
|
+
}
|
|
339
|
+
catch (err) {
|
|
340
|
+
signal.throwIfAborted();
|
|
341
|
+
response.setError(toError(err));
|
|
342
|
+
}
|
|
343
|
+
signal.throwIfAborted();
|
|
344
|
+
return await response.handle(context, this.#dataFormat(this.#config.resolved));
|
|
345
|
+
}
|
|
346
|
+
async #runBrowserTool(tool, params, response, context, signal, onTelemetryData) {
|
|
347
|
+
// ensureBrowser() has no cancellation mechanism, so this timeout only
|
|
348
|
+
// stops us from waiting — the attempt itself keeps running abandoned.
|
|
349
|
+
// abandonPendingBrowserAttemptOnTimeout() tells BrowserManager to
|
|
350
|
+
// discard that attempt if it succeeds later instead of handing it to a
|
|
351
|
+
// subsequent caller — see BrowserManager#abandonPendingAttempt()'s doc
|
|
352
|
+
// comment for the full mechanism.
|
|
353
|
+
const browser = await this.#raceWithTimeout(context.ensureBrowser(), () => this.abandonPendingBrowserAttemptOnTimeout(), signal);
|
|
354
|
+
logger?.(`${tool.name} browser: resolved`);
|
|
355
|
+
if (context.consumeReconnectNotice()) {
|
|
356
|
+
response.setReconnectNotice();
|
|
357
|
+
}
|
|
358
|
+
let page;
|
|
359
|
+
try {
|
|
360
|
+
await validateToolFiles(tool, params, context, isLocalBrowser(browser));
|
|
361
|
+
signal.throwIfAborted();
|
|
362
|
+
if (isPageScopedTool(tool)) {
|
|
363
|
+
const pageId = routedPageId(tool, this.#config.resolved, params);
|
|
364
|
+
page =
|
|
365
|
+
pageId !== undefined
|
|
366
|
+
? context.getPageById(pageId)
|
|
367
|
+
: context.getSelectedMcpPage();
|
|
368
|
+
await page?.init({ emulateFocus: true });
|
|
369
|
+
signal.throwIfAborted();
|
|
370
|
+
response.setPage(page);
|
|
371
|
+
// A call that runs beside others can't tell its own errors apart.
|
|
372
|
+
if (tool.concurrency !== 'none') {
|
|
373
|
+
response.includeConsoleErrorsFrom(page);
|
|
374
|
+
}
|
|
375
|
+
if (tool.blockedByDialog) {
|
|
376
|
+
page.throwIfDialogOpen();
|
|
377
|
+
}
|
|
378
|
+
await tool.handler({
|
|
379
|
+
params,
|
|
380
|
+
page,
|
|
381
|
+
}, response, context);
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
await tool.handler({
|
|
385
|
+
params,
|
|
386
|
+
}, response, context);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
catch (err) {
|
|
390
|
+
signal.throwIfAborted();
|
|
391
|
+
response.setError(toError(err));
|
|
392
|
+
}
|
|
393
|
+
signal.throwIfAborted();
|
|
394
|
+
const devToolsData = await context.getDevToolsData(page);
|
|
395
|
+
signal.throwIfAborted();
|
|
396
|
+
onTelemetryData(devToolsData, context.getSelectedMcpPageUrl(page));
|
|
397
|
+
return await response.handle(context, this.#dataFormat(this.#config.resolved));
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* The queue the call runs on. `'none'` tools run outside the runner.
|
|
401
|
+
* `'page'` tools run on the queue of the page named by `rawArgs.pageId`
|
|
402
|
+
* when page id routing applies; every other call runs on the context
|
|
403
|
+
* queue.
|
|
404
|
+
*/
|
|
405
|
+
#queueFor(context, rawArgs) {
|
|
406
|
+
const tool = this.#tool;
|
|
407
|
+
switch (tool.concurrency) {
|
|
408
|
+
case 'none':
|
|
409
|
+
return undefined;
|
|
410
|
+
case 'page': {
|
|
411
|
+
const pageId = routedPageId(tool, this.#config.resolved, rawArgs);
|
|
412
|
+
return pageId !== undefined
|
|
413
|
+
? context.pageTaskQueue(pageId)
|
|
414
|
+
: context.taskQueue;
|
|
415
|
+
}
|
|
416
|
+
default:
|
|
417
|
+
return context.taskQueue;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Cancellation stops waiting for a result, but running work keeps its queue
|
|
422
|
+
* until it settles, including response processing, to preserve serialization.
|
|
423
|
+
* Operations without cancellation support can keep the queue indefinitely.
|
|
424
|
+
*/
|
|
425
|
+
async handle(rawArgs = {}, options) {
|
|
426
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
427
|
+
try {
|
|
428
|
+
const signal = options?.signal ?? new AbortController().signal;
|
|
429
|
+
signal.throwIfAborted();
|
|
430
|
+
const context = await raceWithSignal(this.getContext(), signal);
|
|
431
|
+
// Loaded before the call takes its queue, so waiting never holds a queue.
|
|
432
|
+
const createResponse = await raceWithSignal(loadResponseFactory(), signal);
|
|
433
|
+
let queueGuard;
|
|
434
|
+
try {
|
|
435
|
+
queueGuard = await this.#queueFor(context, rawArgs)?.scheduleTask(signal);
|
|
436
|
+
}
|
|
437
|
+
catch (err) {
|
|
438
|
+
signal.throwIfAborted();
|
|
439
|
+
// The queue was disposed while the call waited, e.g. the page closed.
|
|
440
|
+
return errorResult(getErrorMessage(err));
|
|
441
|
+
}
|
|
442
|
+
const guard = __addDisposableResource(env_1, new DisposableStack(), false);
|
|
443
|
+
guard.use(queueGuard);
|
|
444
|
+
signal.throwIfAborted();
|
|
445
|
+
if (options?.viaMcp && this.#disabled) {
|
|
446
|
+
throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Tool ${this.#tool.name} disabled`);
|
|
447
|
+
}
|
|
448
|
+
if (this.#disabledReason) {
|
|
449
|
+
return errorResult(this.#disabledReason);
|
|
450
|
+
}
|
|
451
|
+
const tool = this.#tool;
|
|
452
|
+
const parseResult = this.#registeredInputSchema.safeParse(rawArgs);
|
|
453
|
+
if (!parseResult.success) {
|
|
454
|
+
return errorResult(formatValidationError(tool.name, parseResult.error));
|
|
455
|
+
}
|
|
456
|
+
const params = parseResult.data;
|
|
457
|
+
const startTime = Date.now();
|
|
458
|
+
let success = false;
|
|
459
|
+
let devToolsData;
|
|
460
|
+
let pageUrl;
|
|
461
|
+
try {
|
|
462
|
+
logger?.(`${tool.name} request: ${JSON.stringify(params, null, ' ')}`);
|
|
463
|
+
const response = createResponse(isSlimTool(tool), this.#config);
|
|
464
|
+
// The execution owns the queue even when its caller stops waiting.
|
|
465
|
+
const execution = isBrowserlessTool(tool)
|
|
466
|
+
? this.#runBrowserlessTool(tool, params, response, context, signal)
|
|
467
|
+
: this.#runBrowserTool(tool, params, response, context, signal, (data, url) => {
|
|
468
|
+
devToolsData = data;
|
|
469
|
+
pageUrl = url;
|
|
470
|
+
});
|
|
471
|
+
const executionGuard = guard.move();
|
|
472
|
+
const completion = execution.finally(() => executionGuard.dispose());
|
|
473
|
+
const { content, structuredContent } = await raceWithSignal(completion, signal);
|
|
474
|
+
const result = {
|
|
475
|
+
content,
|
|
476
|
+
};
|
|
477
|
+
if (response.error) {
|
|
478
|
+
result.isError = true;
|
|
479
|
+
}
|
|
480
|
+
success = true;
|
|
481
|
+
if (this.#config.resolved.experimentalStructuredContent) {
|
|
482
|
+
result.structuredContent = structuredContent;
|
|
483
|
+
}
|
|
484
|
+
return result;
|
|
485
|
+
}
|
|
486
|
+
catch (err) {
|
|
487
|
+
if (signal.aborted) {
|
|
488
|
+
logger?.(`${tool.name} cancelled:`, signal.reason);
|
|
489
|
+
}
|
|
490
|
+
signal.throwIfAborted();
|
|
491
|
+
logger?.(`${tool.name} error:`, err, err?.stack);
|
|
492
|
+
let errorText = err && typeof err === 'object' && 'message' in err
|
|
493
|
+
? err.message
|
|
494
|
+
: String(err);
|
|
495
|
+
let cause = err && typeof err === 'object' && 'cause' in err
|
|
496
|
+
? err.cause
|
|
497
|
+
: undefined;
|
|
498
|
+
const seenCauses = new Set([err]);
|
|
499
|
+
while (cause &&
|
|
500
|
+
typeof cause === 'object' &&
|
|
501
|
+
!seenCauses.has(cause) &&
|
|
502
|
+
'message' in cause &&
|
|
503
|
+
typeof cause.message === 'string') {
|
|
504
|
+
seenCauses.add(cause);
|
|
505
|
+
errorText += `\nCause: ${cause.message}`;
|
|
506
|
+
cause = 'cause' in cause ? cause.cause : undefined;
|
|
507
|
+
}
|
|
508
|
+
return errorResult(errorText);
|
|
509
|
+
}
|
|
510
|
+
finally {
|
|
511
|
+
void ClearcutLogger.get()?.logToolInvocation({
|
|
512
|
+
toolName: tool.name,
|
|
513
|
+
params: rawArgs,
|
|
514
|
+
schema: tool.schema,
|
|
515
|
+
success,
|
|
516
|
+
latencyMs: Date.now() - startTime,
|
|
517
|
+
devToolsData,
|
|
518
|
+
pageUrl,
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
catch (e_1) {
|
|
523
|
+
env_1.error = e_1;
|
|
524
|
+
env_1.hasError = true;
|
|
525
|
+
}
|
|
526
|
+
finally {
|
|
527
|
+
__disposeResources(env_1);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
//# sourceMappingURL=ToolHandler.js.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import child_process from 'node:child_process';
|
|
7
|
+
import fs from 'node:fs/promises';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import process from 'node:process';
|
|
10
|
+
import { PACKAGE_NAME } from '../version.js';
|
|
11
|
+
const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
|
|
12
|
+
function getRegistry() {
|
|
13
|
+
// Use the user's configured npm registry so update checks work behind
|
|
14
|
+
// corporate proxies and private registries. `npm config get registry`
|
|
15
|
+
// honors .npmrc files at every scope and respects npm_config_registry,
|
|
16
|
+
// so it covers direct CLI invocations as well as `npx` / `npm run`.
|
|
17
|
+
try {
|
|
18
|
+
const registry = child_process
|
|
19
|
+
.execSync('npm config get registry', {
|
|
20
|
+
encoding: 'utf8',
|
|
21
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
22
|
+
timeout: 5000,
|
|
23
|
+
windowsHide: true,
|
|
24
|
+
})
|
|
25
|
+
.trim()
|
|
26
|
+
.replace(/\/$/, '');
|
|
27
|
+
if (registry && registry !== 'undefined' && /^https?:\/\//.test(registry)) {
|
|
28
|
+
return registry;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// npm not on PATH or other errors, fall back to default.
|
|
33
|
+
}
|
|
34
|
+
return DEFAULT_REGISTRY;
|
|
35
|
+
}
|
|
36
|
+
const cachePath = process.argv[2];
|
|
37
|
+
if (cachePath) {
|
|
38
|
+
try {
|
|
39
|
+
const response = await fetch(`${getRegistry()}/${encodeURIComponent(PACKAGE_NAME)}/latest`);
|
|
40
|
+
const data = response.ok ? await response.json() : null;
|
|
41
|
+
if (data &&
|
|
42
|
+
typeof data === 'object' &&
|
|
43
|
+
'version' in data &&
|
|
44
|
+
typeof data.version === 'string') {
|
|
45
|
+
await fs.mkdir(path.dirname(cachePath), { recursive: true });
|
|
46
|
+
await fs.writeFile(cachePath, JSON.stringify({ version: data.version }));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// Ignore errors.
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=check-latest-version.js.map
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import '../utils/polyfill.js';
|
|
7
|
+
import process from 'node:process';
|
|
8
|
+
import { BrowserManager } from '../BrowserManager.js';
|
|
9
|
+
import { McpServer } from '../index.js';
|
|
10
|
+
import { ClearcutLogger } from '../telemetry/ClearcutLogger.js';
|
|
11
|
+
import { computeFlagUsage } from '../telemetry/flagUtils.js';
|
|
12
|
+
import { StdioServerTransport } from '../third_party/index.js';
|
|
13
|
+
import { checkForUpdates } from '../utils/check-for-updates.js';
|
|
14
|
+
import { logDisclaimers } from '../utils/disclaimers.js';
|
|
15
|
+
import { logger, saveLogsToFile } from '../utils/logger.js';
|
|
16
|
+
import { setupUnhandledRejectionHandler } from '../utils/errorHandling.js';
|
|
17
|
+
import { PACKAGE_NAME, VERSION } from '../version.js';
|
|
18
|
+
import { mcpOptions } from '../config/mcp-options.js';
|
|
19
|
+
import { ConfigParser } from '../config/ConfigParser.js';
|
|
20
|
+
await checkForUpdates(`Run \`npm install ${PACKAGE_NAME}@latest\` to update.`);
|
|
21
|
+
const configParser = new ConfigParser(VERSION);
|
|
22
|
+
const serverConfig = configParser.parseConfig();
|
|
23
|
+
const args = serverConfig.resolved;
|
|
24
|
+
const logFile = args.logFile ? saveLogsToFile(args.logFile) : undefined;
|
|
25
|
+
setupUnhandledRejectionHandler(() => {
|
|
26
|
+
process.exit(1);
|
|
27
|
+
});
|
|
28
|
+
logger?.(`Starting Chrome DevTools MCP Server v${VERSION}`);
|
|
29
|
+
const browserManager = new BrowserManager(serverConfig, {
|
|
30
|
+
logFile,
|
|
31
|
+
});
|
|
32
|
+
const serverPromise = McpServer.from(serverConfig, {
|
|
33
|
+
browserManager,
|
|
34
|
+
});
|
|
35
|
+
// Shutdown on stdin EOF (stdio MCP convention — the client closes the
|
|
36
|
+
// transport to signal exit) and on standard termination signals. Without
|
|
37
|
+
// this, an active Chrome subprocess keeps the Node event loop ref'd after
|
|
38
|
+
// stdin closes and the server hangs until something else kills it.
|
|
39
|
+
let shuttingDown = false;
|
|
40
|
+
async function shutdown(reason) {
|
|
41
|
+
if (shuttingDown) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
shuttingDown = true;
|
|
45
|
+
logger?.(`Shutting down (${reason})`);
|
|
46
|
+
// Backstop in case browser teardown hangs (e.g. unresponsive Chrome,
|
|
47
|
+
// slow beforeunload handlers, many tabs). Exits 0 because we still
|
|
48
|
+
// honored the shutdown request; the log line preserves observability.
|
|
49
|
+
// Unref'd so it doesn't keep the loop alive on the clean path.
|
|
50
|
+
setTimeout(() => {
|
|
51
|
+
logger?.('Shutdown timeout exceeded, forcing exit');
|
|
52
|
+
process.exit(0);
|
|
53
|
+
}, 5000).unref();
|
|
54
|
+
const server = await serverPromise;
|
|
55
|
+
await server.close();
|
|
56
|
+
process.exit(0);
|
|
57
|
+
}
|
|
58
|
+
process.stdin.on('end', () => {
|
|
59
|
+
void shutdown('stdin end');
|
|
60
|
+
});
|
|
61
|
+
process.stdin.on('close', () => {
|
|
62
|
+
void shutdown('stdin close');
|
|
63
|
+
});
|
|
64
|
+
process.on('SIGTERM', () => {
|
|
65
|
+
void shutdown('SIGTERM');
|
|
66
|
+
});
|
|
67
|
+
process.on('SIGINT', () => {
|
|
68
|
+
void shutdown('SIGINT');
|
|
69
|
+
});
|
|
70
|
+
process.on('SIGHUP', () => {
|
|
71
|
+
void shutdown('SIGHUP');
|
|
72
|
+
});
|
|
73
|
+
const server = await serverPromise;
|
|
74
|
+
const transport = new StdioServerTransport();
|
|
75
|
+
await server.connect(transport);
|
|
76
|
+
logger?.('Chrome DevTools MCP Server connected');
|
|
77
|
+
logDisclaimers(args);
|
|
78
|
+
void ClearcutLogger.get()?.logDailyActiveIfNeeded();
|
|
79
|
+
void ClearcutLogger.get()?.logServerStart(computeFlagUsage(args, mcpOptions));
|
|
80
|
+
//# sourceMappingURL=chrome-devtools-mcp-main.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2025 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*/
|
|
7
|
+
import { version } from 'node:process';
|
|
8
|
+
process.title = 'chrome-devtools-mcp';
|
|
9
|
+
const [major, minor] = version.substring(1).split('.').map(Number);
|
|
10
|
+
if (major === 20 && minor < 19) {
|
|
11
|
+
console.error(`ERROR: \`chrome-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: \`chrome-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: \`chrome-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('./chrome-devtools-mcp-main.js');
|
|
23
|
+
//# sourceMappingURL=chrome-devtools-mcp.js.map
|