Skip to main content
Glama

browser_create_instance

Launch a new browser instance for automated testing or web scraping with configurable browser type, headless mode, and viewport settings.

Instructions

Create a new browser instance

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
browserTypeNoBrowser typechromium
headlessNoWhether to run in headless mode
viewportNoViewport size
userAgentNoUser agent string
metadataNoInstance metadata

Implementation Reference

  • Tool schema definition for 'browser_create_instance' including name, description, and detailed inputSchema with properties like browserType, headless, viewport, userAgent, metadata.
      name: 'browser_create_instance',
      description: 'Create a new browser instance',
      inputSchema: {
        type: 'object',
        properties: {
          browserType: {
            type: 'string',
            enum: ['chromium', 'firefox', 'webkit'],
            description: 'Browser type',
            default: 'chromium'
          },
          headless: {
            type: 'boolean',
            description: 'Whether to run in headless mode',
            default: true
          },
          viewport: {
            type: 'object',
            properties: {
              width: { type: 'number', default: 1280 },
              height: { type: 'number', default: 720 }
            },
            description: 'Viewport size'
          },
          userAgent: {
            type: 'string',
            description: 'User agent string'
          },
          metadata: {
            type: 'object',
            properties: {
              name: { type: 'string', description: 'Instance name' },
              description: { type: 'string', description: 'Instance description' },
              tags: { type: 'array', items: { type: 'string' }, description: 'Tags' }
            },
            description: 'Instance metadata'
          }
        }
      }
    },
  • Handler case in BrowserTools.executeTools method that processes 'browser_create_instance' tool call, extracts arguments, and delegates to browserManager.createInstance.
    case 'browser_create_instance':
      return await this.browserManager.createInstance(
        {
          browserType: args.browserType || 'chromium',
          headless: args.headless ?? true,
          viewport: args.viewport || { width: 1280, height: 720 },
          userAgent: args.userAgent
        },
        args.metadata
      );
  • Core implementation of createInstance in BrowserManager: launches Playwright browser based on config, handles proxy configuration, creates context and page, generates UUID, stores instance.
    async createInstance(
      browserConfig?: Partial<BrowserConfig>,
      metadata?: BrowserInstance['metadata']
    ): Promise<ToolResult> {
      try {
        if (this.instances.size >= this.config.maxInstances) {
          return {
            success: false,
            error: `Maximum number of instances (${this.config.maxInstances}) reached`
          };
        }
    
        const config = { ...this.config.defaultBrowserConfig, ...browserConfig };
        const browser = await this.launchBrowser(config);
        
        const contextOptions: any = {
          viewport: config.viewport,
          ...config.contextOptions
        };
        if (config.userAgent) {
          contextOptions.userAgent = config.userAgent;
        }
        
        // Add proxy configuration to context
        const effectiveProxy = this.getEffectiveProxy(browserConfig);
        if (effectiveProxy) {
          contextOptions.proxy = { server: effectiveProxy };
        }
        
        const context = await browser.newContext(contextOptions);
    
        const page = await context.newPage();
        
        const instanceId = uuidv4();
        const instance: BrowserInstance = {
          id: instanceId,
          browser,
          context,
          page,
          createdAt: new Date(),
          lastUsed: new Date(),
          isActive: true,
          ...(metadata && { metadata })
        };
    
        this.instances.set(instanceId, instance);
    
        return {
          success: true,
          data: {
            instanceId,
            browserType: config.browserType,
            headless: config.headless,
            viewport: config.viewport,
            proxy: effectiveProxy,
            metadata
          },
          instanceId
        };
      } catch (error) {
        return {
          success: false,
          error: `Failed to create browser instance: ${error instanceof Error ? error.message : error}`
        };
      }
    }
  • src/server.ts:40-45 (registration)
    MCP Server listTools request handler that returns the list of all tools (including browser_create_instance schema) from BrowserTools.getTools().
    this.server.setRequestHandler(ListToolsRequestSchema, async () => {
      const tools = this.browserTools.getTools();
      return {
        tools: tools,
      };
    });
  • src/server.ts:48-75 (registration)
    MCP Server callTool request handler that routes tool execution to BrowserTools.executeTools based on tool name, formats success/error responses.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      try {
        const result = await this.browserTools.executeTools(name, args || {});
        
        if (result.success) {
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(result.data, null, 2),
              },
            ],
          };
        } else {
          throw new McpError(ErrorCode.InternalError, result.error || 'Tool execution failed');
        }
      } catch (error) {
        if (error instanceof McpError) {
          throw error;
        }
        throw new McpError(
          ErrorCode.InternalError,
          `Tool execution failed: ${error instanceof Error ? error.message : error}`
        );
      }
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states 'Create' which implies a write/mutation operation, but doesn't disclose any behavioral traits: no mention of permissions required, whether instances persist across sessions, rate limits, what happens on failure, or what the return value might be (e.g., instance ID). The description is minimal and lacks crucial operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste—it states the core purpose without unnecessary words. It's appropriately sized for a tool with a clear primary function and well-documented schema. Every word earns its place, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (5 parameters with nested objects, no output schema, and no annotations), the description is incomplete. It doesn't explain what a browser instance is in this system, how it's used with sibling tools, what happens after creation, or any error conditions. For a mutation tool with significant parameter structure, more context is needed to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with all parameters well-documented in the schema itself (e.g., browserType with enum values, headless default, viewport structure). The description adds no parameter semantics beyond what's already in the schema—it doesn't explain why you'd choose different browser types, when to use headless mode, or how metadata is used. Baseline 3 is appropriate since the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create') and resource ('new browser instance'), making the purpose immediately understandable. It distinguishes this from sibling tools like browser_list_instances or browser_close_instance by focusing on creation rather than listing or closing. However, it doesn't specify what a 'browser instance' entails in this context (e.g., a controlled browser session for automation).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing to create an instance before using browser_navigate), when not to use it (e.g., if an instance already exists), or how it relates to sibling tools like browser_list_instances for checking existing instances. Usage is implied but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/sailaoda/concurrent-browser-mcp'

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