Skip to main content
Glama
b3nw
by b3nw

browser_refresh

Refresh the current web page to reload content and resolve display issues, with options to wait for specific load states before proceeding.

Instructions

Refresh the current page, similar to pressing F5 or clicking browser refresh

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
waitUntilNoload
timeoutNo

Implementation Reference

  • Handler function that refreshes the current browser page using page.reload() with optional waitUntil and timeout parameters, reports new URL and any redirects.
    async (params: any) => {
      try {
        const input = z.object({
          waitUntil: z.enum(['networkidle', 'domcontentloaded', 'load']).optional().default('load'),
          timeout: z.number().optional()
        }).parse(params);
        await this.playwright.ensureConnected();
        
        const page = this.playwright.getPage();
        
        // Get current URL before refresh
        const currentUrl = page.url();
        
        // Perform the refresh with specified options
        const refreshOptions: any = {
          waitUntil: input.waitUntil
        };
        
        if (input.timeout !== undefined) {
          refreshOptions.timeout = input.timeout;
        }
        
        await page.reload(refreshOptions);
        
        // Get URL after refresh (should be the same unless redirected)
        const newUrl = page.url();
        
        return {
          content: [{
            type: 'text',
            text: `Successfully refreshed page. URL: ${newUrl}${currentUrl !== newUrl ? ` (redirected from ${currentUrl})` : ''}`
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: `Page refresh failed: ${error instanceof Error ? error.message : String(error)}`
          }],
          isError: true
        };
      }
    }
  • Zod input schema definition for the browser_refresh tool, defining optional waitUntil and timeout parameters.
    export const BrowserRefreshInputSchema = z.object({
      waitUntil: z.enum(['networkidle', 'domcontentloaded', 'load']).optional().default('load'),
      timeout: z.number().optional()
    });
  • src/server.ts:559-612 (registration)
    Registration of the browser_refresh tool using this.server.registerTool, including inline schema and handler function.
    this.server.registerTool(
      'browser_refresh',
      {
        title: 'Refresh Current Page',
        description: 'Refresh the current page, similar to pressing F5 or clicking browser refresh',
        inputSchema: {
          waitUntil: z.enum(['networkidle', 'domcontentloaded', 'load']).optional().default('load'),
          timeout: z.number().optional()
        }
      },
      async (params: any) => {
        try {
          const input = z.object({
            waitUntil: z.enum(['networkidle', 'domcontentloaded', 'load']).optional().default('load'),
            timeout: z.number().optional()
          }).parse(params);
          await this.playwright.ensureConnected();
          
          const page = this.playwright.getPage();
          
          // Get current URL before refresh
          const currentUrl = page.url();
          
          // Perform the refresh with specified options
          const refreshOptions: any = {
            waitUntil: input.waitUntil
          };
          
          if (input.timeout !== undefined) {
            refreshOptions.timeout = input.timeout;
          }
          
          await page.reload(refreshOptions);
          
          // Get URL after refresh (should be the same unless redirected)
          const newUrl = page.url();
          
          return {
            content: [{
              type: 'text',
              text: `Successfully refreshed page. URL: ${newUrl}${currentUrl !== newUrl ? ` (redirected from ${currentUrl})` : ''}`
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: 'text',
              text: `Page refresh failed: ${error instanceof Error ? error.message : String(error)}`
            }],
            isError: true
          };
        }
      }
    );

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/b3nw/playwright-mcp-server'

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