Skip to content

Added stagehand_get_html tool to Stagehand MCP Server #81

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

travisrussi
Copy link

Added ability to get the HTML of the current page with a stagehand_get_html MCP tool.

Since the HTML is usually too big to send via the messaging protocol, the HTML file is saved locally to a tmp folder and a simple HTTP Server is spun up to serve the file (usually via CURL from the client). The port defaults to 8080, but can be configured via the STAGEHAND_HTTP_PORT environment variable.

@Kylejeong2
Copy link
Contributor

Hey @travisrussi, what exactly would you need the stagehand_get_html tool for? do you have use cases already in mind?

@travisrussi
Copy link
Author

@Kylejeong2, I was building a web scraper and I wanted to find and test the CSS and XPath selectors. That required having the page HTML stored locally.

My approach was using Stagehand to initially identify the specific elements on the page to build the scraper. When running the scraper, I would use traditional selectors as the primary location method, with Stagehand LLM location as the secondary method (because there's a cost associated with that method).

@Kylejeong2
Copy link
Contributor

@Kylejeong2, I was building a web scraper and I wanted to find and test the CSS and XPath selectors. That required having the page HTML stored locally.

My approach was using Stagehand to initially identify the specific elements on the page to build the scraper. When running the scraper, I would use traditional selectors as the primary location method, with Stagehand LLM location as the secondary method (because there's a cost associated with that method).

Hey @travisrussi, we're going to do a major refactor soon. If you want to have that method in your local version of MCP feel free; we're open source. But for the official version I don't think we're planning on adding this to the tools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants