@mastra/mcp-docs-server 1.2.11-alpha.5 → 1.2.11-alpha.6

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.
@@ -287,6 +287,7 @@ The Reference section provides documentation of Mastra's API, including paramete
287
287
  - [Retention (prune)](https://mastra.ai/reference/storage/retention)
288
288
  - [Upstash Storage](https://mastra.ai/reference/storage/upstash)
289
289
  - [ChunkType](https://mastra.ai/reference/streaming/ChunkType)
290
+ - [smoothStream()](https://mastra.ai/reference/streaming/smoothStream)
290
291
  - [MastraModelOutput](https://mastra.ai/reference/streaming/agents/MastraModelOutput)
291
292
  - [.stream()](https://mastra.ai/reference/streaming/agents/stream)
292
293
  - [.streamLegacy()](https://mastra.ai/reference/streaming/agents/streamLegacy)
@@ -0,0 +1,135 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # `smoothStream()`
4
+
5
+ `smoothStream()` creates an experimental transform stream that buffers text and reasoning deltas before emitting them in consistent chunks. Use it to make streamed responses appear at a steadier pace when a model emits uneven deltas.
6
+
7
+ Non-text chunks pass through unchanged. Any buffered content is emitted before a tool, control, or completion chunk.
8
+
9
+ ## Usage example
10
+
11
+ Pipe an agent's `fullStream` through the transform:
12
+
13
+ ```typescript
14
+ import { smoothStream } from '@mastra/core/stream'
15
+
16
+ const result = await agent.stream('Explain how rainbows form')
17
+
18
+ const stream = result.fullStream.pipeThrough(
19
+ smoothStream({
20
+ delayInMs: 20,
21
+ chunking: 'word',
22
+ }),
23
+ )
24
+
25
+ for await (const chunk of stream) {
26
+ if (chunk.type === 'text-delta') {
27
+ process.stdout.write(chunk.payload.text)
28
+ }
29
+ }
30
+ ```
31
+
32
+ The transform changes only the piped stream. Promise properties and callbacks on the original `MastraModelOutput`, such as `result.text` and `onChunk`, keep the model's original chunk timing.
33
+
34
+ ## AI SDK routes
35
+
36
+ Import `smoothStream()` from `@mastra/ai-sdk` to smooth an agent before `handleChatStream()` converts its output to AI SDK UI chunks:
37
+
38
+ ```typescript
39
+ import { handleChatStream, smoothStream } from '@mastra/ai-sdk'
40
+ import { createUIMessageStreamResponse } from 'ai'
41
+ import { mastra } from '@/src/mastra'
42
+
43
+ export async function POST(req: Request) {
44
+ const params = await req.json()
45
+ const stream = await handleChatStream({
46
+ mastra,
47
+ agentId: 'weatherAgent',
48
+ params,
49
+ experimentalTransform: smoothStream({
50
+ delayInMs: 20,
51
+ chunking: 'word',
52
+ }),
53
+ })
54
+
55
+ return createUIMessageStreamResponse({ stream })
56
+ }
57
+ ```
58
+
59
+ The `@mastra/ai-sdk` export returns a reusable transform factory so route configuration creates a fresh `TransformStream` for every request. The `@mastra/core/stream` export returns a `TransformStream` for direct use with `pipeThrough()`.
60
+
61
+ The reusable factory can also be passed to `Agent.stream()`:
62
+
63
+ ```typescript
64
+ import { smoothStream } from '@mastra/ai-sdk'
65
+
66
+ const result = await agent.stream('Explain how rainbows form', {
67
+ experimentalTransform: smoothStream({ delayInMs: 20 }),
68
+ })
69
+
70
+ for await (const chunk of result.fullStream) {
71
+ // Consume the transformed Mastra chunks.
72
+ }
73
+ ```
74
+
75
+ ## Parameters
76
+
77
+ **options** (`SmoothStreamOptions`): Controls the delay and chunk boundaries for the transformed stream.
78
+
79
+ **options.delayInMs** (`number | null`): Delay in milliseconds after each emitted chunk. Set this value to null to disable the delay.
80
+
81
+ **options.chunking** (`'word' | 'line' | RegExp | SmoothStreamChunkDetector | Intl.Segmenter`): Controls how buffered text and reasoning are divided into chunks.
82
+
83
+ The `chunking` option accepts:
84
+
85
+ - `'word'`: Emits complete words, including trailing whitespace.
86
+ - `'line'`: Emits content through each newline.
87
+ - `RegExp`: Emits content through the first match.
88
+ - `Intl.Segmenter`: Uses locale-aware segmentation, which is useful for languages without spaces between words.
89
+ - `SmoothStreamChunkDetector`: Calls a function with the current buffer. The function returns a non-empty prefix to emit, or `null` or `undefined` to wait for more content.
90
+
91
+ ## Custom chunking
92
+
93
+ Use a regular expression to define a chunk boundary:
94
+
95
+ ```typescript
96
+ const stream = result.fullStream.pipeThrough(
97
+ smoothStream({
98
+ chunking: /[^,]*,\s*/,
99
+ }),
100
+ )
101
+ ```
102
+
103
+ Use `Intl.Segmenter` for locale-aware segmentation:
104
+
105
+ ```typescript
106
+ const stream = result.fullStream.pipeThrough(
107
+ smoothStream({
108
+ chunking: new Intl.Segmenter('ja', { granularity: 'word' }),
109
+ }),
110
+ )
111
+ ```
112
+
113
+ Use a detector function when chunk boundaries depend on custom logic. The returned value must be a prefix of the buffer:
114
+
115
+ ```typescript
116
+ const stream = result.fullStream.pipeThrough(
117
+ smoothStream({
118
+ chunking: buffer => {
119
+ const boundary = buffer.indexOf('. ')
120
+ return boundary === -1 ? null : buffer.slice(0, boundary + 2)
121
+ },
122
+ }),
123
+ )
124
+ ```
125
+
126
+ ## Returns
127
+
128
+ `TransformStream<ChunkType<OUTPUT>, ChunkType<OUTPUT>>`
129
+
130
+ The transform emits smoothed `text-delta` and `reasoning-delta` chunks. It preserves chunk identifiers, run identifiers, sources, and metadata.
131
+
132
+ ## Related
133
+
134
+ - [`MastraModelOutput`](https://mastra.ai/reference/streaming/agents/MastraModelOutput)
135
+ - [`ChunkType`](https://mastra.ai/reference/streaming/ChunkType)
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @mastra/mcp-docs-server
2
2
 
3
+ ## 1.2.11-alpha.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`6218217`](https://github.com/mastra-ai/mastra/commit/62182171b6cfca0b099f1c6a77a2e65e7639ab86), [`d12b2e4`](https://github.com/mastra-ai/mastra/commit/d12b2e4023fd9e3d3e93a9169f5088bcee2a849c)]:
8
+ - @mastra/core@1.54.0-alpha.4
9
+
3
10
  ## 1.2.11-alpha.5
4
11
 
5
12
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mcp-docs-server",
3
- "version": "1.2.11-alpha.5",
3
+ "version": "1.2.11-alpha.6",
4
4
  "description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -28,7 +28,7 @@
28
28
  "jsdom": "^26.1.0",
29
29
  "local-pkg": "^1.1.2",
30
30
  "zod": "^4.4.3",
31
- "@mastra/core": "1.54.0-alpha.3",
31
+ "@mastra/core": "1.54.0-alpha.4",
32
32
  "@mastra/mcp": "^1.15.0"
33
33
  },
34
34
  "devDependencies": {
@@ -47,7 +47,7 @@
47
47
  "vitest": "4.1.10",
48
48
  "@internal/lint": "0.0.117",
49
49
  "@internal/types-builder": "0.0.92",
50
- "@mastra/core": "1.54.0-alpha.3"
50
+ "@mastra/core": "1.54.0-alpha.4"
51
51
  },
52
52
  "homepage": "https://mastra.ai",
53
53
  "repository": {