@mastra/mcp-docs-server 1.1.23-alpha.0 → 1.1.23-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/observability/tracing/overview.md +45 -0
- package/.docs/models/gateways/openrouter.md +3 -2
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/huggingface.md +3 -2
- package/.docs/models/providers/mixlayer.md +75 -0
- package/.docs/models/providers/ollama-cloud.md +2 -1
- package/.docs/models/providers/stepfun.md +8 -7
- package/.docs/models/providers.md +1 -0
- package/.docs/reference/ai-sdk/to-ai-sdk-messages.md +95 -0
- package/.docs/reference/index.md +2 -0
- package/.docs/reference/observability/tracing/configuration.md +8 -1
- package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +66 -11
- package/.docs/reference/observability/tracing/span-filtering.md +95 -0
- package/CHANGELOG.md +15 -0
- package/package.json +5 -5
|
@@ -660,6 +660,50 @@ Processors are executed in the order they're defined, allowing you to chain mult
|
|
|
660
660
|
- Normalizing data formats
|
|
661
661
|
- Enriching spans with business context
|
|
662
662
|
|
|
663
|
+
## Span filtering
|
|
664
|
+
|
|
665
|
+
Span filtering lets you reduce noise and per-span costs before data reaches your observability platform. Configure it per observability instance, so different exporters or environments can keep different levels of detail.
|
|
666
|
+
|
|
667
|
+
- Use `excludeSpanTypes` to drop entire categories of spans with minimal configuration.
|
|
668
|
+
- Use `spanFilter` when you need custom logic based on the exported span data.
|
|
669
|
+
|
|
670
|
+
The following example demonstrates how to combine both options in a single config:
|
|
671
|
+
|
|
672
|
+
```ts
|
|
673
|
+
import { Mastra } from '@mastra/core'
|
|
674
|
+
import { SpanType } from '@mastra/core/observability'
|
|
675
|
+
import { Observability, DefaultExporter } from '@mastra/observability'
|
|
676
|
+
import { LangfuseExporter } from '@mastra/langfuse'
|
|
677
|
+
|
|
678
|
+
export const mastra = new Mastra({
|
|
679
|
+
observability: new Observability({
|
|
680
|
+
configs: {
|
|
681
|
+
default: {
|
|
682
|
+
serviceName: 'my-app',
|
|
683
|
+
exporters: [new DefaultExporter(), new LangfuseExporter()],
|
|
684
|
+
excludeSpanTypes: [SpanType.MODEL_CHUNK, SpanType.MODEL_STEP],
|
|
685
|
+
spanFilter: span => {
|
|
686
|
+
if (span.type === SpanType.TOOL_CALL && span.attributes?.success) {
|
|
687
|
+
return false
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
return true
|
|
691
|
+
},
|
|
692
|
+
},
|
|
693
|
+
},
|
|
694
|
+
}),
|
|
695
|
+
})
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
Filtering happens at export time in this order:
|
|
699
|
+
|
|
700
|
+
1. Internal spans are dropped unless `includeInternalSpans` is `true`.
|
|
701
|
+
2. `excludeSpanTypes` removes matching span types.
|
|
702
|
+
3. `spanOutputProcessors` transform the remaining spans.
|
|
703
|
+
4. `spanFilter` decides whether to keep the final exported span.
|
|
704
|
+
|
|
705
|
+
If `spanFilter` throws, Mastra keeps the span and logs the error to avoid silent data loss. For the full span type list and more examples, see the [Span filtering reference](https://mastra.ai/reference/observability/tracing/span-filtering).
|
|
706
|
+
|
|
663
707
|
### Custom Span Formatters
|
|
664
708
|
|
|
665
709
|
Custom span formatters transform how spans appear in specific observability platforms. Unlike span processors, formatters are configured per-exporter, allowing different formatting for different destinations. Formatters support both synchronous and asynchronous operations.
|
|
@@ -1091,6 +1135,7 @@ Mastra automatically creates spans for:
|
|
|
1091
1135
|
- [Tracing Classes](https://mastra.ai/reference/observability/tracing/instances) - Core classes and methods
|
|
1092
1136
|
- [Span Interfaces](https://mastra.ai/reference/observability/tracing/spans) - Span types and lifecycle
|
|
1093
1137
|
- [Type Definitions](https://mastra.ai/reference/observability/tracing/interfaces) - Complete interface reference
|
|
1138
|
+
- [Span filtering](https://mastra.ai/reference/observability/tracing/span-filtering) - Filtering behavior, span types, and examples
|
|
1094
1139
|
|
|
1095
1140
|
### Exporters
|
|
1096
1141
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenRouter
|
|
2
2
|
|
|
3
|
-
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
3
|
+
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 171 models through Mastra's model router.
|
|
4
4
|
|
|
5
5
|
Learn more in the [OpenRouter documentation](https://openrouter.ai/models).
|
|
6
6
|
|
|
@@ -203,4 +203,5 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
203
203
|
| `z-ai/glm-4.7` |
|
|
204
204
|
| `z-ai/glm-4.7-flash` |
|
|
205
205
|
| `z-ai/glm-5` |
|
|
206
|
-
| `z-ai/glm-5-turbo` |
|
|
206
|
+
| `z-ai/glm-5-turbo` |
|
|
207
|
+
| `z-ai/glm-5.1` |
|
package/.docs/models/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Model Providers
|
|
2
2
|
|
|
3
|
-
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to
|
|
3
|
+
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to 3614 models from 99 providers through a single API.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Hugging Face
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 21 Hugging Face models through Mastra's model router. Authentication is handled automatically using the `HF_TOKEN` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Hugging Face documentation](https://huggingface.co).
|
|
6
6
|
|
|
@@ -54,6 +54,7 @@ for await (const chunk of stream) {
|
|
|
54
54
|
| `huggingface/zai-org/GLM-4.7` | 205K | | | | | | $0.60 | $2 |
|
|
55
55
|
| `huggingface/zai-org/GLM-4.7-Flash` | 200K | | | | | | — | — |
|
|
56
56
|
| `huggingface/zai-org/GLM-5` | 203K | | | | | | $1 | $3 |
|
|
57
|
+
| `huggingface/zai-org/GLM-5.1` | 203K | | | | | | $1 | $3 |
|
|
57
58
|
|
|
58
59
|
## Advanced configuration
|
|
59
60
|
|
|
@@ -83,7 +84,7 @@ const agent = new Agent({
|
|
|
83
84
|
model: ({ requestContext }) => {
|
|
84
85
|
const useAdvanced = requestContext.task === "complex";
|
|
85
86
|
return useAdvanced
|
|
86
|
-
? "huggingface/zai-org/GLM-5"
|
|
87
|
+
? "huggingface/zai-org/GLM-5.1"
|
|
87
88
|
: "huggingface/MiniMaxAI/MiniMax-M2.1";
|
|
88
89
|
}
|
|
89
90
|
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Mixlayer
|
|
2
|
+
|
|
3
|
+
Access 5 Mixlayer models through Mastra's model router. Authentication is handled automatically using the `MIXLAYER_API_KEY` environment variable.
|
|
4
|
+
|
|
5
|
+
Learn more in the [Mixlayer documentation](https://docs.mixlayer.com).
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
MIXLAYER_API_KEY=your-api-key
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { Agent } from "@mastra/core/agent";
|
|
13
|
+
|
|
14
|
+
const agent = new Agent({
|
|
15
|
+
id: "my-agent",
|
|
16
|
+
name: "My Agent",
|
|
17
|
+
instructions: "You are a helpful assistant",
|
|
18
|
+
model: "mixlayer/qwen/qwen3.5-122b-a10b"
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Generate a response
|
|
22
|
+
const response = await agent.generate("Hello!");
|
|
23
|
+
|
|
24
|
+
// Stream a response
|
|
25
|
+
const stream = await agent.stream("Tell me a story");
|
|
26
|
+
for await (const chunk of stream) {
|
|
27
|
+
console.log(chunk);
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
> **Info:** Mastra uses the OpenAI-compatible `/chat/completions` endpoint. Some provider-specific features may not be available. Check the [Mixlayer documentation](https://docs.mixlayer.com) for details.
|
|
32
|
+
|
|
33
|
+
## Models
|
|
34
|
+
|
|
35
|
+
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
36
|
+
| --------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
37
|
+
| `mixlayer/qwen/qwen3.5-122b-a10b` | 262K | | | | | | $0.40 | $3 |
|
|
38
|
+
| `mixlayer/qwen/qwen3.5-27b` | 262K | | | | | | $0.30 | $2 |
|
|
39
|
+
| `mixlayer/qwen/qwen3.5-35b-a3b` | 262K | | | | | | $0.25 | $1 |
|
|
40
|
+
| `mixlayer/qwen/qwen3.5-397b-a17b` | 262K | | | | | | $0.60 | $4 |
|
|
41
|
+
| `mixlayer/qwen/qwen3.5-9b` | 262K | | | | | | $0.10 | $0.40 |
|
|
42
|
+
|
|
43
|
+
## Advanced configuration
|
|
44
|
+
|
|
45
|
+
### Custom headers
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
const agent = new Agent({
|
|
49
|
+
id: "custom-agent",
|
|
50
|
+
name: "custom-agent",
|
|
51
|
+
model: {
|
|
52
|
+
url: "https://models.mixlayer.ai/v1",
|
|
53
|
+
id: "mixlayer/qwen/qwen3.5-122b-a10b",
|
|
54
|
+
apiKey: process.env.MIXLAYER_API_KEY,
|
|
55
|
+
headers: {
|
|
56
|
+
"X-Custom-Header": "value"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Dynamic model selection
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
const agent = new Agent({
|
|
66
|
+
id: "dynamic-agent",
|
|
67
|
+
name: "Dynamic Agent",
|
|
68
|
+
model: ({ requestContext }) => {
|
|
69
|
+
const useAdvanced = requestContext.task === "complex";
|
|
70
|
+
return useAdvanced
|
|
71
|
+
? "mixlayer/qwen/qwen3.5-9b"
|
|
72
|
+
: "mixlayer/qwen/qwen3.5-122b-a10b";
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Ollama Cloud
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 35 Ollama Cloud models through Mastra's model router. Authentication is handled automatically using the `OLLAMA_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Ollama Cloud documentation](https://docs.ollama.com/cloud).
|
|
6
6
|
|
|
@@ -46,6 +46,7 @@ for await (const chunk of stream) {
|
|
|
46
46
|
| `ollama-cloud/glm-4.6` | 203K | | | | | | — | — |
|
|
47
47
|
| `ollama-cloud/glm-4.7` | 203K | | | | | | — | — |
|
|
48
48
|
| `ollama-cloud/glm-5` | 203K | | | | | | — | — |
|
|
49
|
+
| `ollama-cloud/glm-5.1` | 203K | | | | | | — | — |
|
|
49
50
|
| `ollama-cloud/gpt-oss:120b` | 131K | | | | | | — | — |
|
|
50
51
|
| `ollama-cloud/gpt-oss:20b` | 131K | | | | | | — | — |
|
|
51
52
|
| `ollama-cloud/kimi-k2-thinking` | 262K | | | | | | — | — |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# StepFun
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 4 StepFun models through Mastra's model router. Authentication is handled automatically using the `STEPFUN_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [StepFun documentation](https://platform.stepfun.com/docs/zh/overview/concept).
|
|
6
6
|
|
|
@@ -32,11 +32,12 @@ for await (const chunk of stream) {
|
|
|
32
32
|
|
|
33
33
|
## Models
|
|
34
34
|
|
|
35
|
-
| Model
|
|
36
|
-
|
|
|
37
|
-
| `stepfun/step-1-32k`
|
|
38
|
-
| `stepfun/step-2-16k`
|
|
39
|
-
| `stepfun/step-3.5-flash`
|
|
35
|
+
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
36
|
+
| ----------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
37
|
+
| `stepfun/step-1-32k` | 33K | | | | | | $2 | $10 |
|
|
38
|
+
| `stepfun/step-2-16k` | 16K | | | | | | $5 | $16 |
|
|
39
|
+
| `stepfun/step-3.5-flash` | 256K | | | | | | $0.10 | $0.29 |
|
|
40
|
+
| `stepfun/step-3.5-flash-2603` | 256K | | | | | | $0.10 | $0.30 |
|
|
40
41
|
|
|
41
42
|
## Advanced configuration
|
|
42
43
|
|
|
@@ -66,7 +67,7 @@ const agent = new Agent({
|
|
|
66
67
|
model: ({ requestContext }) => {
|
|
67
68
|
const useAdvanced = requestContext.task === "complex";
|
|
68
69
|
return useAdvanced
|
|
69
|
-
? "stepfun/step-3.5-flash"
|
|
70
|
+
? "stepfun/step-3.5-flash-2603"
|
|
70
71
|
: "stepfun/step-1-32k";
|
|
71
72
|
}
|
|
72
73
|
});
|
|
@@ -52,6 +52,7 @@ Direct access to individual AI model providers. Each provider offers unique mode
|
|
|
52
52
|
- [MiniMax (minimaxi.com)](https://mastra.ai/models/providers/minimax-cn)
|
|
53
53
|
- [MiniMax Coding Plan (minimax.io)](https://mastra.ai/models/providers/minimax-coding-plan)
|
|
54
54
|
- [MiniMax Coding Plan (minimaxi.com)](https://mastra.ai/models/providers/minimax-cn-coding-plan)
|
|
55
|
+
- [Mixlayer](https://mastra.ai/models/providers/mixlayer)
|
|
55
56
|
- [Moark](https://mastra.ai/models/providers/moark)
|
|
56
57
|
- [ModelScope](https://mastra.ai/models/providers/modelscope)
|
|
57
58
|
- [Moonshot AI](https://mastra.ai/models/providers/moonshotai)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# toAISdkMessages()
|
|
2
|
+
|
|
3
|
+
Converts messages from various input formats to AI SDK UI message format. `toAISdkMessages()` keeps the existing AI SDK v5/default behavior. If your app is typed against AI SDK v6, pass `version: 'v6'`.
|
|
4
|
+
|
|
5
|
+
`version: 'v6'` uses the MessageList AI SDK v6 UI output path. MessageList input detection and ingestion remain unchanged.
|
|
6
|
+
|
|
7
|
+
## Usage example
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { toAISdkMessages } from '@mastra/ai-sdk/ui'
|
|
11
|
+
import { useChat } from 'ai/react'
|
|
12
|
+
|
|
13
|
+
// Stored messages from your database, memory, or API
|
|
14
|
+
const storedMessages = [
|
|
15
|
+
{ id: '1', role: 'user', content: 'Hello', parts: [{ type: 'text', text: 'Hello' }] },
|
|
16
|
+
{
|
|
17
|
+
id: '2',
|
|
18
|
+
role: 'assistant',
|
|
19
|
+
content: 'Hi there!',
|
|
20
|
+
parts: [{ type: 'text', text: 'Hi there!' }],
|
|
21
|
+
},
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
export default function Chat() {
|
|
25
|
+
const { messages } = useChat({
|
|
26
|
+
initialMessages: toAISdkMessages(storedMessages, { version: 'v6' }),
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div>
|
|
31
|
+
{messages.map(message => (
|
|
32
|
+
<div key={message.id}>
|
|
33
|
+
{message.role}: {message.parts.map(part => (part.type === 'text' ? part.text : null))}
|
|
34
|
+
</div>
|
|
35
|
+
))}
|
|
36
|
+
</div>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Parameters
|
|
42
|
+
|
|
43
|
+
**messages** (`MessageListInput`): Messages to convert. Can be a string, array of strings, a single message object, or an array of message objects in any supported format.
|
|
44
|
+
|
|
45
|
+
**options.version** (`'v5' | 'v6'`): Selects the AI SDK message type to return. Omit it or pass \`'v5'\` for the existing default behavior. Pass \`'v6'\` when your app is typed against AI SDK v6 \`useChat()\` message types.
|
|
46
|
+
|
|
47
|
+
## Returns
|
|
48
|
+
|
|
49
|
+
Returns an array of AI SDK `UIMessage` objects typed for the selected version.
|
|
50
|
+
|
|
51
|
+
**id** (`string`): Unique message identifier.
|
|
52
|
+
|
|
53
|
+
**role** (`'user' | 'assistant' | 'system'`): The role of the message sender.
|
|
54
|
+
|
|
55
|
+
**parts** (`UIMessagePart[]`): Array of UI parts including text, tool results, files, reasoning, sources, and step markers.
|
|
56
|
+
|
|
57
|
+
**metadata** (`Record<string, unknown>`): Optional metadata including createdAt, threadId, resourceId, and custom fields.
|
|
58
|
+
|
|
59
|
+
## Examples
|
|
60
|
+
|
|
61
|
+
### Using the default AI SDK v5 types
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { toAISdkMessages } from '@mastra/ai-sdk/ui'
|
|
65
|
+
|
|
66
|
+
const messages = toAISdkMessages(['Hello', 'How can I help you today?'])
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Returning AI SDK v6 message types
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { toAISdkMessages } from '@mastra/ai-sdk/ui'
|
|
73
|
+
|
|
74
|
+
const messages = toAISdkMessages(['Hello', 'How can I help you today?'], {
|
|
75
|
+
version: 'v6',
|
|
76
|
+
})
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Loading messages with Mastra client
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { MastraClient } from '@mastra/client-js'
|
|
83
|
+
import { toAISdkMessages } from '@mastra/ai-sdk/ui'
|
|
84
|
+
|
|
85
|
+
const client = new MastraClient()
|
|
86
|
+
|
|
87
|
+
const { messages } = await client.listThreadMessages('thread-id', { agentId: 'myAgent' })
|
|
88
|
+
const uiMessages = toAISdkMessages(messages)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Related
|
|
92
|
+
|
|
93
|
+
- [`toAISdkStream()`](https://mastra.ai/reference/ai-sdk/to-ai-sdk-stream)
|
|
94
|
+
- [`toAISdkV5Messages()`](https://mastra.ai/reference/ai-sdk/to-ai-sdk-v5-messages)
|
|
95
|
+
- [`toAISdkV4Messages()`](https://mastra.ai/reference/ai-sdk/to-ai-sdk-v4-messages)
|
package/.docs/reference/index.md
CHANGED
|
@@ -26,6 +26,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
26
26
|
- [handleNetworkStream()](https://mastra.ai/reference/ai-sdk/handle-network-stream)
|
|
27
27
|
- [handleWorkflowStream()](https://mastra.ai/reference/ai-sdk/handle-workflow-stream)
|
|
28
28
|
- [networkRoute()](https://mastra.ai/reference/ai-sdk/network-route)
|
|
29
|
+
- [toAISdkMessages()](https://mastra.ai/reference/ai-sdk/to-ai-sdk-messages)
|
|
29
30
|
- [toAISdkStream()](https://mastra.ai/reference/ai-sdk/to-ai-sdk-stream)
|
|
30
31
|
- [toAISdkV4Messages()](https://mastra.ai/reference/ai-sdk/to-ai-sdk-v4-messages)
|
|
31
32
|
- [toAISdkV5Messages()](https://mastra.ai/reference/ai-sdk/to-ai-sdk-v5-messages)
|
|
@@ -150,6 +151,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
150
151
|
- [Configuration](https://mastra.ai/reference/observability/tracing/configuration)
|
|
151
152
|
- [Instances](https://mastra.ai/reference/observability/tracing/instances)
|
|
152
153
|
- [Interfaces](https://mastra.ai/reference/observability/tracing/interfaces)
|
|
154
|
+
- [Span filtering](https://mastra.ai/reference/observability/tracing/span-filtering)
|
|
153
155
|
- [Spans](https://mastra.ai/reference/observability/tracing/spans)
|
|
154
156
|
- [BatchPartsProcessor](https://mastra.ai/reference/processors/batch-parts-processor)
|
|
155
157
|
- [LanguageDetector](https://mastra.ai/reference/processors/language-detector)
|
|
@@ -26,6 +26,8 @@ interface ObservabilityInstanceConfig {
|
|
|
26
26
|
exporters?: ObservabilityExporter[]
|
|
27
27
|
spanOutputProcessors?: SpanOutputProcessor[]
|
|
28
28
|
includeInternalSpans?: boolean
|
|
29
|
+
excludeSpanTypes?: SpanType[]
|
|
30
|
+
spanFilter?: (span: AnyExportedSpan) => boolean
|
|
29
31
|
requestContextKeys?: string[]
|
|
30
32
|
serializationOptions?: SerializationOptions
|
|
31
33
|
logging?: { enabled?: boolean; level?: LogLevel }
|
|
@@ -44,6 +46,10 @@ interface ObservabilityInstanceConfig {
|
|
|
44
46
|
|
|
45
47
|
**includeInternalSpans** (`boolean`): Include spans internal to Mastra operations
|
|
46
48
|
|
|
49
|
+
**excludeSpanTypes** (`SpanType[]`): Span types to exclude from export. Useful for reducing noise and costs in per-span billing platforms. See the \[Span filtering reference]\(/reference/observability/tracing/span-filtering) for details.
|
|
50
|
+
|
|
51
|
+
**spanFilter** (`(span: AnyExportedSpan) => boolean`): Filter function to control which spans are exported. Return true to keep, false to drop. Runs after excludeSpanTypes and spanOutputProcessors. See the \[Span filtering reference]\(/reference/observability/tracing/span-filtering) for details.
|
|
52
|
+
|
|
47
53
|
**requestContextKeys** (`string[]`): RequestContext keys to extract as metadata (supports dot notation)
|
|
48
54
|
|
|
49
55
|
**serializationOptions** (`SerializationOptions`): Options for controlling serialization of span data (input/output/attributes)
|
|
@@ -199,4 +205,5 @@ Shuts down all observability instances and clears the registry.
|
|
|
199
205
|
- [CloudExporter](https://mastra.ai/reference/observability/tracing/exporters/cloud-exporter) - Cloud setup
|
|
200
206
|
- [Braintrust](https://mastra.ai/reference/observability/tracing/exporters/braintrust) - Braintrust integration
|
|
201
207
|
- [Langfuse](https://mastra.ai/reference/observability/tracing/exporters/langfuse) - Langfuse integration
|
|
202
|
-
- [LangSmith](https://mastra.ai/reference/observability/tracing/exporters/langsmith) - LangSmith integration
|
|
208
|
+
- [LangSmith](https://mastra.ai/reference/observability/tracing/exporters/langsmith) - LangSmith integration
|
|
209
|
+
- [Span filtering](https://mastra.ai/reference/observability/tracing/span-filtering) - Selectively exclude spans
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# CloudExporter
|
|
2
2
|
|
|
3
|
-
Sends
|
|
3
|
+
Sends tracing spans, logs, metrics, scores, and feedback to Mastra Cloud for online visualization and monitoring.
|
|
4
4
|
|
|
5
5
|
## Constructor
|
|
6
6
|
|
|
@@ -24,8 +24,11 @@ interface CloudExporterConfig extends BaseExporterConfig {
|
|
|
24
24
|
/** Cloud access token (from env or config) */
|
|
25
25
|
accessToken?: string
|
|
26
26
|
|
|
27
|
-
/**
|
|
27
|
+
/** Base cloud observability endpoint */
|
|
28
28
|
endpoint?: string
|
|
29
|
+
|
|
30
|
+
/** Explicit cloud traces endpoint override */
|
|
31
|
+
tracesEndpoint?: string
|
|
29
32
|
}
|
|
30
33
|
```
|
|
31
34
|
|
|
@@ -39,7 +42,7 @@ Extends `BaseExporterConfig`, which includes:
|
|
|
39
42
|
The exporter reads these environment variables if not provided in config:
|
|
40
43
|
|
|
41
44
|
- `MASTRA_CLOUD_ACCESS_TOKEN` - Project-scoped access token for authentication (generate in your Mastra Cloud project under **Project Settings → Access Tokens**)
|
|
42
|
-
- `MASTRA_CLOUD_TRACES_ENDPOINT` -
|
|
45
|
+
- `MASTRA_CLOUD_TRACES_ENDPOINT` - Base cloud endpoint (defaults to `https://api.mastra.ai`)
|
|
43
46
|
|
|
44
47
|
## Properties
|
|
45
48
|
|
|
@@ -55,7 +58,59 @@ readonly name = 'mastra-cloud-observability-exporter';
|
|
|
55
58
|
async exportTracingEvent(event: TracingEvent): Promise<void>
|
|
56
59
|
```
|
|
57
60
|
|
|
58
|
-
Processes tracing events
|
|
61
|
+
Processes tracing events for Cloud export.
|
|
62
|
+
|
|
63
|
+
Only `SPAN_ENDED` tracing events are exported. `SPAN_STARTED` and `SPAN_UPDATED` are ignored. Matching spans are buffered and uploaded to the Cloud traces endpoint on the next flush.
|
|
64
|
+
|
|
65
|
+
**Returns:** `Promise<void>` after the tracing event has been accepted for buffering or ignored.
|
|
66
|
+
|
|
67
|
+
### `onLogEvent`
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
async onLogEvent(event: LogEvent): Promise<void>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Processes log signals for Cloud export.
|
|
74
|
+
|
|
75
|
+
Every `LogEvent` passed to this handler is buffered and exported to the Cloud logs endpoint derived from the configured base endpoint. Unlike tracing, there is no additional event-status filtering at the `CloudExporter` level. If the exporter is disabled, this method becomes a no-op.
|
|
76
|
+
|
|
77
|
+
**Returns:** `Promise<void>` after the log event has been accepted for buffering.
|
|
78
|
+
|
|
79
|
+
### `onMetricEvent`
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
async onMetricEvent(event: MetricEvent): Promise<void>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Processes metric signals for Cloud export.
|
|
86
|
+
|
|
87
|
+
Every `MetricEvent` passed to this handler is buffered and exported to the Cloud metrics endpoint derived from the configured base endpoint. There is no additional filtering by metric subtype or status inside `CloudExporter`; the exporter forwards every metric event it receives unless it is disabled.
|
|
88
|
+
|
|
89
|
+
**Returns:** `Promise<void>` after the metric event has been accepted for buffering.
|
|
90
|
+
|
|
91
|
+
### `onScoreEvent`
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
async onScoreEvent(event: ScoreEvent): Promise<void>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Processes score signals for Cloud export.
|
|
98
|
+
|
|
99
|
+
Every `ScoreEvent` passed to this handler is buffered and exported to the Cloud scores endpoint derived from the configured base endpoint. There is no extra filtering at the exporter layer beyond the disabled-exporter check, so all score events received by this method are forwarded.
|
|
100
|
+
|
|
101
|
+
**Returns:** `Promise<void>` after the score event has been accepted for buffering.
|
|
102
|
+
|
|
103
|
+
### `onFeedbackEvent`
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
async onFeedbackEvent(event: FeedbackEvent): Promise<void>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Processes feedback signals for Cloud export.
|
|
110
|
+
|
|
111
|
+
Every `FeedbackEvent` passed to this handler is buffered and exported to the Cloud feedback endpoint derived from the configured base endpoint. There is no feedback-type filtering inside `CloudExporter`; all feedback events received here are forwarded unless the exporter is disabled.
|
|
112
|
+
|
|
113
|
+
**Returns:** `Promise<void>` after the feedback event has been accepted for buffering.
|
|
59
114
|
|
|
60
115
|
### flush
|
|
61
116
|
|
|
@@ -84,10 +139,10 @@ If no access token is provided via config or environment variable, the exporter:
|
|
|
84
139
|
|
|
85
140
|
### Batching
|
|
86
141
|
|
|
87
|
-
The exporter batches spans for efficient network usage:
|
|
142
|
+
The exporter batches tracing spans, logs, metrics, scores, and feedback for efficient network usage:
|
|
88
143
|
|
|
89
|
-
- Flushes when
|
|
90
|
-
- Flushes when `maxBatchWaitMs` elapsed since first
|
|
144
|
+
- Flushes when total buffered event count reaches `maxBatchSize`
|
|
145
|
+
- Flushes when `maxBatchWaitMs` elapsed since the first buffered signal in the batch
|
|
91
146
|
- Flushes on `shutdown()`
|
|
92
147
|
|
|
93
148
|
### Error handling
|
|
@@ -96,11 +151,11 @@ The exporter batches spans for efficient network usage:
|
|
|
96
151
|
- Drops batches after all retries fail
|
|
97
152
|
- Logs errors but continues processing new events
|
|
98
153
|
|
|
99
|
-
###
|
|
154
|
+
### Signal Processing
|
|
100
155
|
|
|
101
|
-
-
|
|
102
|
-
-
|
|
103
|
-
-
|
|
156
|
+
- `exportTracingEvent()` only exports `SPAN_ENDED` tracing events
|
|
157
|
+
- `onLogEvent()`, `onMetricEvent()`, `onScoreEvent()`, and `onFeedbackEvent()` buffer every event they receive for their respective signal type
|
|
158
|
+
- All supported signal batches are uploaded to their matching Cloud publish endpoints during `flush()` and `shutdown()`
|
|
104
159
|
|
|
105
160
|
## `MastraCloudSpanRecord`
|
|
106
161
|
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Span filtering
|
|
2
|
+
|
|
3
|
+
Span filtering controls which spans are exported from an observability config. Use it to reduce noise, lower per-span costs, or keep only the spans that matter for a specific exporter or environment.
|
|
4
|
+
|
|
5
|
+
For a shorter overview of tracing configuration, see [Tracing](https://mastra.ai/docs/observability/tracing/overview).
|
|
6
|
+
|
|
7
|
+
## Usage example
|
|
8
|
+
|
|
9
|
+
The following example demonstrates how to combine `excludeSpanTypes` and `spanFilter` in one observability config:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { Mastra } from '@mastra/core'
|
|
13
|
+
import { SpanType } from '@mastra/core/observability'
|
|
14
|
+
import { Observability, DefaultExporter } from '@mastra/observability'
|
|
15
|
+
import { LangfuseExporter } from '@mastra/langfuse'
|
|
16
|
+
|
|
17
|
+
export const mastra = new Mastra({
|
|
18
|
+
observability: new Observability({
|
|
19
|
+
configs: {
|
|
20
|
+
default: {
|
|
21
|
+
serviceName: 'my-app',
|
|
22
|
+
exporters: [new DefaultExporter(), new LangfuseExporter()],
|
|
23
|
+
excludeSpanTypes: [SpanType.MODEL_CHUNK, SpanType.MODEL_STEP],
|
|
24
|
+
spanFilter: span => {
|
|
25
|
+
if (span.type === SpanType.TOOL_CALL && span.attributes?.success) {
|
|
26
|
+
return false
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return true
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Configuration options
|
|
38
|
+
|
|
39
|
+
**excludeSpanTypes** (`SpanType[]`): Drops spans by type before processors and spanFilter run. Use this for broad, low-overhead filtering.
|
|
40
|
+
|
|
41
|
+
**spanFilter** (`(span: AnyExportedSpan) => boolean`): Receives the exported span and returns true to keep it or false to drop it. Use this when filtering depends on attributes, metadata, timing, or entity identifiers.
|
|
42
|
+
|
|
43
|
+
### `excludeSpanTypes`
|
|
44
|
+
|
|
45
|
+
Use `excludeSpanTypes` when you want to suppress whole categories of spans with minimal configuration.
|
|
46
|
+
|
|
47
|
+
For the current set of supported values, see the [`SpanType` enum](https://github.com/mastra-ai/mastra/blob/main/packages/core/src/observability/types/tracing.ts).
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { SpanType } from '@mastra/core/observability'
|
|
51
|
+
|
|
52
|
+
excludeSpanTypes: [SpanType.MODEL_CHUNK, SpanType.MODEL_STEP, SpanType.WORKFLOW_SLEEP]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### `spanFilter`
|
|
56
|
+
|
|
57
|
+
When filtering depends on the exported span contents, use `spanFilter`.
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { SpanType } from '@mastra/core/observability'
|
|
61
|
+
|
|
62
|
+
spanFilter: span => {
|
|
63
|
+
if (span.type === SpanType.MODEL_CHUNK) return false
|
|
64
|
+
if (span.type === SpanType.TOOL_CALL && span.attributes?.success) return false
|
|
65
|
+
|
|
66
|
+
return true
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Additional examples:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
// Only export spans from production
|
|
74
|
+
spanFilter: span => span.metadata?.environment === 'production'
|
|
75
|
+
|
|
76
|
+
// Exclude spans from a specific entity
|
|
77
|
+
spanFilter: span => span.entityId !== 'noisy-agent'
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Processing order
|
|
81
|
+
|
|
82
|
+
Span filtering happens at export time in this order:
|
|
83
|
+
|
|
84
|
+
1. Internal spans are dropped unless `includeInternalSpans` is `true`.
|
|
85
|
+
2. `excludeSpanTypes` removes matching span types.
|
|
86
|
+
3. `spanOutputProcessors` transform the remaining spans.
|
|
87
|
+
4. `spanFilter` decides whether to keep the final exported span.
|
|
88
|
+
|
|
89
|
+
If `spanFilter` throws an error, Mastra keeps the span and logs the error to avoid silent data loss.
|
|
90
|
+
|
|
91
|
+
## Related
|
|
92
|
+
|
|
93
|
+
- [Tracing overview](https://mastra.ai/docs/observability/tracing/overview) for setup and concepts
|
|
94
|
+
- [Configuration API](https://mastra.ai/reference/observability/tracing/configuration) for `ObservabilityInstanceConfig`
|
|
95
|
+
- [Sensitive data filter](https://mastra.ai/docs/observability/tracing/processors/sensitive-data-filter) for redacting span data
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.1.23-alpha.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`8db7663`](https://github.com/mastra-ai/mastra/commit/8db7663c9a9c735828094c359d2e327fd4f8fba3), [`715710d`](https://github.com/mastra-ai/mastra/commit/715710d12fa47cf88e09d41f13843eddc29327b0), [`378c6c4`](https://github.com/mastra-ai/mastra/commit/378c6c4755726e8d8cf83a14809b350b90d46c62), [`9f91fd5`](https://github.com/mastra-ai/mastra/commit/9f91fd538ab2a44f8cc740bcad8e51205f74fbea), [`ba6fa9c`](https://github.com/mastra-ai/mastra/commit/ba6fa9cc0f3e1912c49fd70d4c3bb8c44903ddaa)]:
|
|
8
|
+
- @mastra/core@1.24.0-alpha.1
|
|
9
|
+
|
|
10
|
+
## 1.1.23-alpha.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`153e864`](https://github.com/mastra-ai/mastra/commit/153e86476b425db7cd0dc8490050096e92964a38), [`98209a0`](https://github.com/mastra-ai/mastra/commit/98209a03c35c5479c25cca26ee0c63eff81e6d74)]:
|
|
15
|
+
- @mastra/core@1.23.1-alpha.0
|
|
16
|
+
- @mastra/mcp@1.4.2-alpha.0
|
|
17
|
+
|
|
3
18
|
## 1.1.22
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.1.23-alpha.
|
|
3
|
+
"version": "1.1.23-alpha.3",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"jsdom": "^26.1.0",
|
|
30
30
|
"local-pkg": "^1.1.2",
|
|
31
31
|
"zod": "^4.3.6",
|
|
32
|
-
"@mastra/core": "1.
|
|
33
|
-
"@mastra/mcp": "^1.4.
|
|
32
|
+
"@mastra/core": "1.24.0-alpha.1",
|
|
33
|
+
"@mastra/mcp": "^1.4.2-alpha.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@hono/node-server": "^1.19.11",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"typescript": "^5.9.3",
|
|
48
48
|
"vitest": "4.0.18",
|
|
49
49
|
"@internal/lint": "0.0.80",
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
50
|
+
"@mastra/core": "1.24.0-alpha.1",
|
|
51
|
+
"@internal/types-builder": "0.0.55"
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://mastra.ai",
|
|
54
54
|
"repository": {
|