@chenpx976/chrome-devtools-mcp 0.0.0-stage → 1.13.1
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 +174 -0
- package/skills/arc-compatibility/SOURCES.md +238 -0
- package/skills/arc-compatibility/references/compatibility.md +115 -0
- package/skills/arc-compatibility/references/output-contract.md +62 -0
- package/skills/arc-compatibility/references/workflows.md +108 -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,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { truncateUrl } from '../utils/text.js';
|
|
7
|
+
export class SnapshotFormatter {
|
|
8
|
+
#snapshot;
|
|
9
|
+
constructor(snapshot) {
|
|
10
|
+
this.#snapshot = snapshot;
|
|
11
|
+
}
|
|
12
|
+
toString() {
|
|
13
|
+
const chunks = [];
|
|
14
|
+
const root = this.#snapshot.root;
|
|
15
|
+
// Top-level content of the snapshot.
|
|
16
|
+
if (!this.#snapshot.verbose &&
|
|
17
|
+
this.#snapshot.hasSelectedElement &&
|
|
18
|
+
!this.#snapshot.selectedElementUid) {
|
|
19
|
+
chunks.push(`Note: there is a selected element in the DevTools Elements panel but it is not included into the current a11y tree snapshot.
|
|
20
|
+
Get a verbose snapshot to include all elements if you are interested in the selected element.\n\n`);
|
|
21
|
+
}
|
|
22
|
+
chunks.push(this.#formatNode(root, 0));
|
|
23
|
+
return chunks.join('');
|
|
24
|
+
}
|
|
25
|
+
toJSON() {
|
|
26
|
+
return this.#nodeToJSON(this.#snapshot.root);
|
|
27
|
+
}
|
|
28
|
+
#formatNode(node, depth = 0) {
|
|
29
|
+
const chunks = [];
|
|
30
|
+
const attributes = this.#getAttributes(node);
|
|
31
|
+
const line = ' '.repeat(depth * 2) +
|
|
32
|
+
attributes.join(' ') +
|
|
33
|
+
(node.id && node.id === this.#snapshot.selectedElementUid
|
|
34
|
+
? ' [selected in the DevTools Elements panel]'
|
|
35
|
+
: '') +
|
|
36
|
+
'\n';
|
|
37
|
+
chunks.push(line);
|
|
38
|
+
if (!this.#hasRedundantTextChildren(node)) {
|
|
39
|
+
for (const child of node.children) {
|
|
40
|
+
chunks.push(this.#formatNode(child, depth + 1));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return chunks.join('');
|
|
44
|
+
}
|
|
45
|
+
#hasRedundantTextChildren(node) {
|
|
46
|
+
if (this.#snapshot.verbose || !node.name || node.children.length === 0) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
let text = '';
|
|
50
|
+
for (const child of node.children) {
|
|
51
|
+
if (child.role !== 'StaticText' ||
|
|
52
|
+
child.children.length !== 0 ||
|
|
53
|
+
child.id === this.#snapshot.selectedElementUid) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
text += child.name ?? '';
|
|
57
|
+
}
|
|
58
|
+
return stripWhitespace(text) === stripWhitespace(node.name);
|
|
59
|
+
}
|
|
60
|
+
#nodeToJSON(node) {
|
|
61
|
+
const rawAttrs = this.#getAttributesMap(node);
|
|
62
|
+
const children = node.children.map(child => this.#nodeToJSON(child));
|
|
63
|
+
const result = structuredClone(rawAttrs);
|
|
64
|
+
if (children.length > 0) {
|
|
65
|
+
result.children = children;
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
#getAttributes(serializedAXNodeRoot) {
|
|
70
|
+
const attributes = [];
|
|
71
|
+
if (serializedAXNodeRoot.id) {
|
|
72
|
+
attributes.push(`uid=${serializedAXNodeRoot.id}`);
|
|
73
|
+
}
|
|
74
|
+
if (serializedAXNodeRoot.role &&
|
|
75
|
+
serializedAXNodeRoot.role !== 'StaticText') {
|
|
76
|
+
attributes.push(serializedAXNodeRoot.role === 'none'
|
|
77
|
+
? 'ignored'
|
|
78
|
+
: serializedAXNodeRoot.role);
|
|
79
|
+
}
|
|
80
|
+
if (serializedAXNodeRoot.name) {
|
|
81
|
+
attributes.push(`"${serializedAXNodeRoot.name}"`);
|
|
82
|
+
}
|
|
83
|
+
const simpleAttrs = this.#getAttributesMap(serializedAXNodeRoot,
|
|
84
|
+
/* excludeSpecial */ true);
|
|
85
|
+
const isOption = serializedAXNodeRoot.role === 'option';
|
|
86
|
+
for (const attr of Object.keys(serializedAXNodeRoot).sort()) {
|
|
87
|
+
if (excludedAttributes.has(attr)) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const mapped = booleanPropertyMap[attr];
|
|
91
|
+
if (mapped &&
|
|
92
|
+
simpleAttrs[mapped] &&
|
|
93
|
+
!(isOption && mapped === 'selectable')) {
|
|
94
|
+
attributes.push(mapped);
|
|
95
|
+
}
|
|
96
|
+
const val = simpleAttrs[attr];
|
|
97
|
+
if (isOption && attr === 'value' && val === serializedAXNodeRoot.name) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (val === true) {
|
|
101
|
+
attributes.push(attr);
|
|
102
|
+
}
|
|
103
|
+
else if (typeof val === 'string' || typeof val === 'number') {
|
|
104
|
+
attributes.push(`${attr}="${val}"`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return attributes;
|
|
108
|
+
}
|
|
109
|
+
#getAttributesMap(node, excludeSpecial = false) {
|
|
110
|
+
const result = {};
|
|
111
|
+
if (!excludeSpecial) {
|
|
112
|
+
if (node.id) {
|
|
113
|
+
result.id = node.id;
|
|
114
|
+
}
|
|
115
|
+
if (node.role) {
|
|
116
|
+
result.role = node.role;
|
|
117
|
+
}
|
|
118
|
+
if (node.name) {
|
|
119
|
+
result.name = node.name;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// Re-implementing the exact logic from original function for #getAttributes to be safe:
|
|
123
|
+
return {
|
|
124
|
+
...result,
|
|
125
|
+
...this.#extractedAttributes(node),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
#extractedAttributes(node) {
|
|
129
|
+
const result = {};
|
|
130
|
+
for (const attr of Object.keys(node).sort()) {
|
|
131
|
+
if (excludedAttributes.has(attr)) {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
const value = node[attr];
|
|
135
|
+
if (typeof value === 'boolean') {
|
|
136
|
+
if (booleanPropertyMap[attr]) {
|
|
137
|
+
result[booleanPropertyMap[attr]] = true;
|
|
138
|
+
}
|
|
139
|
+
if (value) {
|
|
140
|
+
result[attr] = true;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else if (attr === 'url' && typeof value === 'string') {
|
|
144
|
+
// Keep other URLs whole: the snapshot is their only full copy.
|
|
145
|
+
result[attr] = value.startsWith('data:') ? truncateUrl(value) : value;
|
|
146
|
+
}
|
|
147
|
+
else if (typeof value === 'string' || typeof value === 'number') {
|
|
148
|
+
result[attr] = value;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const booleanPropertyMap = {
|
|
155
|
+
disabled: 'disableable',
|
|
156
|
+
expanded: 'expandable',
|
|
157
|
+
focused: 'focusable',
|
|
158
|
+
selected: 'selectable',
|
|
159
|
+
};
|
|
160
|
+
const excludedAttributes = new Set([
|
|
161
|
+
'id',
|
|
162
|
+
'role',
|
|
163
|
+
'name',
|
|
164
|
+
'elementHandle',
|
|
165
|
+
'children',
|
|
166
|
+
'backendNodeId',
|
|
167
|
+
'loaderId',
|
|
168
|
+
]);
|
|
169
|
+
function stripWhitespace(text) {
|
|
170
|
+
return text.replace(/\s+/g, '');
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=SnapshotFormatter.js.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
function formatAuthenticator(authenticator) {
|
|
7
|
+
const lines = [
|
|
8
|
+
'## Virtual authenticator',
|
|
9
|
+
`protocol=${authenticator.protocol}, transport=${authenticator.transport}, hasResidentKey=${authenticator.hasResidentKey}, hasUserVerification=${authenticator.hasUserVerification}, isUserVerified=${authenticator.isUserVerified}`,
|
|
10
|
+
];
|
|
11
|
+
if (!authenticator.credentials.length) {
|
|
12
|
+
lines.push('No credentials.');
|
|
13
|
+
return lines.join('\n');
|
|
14
|
+
}
|
|
15
|
+
lines.push('### Credentials');
|
|
16
|
+
for (const credential of authenticator.credentials) {
|
|
17
|
+
const fields = [
|
|
18
|
+
`credentialId=${credential.credentialId}`,
|
|
19
|
+
`rpId=${credential.rpId ?? 'unknown'}`,
|
|
20
|
+
`discoverable=${credential.isResidentCredential}`,
|
|
21
|
+
`signCount=${credential.signCount}`,
|
|
22
|
+
];
|
|
23
|
+
if (credential.userName) {
|
|
24
|
+
fields.push(`userName=${credential.userName}`);
|
|
25
|
+
}
|
|
26
|
+
lines.push(`- ${fields.join(', ')}`);
|
|
27
|
+
}
|
|
28
|
+
return lines.join('\n');
|
|
29
|
+
}
|
|
30
|
+
export class WebAuthnFormatter {
|
|
31
|
+
#authenticator;
|
|
32
|
+
constructor(authenticator) {
|
|
33
|
+
this.#authenticator = authenticator;
|
|
34
|
+
}
|
|
35
|
+
toJSON() {
|
|
36
|
+
if (!this.#authenticator) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
...this.#authenticator,
|
|
41
|
+
credentials: this.#authenticator.credentials.map(credential => ({
|
|
42
|
+
...credential,
|
|
43
|
+
// Match PublicKeyCredential.id, which the page sees as base64url.
|
|
44
|
+
credentialId: Buffer.from(credential.credentialId, 'base64').toString('base64url'),
|
|
45
|
+
})),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
toString() {
|
|
49
|
+
const authenticator = this.toJSON();
|
|
50
|
+
if (!authenticator) {
|
|
51
|
+
return 'No virtual authenticator on this page.';
|
|
52
|
+
}
|
|
53
|
+
return formatAuthenticator(authenticator);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=WebAuthnFormatter.js.map
|
|
@@ -0,0 +1,434 @@
|
|
|
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 path from 'node:path';
|
|
59
|
+
import { pathToFileURL } from 'node:url';
|
|
60
|
+
import { BrowserManager } from './BrowserManager.js';
|
|
61
|
+
import { ConfigParser } from './config/ConfigParser.js';
|
|
62
|
+
import { ConfigWatcher } from './config/ConfigWatcher.js';
|
|
63
|
+
import { DEFAULT_FILESYSTEM_ROOT, } from './config/mcp-options.js';
|
|
64
|
+
import { ServerConfig } from './config/ServerConfig.js';
|
|
65
|
+
import { loadIssueDescriptions } from './devtools/issueDescriptions.js';
|
|
66
|
+
import { McpContext } from './McpContext.js';
|
|
67
|
+
import { HeapSnapshotManager } from './processors/HeapSnapshotManager.js';
|
|
68
|
+
import { ClearcutLogger } from './telemetry/ClearcutLogger.js';
|
|
69
|
+
import { FilePersistence } from './telemetry/persistence.js';
|
|
70
|
+
import { McpServer as SdkMcpServer, ProtocolError, ProtocolErrorCode, } from './third_party/index.js';
|
|
71
|
+
import { ToolHandler } from './ToolHandler.js';
|
|
72
|
+
import { createTools } from './tools/tools.js';
|
|
73
|
+
import { logCruxDisclaimer } from './utils/disclaimers.js';
|
|
74
|
+
import { getErrorMessage } from './utils/errorHandling.js';
|
|
75
|
+
import { logger } from './utils/logger.js';
|
|
76
|
+
import { TaskRunner } from './utils/TaskRunner.js';
|
|
77
|
+
import { VERSION } from './version.js';
|
|
78
|
+
/**
|
|
79
|
+
* Timeout for a `roots/list` that a tool call is waiting on, matching the 5s
|
|
80
|
+
* default used for page operations. `getContext()` awaits it before
|
|
81
|
+
* `ToolHandler` enters the task runner, so leaving it unbounded lets a client
|
|
82
|
+
* that negotiates `roots` but does not answer delay every tool for the SDK's
|
|
83
|
+
* default of 60s. Background refreshes are not bounded by this, so roots a
|
|
84
|
+
* slow client sends late still land.
|
|
85
|
+
*/
|
|
86
|
+
const ROOTS_REQUEST_TIMEOUT = 5_000;
|
|
87
|
+
export class McpServer {
|
|
88
|
+
server;
|
|
89
|
+
#config;
|
|
90
|
+
#browserManager;
|
|
91
|
+
#context;
|
|
92
|
+
/** Runs every tool call and config reload. */
|
|
93
|
+
#taskRunner = new TaskRunner();
|
|
94
|
+
#heapSnapshotManager = new HeapSnapshotManager(this.#taskRunner);
|
|
95
|
+
/**
|
|
96
|
+
* Client roots stay valid across browser reconnects and only the client can
|
|
97
|
+
* invalidate them through a `roots/list_changed` notification. CLI-configured
|
|
98
|
+
* roots are read from `#config` when combining roots.
|
|
99
|
+
*/
|
|
100
|
+
#lastClientRoots;
|
|
101
|
+
/**
|
|
102
|
+
* The bounded initial `roots/list` request. Every tool call that starts
|
|
103
|
+
* before the client answered waits on the same request, so a client that
|
|
104
|
+
* negotiates roots but never answers only delays the first calls.
|
|
105
|
+
*/
|
|
106
|
+
#initialRoots;
|
|
107
|
+
#configWatcher;
|
|
108
|
+
#tools = new Map();
|
|
109
|
+
constructor(config, options) {
|
|
110
|
+
this.#config = config;
|
|
111
|
+
this.#browserManager = options.browserManager;
|
|
112
|
+
const serverArgs = this.#config.resolved;
|
|
113
|
+
if (serverArgs.usageStatistics) {
|
|
114
|
+
ClearcutLogger.initialize({
|
|
115
|
+
persistence: new FilePersistence(),
|
|
116
|
+
logFile: serverArgs.logFile,
|
|
117
|
+
appVersion: VERSION,
|
|
118
|
+
clearcutEndpoint: serverArgs.clearcutEndpoint,
|
|
119
|
+
clearcutForceFlushIntervalMs: serverArgs.clearcutForceFlushIntervalMs,
|
|
120
|
+
clearcutIncludePidHeader: serverArgs.clearcutIncludePidHeader,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
this.server = new SdkMcpServer({
|
|
124
|
+
name: 'chrome_devtools',
|
|
125
|
+
title: 'Chrome DevTools MCP server',
|
|
126
|
+
version: VERSION,
|
|
127
|
+
}, {
|
|
128
|
+
capabilities: { logging: {}, tools: { listChanged: true } },
|
|
129
|
+
// Enabling or updating many tools at once sends a single notification.
|
|
130
|
+
debouncedNotificationMethods: ['notifications/tools/list_changed'],
|
|
131
|
+
});
|
|
132
|
+
this.#context = McpContext.create(logger, {
|
|
133
|
+
config: this.#config,
|
|
134
|
+
heapSnapshotManager: this.#heapSnapshotManager,
|
|
135
|
+
taskRunner: this.#taskRunner,
|
|
136
|
+
getBrowser: () => this.#browserManager.ensureBrowser(),
|
|
137
|
+
});
|
|
138
|
+
this.#context.setRoots(this.#combinedRoots());
|
|
139
|
+
this.server.server.setRequestHandler('logging/setLevel', () => {
|
|
140
|
+
return {};
|
|
141
|
+
});
|
|
142
|
+
this.server.server.oninitialized = () => {
|
|
143
|
+
const clientName = this.server.server.getClientVersion()?.name;
|
|
144
|
+
if (clientName) {
|
|
145
|
+
ClearcutLogger.get()?.setClientName(clientName);
|
|
146
|
+
}
|
|
147
|
+
if (this.server.server.getClientCapabilities()?.roots) {
|
|
148
|
+
void this.#updateRoots();
|
|
149
|
+
this.server.server.setNotificationHandler('notifications/roots/list_changed', () => {
|
|
150
|
+
void this.#updateRoots();
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
else if (!this.#config.resolved.allowUnrestrictedPaths &&
|
|
154
|
+
((this.#config.resolved.filesystemRoot ?? []).length === 0 ||
|
|
155
|
+
this.#config.resolved.filesystemRoot === DEFAULT_FILESYSTEM_ROOT)) {
|
|
156
|
+
console.warn('[chrome-devtools-mcp] The connecting client did not negotiate the MCP roots ' +
|
|
157
|
+
'capability. Tools that read or write local files will be restricted to the OS temp directory. ' +
|
|
158
|
+
'To restore the previous unrestricted behavior, start the server with ' +
|
|
159
|
+
'--allow-unrestricted-paths.');
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
async connect(transport) {
|
|
164
|
+
if (this.#config.resolved.watchConfig) {
|
|
165
|
+
this.watchConfig();
|
|
166
|
+
}
|
|
167
|
+
return await this.server.connect(transport);
|
|
168
|
+
}
|
|
169
|
+
async callTool(name, args = {}) {
|
|
170
|
+
const toolHandler = this.#tools.get(name)?.handler;
|
|
171
|
+
if (!toolHandler) {
|
|
172
|
+
return {
|
|
173
|
+
content: [
|
|
174
|
+
{
|
|
175
|
+
type: 'text',
|
|
176
|
+
text: `Tool ${name} not found`,
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
isError: true,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return await toolHandler.handle(args);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Applies a new config to the running server. Only reloadable options are
|
|
186
|
+
* applied, all other options keep the value the server was started with.
|
|
187
|
+
* Tools are updated in place and only tools whose listing changed notify
|
|
188
|
+
* the client, which results in at most one `tools/list_changed`
|
|
189
|
+
* notification.
|
|
190
|
+
*/
|
|
191
|
+
async applyConfig(config) {
|
|
192
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
193
|
+
try {
|
|
194
|
+
// Goes ahead of waiting tool calls and waits for running ones, so every
|
|
195
|
+
// waiting call runs with the new config.
|
|
196
|
+
const guard = __addDisposableResource(env_1, await this.#taskRunner.pause(), false);
|
|
197
|
+
await this.#applyConfigLocked(this.#config.mergeReloadable(config));
|
|
198
|
+
}
|
|
199
|
+
catch (e_1) {
|
|
200
|
+
env_1.error = e_1;
|
|
201
|
+
env_1.hasError = true;
|
|
202
|
+
}
|
|
203
|
+
finally {
|
|
204
|
+
__disposeResources(env_1);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
async #applyConfigLocked(nextConfig) {
|
|
208
|
+
const previousArgs = this.#config.resolved;
|
|
209
|
+
const nextArgs = nextConfig.resolved;
|
|
210
|
+
// Build everything before committing so that a throwing tool factory
|
|
211
|
+
// leaves the server untouched.
|
|
212
|
+
const updates = [];
|
|
213
|
+
for (const tool of createTools(nextArgs)) {
|
|
214
|
+
const entry = this.#tools.get(tool.name);
|
|
215
|
+
if (entry) {
|
|
216
|
+
updates.push({ entry, tool });
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
this.#config.commit(nextConfig);
|
|
220
|
+
for (const { entry, tool } of updates) {
|
|
221
|
+
if (entry.handler.update(tool)) {
|
|
222
|
+
entry.registeredTool.update({
|
|
223
|
+
description: tool.description,
|
|
224
|
+
paramsSchema: entry.handler.registeredInputSchema,
|
|
225
|
+
annotations: tool.annotations,
|
|
226
|
+
enabled: !entry.handler.disabled,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (!previousArgs.performanceCrux || previousArgs.slim) {
|
|
231
|
+
logCruxDisclaimer(nextArgs);
|
|
232
|
+
}
|
|
233
|
+
this.#context.setRoots(this.#combinedRoots());
|
|
234
|
+
await this.#context.onConfigChanged(previousArgs);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Watches the config file and applies its changes to the running server.
|
|
238
|
+
*/
|
|
239
|
+
watchConfig() {
|
|
240
|
+
const configPath = this.#config.configPath;
|
|
241
|
+
if (!configPath) {
|
|
242
|
+
console.error('--watchConfig has no effect because no config file was found.');
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
this.#configWatcher?.dispose();
|
|
246
|
+
this.#configWatcher = undefined;
|
|
247
|
+
const watcher = new ConfigWatcher(configPath, content => this.#reloadConfig(watcher, configPath, content));
|
|
248
|
+
try {
|
|
249
|
+
watcher.start();
|
|
250
|
+
}
|
|
251
|
+
catch (err) {
|
|
252
|
+
watcher.dispose();
|
|
253
|
+
console.error(`Failed to watch ${configPath}: ${getErrorMessage(err)}`);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
this.#configWatcher = watcher;
|
|
257
|
+
}
|
|
258
|
+
async #reloadConfig(watcher, configPath, content) {
|
|
259
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
260
|
+
try {
|
|
261
|
+
const guard = __addDisposableResource(env_2, await this.#taskRunner.pause(), false);
|
|
262
|
+
if (this.#configWatcher !== watcher) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
let config;
|
|
266
|
+
let nextConfig;
|
|
267
|
+
try {
|
|
268
|
+
const fileArgs = ConfigParser.parseConfigFile(configPath, content);
|
|
269
|
+
config = this.#config.withFileArgs(fileArgs);
|
|
270
|
+
nextConfig = this.#config.mergeReloadable(config);
|
|
271
|
+
}
|
|
272
|
+
catch (err) {
|
|
273
|
+
const message = `Keeping the previous configuration, failed to reload ${configPath}: ${getErrorMessage(err)}`;
|
|
274
|
+
logger?.(message);
|
|
275
|
+
console.error(message);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
await this.#applyConfigLocked(nextConfig);
|
|
279
|
+
const restartRequired = this.#config.getRestartRequiredChanges(config);
|
|
280
|
+
logger?.(`Applied config changes from ${configPath}`);
|
|
281
|
+
if (restartRequired.length > 0) {
|
|
282
|
+
const message = `Restart chrome-devtools-mcp to fully apply changes to ${restartRequired.map(name => `--${name}`).join(', ')} from ${configPath}.`;
|
|
283
|
+
logger?.(message);
|
|
284
|
+
console.error(message);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
catch (e_2) {
|
|
288
|
+
env_2.error = e_2;
|
|
289
|
+
env_2.hasError = true;
|
|
290
|
+
}
|
|
291
|
+
finally {
|
|
292
|
+
__disposeResources(env_2);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Closes the MCP connection and disposes internal context/listeners.
|
|
297
|
+
*/
|
|
298
|
+
async close() {
|
|
299
|
+
this.#configWatcher?.dispose();
|
|
300
|
+
this.#configWatcher = undefined;
|
|
301
|
+
try {
|
|
302
|
+
this.#context.dispose();
|
|
303
|
+
}
|
|
304
|
+
catch (err) {
|
|
305
|
+
logger?.('Failed to dispose context', err);
|
|
306
|
+
}
|
|
307
|
+
this.#heapSnapshotManager.dispose();
|
|
308
|
+
await Promise.allSettled([
|
|
309
|
+
this.#browserManager.close(),
|
|
310
|
+
this.server.close(),
|
|
311
|
+
]);
|
|
312
|
+
}
|
|
313
|
+
[Symbol.dispose]() {
|
|
314
|
+
this.close().catch(err => {
|
|
315
|
+
logger?.('Failed to dispose McpServer', err);
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
async [Symbol.asyncDispose]() {
|
|
319
|
+
await this.close();
|
|
320
|
+
}
|
|
321
|
+
static async from(config, options) {
|
|
322
|
+
const server = new McpServer(config, options);
|
|
323
|
+
await server.#init();
|
|
324
|
+
return server;
|
|
325
|
+
}
|
|
326
|
+
async #init() {
|
|
327
|
+
// Tool definitions take a ParsedArguments snapshot; reload recreates them.
|
|
328
|
+
for (const tool of createTools(this.#config.resolved)) {
|
|
329
|
+
this.#registerTool(tool);
|
|
330
|
+
}
|
|
331
|
+
this.#setToolCallRequestHandler();
|
|
332
|
+
await loadIssueDescriptions();
|
|
333
|
+
}
|
|
334
|
+
#combinedRoots() {
|
|
335
|
+
const serverArgs = this.#config.resolved;
|
|
336
|
+
const configuredRoots = (serverArgs.allowUnrestrictedPaths ? [] : (serverArgs.filesystemRoot ?? [])).map(root => {
|
|
337
|
+
const rootPath = path.resolve(root);
|
|
338
|
+
return {
|
|
339
|
+
uri: pathToFileURL(rootPath).href,
|
|
340
|
+
name: path.basename(rootPath) || rootPath,
|
|
341
|
+
};
|
|
342
|
+
});
|
|
343
|
+
if (configuredRoots.length === 0 && this.#lastClientRoots === undefined) {
|
|
344
|
+
return undefined;
|
|
345
|
+
}
|
|
346
|
+
return [...configuredRoots, ...(this.#lastClientRoots ?? [])];
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* `timeout` is only passed where a tool call is waiting on the result – the
|
|
350
|
+
* background refreshes (on initialization and `roots/list_changed`) block
|
|
351
|
+
* nobody, so bounding them would just discard roots a slow client was about
|
|
352
|
+
* to send
|
|
353
|
+
*/
|
|
354
|
+
async #updateRoots(timeout) {
|
|
355
|
+
if (!this.server.server.getClientCapabilities()?.roots) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
try {
|
|
359
|
+
const result = await this.server.server.request({ method: 'roots/list' }, timeout === undefined ? undefined : { timeout });
|
|
360
|
+
this.#lastClientRoots = result.roots;
|
|
361
|
+
this.#context.setRoots(this.#combinedRoots());
|
|
362
|
+
}
|
|
363
|
+
catch (e) {
|
|
364
|
+
logger?.('Failed to list roots', e);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
async #getContext() {
|
|
368
|
+
if (this.#lastClientRoots === undefined) {
|
|
369
|
+
// Nothing listed yet, so this call has to wait – bounded, since every
|
|
370
|
+
// tool call waits on it, and a later background refresh still lands
|
|
371
|
+
this.#initialRoots ??= this.#updateRoots(ROOTS_REQUEST_TIMEOUT);
|
|
372
|
+
await this.#initialRoots;
|
|
373
|
+
}
|
|
374
|
+
return this.#context;
|
|
375
|
+
}
|
|
376
|
+
#createToolHandler(tool) {
|
|
377
|
+
return new ToolHandler(tool, this.#config, () => this.#getContext(), () => this.#browserManager.abandonPendingAttempt());
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Overrides the SDK's `tools/call` handler so enabled and input-schema
|
|
381
|
+
* checks run inside `ToolHandler.handle()` inside the task runner.
|
|
382
|
+
*/
|
|
383
|
+
#setToolCallRequestHandler() {
|
|
384
|
+
this.server.server.setRequestHandler('tools/call', async (request, ctx) => {
|
|
385
|
+
const entry = this.#tools.get(request.params.name);
|
|
386
|
+
if (!entry) {
|
|
387
|
+
throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Tool ${request.params.name} not found`);
|
|
388
|
+
}
|
|
389
|
+
const result = await entry.handler.handle(request.params.arguments, {
|
|
390
|
+
viaMcp: true,
|
|
391
|
+
signal: ctx.mcpReq.signal,
|
|
392
|
+
});
|
|
393
|
+
return this.server.server.projectCallToolResult(result, undefined);
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
#registerTool(tool) {
|
|
397
|
+
const handler = this.#createToolHandler(tool);
|
|
398
|
+
const registeredTool = this.server.registerTool(tool.name, {
|
|
399
|
+
description: tool.description,
|
|
400
|
+
inputSchema: handler.registeredInputSchema,
|
|
401
|
+
annotations: tool.annotations,
|
|
402
|
+
}, args => handler.handle(args));
|
|
403
|
+
if (handler.disabled) {
|
|
404
|
+
registeredTool.disable();
|
|
405
|
+
}
|
|
406
|
+
this.#tools.set(tool.name, { handler, registeredTool });
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Creates and initializes a Chrome DevTools MCP server instance.
|
|
411
|
+
*
|
|
412
|
+
* Maintained as a public API for backwards compatibility because external
|
|
413
|
+
* consumers and integrations rely on `createMcpServer()`. For new code,
|
|
414
|
+
* prefer using `McpServer.from(config, options)`.
|
|
415
|
+
*/
|
|
416
|
+
export async function createMcpServer(serverArgs, options) {
|
|
417
|
+
// createMcpServer takes a flat ParsedArguments snapshot and only returns
|
|
418
|
+
// SdkMcpServer, so instances created here are never reloaded.
|
|
419
|
+
const serverConfig = new ServerConfig({
|
|
420
|
+
cliArgs: {},
|
|
421
|
+
fileArgs: {},
|
|
422
|
+
configPath: undefined,
|
|
423
|
+
resolved: serverArgs,
|
|
424
|
+
});
|
|
425
|
+
const browserManager = new BrowserManager(serverConfig, {
|
|
426
|
+
logFile: options.logFile,
|
|
427
|
+
});
|
|
428
|
+
const server = await McpServer.from(serverConfig, {
|
|
429
|
+
browserManager,
|
|
430
|
+
...options,
|
|
431
|
+
});
|
|
432
|
+
return { server: server.server };
|
|
433
|
+
}
|
|
434
|
+
//# sourceMappingURL=index.js.map
|