Skip to main content
Glama

Better Playwright MCP

by livoras

browserNavigateBack

Navigate to the previous page in a browser session, with optional wait time to capture snapshots post-operation, enabling efficient web automation and interaction tracking.

Instructions

返回到上一页

Input Schema

NameRequiredDescriptionDefault
pageIdYes页面ID
waitForTimeoutNo操作后等待获取快照的延迟时间(毫秒,默认2000)

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "pageId": { "description": "页面ID", "type": "string" }, "waitForTimeout": { "description": "操作后等待获取快照的延迟时间(毫秒,默认2000)", "type": "number" } }, "required": [ "pageId" ], "type": "object" }

Implementation Reference

  • The handler function for the 'browser_navigate_back' tool. It calls goBack on the current tab's page, includes a snapshot in the response, and adds the corresponding Playwright code snippet.
    handle: async (tab, params, response) => { await tab.page.goBack(); response.setIncludeSnapshot(); response.addCode(`await page.goBack();`); },
  • Schema definition for the 'browser_navigate_back' tool, including name, title, description, empty input schema, and readOnly type.
    schema: { name: 'browser_navigate_back', title: 'Go back', description: 'Go back to the previous page', inputSchema: z.object({}), type: 'readOnly', },
  • lib/tools.js:32-49 (registration)
    Registration of all tools, including the navigate tools (which contain 'browser_navigate_back') by spreading the imported navigate array into the allTools export.
    export const allTools = [ ...common, ...console, ...dialogs, ...evaluate, ...files, ...form, ...install, ...keyboard, ...navigate, ...network, ...mouse, ...pdf, ...screenshot, ...snapshot, ...tabs, ...wait, ];
  • MCP tool listing registration: maps internal tools (including 'browser_navigate_back') to MCP tool format using toMcpTool.
    async listTools() { return this._tools.map(tool => toMcpTool(tool.schema)); }
  • MCP tool execution: finds tool by name (e.g., 'browser_navigate_back'), parses arguments, calls the handle function, and serializes the response.
    async callTool(name, rawArguments) { const tool = this._tools.find(tool => tool.schema.name === name); if (!tool) throw new Error(`Tool "${name}" not found`); const parsedArguments = tool.schema.inputSchema.parse(rawArguments || {}); const context = this._context; const response = new Response(context, name, parsedArguments); context.setRunningTool(name); try { await tool.handle(context, parsedArguments, response); await response.finish(); this._sessionLog?.logResponse(response); } catch (error) { response.addError(String(error)); } finally { context.setRunningTool(undefined); } return response.serialize(); }

Latest Blog Posts

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/livoras/better-playwright-mcp'

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