@mastra/mcp-docs-server 0.13.24 → 0.13.25-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.
Files changed (128) 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 +24 -1
  4. package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +22 -0
  5. package/.docs/organized/changelogs/%40mastra%2Fastra.md +19 -19
  6. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +19 -19
  7. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +21 -21
  8. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +46 -46
  9. package/.docs/organized/changelogs/%40mastra%2Fcloud.md +19 -19
  10. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +21 -21
  11. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +21 -21
  12. package/.docs/organized/changelogs/%40mastra%2Fcore.md +104 -104
  13. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +19 -19
  14. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +40 -40
  15. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +33 -33
  16. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +34 -34
  17. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +34 -34
  18. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +59 -59
  19. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +21 -21
  20. package/.docs/organized/changelogs/%40mastra%2Fevals.md +24 -24
  21. package/.docs/organized/changelogs/%40mastra%2Flance.md +21 -21
  22. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +29 -29
  23. package/.docs/organized/changelogs/%40mastra%2Floggers.md +19 -19
  24. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +25 -25
  25. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +19 -19
  26. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +22 -22
  27. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +27 -27
  28. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +21 -21
  29. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +21 -21
  30. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +19 -19
  31. package/.docs/organized/changelogs/%40mastra%2Fpg.md +33 -33
  32. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +19 -19
  33. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +73 -73
  34. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +20 -20
  35. package/.docs/organized/changelogs/%40mastra%2Frag.md +22 -22
  36. package/.docs/organized/changelogs/%40mastra%2Freact.md +17 -0
  37. package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +18 -0
  38. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
  39. package/.docs/organized/changelogs/%40mastra%2Fserver.md +51 -51
  40. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +19 -19
  41. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +24 -24
  42. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +19 -19
  43. package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +19 -19
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +19 -19
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +19 -19
  46. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +19 -19
  47. package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +20 -3
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +18 -0
  49. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +21 -21
  50. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +20 -20
  51. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +20 -20
  52. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +21 -21
  53. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +19 -19
  54. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +19 -19
  55. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +19 -19
  56. package/.docs/organized/changelogs/create-mastra.md +32 -32
  57. package/.docs/organized/changelogs/mastra.md +64 -64
  58. package/.docs/organized/code-examples/agent.md +0 -4
  59. package/.docs/organized/code-examples/ai-elements.md +47 -0
  60. package/.docs/organized/code-examples/heads-up-game.md +5 -5
  61. package/.docs/raw/auth/clerk.mdx +3 -3
  62. package/.docs/raw/index.mdx +1 -0
  63. package/.docs/raw/observability/ai-tracing/exporters/braintrust.mdx +81 -0
  64. package/.docs/raw/observability/ai-tracing/exporters/cloud.mdx +120 -0
  65. package/.docs/raw/observability/ai-tracing/exporters/default.mdx +168 -0
  66. package/.docs/raw/observability/ai-tracing/exporters/langfuse.mdx +121 -0
  67. package/.docs/raw/observability/ai-tracing/exporters/langsmith.mdx +88 -0
  68. package/.docs/raw/observability/ai-tracing/exporters/otel.mdx +250 -0
  69. package/.docs/raw/observability/ai-tracing/overview.mdx +565 -0
  70. package/.docs/raw/observability/ai-tracing/processors/sensitive-data-filter.mdx +274 -0
  71. package/.docs/raw/observability/{tracing.mdx → otel-tracing.mdx} +2 -2
  72. package/.docs/raw/observability/overview.mdx +66 -0
  73. package/.docs/raw/reference/agents/generate.mdx +39 -1
  74. package/.docs/raw/reference/agents/generateVNext.mdx +34 -2
  75. package/.docs/raw/reference/agents/network.mdx +35 -3
  76. package/.docs/raw/reference/auth/clerk.mdx +1 -1
  77. package/.docs/raw/reference/client-js/agents.mdx +4 -13
  78. package/.docs/raw/reference/client-js/mastra-client.mdx +10 -0
  79. package/.docs/raw/reference/client-js/observability.mdx +76 -0
  80. package/.docs/raw/reference/core/getScorer.mdx +75 -0
  81. package/.docs/raw/reference/core/getScorerByName.mdx +75 -0
  82. package/.docs/raw/reference/core/getScorers.mdx +42 -0
  83. package/.docs/raw/reference/core/mastra-class.mdx +7 -0
  84. package/.docs/raw/reference/observability/ai-tracing/ai-tracing.mdx +182 -0
  85. package/.docs/raw/reference/observability/ai-tracing/configuration.mdx +234 -0
  86. package/.docs/raw/reference/observability/ai-tracing/exporters/braintrust.mdx +112 -0
  87. package/.docs/raw/reference/observability/ai-tracing/exporters/cloud-exporter.mdx +176 -0
  88. package/.docs/raw/reference/observability/ai-tracing/exporters/console-exporter.mdx +148 -0
  89. package/.docs/raw/reference/observability/ai-tracing/exporters/default-exporter.mdx +196 -0
  90. package/.docs/raw/reference/observability/ai-tracing/exporters/langfuse.mdx +116 -0
  91. package/.docs/raw/reference/observability/ai-tracing/exporters/langsmith.mdx +112 -0
  92. package/.docs/raw/reference/observability/ai-tracing/exporters/otel.mdx +355 -0
  93. package/.docs/raw/reference/observability/ai-tracing/interfaces.mdx +651 -0
  94. package/.docs/raw/reference/observability/ai-tracing/processors/sensitive-data-filter.mdx +178 -0
  95. package/.docs/raw/reference/observability/ai-tracing/span.mdx +371 -0
  96. package/.docs/raw/reference/observability/{logger.mdx → logging/pino-logger.mdx} +1 -1
  97. package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/index.mdx +6 -4
  98. package/.docs/raw/reference/scorers/create-scorer.mdx +59 -9
  99. package/.docs/raw/reference/scorers/mastra-scorer.mdx +6 -0
  100. package/.docs/raw/reference/scorers/run-experiment.mdx +216 -0
  101. package/.docs/raw/reference/streaming/ChunkType.mdx +3 -2
  102. package/.docs/raw/reference/streaming/agents/MastraModelOutput.mdx +1 -1
  103. package/.docs/raw/reference/streaming/agents/stream.mdx +41 -3
  104. package/.docs/raw/reference/streaming/agents/streamVNext.mdx +34 -2
  105. package/.docs/raw/reference/streaming/workflows/resumeStreamVNext.mdx +17 -1
  106. package/.docs/raw/reference/streaming/workflows/stream.mdx +39 -1
  107. package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +39 -1
  108. package/.docs/raw/reference/tools/create-tool.mdx +34 -1
  109. package/.docs/raw/reference/workflows/run-methods/resume.mdx +38 -0
  110. package/.docs/raw/reference/workflows/run-methods/start.mdx +38 -0
  111. package/.docs/raw/scorers/custom-scorers.mdx +16 -1
  112. package/.docs/raw/scorers/overview.mdx +28 -0
  113. package/CHANGELOG.md +15 -0
  114. package/package.json +6 -6
  115. package/.docs/raw/observability/ai-tracing.mdx +0 -597
  116. /package/.docs/raw/reference/observability/{otel-config.mdx → otel-tracing/otel-config.mdx} +0 -0
  117. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/arize-ax.mdx +0 -0
  118. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/arize-phoenix.mdx +0 -0
  119. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/braintrust.mdx +0 -0
  120. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/dash0.mdx +0 -0
  121. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/keywordsai.mdx +0 -0
  122. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/laminar.mdx +0 -0
  123. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/langfuse.mdx +0 -0
  124. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/langsmith.mdx +0 -0
  125. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/langwatch.mdx +0 -0
  126. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/new-relic.mdx +0 -0
  127. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/signoz.mdx +0 -0
  128. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/traceloop.mdx +0 -0
@@ -0,0 +1,274 @@
1
+ ---
2
+ title: "Sensitive Data Filter | Processors | Observability | Mastra Docs"
3
+ description: "Protect sensitive information in your AI traces with automatic data redaction"
4
+ ---
5
+
6
+ import { Callout } from "nextra/components";
7
+
8
+ # Sensitive Data Filter
9
+
10
+ The Sensitive Data Filter is a span processor that automatically redacts sensitive information from your AI traces before they're exported. This ensures that passwords, API keys, tokens, and other confidential data never leave your application or get stored in observability platforms.
11
+
12
+ ## Default Configuration
13
+
14
+ By default, the Sensitive Data Filter is automatically enabled when you use the standard Mastra configuration:
15
+
16
+ ```ts filename="src/mastra/index.ts" showLineNumbers copy
17
+ export const mastra = new Mastra({
18
+ observability: {
19
+ default: { enabled: true }, // Automatically includes SensitiveDataFilter
20
+ },
21
+ storage: new LibSQLStore({
22
+ url: "file:./mastra.db",
23
+ }),
24
+ });
25
+ ```
26
+
27
+ With the default configuration, the filter automatically redacts these common sensitive field names:
28
+
29
+ - `password`
30
+ - `token`
31
+ - `secret`
32
+ - `key`
33
+ - `apikey`
34
+ - `auth`
35
+ - `authorization`
36
+ - `bearer`
37
+ - `bearertoken`
38
+ - `jwt`
39
+ - `credential`
40
+ - `clientsecret`
41
+ - `privatekey`
42
+ - `refresh`
43
+ - `ssn`
44
+
45
+ <Callout>
46
+ Field matching is case-insensitive and normalizes separators. For example, `api-key`, `api_key`, and `Api Key` are all treated as `apikey`.
47
+ </Callout>
48
+
49
+ ## How It Works
50
+
51
+ The Sensitive Data Filter processes spans before they're sent to exporters, scanning through:
52
+
53
+ - **Attributes** - Span metadata and properties
54
+ - **Metadata** - Custom metadata attached to spans
55
+ - **Input** - Data sent to agents, tools, and LLMs
56
+ - **Output** - Responses and results
57
+ - **Error Information** - Stack traces and error details
58
+
59
+ When a sensitive field is detected, its value is replaced with `[REDACTED]` by default. The filter handles nested objects, arrays, and circular references safely.
60
+
61
+ ## Custom Configuration
62
+
63
+ You can customize which fields are redacted and how redaction appears:
64
+
65
+ ```ts filename="src/mastra/index.ts" showLineNumbers copy
66
+ import { SensitiveDataFilter, DefaultExporter } from '@mastra/core/ai-tracing';
67
+
68
+ export const mastra = new Mastra({
69
+ observability: {
70
+ configs: {
71
+ production: {
72
+ serviceName: 'my-service',
73
+ exporters: [new DefaultExporter()],
74
+ processors: [
75
+ new SensitiveDataFilter({
76
+ // Add custom sensitive fields
77
+ sensitiveFields: [
78
+ // Default fields
79
+ 'password', 'token', 'secret', 'key', 'apikey',
80
+ // Custom fields for your application
81
+ 'creditCard', 'bankAccount', 'routingNumber',
82
+ 'email', 'phoneNumber', 'dateOfBirth',
83
+ ],
84
+ // Custom redaction token
85
+ redactionToken: '***SENSITIVE***',
86
+ // Redaction style
87
+ redactionStyle: 'full', // or 'partial'
88
+ })
89
+ ],
90
+ },
91
+ },
92
+ },
93
+ });
94
+ ```
95
+
96
+ ## Redaction Styles
97
+
98
+ The filter supports two redaction styles:
99
+
100
+ ### Full Redaction (Default)
101
+
102
+ Replaces the entire value with a fixed token:
103
+
104
+ ```json
105
+ // Before
106
+ {
107
+ "apiKey": "sk-abc123xyz789def456",
108
+ "userId": "user_12345"
109
+ }
110
+
111
+ // After
112
+ {
113
+ "apiKey": "[REDACTED]",
114
+ "userId": "user_12345"
115
+ }
116
+ ```
117
+
118
+ ### Partial Redaction
119
+
120
+ Shows the first and last 3 characters, useful for debugging without exposing full values:
121
+
122
+ ```ts
123
+ new SensitiveDataFilter({
124
+ redactionStyle: 'partial'
125
+ })
126
+ ```
127
+
128
+ ```json
129
+ // Before
130
+ {
131
+ "apiKey": "sk-abc123xyz789def456",
132
+ "creditCard": "4111111111111111"
133
+ }
134
+
135
+ // After
136
+ {
137
+ "apiKey": "sk-…456",
138
+ "creditCard": "411…111"
139
+ }
140
+ ```
141
+
142
+ Values shorter than 7 characters are fully redacted to prevent information leakage.
143
+
144
+ ## Field Matching Rules
145
+
146
+ The filter uses intelligent field matching:
147
+
148
+ 1. **Case-Insensitive**: `APIKey`, `apikey`, and `ApiKey` are all matched
149
+ 2. **Separator-Agnostic**: `api-key`, `api_key`, and `apiKey` are treated identically
150
+ 3. **Exact Matching**: After normalization, fields must match exactly
151
+ - `token` matches `token`, `Token`, `TOKEN`
152
+ - `token` does NOT match `promptTokens` or `tokenCount`
153
+
154
+ ## Nested Object Handling
155
+
156
+ The filter recursively processes nested structures:
157
+
158
+ ```json
159
+ // Before
160
+ {
161
+ "user": {
162
+ "id": "12345",
163
+ "credentials": {
164
+ "password": "SuperSecret123!",
165
+ "apiKey": "sk-production-key"
166
+ }
167
+ },
168
+ "config": {
169
+ "auth": {
170
+ "jwt": "eyJhbGciOiJIUzI1NiIs..."
171
+ }
172
+ }
173
+ }
174
+
175
+ // After
176
+ {
177
+ "user": {
178
+ "id": "12345",
179
+ "credentials": {
180
+ "password": "[REDACTED]",
181
+ "apiKey": "[REDACTED]"
182
+ }
183
+ },
184
+ "config": {
185
+ "auth": {
186
+ "jwt": "[REDACTED]"
187
+ }
188
+ }
189
+ }
190
+ ```
191
+
192
+ ## Performance Considerations
193
+
194
+ The Sensitive Data Filter is designed to be lightweight and efficient:
195
+
196
+ - **Synchronous Processing**: No async operations, minimal latency impact
197
+ - **Circular Reference Handling**: Safely handles complex object graphs
198
+ - **Error Recovery**: If filtering fails, the field is replaced with an error marker rather than crashing
199
+
200
+ ## Disabling the Filter
201
+
202
+ If you need to disable sensitive data filtering (not recommended for production):
203
+
204
+ ```ts filename="src/mastra/index.ts" showLineNumbers copy
205
+ export const mastra = new Mastra({
206
+ observability: {
207
+ configs: {
208
+ debug: {
209
+ serviceName: 'debug-service',
210
+ processors: [], // No processors, including no SensitiveDataFilter
211
+ exporters: [new DefaultExporter()],
212
+ },
213
+ },
214
+ },
215
+ });
216
+ ```
217
+
218
+ <Callout type="warning">
219
+ Only disable sensitive data filtering in controlled environments. Never disable it when sending traces to external services or shared storage.
220
+ </Callout>
221
+
222
+ ## Common Use Cases
223
+
224
+ ### Healthcare Applications
225
+
226
+ ```ts
227
+ new SensitiveDataFilter({
228
+ sensitiveFields: [
229
+ // HIPAA-related fields
230
+ 'ssn', 'socialSecurityNumber',
231
+ 'medicalRecordNumber', 'mrn',
232
+ 'healthInsuranceNumber',
233
+ 'diagnosisCode', 'icd10',
234
+ 'prescription', 'medication',
235
+ ]
236
+ })
237
+ ```
238
+
239
+ ### Financial Services
240
+
241
+ ```ts
242
+ new SensitiveDataFilter({
243
+ sensitiveFields: [
244
+ // PCI compliance fields
245
+ 'creditCard', 'ccNumber', 'cardNumber',
246
+ 'cvv', 'cvc', 'securityCode',
247
+ 'expirationDate', 'expiry',
248
+ 'bankAccount', 'accountNumber',
249
+ 'routingNumber', 'iban', 'swift',
250
+ ]
251
+ })
252
+ ```
253
+
254
+ ## Error Handling
255
+
256
+ If the filter encounters an error while processing a field, it replaces the field with a safe error marker:
257
+
258
+ ```json
259
+ {
260
+ "problematicField": {
261
+ "error": {
262
+ "processor": "sensitive-data-filter"
263
+ }
264
+ }
265
+ }
266
+ ```
267
+
268
+ This ensures that processing errors don't prevent traces from being exported or cause application crashes.
269
+
270
+ ## Related
271
+
272
+ - [SensitiveDataFilter API](/reference/observability/ai-tracing/processors/sensitive-data-filter)
273
+ - [Basic AI Tracing Example](/examples/observability/basic-ai-tracing)
274
+
@@ -1,11 +1,11 @@
1
1
  ---
2
- title: "Tracing | Mastra Observability Documentation"
2
+ title: "OTEL Tracing | Mastra Observability Documentation"
3
3
  description: "Set up OpenTelemetry tracing for Mastra applications"
4
4
  ---
5
5
 
6
6
  import Image from "next/image";
7
7
 
8
- # Tracing
8
+ # OTEL Tracing
9
9
 
10
10
  Mastra supports the OpenTelemetry Protocol (OTLP) for tracing and monitoring your application. When telemetry is enabled, Mastra automatically traces all core primitives including agent operations, LLM interactions, tool executions, integration calls, workflow runs, and database operations. Your telemetry data can then be exported to any OTEL collector.
11
11
 
@@ -0,0 +1,66 @@
1
+ ---
2
+ title: "Overview | Observability | Mastra Docs"
3
+ description: Monitor and debug applications with Mastra's Observability features.
4
+ ---
5
+
6
+ import { Callout } from "nextra/components";
7
+
8
+ # Observability Overview
9
+
10
+ Mastra provides comprehensive observability features designed specifically for AI applications. Monitor LLM operations, trace agent decisions, and debug complex workflows with specialized tools that understand AI-specific patterns.
11
+
12
+ ## Key Features
13
+
14
+ ### Structured Logging
15
+ Debug applications with contextual logging:
16
+ - **Context propagation**: Automatic correlation with traces
17
+ - **Configurable levels**: Filter by severity in development and production
18
+
19
+ ### AI Tracing
20
+ Specialized tracing for AI operations that captures:
21
+ - **LLM interactions**: Token usage, latency, prompts, and completions
22
+ - **Agent execution**: Decision paths, tool calls, and memory operations
23
+ - **Workflow steps**: Branching logic, parallel execution, and step outputs
24
+ - **Automatic instrumentation**: Zero-configuration tracing with decorators
25
+
26
+ ### OTEL Tracing
27
+ Traditional distributed tracing with OpenTelemetry:
28
+ - **Standard OTLP protocol**: Compatible with existing observability infrastructure
29
+ - **HTTP and database instrumentation**: Automatic spans for common operations
30
+ - **Provider integrations**: Datadog, New Relic, Jaeger, and other OTLP collectors
31
+ - **Distributed context**: W3C Trace Context propagation
32
+
33
+ ## Quick Start
34
+
35
+ Configure Observability in your Mastra instance:
36
+
37
+ ```typescript filename="src/mastra/index.ts"
38
+ import { Mastra } from "@mastra/core";
39
+ import { PinoLogger } from "@mastra/core";
40
+ import { LibSqlStorage } from "@mastra/libsql";
41
+
42
+ export const mastra = new Mastra({
43
+ // ... other config
44
+ logger: new PinoLogger(),
45
+ observability: {
46
+ default: { enabled: true }, // Enables AI Tracing
47
+ },
48
+ storage: new LibSQLStore({
49
+ url: "file:./mastra.db", // Storage is required for tracing
50
+ }),
51
+ telemetry: {
52
+ enabled: true, // Enables OTEL Tracing
53
+ }
54
+ });
55
+ ```
56
+
57
+ With this basic setup, you will see Traces and Logs in both the Playground and in Mastra Cloud.
58
+
59
+ We also support various external tracing providers like Langfuse, Braintrust, and any OpenTelemetry-compatible platform (Datadog, New Relic, SigNoz, etc.). See more about this in the [AI Tracing](/docs/observability/ai-tracing.mdx) documentation.
60
+
61
+ ## What's Next?
62
+
63
+ - **[Set up AI Tracing](/docs/observability/ai-tracing.mdx)**: Configure tracing for your application
64
+ - **[Configure Logging](/docs/observability/logging.mdx)**: Add structured logging
65
+ - **[View Examples](/examples/observability/basic-ai-tracing.mdx)**: See observability in action
66
+ - **[API Reference](/reference/observability/ai-tracing/ai-tracing.mdx)**: Detailed configuration options
@@ -193,7 +193,7 @@ await agent.generate("message for agent");
193
193
  type: "TelemetrySettings",
194
194
  isOptional: true,
195
195
  description:
196
- "Settings for telemetry collection during generation.",
196
+ "Settings for OTLP telemetry collection during generation (not AI tracing).",
197
197
  properties: [
198
198
  {
199
199
  parameters: [{
@@ -339,6 +339,38 @@ await agent.generate("message for agent");
339
339
  isOptional: true,
340
340
  description: "Runtime context for dependency injection and contextual information.",
341
341
  },
342
+ {
343
+ name: "tracingContext",
344
+ type: "TracingContext",
345
+ isOptional: true,
346
+ description: "AI tracing context for creating child spans and adding metadata. Automatically injected when using Mastra's tracing system.",
347
+ properties: [
348
+ {
349
+ parameters: [{
350
+ name: "currentSpan",
351
+ type: "AISpan",
352
+ isOptional: true,
353
+ description: "Current AI span for creating child spans and adding metadata. Use this to create custom child spans or update span attributes during execution."
354
+ }]
355
+ }
356
+ ]
357
+ },
358
+ {
359
+ name: "tracingOptions",
360
+ type: "TracingOptions",
361
+ isOptional: true,
362
+ description: "Options for AI tracing configuration.",
363
+ properties: [
364
+ {
365
+ parameters: [{
366
+ name: "metadata",
367
+ type: "Record<string, any>",
368
+ isOptional: true,
369
+ description: "Metadata to add to the root trace span. Useful for adding custom attributes like user IDs, session IDs, or feature flags."
370
+ }]
371
+ }
372
+ ]
373
+ },
342
374
  {
343
375
  name: "maxTokens",
344
376
  type: "number",
@@ -430,6 +462,12 @@ await agent.generate("message for agent");
430
462
  }
431
463
  ]
432
464
  },
465
+ {
466
+ name: "traceId",
467
+ type: "string",
468
+ isOptional: true,
469
+ description: "The trace ID associated with this execution when AI tracing is enabled. Use this to correlate logs and debug execution flow.",
470
+ },
433
471
  ]}
434
472
  />
435
473
 
@@ -105,6 +105,32 @@ const aiSdkResult = await agent.generateVNext("message for agent", {
105
105
  type: "TracingContext",
106
106
  isOptional: true,
107
107
  description: "AI tracing context for span hierarchy and metadata.",
108
+ properties: [
109
+ {
110
+ parameters: [{
111
+ name: "currentSpan",
112
+ type: "AISpan",
113
+ isOptional: true,
114
+ description: "Current AI span for creating child spans and adding metadata."
115
+ }]
116
+ }
117
+ ]
118
+ },
119
+ {
120
+ name: "tracingOptions",
121
+ type: "TracingOptions",
122
+ isOptional: true,
123
+ description: "Options for AI tracing configuration.",
124
+ properties: [
125
+ {
126
+ parameters: [{
127
+ name: "metadata",
128
+ type: "Record<string, any>",
129
+ isOptional: true,
130
+ description: "Metadata to add to the root trace span."
131
+ }]
132
+ }
133
+ ]
108
134
  },
109
135
  {
110
136
  name: "returnScorerData",
@@ -286,7 +312,7 @@ const aiSdkResult = await agent.generateVNext("message for agent", {
286
312
  name: "telemetry",
287
313
  type: "TelemetrySettings",
288
314
  isOptional: true,
289
- description: "Telemetry collection settings for observability.",
315
+ description: "Settings for OTLP telemetry collection (not AI tracing).",
290
316
  properties: [
291
317
  {
292
318
  parameters: [{
@@ -518,7 +544,13 @@ const aiSdkResult = await agent.generateVNext("message for agent", {
518
544
  {
519
545
  name: "result",
520
546
  type: "Awaited<ReturnType<MastraModelOutput<Output>['getFullOutput']>> | Awaited<ReturnType<AISDKV5OutputStream<Output>['getFullOutput']>>",
521
- description: "Returns the full output of the generation process. When format is 'mastra' (default), returns MastraModelOutput result. When format is 'aisdk', returns AISDKV5OutputStream result for AI SDK v5 compatibility.",
547
+ description: "Returns the full output of the generation process. When format is 'mastra' (default), returns MastraModelOutput result with traceId property. When format is 'aisdk', returns AISDKV5OutputStream result for AI SDK v5 compatibility.",
548
+ },
549
+ {
550
+ name: "traceId",
551
+ type: "string",
552
+ isOptional: true,
553
+ description: "The trace ID associated with this execution when AI tracing is enabled. Available in the result object (result.traceId for Mastra format).",
522
554
  },
523
555
  ]}
524
556
  />
@@ -107,14 +107,40 @@ await agent.network(`
107
107
  name: "tracingContext",
108
108
  type: "TracingContext",
109
109
  isOptional: true,
110
- description: "AI tracing context for span hierarchy and metadata.",
110
+ description: "AI tracing context for creating child spans and adding metadata. Automatically injected when using Mastra's tracing system.",
111
+ properties: [
112
+ {
113
+ parameters: [{
114
+ name: "currentSpan",
115
+ type: "AISpan",
116
+ isOptional: true,
117
+ description: "Current AI span for creating child spans and adding metadata. Use this to create custom child spans or update span attributes during execution."
118
+ }]
119
+ }
120
+ ]
121
+ },
122
+ {
123
+ name: "tracingOptions",
124
+ type: "TracingOptions",
125
+ isOptional: true,
126
+ description: "Options for AI tracing configuration.",
127
+ properties: [
128
+ {
129
+ parameters: [{
130
+ name: "metadata",
131
+ type: "Record<string, any>",
132
+ isOptional: true,
133
+ description: "Metadata to add to the root trace span. Useful for adding custom attributes like user IDs, session IDs, or feature flags."
134
+ }]
135
+ }
136
+ ]
111
137
  },
112
138
  {
113
139
  name: "telemetry",
114
140
  type: "TelemetrySettings",
115
141
  isOptional: true,
116
142
  description:
117
- "Settings for telemetry collection during streaming.",
143
+ "Settings for OTLP telemetry collection during streaming (not AI tracing).",
118
144
  properties: [
119
145
  {
120
146
  parameters: [{
@@ -227,6 +253,12 @@ await agent.network(`
227
253
  isOptional: true,
228
254
  description: "Runtime context for dependency injection and contextual information.",
229
255
  },
256
+ {
257
+ name: "traceId",
258
+ type: "string",
259
+ isOptional: true,
260
+ description: "The trace ID associated with this execution when AI tracing is enabled. Use this to correlate logs and debug execution flow.",
261
+ },
230
262
  ]}
231
263
  />
232
264
 
@@ -255,4 +287,4 @@ await agent.network(`
255
287
  description: "A promise that resolves to token usage statistics",
256
288
  },
257
289
  ]}
258
- />
290
+ />
@@ -11,7 +11,7 @@ The `MastraAuthClerk` class provides authentication for Mastra applications usin
11
11
 
12
12
  ```typescript filename="src/mastra/index.ts" showLineNumbers copy
13
13
  import { Mastra } from "@mastra/core/mastra";
14
- import { MastraAuthClerk } from '@mastra/clerk-auth';
14
+ import { MastraAuthClerk } from '@mastra/auth-clerk';
15
15
 
16
16
  export const mastra = new Mastra({
17
17
  // ..
@@ -165,26 +165,17 @@ const liveEvals = await agent.liveEvals();
165
165
 
166
166
  <StreamVNextCallout />
167
167
 
168
- Stream responses using the enhanced VNext API with improved method signatures. This method provides enhanced capabilities and format flexibility, with support for both Mastra's native format and AI SDK v5 compatibility:
168
+ Stream responses using the enhanced VNext API with improved method signatures.
169
169
 
170
170
  ```typescript
171
171
  const response = await agent.streamVNext(
172
172
  "Tell me a story",
173
173
  {
174
- format: 'mastra', // Default: Mastra's native format
175
174
  threadId: "thread-1",
176
175
  clientTools: { colorChangeTool },
177
176
  }
178
177
  );
179
178
 
180
- // AI SDK v5 compatible format
181
- const response = await agent.streamVNext(
182
- "Tell me a story",
183
- {
184
- format: 'aisdk', // Enable AI SDK v5 compatibility
185
- threadId: "thread-1",
186
- }
187
- );
188
179
 
189
180
  // Process the stream
190
181
  response.processDataStream({
@@ -194,9 +185,9 @@ response.processDataStream({
194
185
  });
195
186
  ```
196
187
 
197
- The `format` parameter determines the output stream format:
198
- - `'mastra'` (default): Returns Mastra's native format
199
- - `'aisdk'`: Returns AI SDK v5 compatible format for frontend integration
188
+ Currently, AI SDK V5 format is not supported in the client SDK.
189
+ For AI SDK v5 compatible format, leverage the `@mastra/ai-sdk` package
190
+ [AI SDK v5 Stream Compatibility](/docs/frameworks/agentic-uis/ai-sdk#enabling-stream-compatibility)
200
191
 
201
192
  ### Generate VNext (Experimental)
202
193
 
@@ -142,6 +142,16 @@ export const mastraClient = new MastraClient({
142
142
  type: "string[]",
143
143
  description: "Returns the list of configured log transport types.",
144
144
  },
145
+ {
146
+ name: "getAITrace(traceId)",
147
+ type: "Promise<AITraceRecord>",
148
+ description: "Retrieves a specific AI trace by ID, including all its spans and details.",
149
+ },
150
+ {
151
+ name: "getAITraces(params)",
152
+ type: "Promise<GetAITracesResponse>",
153
+ description: "Retrieves paginated list of AI trace root spans with optional filtering. Use getAITrace() to get complete traces with all spans.",
154
+ },
145
155
  ]}
146
156
  />
147
157
 
@@ -0,0 +1,76 @@
1
+ ---
2
+ title: Mastra Client Observability API
3
+ description: Learn how to retrieve AI traces, monitor application performance, and score traces using the client-js SDK.
4
+ ---
5
+
6
+ # Observability API
7
+
8
+ The Observability API provides methods to retrieve AI traces, monitor your application's performance, and score traces for evaluation. This helps you understand how your AI agents and workflows are performing.
9
+
10
+ ## Getting a Specific AI Trace
11
+
12
+ Retrieve a specific AI trace by its ID, including all its spans and details:
13
+
14
+ ```typescript
15
+ const trace = await mastraClient.getAITrace("trace-id-123");
16
+ ```
17
+
18
+ ## Getting AI Traces with Filtering
19
+
20
+ Retrieve a paginated list of AI trace root spans with optional filtering:
21
+
22
+ ```typescript
23
+ const traces = await mastraClient.getAITraces({
24
+ pagination: {
25
+ page: 1,
26
+ perPage: 20,
27
+ dateRange: {
28
+ start: new Date('2024-01-01'),
29
+ end: new Date('2024-01-31')
30
+ }
31
+ },
32
+ filters: {
33
+ name: "weather-agent", // Filter by trace name
34
+ spanType: "agent", // Filter by span type
35
+ entityId: "weather-agent-id", // Filter by entity ID
36
+ entityType: "agent" // Filter by entity type
37
+ }
38
+ });
39
+
40
+ console.log(`Found ${traces.spans.length} root spans`);
41
+ console.log(`Total pages: ${traces.pagination.totalPages}`);
42
+
43
+ // To get the complete trace with all spans, use getAITrace
44
+ const completeTrace = await mastraClient.getAITrace(traces.spans[0].traceId);
45
+ ```
46
+
47
+ ## Scoring Traces
48
+
49
+ Score specific traces using registered scorers for evaluation:
50
+
51
+ ```typescript
52
+ const result = await mastraClient.score({
53
+ scorerName: "answer-relevancy",
54
+ targets: [
55
+ { traceId: "trace-1", spanId: "span-1" }, // Score specific span
56
+ { traceId: "trace-2" }, // Score specific span which defaults to the parent span
57
+ ]
58
+ });
59
+ ```
60
+
61
+ ## Getting Scores by Span
62
+
63
+ Retrieve scores for a specific span within a trace:
64
+
65
+ ```typescript
66
+ const scores = await mastraClient.getScoresBySpan({
67
+ traceId: "trace-123",
68
+ spanId: "span-456",
69
+ page: 1,
70
+ perPage: 20
71
+ });
72
+ ```
73
+ ## Related
74
+
75
+ - [Agents API](./agents) - Learn about agent interactions that generate traces
76
+ - [Workflows API](./workflows) - Understand workflow execution monitoring