mcp: return page state from click/fill/scroll tools#1950
Open
mvanhorn wants to merge 1 commit intolightpanda-io:mainfrom
Open
mcp: return page state from click/fill/scroll tools#1950mvanhorn wants to merge 1 commit intolightpanda-io:mainfrom
mvanhorn wants to merge 1 commit intolightpanda-io:mainfrom
Conversation
After click, fill, and scroll actions, return the current page URL and title instead of static success messages. This gives AI agents immediate feedback about the page state after an action, matching the pattern already used by waitForSelector. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
The MCP
click,fill, andscrolltools return static strings like "Clicked successfully." with no information about the resulting page state. After an action, AI agents have to make a separatesemantic_treeorgotocall just to check whether the URL changed or navigation occurred.This PR updates all three action tools to include the page URL and title in their responses, following the same pattern already used by
waitForSelector(which returns"Element found. backendNodeId: {d}").Why this matters
Agents using Lightpanda's MCP server need a closed feedback loop: act, observe what changed, decide the next step. Without post-action state, agents waste round-trips on state checks after every interaction.
fetch, signaling interest in richer tool responsesChanges
handleClick: Returns"Clicked element (backendNodeId: N). Page url: X, title: Y"handleFill: Returns"Filled element (backendNodeId: N) with "text". Page url: X, title: Y"handleScroll: Returns"Scrolled to x: N, y: N. Page url: X, title: Y"All state comes from
page.urlandpage.getTitle()which are already computed - the only new allocation is theallocPrintformat string using the arena allocator.Testing
Existing
"MCP - Actions: click, fill, scroll"test validates action correctness via JS state checks. Build passes withzig build.This contribution was developed with AI assistance (Claude Code).