Skip to main content
Glama

mcp-server-browserbase

Official
by browserbase
Apache 2.0
2,054
2,725
url.ts1.58 kB
import { z } from "zod"; import type { Tool, ToolSchema, ToolResult } from "./tool.js"; import type { Context } from "../context.js"; import type { ToolActionResult } from "../types/types.js"; /** * Stagehand Get URL * * This tool is used to get the current URL of the browser page. */ // Empty schema since getting URL doesn't require any input const GetUrlInputSchema = z.object({}); type GetUrlInput = z.infer<typeof GetUrlInputSchema>; const getUrlSchema: ToolSchema<typeof GetUrlInputSchema> = { name: "browserbase_stagehand_get_url", description: "Return the current page URL (full URL with query/fragment).", inputSchema: GetUrlInputSchema, }; async function handleGetUrl( context: Context, // eslint-disable-next-line @typescript-eslint/no-unused-vars params: GetUrlInput, ): Promise<ToolResult> { const action = async (): Promise<ToolActionResult> => { try { const stagehand = await context.getStagehand(); // Get the current URL from the Playwright page const currentUrl = stagehand.page.url(); return { content: [ { type: "text", text: currentUrl, }, ], }; } catch (error) { const errorMsg = error instanceof Error ? error.message : String(error); throw new Error(`Failed to get current URL: ${errorMsg}`); } }; return { action, waitForNetwork: false, }; } const getUrlTool: Tool<typeof GetUrlInputSchema> = { capability: "core", schema: getUrlSchema, handle: handleGetUrl, }; export default getUrlTool;

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/browserbase/mcp-server-browserbase'

If you have feedback or need assistance with the MCP directory API, please join our Discord server