@mastra/mcp-docs-server 0.13.25-alpha.0 → 0.13.25

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 (92) hide show
  1. package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +12 -1
  2. package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +11 -0
  3. package/.docs/organized/changelogs/%40mastra%2Fastra.md +10 -10
  4. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +10 -10
  5. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +12 -12
  6. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +18 -18
  7. package/.docs/organized/changelogs/%40mastra%2Fcloud.md +10 -10
  8. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +12 -12
  9. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +12 -12
  10. package/.docs/organized/changelogs/%40mastra%2Fcore.md +35 -35
  11. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +10 -10
  12. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +16 -16
  13. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +11 -11
  14. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +11 -11
  15. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +11 -11
  16. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +30 -30
  17. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +12 -12
  18. package/.docs/organized/changelogs/%40mastra%2Fevals.md +10 -10
  19. package/.docs/organized/changelogs/%40mastra%2Flance.md +12 -12
  20. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +20 -20
  21. package/.docs/organized/changelogs/%40mastra%2Floggers.md +11 -11
  22. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +10 -10
  23. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +11 -11
  24. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +13 -13
  25. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +10 -10
  26. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +12 -12
  27. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +12 -12
  28. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +10 -10
  29. package/.docs/organized/changelogs/%40mastra%2Fpg.md +18 -18
  30. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +10 -10
  31. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +24 -24
  32. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +11 -11
  33. package/.docs/organized/changelogs/%40mastra%2Frag.md +10 -10
  34. package/.docs/organized/changelogs/%40mastra%2Freact.md +17 -0
  35. package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -0
  36. package/.docs/organized/changelogs/%40mastra%2Fserver.md +16 -16
  37. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +10 -10
  38. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +12 -12
  39. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +10 -10
  40. package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +10 -10
  41. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +10 -10
  42. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +10 -10
  43. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +10 -10
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +11 -3
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +9 -0
  46. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +12 -12
  47. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +11 -11
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +11 -11
  49. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +12 -12
  50. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +10 -10
  51. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +10 -10
  52. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +10 -10
  53. package/.docs/organized/changelogs/create-mastra.md +11 -11
  54. package/.docs/organized/changelogs/mastra.md +19 -19
  55. package/.docs/organized/code-examples/agent.md +0 -4
  56. package/.docs/organized/code-examples/ai-elements.md +47 -0
  57. package/.docs/organized/code-examples/heads-up-game.md +5 -5
  58. package/.docs/raw/auth/clerk.mdx +3 -3
  59. package/.docs/raw/observability/ai-tracing/exporters/default.mdx +1 -0
  60. package/.docs/raw/observability/ai-tracing/exporters/langsmith.mdx +88 -0
  61. package/.docs/raw/observability/ai-tracing/exporters/otel.mdx +250 -0
  62. package/.docs/raw/observability/ai-tracing/overview.mdx +15 -15
  63. package/.docs/raw/observability/overview.mdx +1 -1
  64. package/.docs/raw/reference/agents/network.mdx +1 -1
  65. package/.docs/raw/reference/auth/clerk.mdx +1 -1
  66. package/.docs/raw/reference/client-js/agents.mdx +4 -13
  67. package/.docs/raw/reference/client-js/mastra-client.mdx +10 -0
  68. package/.docs/raw/reference/client-js/observability.mdx +76 -0
  69. package/.docs/raw/reference/core/getScorer.mdx +75 -0
  70. package/.docs/raw/reference/core/getScorerByName.mdx +75 -0
  71. package/.docs/raw/reference/core/getScorers.mdx +42 -0
  72. package/.docs/raw/reference/core/mastra-class.mdx +7 -0
  73. package/.docs/raw/reference/observability/ai-tracing/ai-tracing.mdx +1 -0
  74. package/.docs/raw/reference/observability/ai-tracing/configuration.mdx +5 -4
  75. package/.docs/raw/reference/observability/ai-tracing/exporters/langsmith.mdx +112 -0
  76. package/.docs/raw/reference/observability/ai-tracing/exporters/otel.mdx +355 -0
  77. package/.docs/raw/reference/observability/logging/pino-logger.mdx +1 -1
  78. package/.docs/raw/reference/observability/otel-tracing/providers/index.mdx +11 -11
  79. package/.docs/raw/reference/scorers/create-scorer.mdx +59 -9
  80. package/.docs/raw/reference/scorers/mastra-scorer.mdx +6 -0
  81. package/.docs/raw/reference/scorers/run-experiment.mdx +216 -0
  82. package/.docs/raw/reference/streaming/ChunkType.mdx +3 -2
  83. package/.docs/raw/reference/streaming/agents/MastraModelOutput.mdx +1 -1
  84. package/.docs/raw/reference/streaming/agents/stream.mdx +2 -2
  85. package/.docs/raw/reference/streaming/workflows/resumeStreamVNext.mdx +17 -1
  86. package/.docs/raw/reference/streaming/workflows/stream.mdx +1 -1
  87. package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +1 -1
  88. package/.docs/raw/scorers/custom-scorers.mdx +16 -1
  89. package/.docs/raw/scorers/overview.mdx +28 -0
  90. package/CHANGELOG.md +16 -0
  91. package/package.json +6 -6
  92. package/.docs/organized/changelogs/%40mastra%2Freact-hooks.md +0 -8
@@ -0,0 +1,250 @@
1
+ ---
2
+ title: "OpenTelemetry Exporter | AI Tracing | Observability | Mastra Docs"
3
+ description: "Send AI traces to any OpenTelemetry-compatible observability platform"
4
+ ---
5
+
6
+ import { Callout } from "nextra/components";
7
+
8
+ # OpenTelemetry Exporter
9
+
10
+ <Callout type="warning">
11
+ The OpenTelemetry exporter is currently **experimental**. APIs and configuration options may change in future releases.
12
+ </Callout>
13
+
14
+ The OpenTelemetry (OTEL) exporter sends your AI traces to any OTEL-compatible observability platform using standardized [OpenTelemetry Semantic Conventions for GenAI](https://opentelemetry.io/docs/specs/semconv/gen-ai/). This ensures broad compatibility with platforms like Datadog, New Relic, SigNoz, Dash0, Traceloop, Laminar, and more.
15
+
16
+ ## When to Use OTEL Exporter
17
+
18
+ The OTEL exporter is ideal when you need:
19
+ - **Platform flexibility** - Send traces to any OTEL-compatible backend
20
+ - **Standards compliance** - Follow OpenTelemetry GenAI semantic conventions
21
+ - **Multi-vendor support** - Configure once, switch providers easily
22
+ - **Enterprise platforms** - Integrate with existing observability infrastructure
23
+ - **Custom collectors** - Send to your own OTEL collector
24
+
25
+ ## Installation
26
+
27
+ Each provider requires specific protocol packages. Install the base exporter plus the protocol package for your provider:
28
+
29
+ ### For HTTP/Protobuf Providers (SigNoz, New Relic, Laminar)
30
+
31
+ ```bash npm2yarn
32
+ npm install @mastra/otel-exporter @opentelemetry/exporter-trace-otlp-proto
33
+ ```
34
+
35
+ ### For gRPC Providers (Dash0)
36
+
37
+ ```bash npm2yarn
38
+ npm install @mastra/otel-exporter @opentelemetry/exporter-trace-otlp-grpc @grpc/grpc-js
39
+ ```
40
+
41
+ ### For HTTP/JSON Providers (Traceloop)
42
+
43
+ ```bash npm2yarn
44
+ npm install @mastra/otel-exporter @opentelemetry/exporter-trace-otlp-http
45
+ ```
46
+
47
+ ## Provider Configurations
48
+
49
+ ### Dash0
50
+
51
+ [Dash0](https://www.dash0.com/) provides real-time observability with automatic insights.
52
+
53
+ ```typescript filename="src/mastra/index.ts"
54
+ import { Mastra } from "@mastra/core";
55
+ import { OtelExporter } from "@mastra/otel-exporter";
56
+
57
+ export const mastra = new Mastra({
58
+ observability: {
59
+ configs: {
60
+ otel: {
61
+ serviceName: 'my-service',
62
+ exporters: [
63
+ new OtelExporter({
64
+ provider: {
65
+ dash0: {
66
+ apiKey: process.env.DASH0_API_KEY,
67
+ endpoint: process.env.DASH0_ENDPOINT, // e.g., 'ingress.us-west-2.aws.dash0.com:4317'
68
+ dataset: 'production', // Optional dataset name
69
+ }
70
+ },
71
+ }),
72
+ ],
73
+ },
74
+ },
75
+ },
76
+ });
77
+ ```
78
+
79
+ <Callout type="info">
80
+ Get your Dash0 endpoint from your dashboard. It should be in the format `ingress.{region}.aws.dash0.com:4317`.
81
+ </Callout>
82
+
83
+ ### SigNoz
84
+
85
+ [SigNoz](https://signoz.io/) is an open-source APM alternative with built-in AI tracing support.
86
+
87
+ ```typescript filename="src/mastra/index.ts"
88
+ new OtelExporter({
89
+ provider: {
90
+ signoz: {
91
+ apiKey: process.env.SIGNOZ_API_KEY,
92
+ region: 'us', // 'us' | 'eu' | 'in'
93
+ // endpoint: 'https://my-signoz.example.com', // For self-hosted
94
+ }
95
+ },
96
+ })
97
+ ```
98
+
99
+ ### New Relic
100
+
101
+ [New Relic](https://newrelic.com/) provides comprehensive observability with AI monitoring capabilities.
102
+
103
+ ```typescript filename="src/mastra/index.ts"
104
+ new OtelExporter({
105
+ provider: {
106
+ newrelic: {
107
+ apiKey: process.env.NEW_RELIC_LICENSE_KEY,
108
+ // endpoint: 'https://otlp.eu01.nr-data.net', // For EU region
109
+ }
110
+ },
111
+ })
112
+ ```
113
+
114
+ ### Traceloop
115
+
116
+ [Traceloop](https://www.traceloop.com/) specializes in LLM observability with automatic prompt tracking.
117
+
118
+ ```typescript filename="src/mastra/index.ts"
119
+ new OtelExporter({
120
+ provider: {
121
+ traceloop: {
122
+ apiKey: process.env.TRACELOOP_API_KEY,
123
+ destinationId: 'my-destination', // Optional
124
+ }
125
+ },
126
+ })
127
+ ```
128
+
129
+ ### Laminar
130
+
131
+ [Laminar](https://www.lmnr.ai/) provides specialized LLM observability and analytics.
132
+
133
+ ```typescript filename="src/mastra/index.ts"
134
+ new OtelExporter({
135
+ provider: {
136
+ laminar: {
137
+ apiKey: process.env.LMNR_PROJECT_API_KEY,
138
+ // teamId: process.env.LAMINAR_TEAM_ID, // Optional, for backwards compatibility
139
+ }
140
+ },
141
+ })
142
+ ```
143
+
144
+ ### Custom/Generic OTEL Endpoints
145
+
146
+ For other OTEL-compatible platforms or custom collectors:
147
+
148
+ ```typescript filename="src/mastra/index.ts"
149
+ new OtelExporter({
150
+ provider: {
151
+ custom: {
152
+ endpoint: 'https://your-collector.example.com/v1/traces',
153
+ protocol: 'http/protobuf', // 'http/json' | 'http/protobuf' | 'grpc'
154
+ headers: {
155
+ 'x-api-key': process.env.API_KEY,
156
+ },
157
+ }
158
+ },
159
+ })
160
+ ```
161
+
162
+ ## Configuration Options
163
+
164
+ ### Complete Configuration
165
+
166
+ ```typescript
167
+ new OtelExporter({
168
+ // Provider configuration (required)
169
+ provider: {
170
+ // Use one of: dash0, signoz, newrelic, traceloop, laminar, custom
171
+ },
172
+
173
+ // Export configuration
174
+ timeout: 30000, // Export timeout in milliseconds
175
+ batchSize: 100, // Number of spans per batch
176
+
177
+ // Debug options
178
+ logLevel: 'info', // 'debug' | 'info' | 'warn' | 'error'
179
+ })
180
+ ```
181
+
182
+ ## OpenTelemetry Semantic Conventions
183
+
184
+ The exporter follows [OpenTelemetry Semantic Conventions for GenAI](https://opentelemetry.io/docs/specs/semconv/gen-ai/), ensuring compatibility with observability platforms:
185
+
186
+ ### Span Naming
187
+ - **LLM Operations**: `chat {model}` or `tool_selection {model}`
188
+ - **Tool Execution**: `tool.execute {tool_name}`
189
+ - **Agent Runs**: `agent.{agent_id}`
190
+ - **Workflow Runs**: `workflow.{workflow_id}`
191
+
192
+ ### Key Attributes
193
+ - `gen_ai.operation.name` - Operation type (chat, tool.execute, etc.)
194
+ - `gen_ai.system` - AI provider (openai, anthropic, etc.)
195
+ - `gen_ai.request.model` - Model identifier
196
+ - `gen_ai.usage.input_tokens` - Number of input tokens
197
+ - `gen_ai.usage.output_tokens` - Number of output tokens
198
+ - `gen_ai.request.temperature` - Sampling temperature
199
+ - `gen_ai.response.finish_reasons` - Completion reason
200
+
201
+ ## Buffering Strategy
202
+
203
+ The exporter buffers spans until a trace is complete:
204
+ 1. Collects all spans for a trace
205
+ 2. Waits 5 seconds after root span completes
206
+ 3. Exports complete trace with preserved parent-child relationships
207
+ 4. Ensures no orphaned spans
208
+
209
+ ## Protocol Selection Guide
210
+
211
+ Choose the right protocol package based on your provider:
212
+
213
+ | Provider | Protocol | Required Package |
214
+ |----------|----------|------------------|
215
+ | Dash0 | gRPC | `@opentelemetry/exporter-trace-otlp-grpc` |
216
+ | SigNoz | HTTP/Protobuf | `@opentelemetry/exporter-trace-otlp-proto` |
217
+ | New Relic | HTTP/Protobuf | `@opentelemetry/exporter-trace-otlp-proto` |
218
+ | Traceloop | HTTP/JSON | `@opentelemetry/exporter-trace-otlp-http` |
219
+ | Laminar | HTTP/Protobuf | `@opentelemetry/exporter-trace-otlp-proto` |
220
+ | Custom | Varies | Depends on your collector |
221
+
222
+ <Callout type="warning">
223
+ Make sure to install the correct protocol package for your provider. The exporter will provide a helpful error message if the wrong package is installed.
224
+ </Callout>
225
+
226
+ ## Troubleshooting
227
+
228
+ ### Missing Dependency Error
229
+
230
+ If you see an error like:
231
+ ```
232
+ HTTP/Protobuf exporter is not installed (required for signoz).
233
+ To use HTTP/Protobuf export, install the required package:
234
+ npm install @opentelemetry/exporter-trace-otlp-proto
235
+ ```
236
+
237
+ Install the suggested package for your provider.
238
+
239
+ ### Common Issues
240
+
241
+ 1. **Wrong protocol package**: Verify you installed the correct exporter for your provider
242
+ 2. **Invalid endpoint**: Check endpoint format matches provider requirements
243
+ 3. **Authentication failures**: Verify API keys and headers are correct
244
+ 4. **No traces appearing**: Check that traces complete (root span must end)
245
+
246
+ ## Related
247
+
248
+ - [AI Tracing Overview](/docs/observability/ai-tracing/overview)
249
+ - [OpenTelemetry GenAI Conventions](https://opentelemetry.io/docs/specs/semconv/gen-ai/)
250
+ - [OTEL Exporter Reference](/reference/observability/ai-tracing/exporters/otel)
@@ -88,13 +88,14 @@ Mastra provides two built-in exporters that work out of the box:
88
88
  ### External Exporters
89
89
 
90
90
  In addition to the internal exporters, Mastra supports integration with popular observability platforms. These exporters allow you to leverage your existing monitoring infrastructure and take advantage of platform-specific features like alerting, dashboards, and correlation with other application metrics.
91
-
92
- - **[Langfuse](/docs/observability/ai-tracing/exporters/langfuse)** - Sends traces to the Langfuse open-source LLM engineering platform
91
+
93
92
  - **[Braintrust](/docs/observability/ai-tracing/exporters/braintrust)** - Exports traces to Braintrust's eval and observability platform
93
+ - **[Langfuse](/docs/observability/ai-tracing/exporters/langfuse)** - Sends traces to the Langfuse open-source LLM engineering platform
94
+ - **[LangSmith](/docs/observability/ai-tracing/exporters/langsmith)** - Pushes traces into LangSmith’s observability and evaluation toolkit
95
+ - **[OpenTelemetry](/docs/observability/ai-tracing/exporters/otel)** - Deliver traces to any OpenTelemetry-compatible observability system
96
+ - Supports: Dash0, Laminar, New Relic, SigNoz, Traceloop, Zipkin, and others!
94
97
 
95
98
  - **Arize** - Coming soon!
96
- - **LangSmith** - Coming soon!
97
- - **OpenTelemetry** - Coming soon!
98
99
 
99
100
  ## Sampling Strategies
100
101
 
@@ -386,15 +387,15 @@ execute: async ({ input, tracingContext }) => {
386
387
  const results = await db.query(input.query);
387
388
  querySpan?.end({
388
389
  output: results.data,
389
- metadata: {
390
+ metadata: {
390
391
  rowsReturned: results.length,
391
392
  queryTimeMs: results.executionTime,
392
- cacheHit: results.fromCache
393
+ cacheHit: results.fromCache
393
394
  }
394
395
  });
395
396
  return results;
396
397
  } catch (error) {
397
- querySpan?.error({
398
+ querySpan?.error({
398
399
  error,
399
400
  metadata: { retryable: isRetryableError(error) }
400
401
  });
@@ -403,7 +404,7 @@ execute: async ({ input, tracingContext }) => {
403
404
  }
404
405
  ```
405
406
 
406
- Child spans automatically inherit the trace context from their parent, maintaining the relationship hierarchy in your observability platform.
407
+ Child spans automatically inherit the trace context from their parent, maintaining the relationship hierarchy in your observability platform.
407
408
 
408
409
  ## Span Processors
409
410
 
@@ -411,7 +412,7 @@ Span processors allow you to transform, filter, or enrich trace data before it's
411
412
 
412
413
  ### Built-in Processors
413
414
 
414
- * [Sensitive Data Filter](/docs/observability/processors/sensitive-data-filter) redacts sensitive information. It is enabled in the default observability config.
415
+ * [Sensitive Data Filter](/docs/observability/ai-tracing/processors/sensitive-data-filter) redacts sensitive information. It is enabled in the default observability config.
415
416
 
416
417
  ### Creating Custom Processors
417
418
 
@@ -422,12 +423,12 @@ import type { AISpanProcessor, AnyAISpan } from '@mastra/core/ai-tracing';
422
423
 
423
424
  export class LowercaseInputProcessor implements AISpanProcessor {
424
425
  name = 'lowercase-processor';
425
-
426
+
426
427
  process(span: AnyAISpan): AnyAISpan {
427
428
  span.input = `${span.input}`.toLowerCase()
428
429
  return span;
429
430
  }
430
-
431
+
431
432
  async shutdown(): Promise<void> {
432
433
  // Cleanup if needed
433
434
  }
@@ -472,7 +473,7 @@ const result = await agent.generate({
472
473
 
473
474
  console.log('Trace ID:', result.traceId);
474
475
 
475
- // Using stream
476
+ // Using stream
476
477
  const streamResult = await agent.stream({
477
478
  messages: [{ role: 'user', content: 'Tell me a story' }]
478
479
  });
@@ -545,7 +546,6 @@ Traces are available in multiple locations:
545
546
 
546
547
  ### Examples
547
548
  - [Basic AI Tracing Example](/examples/observability/basic-ai-tracing) - Working implementation
548
- - [Advanced Tracing Patterns](/examples/observability/advanced-tracing) - Complex scenarios
549
549
 
550
550
  ### Reference Documentation
551
551
  - [Configuration API](/reference/observability/ai-tracing/configuration) - ObservabilityConfig details
@@ -559,7 +559,7 @@ Traces are available in multiple locations:
559
559
  - [ConsoleExporter](/reference/observability/ai-tracing/exporters/console-exporter) - Debug output
560
560
  - [Langfuse](/reference/observability/ai-tracing/exporters/langfuse) - Langfuse integration
561
561
  - [Braintrust](/reference/observability/ai-tracing/exporters/braintrust) - Braintrust integration
562
+ - [OpenTelemetry](/reference/observability/ai-tracing/exporters/otel) - OTEL-compatible platforms
562
563
 
563
564
  ### Processors
564
- - [Sensitive Data Filter](/docs/observability/processors/sensitive-data-filter) - Data redaction
565
- - [Custom Processors Guide](/docs/observability/processors/custom-processors) - Build your own
565
+ - [Sensitive Data Filter](/docs/observability/ai-tracing/processors/sensitive-data-filter) - Data redaction
@@ -56,7 +56,7 @@ export const mastra = new Mastra({
56
56
 
57
57
  With this basic setup, you will see Traces and Logs in both the Playground and in Mastra Cloud.
58
58
 
59
- We also support various external tracing providers like Langfuse and Braintrust. See more about this in the [AI Tracing](/docs/observability/ai-tracing.mdx) documentation.
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
60
 
61
61
  ## What's Next?
62
62
 
@@ -287,4 +287,4 @@ await agent.network(`
287
287
  description: "A promise that resolves to token usage statistics",
288
288
  },
289
289
  ]}
290
- />
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
@@ -0,0 +1,75 @@
1
+ ---
2
+ title: "Reference: getScorer() | Core | Mastra Docs"
3
+ description: "Documentation for the `getScorer()` method in Mastra, which retrieves a specific scorer by its registration key."
4
+ ---
5
+
6
+ # getScorer()
7
+
8
+ The `getScorer()` method retrieves a specific scorer that was registered with the Mastra instance using its registration key. This method provides type-safe access to scorers and throws an error if the requested scorer is not found.
9
+
10
+ ## Usage Example
11
+
12
+ ```typescript
13
+ import { mastra } from './mastra';
14
+
15
+ // Get a specific scorer by key
16
+ const relevancyScorer = mastra.getScorer('relevancyScorer');
17
+
18
+ const weatherAgent = mastra.getAgent('weatherAgent')
19
+
20
+ // Use the scorer to evaluate an AI output
21
+ await weatherAgent.generate('What is the weather in Rome', {
22
+ scorers: {
23
+ answerRelevancy: {
24
+ scorer: relevancyScorer,
25
+ },
26
+ },
27
+ });
28
+ ```
29
+
30
+ ## Parameters
31
+
32
+ <PropertiesTable
33
+ content={[
34
+ {
35
+ name: "key",
36
+ type: "string",
37
+ description: "The registration key of the scorer to retrieve. This should match a key used when registering scorers in the Mastra constructor.",
38
+ isOptional: false,
39
+ },
40
+ ]}
41
+ />
42
+
43
+ ## Returns
44
+
45
+ <PropertiesTable
46
+ content={[
47
+ {
48
+ name: "scorer",
49
+ type: "MastraScorer",
50
+ description: "The MastraScorer instance associated with the provided key.",
51
+ },
52
+ ]}
53
+ />
54
+
55
+ ## Error Handling
56
+
57
+ This method throws a `MastraError` if:
58
+ - The scorer with the specified key is not found
59
+ - No scorers are registered with the Mastra instance
60
+
61
+ ```typescript
62
+ try {
63
+ const scorer = mastra.getScorer('nonExistentScorer');
64
+ } catch (error) {
65
+ if (error.id === 'MASTRA_GET_SCORER_NOT_FOUND') {
66
+ console.log('Scorer not found, using default evaluation');
67
+ }
68
+ }
69
+ ```
70
+
71
+ ## Related
72
+
73
+ - [getScorers()](../../reference/core/getScorers.mdx) - Get all registered scorers
74
+ - [getScorerByName()](../../reference/core/getScorerByName.mdx) - Get a scorer by its name property
75
+ - [Custom Scorers](../../docs/scorers/custom-scorers.mdx) - Learn how to create custom scorers
@@ -0,0 +1,75 @@
1
+ ---
2
+ title: "Reference: getScorerByName() | Core | Mastra Docs"
3
+ description: "Documentation for the `getScorerByName()` method in Mastra, which retrieves a scorer by its name property rather than registration key."
4
+ ---
5
+
6
+ # getScorerByName()
7
+
8
+ The `getScorerByName()` method retrieves a scorer by searching for its `name` property rather than the registration key. This is useful when you know the scorer's display name but not necessarily how it was registered in the Mastra instance.
9
+
10
+ ## Usage Example
11
+
12
+ ```typescript
13
+ import { mastra } from './mastra';
14
+
15
+ // Get a scorer by its name property
16
+ const relevancyScorer = mastra.getScorerByName('Answer Relevancy');
17
+
18
+ const weatherAgent = mastra.getAgent('weatherAgent')
19
+
20
+ // Use the scorer to evaluate an AI output
21
+ await weatherAgent.generate('What is the weather in Rome', {
22
+ scorers: {
23
+ answerRelevancy: {
24
+ scorer: relevancyScorer,
25
+ },
26
+ },
27
+ });
28
+ ```
29
+
30
+ ## Parameters
31
+
32
+ <PropertiesTable
33
+ content={[
34
+ {
35
+ name: "name",
36
+ type: "string",
37
+ description: "The name property of the scorer to retrieve. This should match the 'name' field specified when creating the scorer with createScorer().",
38
+ isOptional: false,
39
+ },
40
+ ]}
41
+ />
42
+
43
+ ## Returns
44
+
45
+ <PropertiesTable
46
+ content={[
47
+ {
48
+ name: "scorer",
49
+ type: "MastraScorer",
50
+ description: "The MastraScorer instance that has the matching name property.",
51
+ },
52
+ ]}
53
+ />
54
+
55
+ ## Error Handling
56
+
57
+ This method throws a `MastraError` if:
58
+ - No scorer with the specified name is found
59
+ - No scorers are registered with the Mastra instance
60
+
61
+ ```typescript
62
+ try {
63
+ const scorer = mastra.getScorerByName('Non-existent Scorer');
64
+ } catch (error) {
65
+ if (error.id === 'MASTRA_GET_SCORER_BY_NAME_NOT_FOUND') {
66
+ console.log('Scorer with that name not found');
67
+ }
68
+ }
69
+ ```
70
+
71
+ ## Related
72
+
73
+ - [getScorer()](../../reference/core/getScorer) - Get a scorer by its registration key
74
+ - [getScorers()](../../reference/core/getScorers) - Get all registered scorers
75
+ - [createScorer()](../../reference/scorers/create-scorer) - Learn how to create scorers with names