> ## Documentation Index
> Fetch the complete documentation index at: https://docs.browseagent.pro/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuration

> Learn how to configure Browseagent server with command line flags and configuration files for different environments and use cases.

This guide covers the available options and best practices for configuring Browseagent effectively.

### Command Line Flags

All available command line options for customizing server behavior:

| Flag              | Description                  | Default       | Example                  |
| ----------------- | ---------------------------- | ------------- | ------------------------ |
| `--debug`         | Enable detailed logging      | `false`       | `--debug`                |
| `--port <number>` | WebSocket port for extension | `8765`        | `--port 9000`            |
| `--config <path>` | Configuration file path      | None          | `--config ./config.json` |
| `--stdio`         | Force STDIO mode             | Auto-detected | `--stdio`                |
| `--websocket`     | Force WebSocket mode (dev)   | `false`       | `--websocket`            |

### Basic Command Line Examples

<CodeGroup>
  ```json Debug Mode theme={null}
  {
    "mcpServers": {
      "browseagent": {
        "command": "npx",
        "args": ["@browseagent/mcp@latest", "--debug"]
      }
    }
  }
  ```

  ```json Custom Port theme={null}
  {
    "mcpServers": {
      "browseagent": {
        "command": "npx", 
        "args": ["@browseagent/mcp@latest", "--port", "9000"]
      }
    }
  }
  ```

  ```json Multiple Options theme={null}
  {
    "mcpServers": {
      "browseagent": {
        "command": "npx",
        "args": [
          "@browseagent/mcp@latest", 
          "--debug",
          "--port", "8765"
        ]
      }
    }
  }
  ```
</CodeGroup>

### Creating a Configuration File

Create `browseagent.config.json` for advanced settings:

```json theme={null}
{
  "debug": false,
  "port": 8765,
  "host": "127.0.0.1",
  "timeout": 30000,
  "heartbeatInterval": 30000,
  "connectionTimeout": 60000,
  "maxRetries": 3,
  "toolTimeout": 60000
}
```

**Usage:**

```json theme={null}
{
  "mcpServers": {
    "browseagent": {
      "command": "npx",
      "args": ["@browseagent/mcp@latest", "--config", "./browseagent.config.json"]
    }
  }
}
```

### Configuration Sections Explained

<CodeGroup>
  ```json Server Configuration theme={null}
  {
    "debug": false,           // Enable debug logging
    "port": 8765,            // WebSocket port
    "host": "127.0.0.1",     // Bind host
    "timeout": 30000         // Request timeout in milliseconds
  }
  ```

  ```json Extension Communication theme={null}
  {
    "heartbeatInterval": 30000,  // Heartbeat frequency in ms
    "connectionTimeout": 60000,  // Connection timeout in ms
    "maxRetries": 3            // Max reconnection attempts
  }
  ```

  ```json Tool Behavior theme={null}
  {
    "toolTimeout": 60000       // Tool execution timeout
  }
  ```
</CodeGroup>

### Environment-Specific Configurations

<AccordionGroup>
  <Accordion title="Development Environment">
    **Features:**

    * Detailed debug logging
    * Extended timeouts
    * WebSocket mode for extension testing

    ```json theme={null}
    {
      "mcpServers": {
        "browseagent-dev": {
          "command": "npx",
          "args": [
            "@browseagent/mcp@latest",
            "--debug",
            "--websocket",
            "--config", "./config/development.json"
          ]
        }
      }
    }
    ```

    **Development Config File:**

    ```json theme={null}
    {
      "debug": true,
      "timeout": 120000,
      "toolTimeout": 120000
    }
    ```
  </Accordion>

  <Accordion title="Production Environment">
    **Features:**

    * Optimized performance
    * Minimal logging
    * Error handling focus

    ```json theme={null}
    {
      "mcpServers": {
        "browseagent-prod": {
          "command": "npx",
          "args": [
            "@browseagent/mcp@latest",
            "--config", "./config/production.json"
          ]
        }
      }
    }
    ```

    **Production Config File:**

    ```json theme={null}
    {
      "debug": false,
      "logLevel": "warn",
      "timeout": 30000,
      "toolTimeout": 60000
    }
    ```
  </Accordion>

  <Accordion title="Testing Environment">
    **Features:**

    * WebSocket mode
    * Extended debugging
    * Test-specific settings

    ```json theme={null}
    {
      "mcpServers": {
        "browseagent-test": {
          "command": "npx",
          "args": [
            "@browseagent/mcp@latest",
            "--websocket",
            "--debug",
            "--config", "./config/testing.json"
          ]
        }
      }
    }
    ```
  </Accordion>
</AccordionGroup>

### Multiple Server Instances

<AccordionGroup>
  <Accordion title="Running Multiple Instances">
    ```json theme={null}
    {
      "mcpServers": {
        "browseagent-main": {
          "command": "npx",
          "args": ["@browseagent/mcp@latest"]
        },
        "browseagent-dev": {
          "command": "npx",
          "args": [
            "@browseagent/mcp@latest",
            "--debug",
            "--port", "8766"
          ]
        },
        "browseagent-test": {
          "command": "npx",
          "args": [
            "@browseagent/mcp@latest",
            "--websocket",
            "--port", "8767"
          ]
        }
      }
    }
    ```
  </Accordion>

  <Accordion title="Instance-Specific Configuration">
    Each instance can have different settings:

    **Main Instance (Production-like):**

    ```json theme={null}
    {
      "browseagent-main": {
        "command": "npx",
        "args": ["@browseagent/mcp@latest", "--config", "./main.config.json"]
      }
    }
    ```

    **Development Instance:**

    ```json theme={null}
    {
      "browseagent-dev": {
        "command": "npx",
        "args": [
          "@browseagent/mcp@latest",
          "--debug",
          "--port", "8766",
          "--config", "./dev.config.json"
        ]
      }
    }
    ```
  </Accordion>
</AccordionGroup>

### Performance Tuning

<CodeGroup>
  ```json Tool Optimization theme={null}
  {
    "toolTimeout": 60000         // Tool execution timeout
  }
  ```

  ```json Connection Optimization theme={null}
  {
    "heartbeatInterval": 30000,    // Heartbeat frequency
    "connectionTimeout": 60000,    // Connection timeout
    "maxRetries": 3              // Max reconnection attempts
  }
  ```
</CodeGroup>

### Configuration Validation

```bash theme={null}
# Test server startup with config
npx @browseagent/mcp@latest --config ./config.json --debug

```

### Configuration Templates

<CodeGroup>
  ```json Minimal Configuration theme={null}
  {
    "port": 8765
  }
  ```

  ```json Host Configuration theme={null}
  {
    "host": "127.0.0.1",          // Bind only to localhost
    "port": 8765,                 // Non-standard port
  }
  ```

  ```json Full Configuration theme={null}
  {
    "debug": false,
    "port": 8765,
    "host": "127.0.0.1",
    "timeout": 30000,
    "heartbeatInterval": 30000,
    "connectionTimeout": 60000,
    "maxRetries": 3,
    "toolTimeout": 60000
  }
  ```
</CodeGroup>
