Repository navigation
Conversation
…t ergonomics - Add skills/chrome-devtools-sdk/SKILL.md and README SDK documentation (verified in verify-npm-package.js). - Emit per-tool JSDoc descriptions and typed return shapes (evaluate_script.result, get_css_styles.matchedStyles, take_screenshot.images, list_pages.pages) in src/sdk/tools.d.ts. - Auto-supply pageId for evaluate_script (unless serviceWorkerId is set) and parse its fenced JSON return value onto result. - Preserve image blocks on take_screenshot() when filePath is omitted. - Default structuredContent.pages to [] when empty, throw an actionable error when no page is open, refresh and retry once if a cached selectedPageId closes, and auto-initialize collectors on newly created targets (autoInitNewPages) when attaching to external browsers.
Collaborator
|
Closing this due to #3639 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Prototype of a thin, strongly typed Node/TypeScript SDK exposed at
chrome-devtools-mcp/sdkfor programmatic browser inspection alongside Playwright, Puppeteer, or standalone Node scripts, plus a companionchrome-devtools-sdkagent skill.What changed
src/sdk/index.ts): Built directly onMcpServer.from(config, {browserManager, autoInitNewPages})andserver.callTool(name, args), avoiding child-process stdio spawn overhead and spurious MCProotscapability warnings.package.json,scripts/verify-npm-package.js): Adds"exports"exposing"./sdk"(JS entry + self-contained.d.tstypes) while preserving"."(./out/Default/gen/src/index.js) for existingMcpServerandcreateMcpServerconsumers.scripts/generate-sdk-types.ts->src/sdk/tools.d.ts): Generates a pure.d.tsinterface (DevToolsSdkTools, zero emitted runtime JS) with per-tool JSDoc descriptions directly fromcreateTools()Zod schemas, wired intonpm run genvianpm run sdk:generate.skills/chrome-devtools-sdk/SKILL.md,README.md): Adds a concise agent skill covering standalone and Playwright/Puppeteer coexistence patterns, core API reference, and common gotchas, packaged in the npm tarball and listed inREADME.md.attachDevTools(options)enablesexperimentalStructuredContent: trueby default and exposes all public tools as typed async methods returning{...structuredContent, text}and throwing anErrorwhenisErroris true.findUid(snapshot, matcher),close(), and[Symbol.asyncDispose]().pageIdon page-scoped tools andevaluate_script(unlessserviceWorkerIdis set), throws an actionable error when no page is open, and refreshesselectedPageIdwith a one-time retry if the active tab closes externally.evaluate_script's JSON payload ontoresult, preserves base64 image blocks ontake_screenshot().imageswhenfilePathis omitted, and typesget_css_styles().matchedStyles.src/sdk/index.ts,src/McpContext.ts,src/index.ts): When attaching viabrowserUrl,wsEndpoint, orautoConnect(andautoSelectPageis notfalse), automatically selects the active page on connect and enablesautoInitNewPagesso collectors also attach to pages created afterattachDevTools()without changing focus. PreservesdefaultViewport: nulland disconnects without closing the external browser.src/McpResponse.ts): SetsstructuredContent.networkRequests,structuredContent.consoleMessages, andstructuredContent.pagesto[]instead ofundefinedwhen empty.Usage example (Playwright coexistence)
Verification
npm run sdk:generate && npm run build && npm run check-format && npm run verify-npm-packagepassed (verifying SDK.d.tsfiles andskills/chrome-devtools-sdk/SKILL.mdin the tarball).tests/sdk.test.ts,tests/McpResponse.test.ts,tests/McpContext.test.ts: 222/222) and full test suite (2303/2303 pass, 0 fail, 4 skipped) passed.Google Chrome 161.0.8196.0 canaryandplaywright 1.58.2:tsc --noEmit --stricttypecheck againstchrome-devtools-mcp/sdk.d.tspassed.evaluate_scriptwithoutpageId+ parsed.result, inlinetake_screenshot().images, typedget_css_styles().matchedStyles,list_pages().pagesempty-array default + actionable zero-page error, automatic stale-tab recovery when Playwright closes the active tab, viewport preservation (375x812), and post-attachtargetcreatedcollector initialization.