Windsurf Integration
Integrate Stagehand with Windsurf via MCP
Integrating Stagehand with Windsurf Code Editor
This guide will walk you through setting up Stagehand’s MCP (Model Context Protocol) server with Windsurf Code Editor, enabling AI-powered web automation capabilities directly from your coding environment.
Prerequisites
- Windsurf Code Editor installed on your system
- A Browserbase account with API key and project ID
- OpenAI API key
- Node.js and npm installed
Installation Steps
1. Install the Stagehand MCP Server
First, you need to install the Stagehand MCP server from the GitHub repository:
2. Configure Windsurf to Use Stagehand
Once you have installed the Stagehand MCP server, you need to configure Windsurf to use it:
-
Open your MCP configuration file located at
~/.codeium/windsurf/mcp_config.json
You can access it by clicking on the configure button with the hammer next to it.
-
Add the following configuration (replace the paths and API keys with your own):
3. Refresh your Windsurf MCP Servers
After adding the configuration, click on the refresh button with the spinning arrows next to it.
Available Commands
Once integrated with Windsurf, your AI assistant can use the following Stagehand commands:
- stagehand_navigate: Navigate to a URL in the browser
- stagehand_act: Perform an action on a web page element
- stagehand_extract: Extract structured data from the web page
- stagehand_observe: Observe elements on the web page
- screenshot: Take a screenshot of the current page
Example Usage
Here’s how you can use Stagehand with Windsurf:
-
In Windsurf, ask your AI assistant to perform a web task:
-
The AI will use Stagehand’s commands to:
- Navigate to the React documentation website
- Interact with the page if necessary
- Extract the relevant information
- Return the results directly in your coding environment
Example Workflow
Here’s a sample workflow you might follow:
Viewing Browser Sessions
You can view your browser sessions in Browserbase by going to the Browserbase dashboard and clicking on the “Sessions” tab.
Troubleshooting
If you encounter issues with the integration:
- Ensure the MCP server is running
- Check that your environment variables in the configuration file are set correctly
- Verify that the path to the MCP server’s index.js file is correct
- Check the Windsurf logs for any error messages
- Make sure your Browserbase and OpenAI API keys are valid
Additional Resources
Join the Stagehand Slack community for support and to connect with other users.