Skip to content

Commit 1d3853f

Browse files
authored
Merge pull request #100 from brightdata/feat/polling-configuration
feat: add configurable timeout
2 parents 06e5441 + 30720d2 commit 1d3853f

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,13 +398,32 @@ Try the Web MCP without any setup:
398398
"PRO_MODE": "true", // Enable all 60+ tools
399399
"RATE_LIMIT": "100/1h", // Custom rate limiting
400400
"WEB_UNLOCKER_ZONE": "custom", // Custom unlocker zone
401-
"BROWSER_ZONE": "custom_browser" // Custom browser zone
401+
"BROWSER_ZONE": "custom_browser", // Custom browser zone
402+
"POLLING_TIMEOUT": "600" // Polling timeout in seconds (default: 600)
402403
}
403404
}
404405
}
405406
}
406407
```
407408

409+
### Environment Variables
410+
411+
| Variable | Description | Default | Example |
412+
|----------|-------------|---------|---------|
413+
| `API_TOKEN` | Your Bright Data API token (required) | - | `your-token-here` |
414+
| `PRO_MODE` | Enable all 60+ tools | `false` | `true` |
415+
| `RATE_LIMIT` | Custom rate limiting | unlimited | `100/1h`, `50/30m` |
416+
| `WEB_UNLOCKER_ZONE` | Custom Web Unlocker zone name | `mcp_unlocker` | `my_custom_zone` |
417+
| `BROWSER_ZONE` | Custom Browser zone name | `mcp_browser` | `my_browser_zone` |
418+
| `POLLING_TIMEOUT` | Timeout for web_data_* tools polling (seconds) | `600` | `300`, `1200` |
419+
| `GROUPS` | Comma-separated tool group IDs | - | `ecommerce,browser` |
420+
| `TOOLS` | Comma-separated individual tool names | - | `extract,scrape_as_html` |
421+
422+
**Notes:**
423+
- `POLLING_TIMEOUT` controls how long web_data_* tools wait for results. Each second = 1 polling attempt.
424+
- Lower values (e.g., 300) will fail faster on slow data collections.
425+
- Higher values (e.g., 1200) allow more time for complex scraping tasks.
426+
408427
---
409428

410429
## 📚 Documentation

server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const api_token = process.env.API_TOKEN;
1414
const unlocker_zone = process.env.WEB_UNLOCKER_ZONE || 'mcp_unlocker';
1515
const browser_zone = process.env.BROWSER_ZONE || 'mcp_browser';
1616
const pro_mode = process.env.PRO_MODE === 'true';
17+
const polling_timeout = parseInt(process.env.POLLING_TIMEOUT || '600', 10);
1718
const pro_mode_tools = ['search_engine', 'scrape_as_markdown',
1819
'search_engine_batch', 'scrape_batch'];
1920
const tool_groups = process.env.GROUPS ?
@@ -899,7 +900,7 @@ for (let {dataset_id, id, description, inputs, defaults = {}, fixed_values = {}}
899900
let snapshot_id = trigger_response.data.snapshot_id;
900901
console.error(`[${tool_name}] triggered collection with `
901902
+`snapshot ID: ${snapshot_id}`);
902-
let max_attempts = 600;
903+
let max_attempts = polling_timeout;
903904
let attempts = 0;
904905
while (attempts < max_attempts)
905906
{

server.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@
5858
"isRequired": false,
5959
"isSecret": false,
6060
"format": "string"
61+
},
62+
{
63+
"name": "POLLING_TIMEOUT",
64+
"description": "Polling timeout in seconds for web_data_* tools (default: 600)",
65+
"isRequired": false,
66+
"isSecret": false,
67+
"format": "number"
6168
}
6269
]
6370
}

0 commit comments

Comments
 (0)