MCPcopy
hub / github.com/browserbase/mcp-server-browserbase / action

Function action

src/tools/session.ts:17–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15
16async function handleStart(context: Context): Promise<ToolResult> {
17 const action = async (): Promise<ToolActionResult> => {
18 try {
19 const sessionManager = context.getSessionManager();
20 const config = context.config;
21 const targetSessionId = sessionManager.getDefaultSessionId();
22
23 const session: BrowserSession =
24 await sessionManager.ensureDefaultSessionInternal(config);
25
26 if (
27 !session ||
28 !session.page ||
29 !session.sessionId ||
30 !session.stagehand
31 ) {
32 throw new Error(
33 `SessionManager failed to return a valid session object for ID: ${targetSessionId}`,
34 );
35 }
36
37 const browserbaseSessionId = session.stagehand.browserbaseSessionId;
38
39 return {
40 content: [
41 {
42 type: "text",
43 text: JSON.stringify({
44 success: true,
45 data: {
46 sessionId: browserbaseSessionId,
47 },
48 }),
49 },
50 ],
51 };
52 } catch (error: unknown) {
53 const errorMessage =
54 error instanceof Error ? error.message : String(error);
55 throw new Error(`Failed to create Browserbase session: ${errorMessage}`);
56 }
57 };
58
59 return {
60 action: action,

Callers

nothing calls this directly

Calls 5

getSessionManagerMethod · 0.80
getDefaultSessionIdMethod · 0.80
getSessionMethod · 0.80
cleanupSessionMethod · 0.80

Tested by

no test coverage detected