@mastra/brightdata 0.3.1-alpha.0 → 0.3.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -82
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,104 +3,40 @@
|
|
|
3
3
|
[Bright Data](https://brightdata.com) web search and web fetch tools for [Mastra](https://mastra.ai) agents.
|
|
4
4
|
|
|
5
5
|
Backed by the official [`@brightdata/sdk`](https://github.com/brightdata/sdk-js). Bright Data's SERP API and Web Unlocker bypass bot detection and CAPTCHAs, so the tools work on sites that block typical scrapers.
|
|
6
|
-
|
|
7
6
|
## Installation
|
|
8
7
|
|
|
9
8
|
```bash
|
|
10
|
-
npm install @mastra/brightdata
|
|
9
|
+
npm install @mastra/brightdata
|
|
11
10
|
```
|
|
12
11
|
|
|
13
|
-
##
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Set `BRIGHTDATA_API_TOKEN` and configure the Bright Data zones used by the tools.
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
|
-
import { Agent } from '@mastra/core/agent';
|
|
19
18
|
import { createBrightDataTools } from '@mastra/brightdata';
|
|
19
|
+
import { Agent } from '@mastra/core/agent';
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
// Or pass an explicit API token:
|
|
23
|
-
// const tools = createBrightDataTools({ apiKey: 'brd_...' });
|
|
21
|
+
const { webSearch, webFetch } = createBrightDataTools();
|
|
24
22
|
|
|
25
|
-
const
|
|
26
|
-
id: '
|
|
27
|
-
name: '
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
tools,
|
|
23
|
+
export const researchAgent = new Agent({
|
|
24
|
+
id: 'research-agent',
|
|
25
|
+
name: 'Research Agent',
|
|
26
|
+
model: 'openai/gpt-5.6-sol',
|
|
27
|
+
instructions: 'Search for relevant pages, then fetch the best sources before answering.',
|
|
28
|
+
tools: { webSearch, webFetch },
|
|
32
29
|
});
|
|
33
30
|
```
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
## Individual Tools
|
|
38
|
-
|
|
39
|
-
Each tool can be created independently:
|
|
40
|
-
|
|
41
|
-
```typescript
|
|
42
|
-
import { createBrightDataSearchTool, createBrightDataFetchTool } from '@mastra/brightdata';
|
|
43
|
-
|
|
44
|
-
const search = createBrightDataSearchTool({ apiKey: 'brd_...' });
|
|
45
|
-
const fetch = createBrightDataFetchTool(); // uses BRIGHTDATA_API_TOKEN env var
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Web Search (`brightdata-search`)
|
|
49
|
-
|
|
50
|
-
```typescript
|
|
51
|
-
import { createBrightDataSearchTool } from '@mastra/brightdata';
|
|
52
|
-
|
|
53
|
-
const searchTool = createBrightDataSearchTool();
|
|
32
|
+
## Documentation
|
|
54
33
|
|
|
55
|
-
|
|
56
|
-
// - query (required)
|
|
57
|
-
// - country: 2-letter code (e.g., 'us', 'gb')
|
|
58
|
-
// - start: result offset for pagination (e.g. 10 for the second page of 10 results)
|
|
59
|
-
//
|
|
60
|
-
// Returns:
|
|
61
|
-
// {
|
|
62
|
-
// query: string,
|
|
63
|
-
// results: Array<{ link, title, description }>,
|
|
64
|
-
// currentPage: number
|
|
65
|
-
// }
|
|
66
|
-
```
|
|
34
|
+
- [@mastra/brightdata documentation](https://mastra.ai/integrations/tools/brightdata)
|
|
67
35
|
|
|
68
|
-
|
|
36
|
+
## Changelog
|
|
69
37
|
|
|
70
|
-
|
|
71
|
-
import { createBrightDataFetchTool } from '@mastra/brightdata';
|
|
72
|
-
|
|
73
|
-
const fetchTool = createBrightDataFetchTool();
|
|
74
|
-
|
|
75
|
-
// Accepts: url (required)
|
|
76
|
-
// Returns: { url, content } // content is Markdown
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Configuration
|
|
80
|
-
|
|
81
|
-
| Option | Type | Default | Description |
|
|
82
|
-
|---|---|---|---|
|
|
83
|
-
| `apiKey` | `string` | `process.env.BRIGHTDATA_API_TOKEN` | Your Bright Data API token |
|
|
84
|
-
|
|
85
|
-
All tools accept the full `BrightDataClientOptions` from `@brightdata/sdk` (including `timeout`, `webUnlockerZone`, `serpZone`, `rateLimit`, etc.). If no API token is found, the tool throws a clear error at execution time.
|
|
86
|
-
|
|
87
|
-
## RAG Pairing Example
|
|
88
|
-
|
|
89
|
-
Combine search and fetch for retrieval-augmented generation:
|
|
90
|
-
|
|
91
|
-
```typescript
|
|
92
|
-
import { Agent } from '@mastra/core/agent';
|
|
93
|
-
import { createBrightDataTools } from '@mastra/brightdata';
|
|
94
|
-
|
|
95
|
-
const agent = new Agent({
|
|
96
|
-
id: 'rag-agent',
|
|
97
|
-
name: 'Research Assistant',
|
|
98
|
-
model: 'anthropic/claude-sonnet-4-6',
|
|
99
|
-
instructions: `You are a research assistant. Use brightdata-search to find relevant pages, then use brightdata-fetch to get full Markdown content from the best results.`,
|
|
100
|
-
tools: createBrightDataTools(),
|
|
101
|
-
});
|
|
102
|
-
```
|
|
38
|
+
See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/integrations/brightdata/CHANGELOG.md) for version history and release notes.
|
|
103
39
|
|
|
104
|
-
##
|
|
40
|
+
## Support
|
|
105
41
|
|
|
106
|
-
|
|
42
|
+
We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/brightdata",
|
|
3
|
-
"version": "0.3.1-alpha.
|
|
3
|
+
"version": "0.3.1-alpha.1",
|
|
4
4
|
"description": "Bright Data web search and web fetch tools for Mastra agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"zod": "^4.4.3",
|
|
54
54
|
"@internal/lint": "0.0.129",
|
|
55
55
|
"@internal/types-builder": "0.0.104",
|
|
56
|
-
"@mastra/core": "1.64.0-alpha.
|
|
56
|
+
"@mastra/core": "1.64.0-alpha.7"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build:lib": "tsdown --silent --config tsdown.config.ts",
|