-
Notifications
You must be signed in to change notification settings - Fork 294
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
Changes from 6 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { z } from "zod"; | ||
import { Browserbase } from "@browserbasehq/sdk"; | ||
import type { Tool, ToolSchema, ToolResult } from "./tool.js"; | ||
import type { Context } from "../context.js"; | ||
import type { ToolActionResult } from "../types/types.js"; | ||
|
@@ -36,27 +35,12 @@ async function handleNavigate( | |
throw new Error("No Browserbase session ID available"); | ||
} | ||
|
||
// Get the debug URL using Browserbase SDK | ||
const bb = new Browserbase({ | ||
apiKey: context.config.browserbaseApiKey, | ||
}); | ||
const debugUrl = (await bb.sessions.debug(sessionId)) | ||
.debuggerFullscreenUrl; | ||
|
||
return { | ||
content: [ | ||
{ | ||
type: "text", | ||
text: `Navigated to: ${params.url}`, | ||
}, | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unnecessary on navigate tool |
||
type: "text", | ||
text: `View the live session here: https://www.browserbase.com/sessions/${sessionId}`, | ||
}, | ||
{ | ||
type: "text", | ||
text: `Browserbase Live Debugger URL: ${debugUrl}`, | ||
}, | ||
], | ||
}; | ||
} catch (error) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ import type { Tool, ToolSchema, ToolResult } from "./tool.js"; | |
import type { Context } from "../context.js"; | ||
import type { ToolActionResult } from "../types/types.js"; | ||
import { Browserbase } from "@browserbasehq/sdk"; | ||
import { createUIResource } from "@mcp-ui/server"; | ||
|
||
// Import SessionManager functions | ||
import { | ||
|
@@ -13,6 +14,7 @@ import { | |
getSession, | ||
} from "../sessionManager.js"; | ||
import type { BrowserSession } from "../types/types.js"; | ||
import { TextContent } from "@modelcontextprotocol/sdk/types.js"; | ||
|
||
// --- Tool: Create Session --- | ||
const CreateSessionInputSchema = z.object({ | ||
|
@@ -99,8 +101,17 @@ async function handleCreateSession( | |
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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. ah oops didn't see |
||
text: `Browserbase Live Session View URL: https://www.browserbase.com/sessions/${session.sessionId}`, | ||
}, | ||
{ | ||
type: "text", | ||
text: `Browserbase Live Debugger URL: ${debugUrl}`, | ||
}, | ||
createUIResource({ | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. style: Type assertion |
||
], | ||
}; | ||
} catch (error: unknown) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2022", | ||
"module": "Node16", | ||
"moduleResolution": "Node16", | ||
"module": "ESNext", | ||
"moduleResolution": "bundler", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 |
||
"strict": true, | ||
"esModuleInterop": true, | ||
"skipLibCheck": true, | ||
|
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