Add browser_evaluate tool for JavaScript execution#60
Merged
hugs merged 7 commits intoVibiumDev:mainfrom Feb 8, 2026
Merged
Conversation
Add --disable-notifications flag and set notifications content setting to block, preventing the "Google Chrome for Testing Notifications" dialog from appearing on first launch. Co-Authored-By: Claude Opus 4.5 <[email protected]>
This adds a new MCP tool `browser_evaluate` that allows executing JavaScript code in the browser and returning the result. Changes: - Add browser_evaluate tool schema in mcp/schema.go - Implement browserEvaluate handler in mcp/handlers.go - Update tests to expect 8 tools instead of 7 - Add test for browser_evaluate functionality The tool uses the existing Evaluate() method from the BiDi client, making this a small addition that exposes existing functionality. Use case: Extract HTML content from page elements, inspect DOM state, or run custom JavaScript for automation tasks. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Makes it clear that browser_evaluate is the primary tool for extracting data from pages, not just executing arbitrary JavaScript. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Update MCP tools documentation to include the browser_evaluate tool added in PR VibiumDev#60. This tool executes JavaScript in the browser to extract data, query the DOM, or inspect page state. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Implement feature parity with JavaScript client and MCP server by adding evaluate() method to execute JavaScript in the page context. Changes: - Add async evaluate() method to Vibe class - Add sync evaluate() method to VibeSync class - Add comprehensive tests for string, numeric, and object evaluations - Use script.evaluate BiDi protocol method All Python client tests pass. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Add browser_evaluate to MCP tools table and showcase the new evaluate() method in all client examples (JavaScript and Python, both sync and async). Changes: - Add browser_evaluate to MCP server tools table - Add evaluate() examples to JS sync and async code samples - Add evaluate() examples to Python sync and async code samples Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Contributor
|
merged. thank you, @jolks! |
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
This PR adds a new MCP tool
browser_evaluatethat allows executing JavaScript code in the browser and returning the result. Also addsevaluate()method to the Python client for feature parity with the JavaScript client.Changes
MCP Server (Go):
browser_evaluatetool schema inmcp/schema.gobrowserEvaluatehandler inmcp/handlers.gobrowser_evaluatefunctionalityPython Client:
evaluate()method toVibeclass (async API)evaluate()method toVibeSyncclass (sync API)JavaScript Client:
evaluate()method already exists (clients/javascript/src/vibe.ts:68-82)Implementation
The MCP tool uses the existing
Evaluate()method from the BiDi client, making this a small addition (~50 lines) that exposes existing functionality.The Python client implementation mirrors the JavaScript client's
evaluate()method, using thescript.evaluateBiDi protocol method.Context
The underlying Go BiDi client has always had an
Evaluate()method, and the JavaScript client has hadevaluate()since its initial implementation. This PR:browser_evaluatetoolevaluate()method to the Python client for feature parityUse Cases
document.querySelector('#container').outerHTML)document.title,window.location.href)Testing
MCP Server Tests:
Python Client Tests:
document.title)2 + 2)window.location.href)make test-python # Python client test passed!Feature Parity
All three interfaces now support JavaScript evaluation:
browser_evaluatetool) - NEWvibe.evaluate()method) - already existedvibe.evaluate()method) - NEWRelated
This enables use cases like extracting structured data from web pages without relying solely on CSS selectors, which was the motivation for this addition.