-
Notifications
You must be signed in to change notification settings - Fork 8
execute_playwright_code: drop replays + browser lifecycle; add manage_replays tool #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dprevoznik
wants to merge
7
commits into
main
Choose a base branch
from
hypeship/playwright-drop-replays
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+112
−66
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dd9971e
Remove per-call replay recording from execute_playwright_code
dprevoznik e1f8ca3
Make execute_playwright_code a passthrough (require session_id)
dprevoznik e704041
Add manage_replays tool for session-scoped video replays
dprevoznik 43a5861
Document manage_replays tool and replays toolset
dprevoznik 4556783
Note paid-tier requirement in manage_replays description
dprevoznik f6879f5
Note replays are MP4 videos in README
dprevoznik 1265a2d
Drop screenshot guidance from execute_playwright_code description
dprevoznik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; | ||
| import { z } from "zod"; | ||
| import { createKernelClient } from "@/lib/mcp/kernel-client"; | ||
| import { | ||
| errorResponse, | ||
| itemsJsonResponse, | ||
| jsonResponse, | ||
| textResponse, | ||
| toolErrorResponse, | ||
| } from "@/lib/mcp/responses"; | ||
|
|
||
| export function registerReplayTools(server: McpServer) { | ||
| // manage_replays -- Start, stop, and list video replay recordings for a session | ||
| server.tool( | ||
| "manage_replays", | ||
| 'Manage video replay recordings for a browser session. Use "start" to begin recording a session (returns a replay_id and a viewable URL), "stop" to end a recording and persist the video, or "list" to see all replays for a session with their view URLs. Recording is session-scoped: start once, run your automation, then stop -- rather than recording each action separately. Requires a paid Kernel plan; not available on the free tier.', | ||
| { | ||
| action: z | ||
| .enum(["start", "stop", "list"]) | ||
| .describe("Operation to perform."), | ||
| session_id: z.string().describe("Browser session ID."), | ||
| replay_id: z.string().describe("(stop) Replay ID to stop.").optional(), | ||
| framerate: z | ||
| .number() | ||
| .int() | ||
| .min(1) | ||
| .describe( | ||
| "(start) Recording framerate in fps. Values above 20 require GPU to be enabled on the session.", | ||
| ) | ||
| .optional(), | ||
| max_duration_in_seconds: z | ||
| .number() | ||
| .int() | ||
| .min(1) | ||
| .describe("(start) Maximum recording duration in seconds.") | ||
| .optional(), | ||
| record_audio: z | ||
| .boolean() | ||
| .describe( | ||
| "(start) Record audio in addition to video. Defaults to video-only.", | ||
| ) | ||
| .optional(), | ||
| }, | ||
| { | ||
| title: "Manage browser session replays", | ||
| readOnlyHint: false, | ||
| destructiveHint: false, | ||
| idempotentHint: false, | ||
| openWorldHint: false, | ||
| }, | ||
| async (params, extra) => { | ||
| if (!extra.authInfo) throw new Error("Authentication required"); | ||
| const client = createKernelClient(extra.authInfo.token); | ||
|
|
||
| try { | ||
| switch (params.action) { | ||
| case "start": { | ||
| const body = { | ||
| ...(params.framerate !== undefined && { | ||
| framerate: params.framerate, | ||
| }), | ||
| ...(params.max_duration_in_seconds !== undefined && { | ||
| max_duration_in_seconds: params.max_duration_in_seconds, | ||
| }), | ||
| ...(params.record_audio !== undefined && { | ||
| record_audio: params.record_audio, | ||
| }), | ||
| }; | ||
| const replay = await client.browsers.replays.start( | ||
| params.session_id, | ||
| Object.keys(body).length > 0 ? body : undefined, | ||
| ); | ||
| return jsonResponse(replay); | ||
| } | ||
| case "stop": { | ||
| if (!params.replay_id) | ||
| return errorResponse("Error: replay_id is required for stop."); | ||
| await client.browsers.replays.stop(params.replay_id, { | ||
| id: params.session_id, | ||
| }); | ||
| return textResponse("Replay stopped successfully"); | ||
| } | ||
| case "list": { | ||
| const replays = await client.browsers.replays.list( | ||
| params.session_id, | ||
| ); | ||
| return itemsJsonResponse(replays, { | ||
| emptyText: "No replays found for this session", | ||
| }); | ||
| } | ||
| } | ||
| } catch (error) { | ||
| return toolErrorResponse("manage_replays", params.action, error); | ||
| } | ||
| }, | ||
| ); | ||
| } | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List skips pagination contract
Medium Severity
manage_replayslistcallsbrowsers.replays.listwith onlysession_idand returns viaitemsJsonResponse, withoutpaginationParamsorpaginatedJsonResponse. Other MCP toollistactions exposelimit/offsetand return{ items, has_more, next_offset }, so this path breaks the shared list contract agents rely on.Triggered by learned rule: MCP resources iterate all pages; tool list actions return single pages
Reviewed by Cursor Bugbot for commit 1265a2d. Configure here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not applicable here — the SDK's
browsers.replays.list(id)returns a plainArray(ReplayListResponse), not a paginated page. There's nolimit/offset/cursor to honor (unlikeextensions.list/proxies.list, which return a page object), so it returns every replay for the session in one call.itemsJsonResponsestill emits the shared{ items, has_more, next_offset }envelope, so agents get the same shape. AddingpaginationParamswould advertise pagination the endpoint doesn't support. Leaving as-is.