@mastra/mcp-docs-server 1.1.22-alpha.9 → 1.1.23-alpha.0

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.
@@ -0,0 +1,284 @@
1
+ # MastraBrowser class
2
+
3
+ The `MastraBrowser` class is the abstract base class for browser automation providers. It defines the common interface for launching browsers, managing thread isolation, streaming screencasts, and handling input events.
4
+
5
+ You don't instantiate `MastraBrowser` directly. Instead, use a provider implementation:
6
+
7
+ - [`AgentBrowser`](https://mastra.ai/reference/browser/agent-browser): Deterministic browser automation using refs
8
+ - [`StagehandBrowser`](https://mastra.ai/reference/browser/stagehand-browser): AI-powered browser automation using natural language
9
+
10
+ ## Usage example
11
+
12
+ ```typescript
13
+ import { Agent } from '@mastra/core/agent'
14
+ import { AgentBrowser } from '@mastra/agent-browser'
15
+
16
+ const browser = new AgentBrowser({
17
+ headless: true,
18
+ viewport: { width: 1280, height: 720 },
19
+ scope: 'thread',
20
+ })
21
+
22
+ export const browserAgent = new Agent({
23
+ name: 'browser-agent',
24
+ instructions: 'You can browse the web to find information.',
25
+ model: 'openai/gpt-5.4',
26
+ browser,
27
+ })
28
+ ```
29
+
30
+ ## Constructor parameters
31
+
32
+ **headless** (`boolean`): Whether to run the browser in headless mode (no visible UI). (Default: `true`)
33
+
34
+ **viewport** (`{ width: number; height: number }`): Browser viewport dimensions. Controls the size of the browser window. (Default: `{ width: 1280, height: 720 }`)
35
+
36
+ **timeout** (`number`): Default timeout in milliseconds for browser operations. (Default: `10000`)
37
+
38
+ **cdpUrl** (`string | (() => string | Promise<string>)`): CDP WebSocket URL, HTTP endpoint, or sync/async provider function. When provided, connects to an existing browser instead of launching a new one. HTTP endpoints are resolved to WebSocket internally. Can't be used with scope: 'thread' (automatically uses shared scope).
39
+
40
+ **scope** (`'shared' | 'thread'`): Browser instance scope across threads. 'shared' means all threads share a single browser instance. 'thread' means each thread gets its own browser instance (full isolation). (Default: `'thread' (or 'shared' when cdpUrl is provided)`)
41
+
42
+ **onLaunch** (`(args: { browser: MastraBrowser }) => void | Promise<void>`): Callback invoked after the browser reaches 'ready' status.
43
+
44
+ **onClose** (`(args: { browser: MastraBrowser }) => void | Promise<void>`): Callback invoked before the browser is closed.
45
+
46
+ **screencast** (`ScreencastOptions`): Configuration for streaming browser frames.
47
+
48
+ **screencast.format** (`'jpeg' | 'png'`): Image format for screencast frames.
49
+
50
+ **screencast.quality** (`number`): Image quality (1-100). Only applies to JPEG format.
51
+
52
+ **screencast.maxWidth** (`number`): Maximum width for screencast frames.
53
+
54
+ **screencast.maxHeight** (`number`): Maximum height for screencast frames.
55
+
56
+ **screencast.everyNthFrame** (`number`): Capture every Nth frame to reduce bandwidth.
57
+
58
+ ## Properties
59
+
60
+ The following properties (`id`, `name`, `provider`) are abstract and must be defined by concrete provider implementations:
61
+
62
+ **id** (`string`): Unique identifier for this browser instance. Abstract - defined by provider.
63
+
64
+ **name** (`string`): Human-readable name of the browser provider (e.g., 'AgentBrowser', 'StagehandBrowser'). Abstract - defined by provider.
65
+
66
+ **provider** (`string`): Provider identifier (e.g., 'vercel-labs/agent-browser', 'browserbase/stagehand'). Abstract - defined by provider.
67
+
68
+ **headless** (`boolean`): Whether the browser is running in headless mode.
69
+
70
+ **status** (`BrowserStatus`): Current browser status: 'pending', 'launching', 'ready', 'error', 'closing', or 'closed'.
71
+
72
+ ## Methods
73
+
74
+ ### Lifecycle
75
+
76
+ #### `ensureReady()`
77
+
78
+ Ensures the browser is launched and ready for use. Automatically called before tool execution. Implemented in the base class.
79
+
80
+ ```typescript
81
+ await browser.ensureReady()
82
+ ```
83
+
84
+ #### `close()`
85
+
86
+ Closes the browser and cleans up all resources. Implemented in the base class with race-condition-safe handling.
87
+
88
+ ```typescript
89
+ await browser.close()
90
+ ```
91
+
92
+ #### `isBrowserRunning()`
93
+
94
+ Checks if the browser is currently running.
95
+
96
+ ```typescript
97
+ const isRunning = browser.isBrowserRunning()
98
+ ```
99
+
100
+ **Returns:** `boolean`
101
+
102
+ ### Thread management
103
+
104
+ #### `setCurrentThread(threadId)`
105
+
106
+ Sets the current thread ID for browser operations. Used internally by the agent runtime.
107
+
108
+ ```typescript
109
+ browser.setCurrentThread('thread-123')
110
+ ```
111
+
112
+ #### `getCurrentThread()`
113
+
114
+ Gets the current thread ID.
115
+
116
+ ```typescript
117
+ const threadId = browser.getCurrentThread()
118
+ ```
119
+
120
+ **Returns:** `string`
121
+
122
+ #### `hasThreadSession(threadId)`
123
+
124
+ Checks if a thread has an active browser session.
125
+
126
+ ```typescript
127
+ const hasSession = browser.hasThreadSession('thread-123')
128
+ ```
129
+
130
+ **Returns:** `boolean`
131
+
132
+ #### `closeThreadSession(threadId)`
133
+
134
+ Closes a specific thread's browser session. For 'thread' scope, this closes that thread's browser instance. For 'shared' scope, this clears the thread's state.
135
+
136
+ ```typescript
137
+ await browser.closeThreadSession('thread-123')
138
+ ```
139
+
140
+ ### Tools
141
+
142
+ #### `getTools()`
143
+
144
+ Returns the browser tools for use with agents. Each provider returns different tools based on its paradigm.
145
+
146
+ ```typescript
147
+ const tools = browser.getTools()
148
+ ```
149
+
150
+ **Returns:** `Record<string, Tool>`
151
+
152
+ ### Screencast
153
+
154
+ #### `startScreencast(options?, threadId?)`
155
+
156
+ Starts streaming browser frames. Returns a `ScreencastStream` that emits frame events.
157
+
158
+ ```typescript
159
+ const stream = await browser.startScreencast({ format: 'jpeg', quality: 80 }, 'thread-123')
160
+
161
+ stream.on('frame', frame => {
162
+ console.log('Frame received:', frame.data.length, 'bytes')
163
+ })
164
+
165
+ stream.on('stop', reason => {
166
+ console.log('Screencast stopped:', reason)
167
+ })
168
+ ```
169
+
170
+ **Returns:** `Promise<ScreencastStream>`
171
+
172
+ ### Input injection
173
+
174
+ #### `injectMouseEvent(params, threadId?)`
175
+
176
+ Injects a mouse event into the browser. Used by Studio for live interaction.
177
+
178
+ ```typescript
179
+ await browser.injectMouseEvent({
180
+ type: 'mousePressed',
181
+ x: 100,
182
+ y: 200,
183
+ button: 'left',
184
+ clickCount: 1,
185
+ })
186
+ ```
187
+
188
+ #### `injectKeyboardEvent(params, threadId?)`
189
+
190
+ Injects a keyboard event into the browser. Used by Studio for live interaction.
191
+
192
+ ```typescript
193
+ await browser.injectKeyboardEvent({
194
+ type: 'keyDown',
195
+ key: 'Enter',
196
+ code: 'Enter',
197
+ })
198
+ ```
199
+
200
+ ### State
201
+
202
+ #### `getState(threadId?)`
203
+
204
+ Gets the current browser state including URL and tabs.
205
+
206
+ ```typescript
207
+ const state = await browser.getState('thread-123')
208
+ console.log('Current URL:', state.currentUrl)
209
+ console.log('Tabs:', state.tabs)
210
+ ```
211
+
212
+ **Returns:** `Promise<BrowserState>`
213
+
214
+ ```typescript
215
+ interface BrowserState {
216
+ currentUrl: string | null
217
+ tabs: BrowserTabState[]
218
+ activeTabIndex: number
219
+ }
220
+
221
+ interface BrowserTabState {
222
+ id: string
223
+ url: string
224
+ title: string
225
+ }
226
+ ```
227
+
228
+ #### `getCurrentUrl(threadId?)`
229
+
230
+ Gets the current page URL.
231
+
232
+ ```typescript
233
+ const url = await browser.getCurrentUrl()
234
+ ```
235
+
236
+ **Returns:** `Promise<string | null>`
237
+
238
+ ## Browser scope
239
+
240
+ The `scope` option controls how browser instances are shared across conversation threads:
241
+
242
+ | Scope | Description | Use case |
243
+ | ---------- | ------------------------------------------- | ---------------------------------------- |
244
+ | `'shared'` | All threads share a single browser instance | Cost-efficient for non-conflicting tasks |
245
+ | `'thread'` | Each thread gets its own browser instance | Full isolation for concurrent users |
246
+
247
+ ```typescript
248
+ // Shared browser for all threads
249
+ const sharedBrowser = new AgentBrowser({
250
+ scope: 'shared',
251
+ })
252
+
253
+ // Isolated browser per thread
254
+ const isolatedBrowser = new AgentBrowser({
255
+ scope: 'thread',
256
+ })
257
+ ```
258
+
259
+ When using `cdpUrl` to connect to an external browser, the scope automatically falls back to `'shared'` since you can't spawn new browser instances.
260
+
261
+ ## Cloud browser providers
262
+
263
+ Connect to cloud browser services using the `cdpUrl` option:
264
+
265
+ ```typescript
266
+ // Static CDP URL
267
+ const browser = new AgentBrowser({
268
+ cdpUrl: 'wss://browser.example.com/ws',
269
+ })
270
+
271
+ // Dynamic CDP URL (e.g., session-based)
272
+ const browser = new AgentBrowser({
273
+ cdpUrl: async () => {
274
+ const session = await createBrowserSession()
275
+ return session.wsUrl
276
+ },
277
+ })
278
+ ```
279
+
280
+ ## Related
281
+
282
+ - [AgentBrowser](https://mastra.ai/reference/browser/agent-browser): Deterministic browser automation
283
+ - [StagehandBrowser](https://mastra.ai/reference/browser/stagehand-browser): AI-powered browser automation
284
+ - [Browser overview](https://mastra.ai/docs/browser/overview): Conceptual guide to browser automation
@@ -0,0 +1,290 @@
1
+ # StagehandBrowser class
2
+
3
+ The `StagehandBrowser` class provides AI-powered browser automation using [Stagehand](https://github.com/browserbase/stagehand). It uses natural language instructions for interactions instead of element refs.
4
+
5
+ Use `StagehandBrowser` when you want AI to interpret and execute browser actions from natural language. For deterministic automation using element refs, see [`AgentBrowser`](https://mastra.ai/reference/browser/agent-browser).
6
+
7
+ ## Usage example
8
+
9
+ ```typescript
10
+ import { Agent } from '@mastra/core/agent'
11
+ import { StagehandBrowser } from '@mastra/stagehand'
12
+
13
+ const browser = new StagehandBrowser({
14
+ headless: true,
15
+ model: 'openai/gpt-5.4',
16
+ selfHeal: true,
17
+ })
18
+
19
+ export const browserAgent = new Agent({
20
+ name: 'browser-agent',
21
+ instructions: `You can browse the web using natural language.
22
+ Use stagehand_act to perform actions like "click the login button".
23
+ Use stagehand_extract to get data from pages.`,
24
+ model: 'openai/gpt-5.4',
25
+ browser,
26
+ })
27
+ ```
28
+
29
+ ## Constructor parameters
30
+
31
+ **headless** (`boolean`): Whether to run the browser in headless mode. (Default: `true`)
32
+
33
+ **viewport** (`{ width: number; height: number }`): Browser viewport dimensions. (Default: `{ width: 1280, height: 720 }`)
34
+
35
+ **env** (`'LOCAL' | 'BROWSERBASE'`): Environment to run the browser in. Use 'BROWSERBASE' for cloud execution. (Default: `'LOCAL'`)
36
+
37
+ **apiKey** (`string`): Browserbase API key. Required when env is 'BROWSERBASE'.
38
+
39
+ **projectId** (`string`): Browserbase project ID. Required when env is 'BROWSERBASE'.
40
+
41
+ **model** (`string | ModelConfiguration`): Model configuration for AI operations. Can be a string like 'openai/gpt-5.4' or an object with modelName, apiKey, and baseURL. (Default: `'openai/gpt-5.4'`)
42
+
43
+ **selfHeal** (`boolean`): Enable self-healing selectors. When enabled, Stagehand uses AI to find elements even when initial selectors fail. (Default: `true`)
44
+
45
+ **domSettleTimeout** (`number`): Timeout in milliseconds for DOM to settle after actions. (Default: `5000`)
46
+
47
+ **verbose** (`0 | 1 | 2`): Logging verbosity level. 0 = silent, 1 = errors only, 2 = verbose. (Default: `1`)
48
+
49
+ **systemPrompt** (`string`): Custom system prompt for AI operations.
50
+
51
+ **cdpUrl** (`string | (() => string | Promise<string>)`): CDP WebSocket URL or HTTP endpoint for connecting to an existing browser. HTTP endpoints are resolved to WebSocket internally.
52
+
53
+ **scope** (`'shared' | 'thread'`): Browser instance scope across threads. (Default: `'thread' (or 'shared' when cdpUrl is provided)`)
54
+
55
+ **timeout** (`number`): Default timeout in milliseconds for browser operations. (Default: `10000`)
56
+
57
+ **onLaunch** (`(args: { browser: MastraBrowser }) => void | Promise<void>`): Callback invoked after the browser is ready.
58
+
59
+ **onClose** (`(args: { browser: MastraBrowser }) => void | Promise<void>`): Callback invoked before the browser closes.
60
+
61
+ **screencast** (`ScreencastOptions`): Configuration for streaming browser frames to Studio.
62
+
63
+ ## Tools
64
+
65
+ `StagehandBrowser` provides 6 AI-powered tools for browser automation:
66
+
67
+ | Tool | Description |
68
+ | -------------------- | --------------------------------------------------- |
69
+ | `stagehand_act` | Perform actions using natural language instructions |
70
+ | `stagehand_extract` | Extract structured data from pages |
71
+ | `stagehand_observe` | Discover actionable elements on a page |
72
+ | `stagehand_navigate` | Navigate to a URL |
73
+ | `stagehand_tabs` | Manage browser tabs |
74
+ | `stagehand_close` | Close the browser |
75
+
76
+ ## Tool reference
77
+
78
+ ### `stagehand_act`
79
+
80
+ Perform an action using natural language instructions. The AI interprets your instruction and executes the appropriate browser action.
81
+
82
+ ```text
83
+ // Tool input
84
+ {
85
+ "instruction": "click the login button",
86
+ "variables": { "username": "john" },
87
+ "useVision": true,
88
+ "timeout": 30000
89
+ }
90
+
91
+ // With variable substitution
92
+ {
93
+ "instruction": "type %email% into the email field",
94
+ "variables": { "email": "user@example.com" }
95
+ }
96
+ ```
97
+
98
+ | Parameter | Type | Description |
99
+ | ------------- | ------------------------ | ---------------------------------------------------- |
100
+ | `instruction` | `string` | Natural language instruction (required) |
101
+ | `variables` | `Record<string, string>` | Variables for %variableName% substitution (optional) |
102
+ | `useVision` | `boolean` | Enable vision capabilities (optional) |
103
+ | `timeout` | `number` | Timeout in ms (optional) |
104
+
105
+ **Returns:**
106
+
107
+ ```typescript
108
+ interface ActResult {
109
+ success: boolean
110
+ message?: string
111
+ action?: string
112
+ url?: string
113
+ }
114
+ ```
115
+
116
+ ### `stagehand_extract`
117
+
118
+ Extract structured data from a page using natural language instructions.
119
+
120
+ ```text
121
+ // Basic extraction
122
+ {
123
+ "instruction": "extract all product names and prices"
124
+ }
125
+
126
+ // With schema for structured output
127
+ {
128
+ "instruction": "extract the product information",
129
+ "schema": {
130
+ "type": "object",
131
+ "properties": {
132
+ "name": { "type": "string" },
133
+ "price": { "type": "number" },
134
+ "inStock": { "type": "boolean" }
135
+ }
136
+ }
137
+ }
138
+ ```
139
+
140
+ **Returns:**
141
+
142
+ ```typescript
143
+ interface ExtractResult<T = unknown> {
144
+ success: boolean
145
+ data?: T
146
+ hint?: string
147
+ error?: string
148
+ url?: string
149
+ }
150
+ ```
151
+
152
+ ### `stagehand_observe`
153
+
154
+ Discover actionable elements on a page. Returns a list of elements with their selectors and descriptions.
155
+
156
+ ```text
157
+ // Find specific elements
158
+ {
159
+ "instruction": "find all buttons related to checkout"
160
+ }
161
+
162
+ // Find all interactive elements
163
+ {
164
+ "onlyVisible": true
165
+ }
166
+ ```
167
+
168
+ | Parameter | Type | Description |
169
+ | ------------- | --------- | --------------------------------------------------------- |
170
+ | `instruction` | `string` | Natural language instruction (optional, omit to find all) |
171
+ | `onlyVisible` | `boolean` | Only include visible elements (optional) |
172
+ | `timeout` | `number` | Timeout in ms (optional) |
173
+
174
+ **Returns:**
175
+
176
+ ```typescript
177
+ interface ObserveResult {
178
+ success: boolean
179
+ actions: StagehandAction[]
180
+ url?: string
181
+ }
182
+
183
+ interface StagehandAction {
184
+ selector: string
185
+ description: string
186
+ method?: string
187
+ arguments?: string[]
188
+ }
189
+ ```
190
+
191
+ ### `stagehand_navigate`
192
+
193
+ Navigate to a URL.
194
+
195
+ ```text
196
+ // Tool input
197
+ {
198
+ "url": "https://example.com",
199
+ "waitUntil": "domcontentloaded"
200
+ }
201
+ ```
202
+
203
+ | Parameter | Type | Description |
204
+ | ----------- | ----------------------------------------------- | ----------------------------------------------- |
205
+ | `url` | `string` | URL to navigate to (required) |
206
+ | `waitUntil` | `"load" \| "domcontentloaded" \| "networkidle"` | When to consider navigation complete (optional) |
207
+
208
+ ### `stagehand_tabs`
209
+
210
+ Manage browser tabs.
211
+
212
+ ```text
213
+ // List all tabs
214
+ { "action": "list" }
215
+
216
+ // Open new tab
217
+ { "action": "new", "url": "https://example.com" }
218
+
219
+ // Switch to tab by index
220
+ { "action": "switch", "index": 0 }
221
+
222
+ // Close tab by index (or current if omitted)
223
+ { "action": "close", "index": 1 }
224
+ ```
225
+
226
+ ### `stagehand_close`
227
+
228
+ Close the browser and clean up resources.
229
+
230
+ ```text
231
+ // Tool input (no parameters required)
232
+
233
+ ```
234
+
235
+ ## Using Browserbase
236
+
237
+ Run Stagehand in the cloud using Browserbase:
238
+
239
+ ```typescript
240
+ const browser = new StagehandBrowser({
241
+ env: 'BROWSERBASE',
242
+ apiKey: process.env.BROWSERBASE_API_KEY,
243
+ projectId: process.env.BROWSERBASE_PROJECT_ID,
244
+ model: 'openai/gpt-5.4',
245
+ })
246
+ ```
247
+
248
+ ## Model configuration
249
+
250
+ Configure the AI model for Stagehand operations:
251
+
252
+ ```typescript
253
+ // String format: "provider/model"
254
+ const browser = new StagehandBrowser({
255
+ model: 'openai/gpt-5.4',
256
+ })
257
+
258
+ // Object format for custom configuration
259
+ const browser = new StagehandBrowser({
260
+ model: {
261
+ modelName: 'gpt-5.4',
262
+ apiKey: process.env.OPENAI_API_KEY,
263
+ baseURL: 'https://api.openai.com/v1',
264
+ },
265
+ })
266
+ ```
267
+
268
+ Supported providers:
269
+
270
+ - OpenAI: `"openai/gpt-5.4"`, `"openai/gpt-5.4-mini"`
271
+ - Anthropic: `"anthropic/claude-3-5-sonnet-20241022"`
272
+
273
+ ## AgentBrowser vs StagehandBrowser
274
+
275
+ | Aspect | AgentBrowser | StagehandBrowser |
276
+ | --------------- | -------------------------- | --------------------- |
277
+ | **Approach** | Deterministic refs (`@e5`) | Natural language |
278
+ | **Precision** | Exact element targeting | AI interpretation |
279
+ | **Flexibility** | Requires a snapshot first | Direct instructions |
280
+ | **Use case** | Reproducible automation | Adaptive automation |
281
+ | **Speed** | Faster (no AI inference) | Slower (AI inference) |
282
+
283
+ Choose `AgentBrowser` for precise, reproducible automation. Choose `StagehandBrowser` for flexible, natural language interactions.
284
+
285
+ ## Related
286
+
287
+ - [MastraBrowser](https://mastra.ai/reference/browser/mastra-browser): Base class reference
288
+ - [AgentBrowser](https://mastra.ai/reference/browser/agent-browser): Deterministic alternative
289
+ - [Browser overview](https://mastra.ai/docs/browser/overview): Conceptual guide
290
+ - [Stagehand guide](https://mastra.ai/docs/browser/stagehand): Usage guide
@@ -39,6 +39,9 @@ The Reference section provides documentation of Mastra's API, including paramete
39
39
  - [Okta](https://mastra.ai/reference/auth/okta)
40
40
  - [Supabase](https://mastra.ai/reference/auth/supabase)
41
41
  - [WorkOS](https://mastra.ai/reference/auth/workos)
42
+ - [AgentBrowser](https://mastra.ai/reference/browser/agent-browser)
43
+ - [MastraBrowser Class](https://mastra.ai/reference/browser/mastra-browser)
44
+ - [StagehandBrowser](https://mastra.ai/reference/browser/stagehand-browser)
42
45
  - [create-mastra](https://mastra.ai/reference/cli/create-mastra)
43
46
  - [mastra](https://mastra.ai/reference/cli/mastra)
44
47
  - [Agents API](https://mastra.ai/reference/client-js/agents)
@@ -0,0 +1,122 @@
1
+ # ArthurExporter
2
+
3
+ Sends Tracing data to [Arthur Engine](https://github.com/arthur-ai/arthur-engine) using OpenTelemetry and OpenInference semantic conventions.
4
+
5
+ ## Constructor
6
+
7
+ ```typescript
8
+ new ArthurExporter(config: ArthurExporterConfig)
9
+ ```
10
+
11
+ ## `ArthurExporterConfig`
12
+
13
+ ```typescript
14
+ type ArthurExporterConfig = Omit<OtelExporterConfig, 'provider' | 'exporter'> & {
15
+ apiKey?: string
16
+ endpoint?: string
17
+ taskId?: string
18
+ headers?: Record<string, string>
19
+ }
20
+ ```
21
+
22
+ Inherits from `OtelExporterConfig` (excluding `provider` and `exporter`), which includes:
23
+
24
+ - `timeout?: number` - Export timeout in milliseconds (default: 30000)
25
+ - `batchSize?: number` - Number of spans per batch (default: 512)
26
+ - `logLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error'` - Log level (default: WARN)
27
+ - `resourceAttributes?: Record<string, any>` - Custom resource attributes
28
+
29
+ ### Metadata passthrough
30
+
31
+ Non-reserved span attributes are serialized into the OpenInference `metadata` payload. Add them via `tracingOptions.metadata` (e.g., `companyId`, `tier`). Reserved fields such as `input`, `output`, `sessionId`, thread/user IDs, and OpenInference IDs are excluded automatically.
32
+
33
+ ## Methods
34
+
35
+ ### `exportTracingEvent`
36
+
37
+ ```typescript
38
+ async exportTracingEvent(event: TracingEvent): Promise<void>
39
+ ```
40
+
41
+ Exports a tracing event to the configured endpoint.
42
+
43
+ ### export
44
+
45
+ ```typescript
46
+ async export(spans: ReadOnlySpan[]): Promise<void>
47
+ ```
48
+
49
+ Batch exports spans using OpenTelemetry with OpenInference semantic conventions.
50
+
51
+ ### flush
52
+
53
+ ```typescript
54
+ async flush(): Promise<void>
55
+ ```
56
+
57
+ Force flushes any buffered spans to the configured endpoint without shutting down the exporter. Useful in serverless environments where you need to ensure spans are exported before the runtime terminates.
58
+
59
+ ### shutdown
60
+
61
+ ```typescript
62
+ async shutdown(): Promise<void>
63
+ ```
64
+
65
+ Flushes pending data and shuts down the client.
66
+
67
+ ## Usage
68
+
69
+ ### Zero-Config (using environment variables)
70
+
71
+ ```typescript
72
+ import { ArthurExporter } from '@mastra/arthur'
73
+
74
+ // Set ARTHUR_API_KEY and ARTHUR_BASE_URL (optionally ARTHUR_TASK_ID)
75
+ const exporter = new ArthurExporter()
76
+ ```
77
+
78
+ ### Explicit Configuration
79
+
80
+ ```typescript
81
+ import { ArthurExporter } from '@mastra/arthur'
82
+
83
+ const exporter = new ArthurExporter({
84
+ apiKey: process.env.ARTHUR_API_KEY!,
85
+ endpoint: 'http://localhost:3030',
86
+ taskId: process.env.ARTHUR_TASK_ID, // Optional
87
+ })
88
+ ```
89
+
90
+ ## `OpenInference` semantic conventions
91
+
92
+ The ArthurExporter implements [OpenInference Semantic Conventions](https://github.com/Arize-ai/openinference/tree/main/spec) for generative AI applications, providing standardized trace structure across different observability platforms.
93
+
94
+ ## Tags support
95
+
96
+ The ArthurExporter supports trace tagging for categorization and filtering. Tags are only applied to root spans and are mapped to the native OpenInference `tag.tags` semantic convention.
97
+
98
+ ### Usage
99
+
100
+ ```typescript
101
+ const result = await agent.generate('Hello', {
102
+ tracingOptions: {
103
+ tags: ['production', 'experiment-v2', 'user-request'],
104
+ },
105
+ })
106
+ ```
107
+
108
+ ### How Tags Are Stored
109
+
110
+ Tags are stored using the OpenInference `tag.tags` attribute:
111
+
112
+ ```json
113
+ {
114
+ "tag.tags": ["production", "experiment-v2", "user-request"]
115
+ }
116
+ ```
117
+
118
+ ## Related
119
+
120
+ - [ArthurExporter Documentation](https://mastra.ai/docs/observability/tracing/exporters/arthur)
121
+ - [Arthur Engine documentation](https://docs.arthur.ai/)
122
+ - [Arthur Engine repository](https://github.com/arthur-ai/arthur-engine)