-
Notifications
You must be signed in to change notification settings - Fork 274
add mcp ui to embed browser in compatible clients #108
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Summary
This PR introduces MCP UI functionality to the Browserbase MCP server, enabling visual browser session interfaces directly within MCP clients. The changes transform the server from a command-line only tool to one that supports embedded UI components.
Key changes include:
- UI Integration: Added
@mcp-ui/server
dependency and integrated UI resource creation in the session management tool, allowing users to view Browserbase debugger interfaces as embedded iframes - Module System Modernization: Updated TypeScript configuration from Node16 to ESNext with bundler resolution to support modern UI libraries and bundling tools
- Import Compatibility: Changed dotenv import from default to namespace import (
import * as dotenv
) for better ESM compatibility - Code Reorganization: Cleaned up debug URL display in the navigate tool, consolidating this functionality into dedicated session management where it's more appropriate
- Server Architecture Enhancement: Restructured the main index.ts to export a default function with Zod-based configuration validation and standardized tool registration
These changes integrate seamlessly with the existing browser automation capabilities while adding a visual layer that enhances user experience. The UI resources use standard iframe embedding to display Browserbase's debugger interface, and the modular approach ensures backward compatibility with existing MCP protocol implementations.
Confidence score: 3/5
- This PR introduces significant architectural changes that could impact module resolution and runtime behavior
- Score reflects concerns about TypeScript configuration changes that may affect Node.js compatibility and the type assertion workaround in session.ts
- Pay close attention to tsconfig.json and src/tools/session.ts for potential runtime issues
5 files reviewed, 1 comment
uri: "ui://analytics-dashboard/main", | ||
content: { type: "externalUrl", iframeUrl: debugUrl }, | ||
encoding: "text", | ||
}) as unknown as TextContent, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Type assertion as unknown as TextContent
suggests type incompatibility. Consider updating the content array type to properly support UI resources or create a union type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small changes, mostly due to keeping feature requests.
Also wondering about the ESNext stuff, why we need to change. Does the dockerfile need to change for us to be able to deploy to smithery as well?
apiKey: context.config.browserbaseApiKey, | ||
}); | ||
const debugUrl = (await bb.sessions.debug(sessionId)) | ||
.debuggerFullscreenUrl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had a feature request to include the liveview/debug url in the output from these tool calls which is why they're still in here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah these are now in session create instead of on navigate; redundant to have it on every navigate call within a session
"module": "Node16", | ||
"moduleResolution": "Node16", | ||
"module": "ESNext", | ||
"moduleResolution": "bundler", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why we're changing to ESNext here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah node 16 is super old and past end of life. we can use nodenext here as well or you can pin the version
); | ||
|
||
return { | ||
content: [ | ||
{ | ||
type: "text", | ||
text: `Browserbase Live Session View URL: https://www.browserbase.com/sessions/${session.sessionId}\nBrowserbase Live Debugger URL: ${debugUrl}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing as above, can technically change this to be another text output as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's what i did, are you saying you prefer it this way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah oops didn't see
return { | ||
content: [ | ||
{ | ||
type: "text", | ||
text: `Navigated to: ${params.url}`, | ||
}, | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary on navigate tool
apiKey: context.config.browserbaseApiKey, | ||
}); | ||
const debugUrl = (await bb.sessions.debug(sessionId)) | ||
.debuggerFullscreenUrl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah these are now in session create instead of on navigate; redundant to have it on every navigate call within a session
"module": "Node16", | ||
"moduleResolution": "Node16", | ||
"module": "ESNext", | ||
"moduleResolution": "bundler", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah node 16 is super old and past end of life. we can use nodenext here as well or you can pin the version
); | ||
|
||
return { | ||
content: [ | ||
{ | ||
type: "text", | ||
text: `Browserbase Live Session View URL: https://www.browserbase.com/sessions/${session.sessionId}\nBrowserbase Live Debugger URL: ${debugUrl}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's what i did, are you saying you prefer it this way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah looks good, the only thing is just pnpm install to get the right version of dotenv to pass our ci
); | ||
|
||
return { | ||
content: [ | ||
{ | ||
type: "text", | ||
text: `Browserbase Live Session View URL: https://www.browserbase.com/sessions/${session.sessionId}\nBrowserbase Live Debugger URL: ${debugUrl}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah oops didn't see
Added MCP UI and cleaned up a few small things to support latest spec
Built-in.Retina.Display.mp4