Skip to content

mcp: return page state from click/fill/scroll tools#1950

Open
mvanhorn wants to merge 1 commit intolightpanda-io:mainfrom
mvanhorn:osc/feat-mcp-action-feedback
Open

mcp: return page state from click/fill/scroll tools#1950
mvanhorn wants to merge 1 commit intolightpanda-io:mainfrom
mvanhorn:osc/feat-mcp-action-feedback

Conversation

@mvanhorn
Copy link
Contributor

Summary

The MCP click, fill, and scroll tools return static strings like "Clicked successfully." with no information about the resulting page state. After an action, AI agents have to make a separate semantic_tree or goto call 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.

  • #1401 - Click/submit actions don't surface navigation feedback
  • #1890 - Multi-step form POST loses track of page state between steps
  • #1927 - Maintainers added wait-until options to fetch, signaling interest in richer tool responses

Changes

  • 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"
  • Tool descriptions updated to document the return format

All state comes from page.url and page.getTitle() which are already computed - the only new allocation is the allocPrint format string using the arena allocator.

Testing

Existing "MCP - Actions: click, fill, scroll" test validates action correctness via JS state checks. Build passes with zig build.

This contribution was developed with AI assistance (Claude Code).

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>
@arrufat arrufat self-assigned this Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants