Skip to content

[Refactor]: Stagehand MCP becoming the Browserbase MCP #89

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 29 commits into
base: main
Choose a base branch
from

Conversation

Kylejeong2
Copy link
Collaborator

@Kylejeong2 Kylejeong2 commented Jun 22, 2025

What

Switching the Browserbase MCP to be purely stagehand based.

To be hosted at mcp.browserbase.com/mcp and by smitihery.

Stagehand Primitives as tool calls + new tools to run stagehand sessions in parallel.

@Kylejeong2 Kylejeong2 requested a review from Copilot July 3, 2025 06:14
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the MCP server by removing the old Stagehand-only implementation and introducing a unified Browserbase MCP powered by Stagehand.

  • Fully deletes the stagehand directory (old MCP implementation).
  • Adds a new TypeScript-based src/ directory with updated tool definitions, server setup, and CLI.
  • Updates branding to “Browserbase MCP” across resources, prompts, and documentation.

Reviewed Changes

Copilot reviewed 66 out of 77 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
stagehand/src/tools.ts Removed old Stagehand tool definitions.
stagehand/src/server.ts Removed legacy Stagehand MCP server logic.
src/utils.ts Updated sanitizeMessage signature and added sanitizeForFilePath.
src/tools/index.ts Newly exports Browserbase Stagehand tools and multi-session tools.
src/index.ts Main MCP server entrypoint using Browserbase and Stagehand.
src/program.ts CLI program to start the new MCP server via Stdio or HTTP transports.
Files not reviewed (2)
  • browserbase/package-lock.json: Language not supported
  • stagehand/package-lock.json: Language not supported

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Major architectural overhaul replacing the Browserbase MCP implementation with a pure Stagehand-based system, streamlining browser automation capabilities and modernizing the codebase.

  • Consolidated server architecture by moving from browserbase/ and stagehand/ directories to a unified src/ structure with improved MCP tools (src/tools/*)
  • Added robust multi-session support in src/tools/multiSession.ts enabling parallel browser automation with session-aware tools
  • Implemented new model integration system in src/mcp/sampling.ts for LLM-powered browser automation with pre-built templates
  • Enhanced type safety across the codebase with Zod schema validation and strict TypeScript types in src/types/types.ts
  • Added new CI/CD pipelines with Node.js 22 in .github/workflows/, noting potential timing considerations for LTS status

💡 (3/5) Reply to the bot's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!

72 files reviewed, 18 comments
Edit PR Review Bot Settings | Greptile

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Recent changes focus on package management modernization and session handling improvements while completing the Stagehand integration.

  • Migrated to pnpm with new workspace configuration, strict engine requirements, and updated CI/CD workflows
  • Enhanced session cleanup with proper disconnect event handling and memory leak prevention in src/stagehandStore.ts
  • Simplified configuration system in src/config.ts by removing filesystem operations, defaulting to 'google/gemini-2.0-flash' model
  • Removed src/utils.ts and redundant prompts like click_search_button as functionality moves to Stagehand core
  • Added comprehensive documentation in README.md for model configurations (Gemini, GPT-4, Claude) and multi-session capabilities

12 files reviewed, 2 comments
Edit PR Review Bot Settings | Greptile

@Kylejeong2 Kylejeong2 marked this pull request as ready for review July 3, 2025 20:41
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Recent changes focus on CI/CD improvements, package publishing workflow updates, and screenshot handling enhancements.

  • Modified CI workflow in .github/workflows/ci.yml to optimize pnpm and Node.js setup order
  • Switched to prepublishOnly npm lifecycle hook in package.json for safer package publishing
  • Added project-specific screenshot naming in src/tools/screenshot.ts with browserbaseProjectId prefix
  • Added URL validation in src/transport.ts to prevent crashes from malformed requests
  • Bumped version to 2.0.0 with updated package description reflecting Stagehand integration

6 files reviewed, 1 comment
Edit PR Review Bot Settings | Greptile

@smithery-ai smithery-ai bot had a problem deploying to production July 4, 2025 00:38 Failure
@smithery-ai smithery-ai bot had a problem deploying to production July 4, 2025 00:43 Failure
@smithery-ai smithery-ai bot had a problem deploying to production July 4, 2025 00:44 Failure
@smithery-ai smithery-ai bot had a problem deploying to production July 4, 2025 01:10 Failure
@smithery-ai smithery-ai bot had a problem deploying to production July 4, 2025 01:10 Failure
@smithery-ai smithery-ai bot had a problem deploying to production July 4, 2025 03:49 Failure
@smithery-ai smithery-ai bot had a problem deploying to production July 4, 2025 04:43 Failure
@smithery-ai smithery-ai bot had a problem deploying to production July 4, 2025 04:43 Failure
@smithery-ai smithery-ai bot had a problem deploying to production July 4, 2025 04:52 Failure
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