@mastra/mcp-docs-server 0.13.24-alpha.3 → 0.13.25-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.
Files changed (105) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +8 -8
  2. package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
  3. package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +12 -0
  4. package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +11 -0
  5. package/.docs/organized/changelogs/%40mastra%2Fastra.md +10 -10
  6. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +10 -10
  7. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +10 -10
  8. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +29 -29
  9. package/.docs/organized/changelogs/%40mastra%2Fcloud.md +10 -10
  10. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +10 -10
  11. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +11 -11
  12. package/.docs/organized/changelogs/%40mastra%2Fcore.md +70 -70
  13. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +10 -10
  14. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +25 -25
  15. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +23 -23
  16. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +24 -24
  17. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +24 -24
  18. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +30 -30
  19. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +10 -10
  20. package/.docs/organized/changelogs/%40mastra%2Fevals.md +21 -21
  21. package/.docs/organized/changelogs/%40mastra%2Flance.md +11 -11
  22. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +10 -10
  23. package/.docs/organized/changelogs/%40mastra%2Floggers.md +10 -10
  24. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +17 -17
  25. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +10 -10
  26. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +10 -10
  27. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +18 -18
  28. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +10 -10
  29. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +10 -10
  30. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +11 -11
  31. package/.docs/organized/changelogs/%40mastra%2Fpg.md +16 -16
  32. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +10 -10
  33. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +56 -56
  34. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +11 -11
  35. package/.docs/organized/changelogs/%40mastra%2Frag.md +13 -13
  36. package/.docs/organized/changelogs/%40mastra%2Freact-hooks.md +8 -0
  37. package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -0
  38. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
  39. package/.docs/organized/changelogs/%40mastra%2Fserver.md +36 -36
  40. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +10 -10
  41. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +13 -13
  42. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +10 -10
  43. package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +10 -10
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +10 -10
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +10 -10
  46. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +10 -10
  47. package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +9 -0
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +9 -0
  49. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +11 -11
  50. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +11 -11
  51. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +11 -11
  52. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +11 -11
  53. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +10 -10
  54. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +10 -10
  55. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +10 -10
  56. package/.docs/organized/changelogs/create-mastra.md +28 -28
  57. package/.docs/organized/changelogs/mastra.md +52 -52
  58. package/.docs/raw/index.mdx +1 -0
  59. package/.docs/raw/observability/ai-tracing/exporters/braintrust.mdx +81 -0
  60. package/.docs/raw/observability/ai-tracing/exporters/cloud.mdx +120 -0
  61. package/.docs/raw/observability/ai-tracing/exporters/default.mdx +167 -0
  62. package/.docs/raw/observability/ai-tracing/exporters/langfuse.mdx +121 -0
  63. package/.docs/raw/observability/ai-tracing/overview.mdx +565 -0
  64. package/.docs/raw/observability/ai-tracing/processors/sensitive-data-filter.mdx +274 -0
  65. package/.docs/raw/observability/{tracing.mdx → otel-tracing.mdx} +2 -2
  66. package/.docs/raw/observability/overview.mdx +66 -0
  67. package/.docs/raw/reference/agents/generate.mdx +39 -1
  68. package/.docs/raw/reference/agents/generateVNext.mdx +34 -2
  69. package/.docs/raw/reference/agents/network.mdx +34 -2
  70. package/.docs/raw/reference/observability/ai-tracing/ai-tracing.mdx +181 -0
  71. package/.docs/raw/reference/observability/ai-tracing/configuration.mdx +233 -0
  72. package/.docs/raw/reference/observability/ai-tracing/exporters/braintrust.mdx +112 -0
  73. package/.docs/raw/reference/observability/ai-tracing/exporters/cloud-exporter.mdx +176 -0
  74. package/.docs/raw/reference/observability/ai-tracing/exporters/console-exporter.mdx +148 -0
  75. package/.docs/raw/reference/observability/ai-tracing/exporters/default-exporter.mdx +196 -0
  76. package/.docs/raw/reference/observability/ai-tracing/exporters/langfuse.mdx +116 -0
  77. package/.docs/raw/reference/observability/ai-tracing/interfaces.mdx +651 -0
  78. package/.docs/raw/reference/observability/ai-tracing/processors/sensitive-data-filter.mdx +178 -0
  79. package/.docs/raw/reference/observability/ai-tracing/span.mdx +371 -0
  80. package/.docs/raw/reference/observability/otel-tracing/providers/index.mdx +22 -0
  81. package/.docs/raw/reference/streaming/agents/stream.mdx +39 -1
  82. package/.docs/raw/reference/streaming/agents/streamVNext.mdx +34 -2
  83. package/.docs/raw/reference/streaming/workflows/stream.mdx +38 -0
  84. package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +38 -0
  85. package/.docs/raw/reference/tools/create-tool.mdx +34 -1
  86. package/.docs/raw/reference/workflows/run-methods/resume.mdx +38 -0
  87. package/.docs/raw/reference/workflows/run-methods/start.mdx +38 -0
  88. package/CHANGELOG.md +15 -0
  89. package/package.json +5 -5
  90. package/.docs/raw/observability/ai-tracing.mdx +0 -597
  91. package/.docs/raw/reference/observability/providers/index.mdx +0 -20
  92. /package/.docs/raw/reference/observability/{logger.mdx → logging/pino-logger.mdx} +0 -0
  93. /package/.docs/raw/reference/observability/{otel-config.mdx → otel-tracing/otel-config.mdx} +0 -0
  94. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/arize-ax.mdx +0 -0
  95. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/arize-phoenix.mdx +0 -0
  96. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/braintrust.mdx +0 -0
  97. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/dash0.mdx +0 -0
  98. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/keywordsai.mdx +0 -0
  99. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/laminar.mdx +0 -0
  100. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/langfuse.mdx +0 -0
  101. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/langsmith.mdx +0 -0
  102. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/langwatch.mdx +0 -0
  103. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/new-relic.mdx +0 -0
  104. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/signoz.mdx +0 -0
  105. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/traceloop.mdx +0 -0
@@ -0,0 +1,181 @@
1
+ ---
2
+ title: "AITracing | AI Tracing | Reference"
3
+ description: Core AI Tracing classes and methods
4
+ ---
5
+
6
+ import { PropertiesTable } from "@/components/properties-table";
7
+
8
+ # AITracing
9
+
10
+ ## DefaultAITracing
11
+
12
+ Default implementation of the AITracing interface.
13
+
14
+ ### Constructor
15
+
16
+ ```typescript
17
+ new DefaultAITracing(config: TracingConfig)
18
+ ```
19
+
20
+ Creates a new DefaultAITracing instance with the specified configuration.
21
+
22
+ ### Properties
23
+
24
+ Inherits all properties and methods from BaseAITracing.
25
+
26
+ ## BaseAITracing
27
+
28
+ Base class for custom AI tracing implementations.
29
+
30
+ ### Methods
31
+
32
+ #### getConfig
33
+
34
+ ```typescript
35
+ getConfig(): Readonly<Required<TracingConfig>>
36
+ ```
37
+
38
+ Returns the current tracing configuration.
39
+
40
+ #### getExporters
41
+
42
+ ```typescript
43
+ getExporters(): readonly AITracingExporter[]
44
+ ```
45
+
46
+ Returns all configured exporters.
47
+
48
+ #### getProcessors
49
+
50
+ ```typescript
51
+ getProcessors(): readonly AISpanProcessor[]
52
+ ```
53
+
54
+ Returns all configured processors.
55
+
56
+ #### getLogger
57
+
58
+ ```typescript
59
+ getLogger(): IMastraLogger
60
+ ```
61
+
62
+ Returns the logger instance for exporters and other components.
63
+
64
+ #### startSpan
65
+
66
+ ```typescript
67
+ startSpan<TType extends AISpanType>(
68
+ options: StartSpanOptions<TType>
69
+ ): AISpan<TType>
70
+ ```
71
+
72
+ Start a new span of a specific AISpanType. Creates the root span of a trace if no parent is provided.
73
+
74
+ <PropertiesTable
75
+ props={[
76
+ {
77
+ name: "type",
78
+ type: "AISpanType",
79
+ description: "Type of span to create",
80
+ required: true,
81
+ },
82
+ {
83
+ name: "name",
84
+ type: "string",
85
+ description: "Name of the span",
86
+ required: true,
87
+ },
88
+ {
89
+ name: "parent",
90
+ type: "AnyAISpan",
91
+ description: "Parent span (if not root)",
92
+ required: false,
93
+ },
94
+ {
95
+ name: "attributes",
96
+ type: "AISpanTypeMap[TType]",
97
+ description: "Type-specific attributes",
98
+ required: false,
99
+ },
100
+ {
101
+ name: "metadata",
102
+ type: "Record<string, any>",
103
+ description: "User-defined metadata",
104
+ required: false,
105
+ },
106
+ {
107
+ name: "input",
108
+ type: "any",
109
+ description: "Initial input data",
110
+ required: false,
111
+ },
112
+ {
113
+ name: "customSamplerOptions",
114
+ type: "CustomSamplerOptions",
115
+ description: "Options for custom sampler",
116
+ required: false,
117
+ },
118
+ ]}
119
+ />
120
+
121
+ #### shutdown
122
+
123
+ ```typescript
124
+ async shutdown(): Promise<void>
125
+ ```
126
+
127
+ Shuts down all exporters and processors, cleaning up resources.
128
+
129
+ ## Custom Implementation
130
+
131
+ To create a custom AI tracing implementation, extend BaseAITracing:
132
+
133
+ ```typescript
134
+ class CustomAITracing extends BaseAITracing {
135
+ constructor(config: TracingConfig) {
136
+ super(config);
137
+ // Custom initialization
138
+ }
139
+
140
+ // Override methods as needed
141
+ startSpan<TType extends AISpanType>(
142
+ options: StartSpanOptions<TType>
143
+ ): AISpan<TType> {
144
+ // Custom span creation logic
145
+ return super.startSpan(options);
146
+ }
147
+ }
148
+ ```
149
+
150
+ ## NO-OP Spans
151
+
152
+ When tracing is disabled (sampling returns false), NO-OP spans are returned:
153
+
154
+ ### NoOpAISpan
155
+
156
+ ```typescript
157
+ class NoOpAISpan<TType extends AISpanType> extends BaseAISpan<TType>
158
+ ```
159
+
160
+ A span that performs no operations. All methods are no-ops:
161
+ - `id` returns `'no-op'`
162
+ - `traceId` returns `'no-op-trace'`
163
+ - `isValid` returns `false`
164
+ - `end()`, `error()`, `update()` do nothing
165
+ - `createChildSpan()` returns another NO-OP span
166
+
167
+ ## See Also
168
+
169
+ ### Documentation
170
+ - [AI Tracing Overview](/docs/observability/ai-tracing/overview) - Concepts and usage guide
171
+ - [Configuration Reference](/reference/observability/ai-tracing/configuration) - Configuration options
172
+ - [Interfaces Reference](/reference/observability/ai-tracing/interfaces) - Type definitions
173
+ - [Span Reference](/reference/observability/ai-tracing/span) - Span lifecycle and methods
174
+
175
+ ### Examples
176
+ - [Basic AI Tracing](/examples/observability/basic-ai-tracing) - Getting started example
177
+
178
+ ### Exporters
179
+ - [DefaultExporter](/reference/observability/ai-tracing/exporters/default-exporter) - Storage persistence
180
+ - [CloudExporter](/reference/observability/ai-tracing/exporters/cloud-exporter) - Mastra Cloud integration
181
+ - [ConsoleExporter](/reference/observability/ai-tracing/exporters/console-exporter) - Debug output
@@ -0,0 +1,233 @@
1
+ ---
2
+ title: "Configuration | AI Tracing | Reference"
3
+ description: AI Tracing configuration types and registry functions
4
+ ---
5
+
6
+ import { PropertiesTable } from "@/components/properties-table";
7
+
8
+ # Configuration
9
+
10
+ ## ObservabilityRegistryConfig
11
+
12
+ ```typescript
13
+ interface ObservabilityRegistryConfig {
14
+ default?: { enabled?: boolean };
15
+ configs?: Record<string, TracingConfig | AITracing>;
16
+ configSelector?: ConfigSelector;
17
+ }
18
+ ```
19
+
20
+ <PropertiesTable
21
+ props={[
22
+ {
23
+ name: "default",
24
+ type: "{ enabled?: boolean }",
25
+ description: "Enable default configuration",
26
+ required: false,
27
+ },
28
+ {
29
+ name: "configs",
30
+ type: "Record<string, TracingConfig | AITracing>",
31
+ description: "Named tracing configurations",
32
+ required: false,
33
+ },
34
+ {
35
+ name: "configSelector",
36
+ type: "ConfigSelector",
37
+ description: "Runtime configuration selector",
38
+ required: false,
39
+ },
40
+ ]}
41
+ />
42
+
43
+ ## TracingConfig
44
+
45
+ ```typescript
46
+ interface TracingConfig {
47
+ name: string;
48
+ serviceName: string;
49
+ sampling?: SamplingStrategy;
50
+ exporters?: AITracingExporter[];
51
+ processors?: AISpanProcessor[];
52
+ }
53
+ ```
54
+
55
+ <PropertiesTable
56
+ props={[
57
+ {
58
+ name: "name",
59
+ type: "string",
60
+ description: "Configuration identifier",
61
+ required: true,
62
+ },
63
+ {
64
+ name: "serviceName",
65
+ type: "string",
66
+ description: "Service name in traces",
67
+ required: true,
68
+ },
69
+ {
70
+ name: "sampling",
71
+ type: "SamplingStrategy",
72
+ description: "Sampling configuration",
73
+ required: false,
74
+ },
75
+ {
76
+ name: "exporters",
77
+ type: "AITracingExporter[]",
78
+ description: "Trace data exporters",
79
+ required: false,
80
+ },
81
+ {
82
+ name: "processors",
83
+ type: "AISpanProcessor[]",
84
+ description: "Span processors",
85
+ required: false,
86
+ },
87
+ ]}
88
+ />
89
+
90
+ ## SamplingStrategy
91
+
92
+ ```typescript
93
+ type SamplingStrategy =
94
+ | { type: 'always' }
95
+ | { type: 'never' }
96
+ | { type: 'ratio', probability: number }
97
+ | { type: 'custom', sampler: (options?: TracingOptions) => boolean };
98
+ ```
99
+
100
+ ## ConfigSelector
101
+
102
+ ```typescript
103
+ type ConfigSelector = (
104
+ options: ConfigSelectorOptions,
105
+ availableConfigs: Map<string, AITracing>
106
+ ) => string | undefined;
107
+ ```
108
+
109
+ ## ConfigSelectorOptions
110
+
111
+ ```typescript
112
+ interface ConfigSelectorOptions {
113
+ metadata?: Record<string, any>;
114
+ runtimeContext?: Map<string, any>;
115
+ }
116
+ ```
117
+
118
+ # Registry Functions
119
+
120
+ ## setupAITracing
121
+
122
+ ```typescript
123
+ function setupAITracing(config: ObservabilityRegistryConfig): void
124
+ ```
125
+
126
+ Initializes AI tracing from configuration. Called automatically by Mastra constructor.
127
+
128
+ ## registerAITracing
129
+
130
+ ```typescript
131
+ function registerAITracing(
132
+ name: string,
133
+ instance: AITracing,
134
+ isDefault?: boolean
135
+ ): void
136
+ ```
137
+
138
+ Registers a tracing config in the global registry.
139
+
140
+ ## getAITracing
141
+
142
+ ```typescript
143
+ function getAITracing(name: string): AITracing | undefined
144
+ ```
145
+
146
+ Retrieves a tracing config by name.
147
+
148
+ ## getDefaultAITracing
149
+
150
+ ```typescript
151
+ function getDefaultAITracing(): AITracing | undefined
152
+ ```
153
+
154
+ Returns the default tracing config.
155
+
156
+ ## getSelectedAITracing
157
+
158
+ ```typescript
159
+ function getSelectedAITracing(
160
+ options: ConfigSelectorOptions
161
+ ): AITracing | undefined
162
+ ```
163
+
164
+ Returns the tracing config selected by the config selector or default.
165
+
166
+ ## setSelector
167
+
168
+ ```typescript
169
+ function setSelector(selector: ConfigSelector): void
170
+ ```
171
+
172
+ Sets the global config selector function.
173
+
174
+ ## unregisterAITracing
175
+
176
+ ```typescript
177
+ function unregisterAITracing(name: string): boolean
178
+ ```
179
+
180
+ Removes a tracing config from the registry.
181
+
182
+ ## shutdownAITracingRegistry
183
+
184
+ ```typescript
185
+ async function shutdownAITracingRegistry(): Promise<void>
186
+ ```
187
+
188
+ Shuts down all tracing configs and clears the registry.
189
+
190
+ ## clearAITracingRegistry
191
+
192
+ ```typescript
193
+ function clearAITracingRegistry(): void
194
+ ```
195
+
196
+ Clears all configs without shutdown.
197
+
198
+ ## getAllAITracing
199
+
200
+ ```typescript
201
+ function getAllAITracing(): ReadonlyMap<string, AITracing>
202
+ ```
203
+
204
+ Returns all registered tracing configs.
205
+
206
+ ## hasAITracing
207
+
208
+ ```typescript
209
+ function hasAITracing(name: string): boolean
210
+ ```
211
+
212
+ Checks if a tracing instance exists and is enabled.
213
+
214
+ ## See Also
215
+
216
+ ### Documentation
217
+ - [AI Tracing Overview](/docs/observability/ai-tracing/overview) - Concepts and usage guide
218
+ - [Sampling Strategies](/docs/observability/ai-tracing/overview#sampling-strategies) - Sampling configuration details
219
+ - [Multi-Config Setup](/docs/observability/ai-tracing/overview#multi-config-setup) - Using multiple configurations
220
+
221
+ ### Reference
222
+ - [AITracing Classes](/reference/observability/ai-tracing/ai-tracing) - Core tracing classes
223
+ - [Interfaces](/reference/observability/ai-tracing/interfaces) - Type definitions
224
+ - [Span Reference](/reference/observability/ai-tracing/span) - Span lifecycle
225
+
226
+ ### Examples
227
+ - [Basic AI Tracing](/examples/observability/basic-ai-tracing) - Getting started
228
+
229
+ ### Exporters
230
+ - [DefaultExporter](/reference/observability/ai-tracing/exporters/default-exporter) - Storage configuration
231
+ - [CloudExporter](/reference/observability/ai-tracing/exporters/cloud-exporter) - Cloud setup
232
+ - [Langfuse](/reference/observability/ai-tracing/exporters/langfuse) - Langfuse integration
233
+ - [Braintrust](/reference/observability/ai-tracing/exporters/braintrust) - Braintrust integration
@@ -0,0 +1,112 @@
1
+ ---
2
+ title: "BraintrustExporter | Exporters | AI Tracing | Reference"
3
+ description: Braintrust exporter for AI tracing
4
+ ---
5
+
6
+ import { PropertiesTable } from "@/components/properties-table";
7
+
8
+ # BraintrustExporter
9
+
10
+ Sends AI tracing data to Braintrust for eval and observability.
11
+
12
+ ## Constructor
13
+
14
+ ```typescript
15
+ new BraintrustExporter(config: BraintrustExporterConfig)
16
+ ```
17
+
18
+ ## BraintrustExporterConfig
19
+
20
+ ```typescript
21
+ interface BraintrustExporterConfig {
22
+ apiKey?: string;
23
+ endpoint?: string;
24
+ projectName?: string;
25
+ logLevel?: 'debug' | 'info' | 'warn' | 'error';
26
+ tuningParameters?: Record<string, any>;
27
+ }
28
+ ```
29
+
30
+ <PropertiesTable
31
+ props={[
32
+ {
33
+ name: "apiKey",
34
+ type: "string",
35
+ description: "Braintrust API key",
36
+ required: false,
37
+ },
38
+ {
39
+ name: "endpoint",
40
+ type: "string",
41
+ description: "Custom Braintrust endpoint",
42
+ required: false,
43
+ },
44
+ {
45
+ name: "projectName",
46
+ type: "string",
47
+ description: "Project name (default: 'mastra-tracing')",
48
+ required: false,
49
+ },
50
+ {
51
+ name: "logLevel",
52
+ type: "'debug' | 'info' | 'warn' | 'error'",
53
+ description: "Logger level (default: 'warn')",
54
+ required: false,
55
+ },
56
+ {
57
+ name: "tuningParameters",
58
+ type: "Record<string, any>",
59
+ description: "Tuning parameters for Braintrust",
60
+ required: false,
61
+ },
62
+ ]}
63
+ />
64
+
65
+ ## Methods
66
+
67
+ ### exportEvent
68
+
69
+ ```typescript
70
+ async exportEvent(event: AITracingEvent): Promise<void>
71
+ ```
72
+
73
+ Exports a tracing event to Braintrust.
74
+
75
+ ### export
76
+
77
+ ```typescript
78
+ async export(spans: ReadOnlyAISpan[]): Promise<void>
79
+ ```
80
+
81
+ Batch exports spans to Braintrust.
82
+
83
+ ### shutdown
84
+
85
+ ```typescript
86
+ async shutdown(): Promise<void>
87
+ ```
88
+
89
+ Flushes pending data and shuts down the client.
90
+
91
+ ## Usage
92
+
93
+ ```typescript
94
+ import { BraintrustExporter } from '@mastra/braintrust';
95
+
96
+ const exporter = new BraintrustExporter({
97
+ apiKey: process.env.BRAINTRUST_API_KEY,
98
+ projectName: 'my-ai-project',
99
+ });
100
+ ```
101
+
102
+ ## Span Type Mapping
103
+
104
+ | AI Span Type | Braintrust Type |
105
+ |--------------|-----------------|
106
+ | `LLM_GENERATION` | `llm` |
107
+ | `LLM_CHUNK` | `llm` |
108
+ | `TOOL_CALL` | `tool` |
109
+ | `MCP_TOOL_CALL` | `tool` |
110
+ | `WORKFLOW_CONDITIONAL_EVAL` | `function` |
111
+ | `WORKFLOW_WAIT_EVENT` | `function` |
112
+ | All others | `task` |
@@ -0,0 +1,176 @@
1
+ ---
2
+ title: "CloudExporter | Exporters | AI Tracing | Reference"
3
+ description: API reference for the CloudExporter
4
+ ---
5
+
6
+ import { PropertiesTable } from "@/components/properties-table";
7
+
8
+ # CloudExporter
9
+
10
+ Sends traces to Mastra Cloud for online visualization and monitoring.
11
+
12
+ ## Constructor
13
+
14
+ ```typescript
15
+ new CloudExporter(config?: CloudExporterConfig)
16
+ ```
17
+
18
+ <PropertiesTable
19
+ props={[
20
+ {
21
+ name: "config",
22
+ type: "CloudExporterConfig",
23
+ description: "Configuration options",
24
+ required: false,
25
+ },
26
+ ]}
27
+ />
28
+
29
+ ## CloudExporterConfig
30
+
31
+ ```typescript
32
+ interface CloudExporterConfig {
33
+ /** Maximum number of spans per batch. Default: 1000 */
34
+ maxBatchSize?: number;
35
+
36
+ /** Maximum wait time before flushing in milliseconds. Default: 5000 */
37
+ maxBatchWaitMs?: number;
38
+
39
+ /** Maximum retry attempts. Default: 3 */
40
+ maxRetries?: number;
41
+
42
+ /** Cloud access token (from env or config) */
43
+ accessToken?: string;
44
+
45
+ /** Cloud AI tracing endpoint */
46
+ endpoint?: string;
47
+
48
+ /** Optional logger */
49
+ logger?: IMastraLogger;
50
+ }
51
+ ```
52
+
53
+ ## Environment Variables
54
+
55
+ The exporter reads these environment variables if not provided in config:
56
+
57
+ - `MASTRA_CLOUD_ACCESS_TOKEN` - Access token for authentication
58
+ - `MASTRA_CLOUD_AI_TRACES_ENDPOINT` - Custom endpoint (defaults to `https://api.mastra.ai/ai/spans/publish`)
59
+
60
+ ## Properties
61
+
62
+ ```typescript
63
+ readonly name = 'mastra-cloud-ai-tracing-exporter';
64
+ ```
65
+
66
+ ## Methods
67
+
68
+ ### exportEvent
69
+
70
+ ```typescript
71
+ async exportEvent(event: AITracingEvent): Promise<void>
72
+ ```
73
+
74
+ Processes tracing events. Only exports SPAN_ENDED events to Cloud.
75
+
76
+ <PropertiesTable
77
+ props={[
78
+ {
79
+ name: "event",
80
+ type: "AITracingEvent",
81
+ description: "The tracing event to export",
82
+ required: true,
83
+ },
84
+ ]}
85
+ />
86
+
87
+ ### shutdown
88
+
89
+ ```typescript
90
+ async shutdown(): Promise<void>
91
+ ```
92
+
93
+ Flushes remaining events and performs cleanup.
94
+
95
+ ## Behavior
96
+
97
+ ### Authentication
98
+
99
+ If no access token is provided via config or environment variable, the exporter:
100
+ - Logs a warning with sign-up information
101
+ - Operates as a no-op (discards all events)
102
+
103
+ ### Batching
104
+
105
+ The exporter batches spans for efficient network usage:
106
+ - Flushes when batch size reaches `maxBatchSize`
107
+ - Flushes when `maxBatchWaitMs` elapsed since first span in batch
108
+ - Flushes on `shutdown()`
109
+
110
+ ### Error Handling
111
+
112
+ - Uses exponential backoff retry with `maxRetries` attempts
113
+ - Drops batches after all retries fail
114
+ - Logs errors but continues processing new events
115
+
116
+ ### Event Processing
117
+
118
+ - Only processes `SPAN_ENDED` events
119
+ - Ignores `SPAN_STARTED` and `SPAN_UPDATED` events
120
+ - Formats spans to MastraCloudSpanRecord format
121
+
122
+ ## MastraCloudSpanRecord
123
+
124
+ Internal format for cloud spans:
125
+
126
+ ```typescript
127
+ interface MastraCloudSpanRecord {
128
+ traceId: string;
129
+ spanId: string;
130
+ parentSpanId: string | null;
131
+ name: string;
132
+ spanType: string;
133
+ attributes: Record<string, any> | null;
134
+ metadata: Record<string, any> | null;
135
+ startedAt: Date;
136
+ endedAt: Date | null;
137
+ input: any;
138
+ output: any;
139
+ error: any;
140
+ isEvent: boolean;
141
+ createdAt: Date;
142
+ updatedAt: Date | null;
143
+ }
144
+ ```
145
+
146
+ ## Usage
147
+
148
+ ```typescript
149
+ import { CloudExporter } from '@mastra/core/ai-tracing';
150
+
151
+ // Uses environment variable for token
152
+ const exporter = new CloudExporter();
153
+
154
+ // Explicit configuration
155
+ const customExporter = new CloudExporter({
156
+ accessToken: 'your-token',
157
+ maxBatchSize: 500,
158
+ maxBatchWaitMs: 2000
159
+ });
160
+ ```
161
+
162
+ ## See Also
163
+
164
+ ### Documentation
165
+ - [AI Tracing Overview](/docs/observability/ai-tracing/overview) - Complete guide
166
+ - [Exporters](/docs/observability/ai-tracing/overview#exporters) - Exporter concepts
167
+
168
+ ### Other Exporters
169
+ - [DefaultExporter](/reference/observability/ai-tracing/exporters/default-exporter) - Storage persistence
170
+ - [ConsoleExporter](/reference/observability/ai-tracing/exporters/console-exporter) - Debug output
171
+ - [Langfuse](/reference/observability/ai-tracing/exporters/langfuse) - Langfuse integration
172
+ - [Braintrust](/reference/observability/ai-tracing/exporters/braintrust) - Braintrust integration
173
+
174
+ ### Reference
175
+ - [Configuration](/reference/observability/ai-tracing/configuration) - Configuration options
176
+ - [Interfaces](/reference/observability/ai-tracing/interfaces) - Type definitions