@mastra/mcp-docs-server 0.13.12 → 0.13.13-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +24 -24
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +34 -34
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +35 -35
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +34 -34
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +41 -41
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +55 -55
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +34 -34
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +7 -0
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +27 -27
- package/.docs/organized/changelogs/%40mastra%2Fgithub.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Flance.md +34 -34
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +38 -38
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +35 -35
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +27 -27
- package/.docs/organized/changelogs/%40mastra%2Fmem0.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +44 -44
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +34 -34
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +33 -0
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +35 -35
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +47 -47
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Frag.md +29 -29
- package/.docs/organized/changelogs/%40mastra%2Fragie.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +41 -41
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +34 -34
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +24 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +27 -27
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +25 -25
- package/.docs/organized/changelogs/create-mastra.md +13 -13
- package/.docs/organized/changelogs/mastra.md +58 -58
- package/.docs/organized/code-examples/a2a.md +1 -1
- package/.docs/organized/code-examples/agent-network.md +1 -1
- package/.docs/organized/code-examples/agent.md +4 -4
- package/.docs/organized/code-examples/agui.md +1 -1
- package/.docs/organized/code-examples/ai-sdk-v5.md +2 -2
- package/.docs/organized/code-examples/client-side-tools.md +1 -1
- package/.docs/organized/code-examples/experimental-auth-weather-agent.md +1 -1
- package/.docs/organized/code-examples/fireworks-r1.md +1 -1
- package/.docs/organized/code-examples/mcp-registry-registry.md +1 -1
- package/.docs/organized/code-examples/memory-per-resource-example.md +1 -1
- package/.docs/organized/code-examples/memory-with-context.md +1 -1
- package/.docs/organized/code-examples/memory-with-processors.md +1 -1
- package/.docs/organized/code-examples/openapi-spec-writer.md +1 -1
- package/.docs/organized/code-examples/weather-agent.md +1 -1
- package/.docs/raw/agents/output-processors.mdx +20 -68
- package/.docs/raw/server-db/storage.mdx +8 -0
- package/package.json +4 -4
|
@@ -82,42 +82,6 @@ Strategies available:
|
|
|
82
82
|
- `filter`: Remove messages containing PII
|
|
83
83
|
- `redact`: Replace PII with placeholder values
|
|
84
84
|
|
|
85
|
-
### `StructuredOutputProcessor`
|
|
86
|
-
|
|
87
|
-
This processor converts unstructured LLM text responses into structured data using an internal agent. It preserves the original text while adding structured data to the response metadata as well as to result.object.
|
|
88
|
-
|
|
89
|
-
```typescript copy showLineNumbers {5-15}
|
|
90
|
-
import { StructuredOutputProcessor } from "@mastra/core/processors";
|
|
91
|
-
import { z } from "zod";
|
|
92
|
-
|
|
93
|
-
const agent = new Agent({
|
|
94
|
-
outputProcessors: [
|
|
95
|
-
new StructuredOutputProcessor({
|
|
96
|
-
schema: z.object({
|
|
97
|
-
sentiment: z.enum(['positive', 'negative', 'neutral']),
|
|
98
|
-
confidence: z.number().min(0).max(1),
|
|
99
|
-
topics: z.array(z.string()),
|
|
100
|
-
}),
|
|
101
|
-
model: openai("gpt-4o-mini"),
|
|
102
|
-
errorStrategy: 'warn', // Log warnings but continue on errors
|
|
103
|
-
instructions: 'Analyze the sentiment and extract key topics from the response',
|
|
104
|
-
}),
|
|
105
|
-
],
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
const result = await agent.generate("Some conversational text")
|
|
109
|
-
|
|
110
|
-
console.log(result.object) // { sentiment: "positive", confidence: 0.6, topics: ["foo", "bar"] }
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
Available options:
|
|
114
|
-
- `schema`: Zod schema defining the expected structured output (required)
|
|
115
|
-
- `model`: Language model for the internal structuring agent (required)
|
|
116
|
-
- `errorStrategy`: Strategy when parsing or validation fails ('strict' | 'warn' | 'fallback', default: 'strict')
|
|
117
|
-
- `fallbackValue`: Fallback value when errorStrategy is 'fallback'
|
|
118
|
-
- `instructions`: Custom instructions for the structuring agent
|
|
119
|
-
|
|
120
|
-
The structured data is stored in `result.object` and the original text is preserved in `result.text`.
|
|
121
85
|
|
|
122
86
|
### `BatchPartsProcessor`
|
|
123
87
|
|
|
@@ -199,21 +163,15 @@ You can chain multiple output processors. They execute sequentially in the order
|
|
|
199
163
|
```typescript copy showLineNumbers {9-18}
|
|
200
164
|
import { Agent } from "@mastra/core/agent";
|
|
201
165
|
import {
|
|
202
|
-
UnicodeNormalizer,
|
|
203
166
|
ModerationProcessor,
|
|
204
|
-
PromptInjectionDetector,
|
|
205
167
|
PIIDetector
|
|
206
168
|
} from "@mastra/core/processors";
|
|
207
169
|
|
|
208
170
|
const secureAgent = new Agent({
|
|
209
171
|
outputProcessors: [
|
|
210
|
-
// 1.
|
|
211
|
-
new UnicodeNormalizer({ stripControlChars: true }),
|
|
212
|
-
// 2. Check for security threats
|
|
213
|
-
new PromptInjectionDetector({ model: openai("gpt-4.1-nano") }),
|
|
214
|
-
// 3. Moderate content
|
|
172
|
+
// 1. Check for security threats
|
|
215
173
|
new ModerationProcessor({ model: openai("gpt-4.1-nano") }),
|
|
216
|
-
//
|
|
174
|
+
// 2. Handle PII
|
|
217
175
|
new PIIDetector({ model: openai("gpt-4.1-nano"), strategy: 'redact' }),
|
|
218
176
|
],
|
|
219
177
|
});
|
|
@@ -226,40 +184,34 @@ You can create custom output processors by implementing the `Processor` interfac
|
|
|
226
184
|
### Streaming Output Processor
|
|
227
185
|
|
|
228
186
|
```typescript copy showLineNumbers {4-25}
|
|
229
|
-
import type { Processor, MastraMessageV2
|
|
230
|
-
import type {
|
|
187
|
+
import type { Processor, MastraMessageV2 } from "@mastra/core/processors";
|
|
188
|
+
import type { ChunkType } from "@mastra/core/stream";
|
|
231
189
|
|
|
232
190
|
class ResponseLengthLimiter implements Processor {
|
|
233
|
-
readonly name = 'response-length-limiter
|
|
191
|
+
readonly name = 'response-length-limiter';
|
|
234
192
|
|
|
235
193
|
constructor(private maxLength: number = 1000) {}
|
|
236
194
|
|
|
237
|
-
async processOutputStream({
|
|
238
|
-
|
|
239
|
-
streamParts:
|
|
195
|
+
async processOutputStream({ part, streamParts, state, abort }: {
|
|
196
|
+
part: ChunkType;
|
|
197
|
+
streamParts: ChunkType[];
|
|
240
198
|
state: Record<string, any>;
|
|
241
199
|
abort: (reason?: string) => never;
|
|
242
|
-
}): Promise<
|
|
200
|
+
}): Promise<ChunkType | null | undefined> {
|
|
243
201
|
// Track cumulative length in state, each processor gets its own state
|
|
244
202
|
if (!state.cumulativeLength) {
|
|
245
203
|
state.cumulativeLength = 0;
|
|
246
204
|
}
|
|
247
205
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if (chunk.type === 'text-delta') {
|
|
251
|
-
state.cumulativeLength += chunk.textDelta.length;
|
|
206
|
+
if (part.type === 'text-delta') {
|
|
207
|
+
state.cumulativeLength += part.payload.text.length;
|
|
252
208
|
|
|
253
209
|
if (state.cumulativeLength > this.maxLength) {
|
|
254
210
|
abort(`Response too long: ${state.cumulativeLength} characters (max: ${this.maxLength})`);
|
|
255
211
|
}
|
|
256
212
|
}
|
|
257
213
|
|
|
258
|
-
|
|
259
|
-
return chunk; // Emit the chunk
|
|
260
|
-
} else {
|
|
261
|
-
return null; // Emit nothing
|
|
262
|
-
}
|
|
214
|
+
return part; // Emit the part
|
|
263
215
|
}
|
|
264
216
|
}
|
|
265
217
|
```
|
|
@@ -267,7 +219,7 @@ class ResponseLengthLimiter implements Processor {
|
|
|
267
219
|
### Final Result Processor
|
|
268
220
|
|
|
269
221
|
```typescript copy showLineNumbers {4-19}
|
|
270
|
-
import type { Processor, MastraMessageV2
|
|
222
|
+
import type { Processor, MastraMessageV2 } from "@mastra/core/processors";
|
|
271
223
|
|
|
272
224
|
class ResponseValidator implements Processor {
|
|
273
225
|
readonly name = 'response-validator';
|
|
@@ -299,9 +251,9 @@ class ResponseValidator implements Processor {
|
|
|
299
251
|
```
|
|
300
252
|
|
|
301
253
|
When creating custom output processors:
|
|
302
|
-
- Always return the processed data (
|
|
254
|
+
- Always return the processed data (parts or messages)
|
|
303
255
|
- Use `abort(reason)` to terminate processing early. Abort is used to simulate blocking a response. Errors thrown with `abort` will be an instance of TripWire.
|
|
304
|
-
- For streaming processors, return `null` or `undefined` to skip emitting a
|
|
256
|
+
- For streaming processors, return `null` or `undefined` to skip emitting a part
|
|
305
257
|
- Keep processors focused on a single responsibility
|
|
306
258
|
- If using an agent inside your processor, use a fast model, limit the size of the response from it as much as possible, and make the system prompt as concise as possible.
|
|
307
259
|
|
|
@@ -315,10 +267,10 @@ const result = await agent.generate('Hello');
|
|
|
315
267
|
console.log(result.text); // Processed text
|
|
316
268
|
console.log(result.object); // Structured data if applicable
|
|
317
269
|
|
|
318
|
-
// Processors also run during streamVNext() for each
|
|
270
|
+
// Processors also run during streamVNext() for each part
|
|
319
271
|
const stream = await agent.streamVNext('Hello');
|
|
320
|
-
for await (const
|
|
321
|
-
console.log(
|
|
272
|
+
for await (const part of stream) {
|
|
273
|
+
console.log(part); // Processed parts
|
|
322
274
|
}
|
|
323
275
|
```
|
|
324
276
|
|
|
@@ -342,9 +294,9 @@ const stream = await agent.streamVNext('Hello', {
|
|
|
342
294
|
});
|
|
343
295
|
```
|
|
344
296
|
|
|
345
|
-
### Structured Output
|
|
297
|
+
### Structured Output Processor
|
|
346
298
|
|
|
347
|
-
|
|
299
|
+
To use the StructuredOutputProcessor, you should use the `structuredOutput` option:
|
|
348
300
|
|
|
349
301
|
```typescript copy showLineNumbers
|
|
350
302
|
import { z } from "zod";
|
|
@@ -497,6 +497,14 @@ const messagesV1 = await mastra.getStorage().getMessages({ threadId: 'your-threa
|
|
|
497
497
|
const messagesV2 = await mastra.getStorage().getMessages({ threadId: 'your-thread-id', format: 'v2' });
|
|
498
498
|
```
|
|
499
499
|
|
|
500
|
+
You can also retrieve messages using an array of message IDs. Note that unlike `getMessages`, this defaults to the V2 format:
|
|
501
|
+
|
|
502
|
+
```typescript copy
|
|
503
|
+
const messagesV1 = await mastra.getStorage().getMessagesById({ messageIds: messageIdArr, format: 'v1' });
|
|
504
|
+
|
|
505
|
+
const messagesV2 = await mastra.getStorage().getMessagesById({ messageIds: messageIdArr });
|
|
506
|
+
```
|
|
507
|
+
|
|
500
508
|
## Storage Providers
|
|
501
509
|
|
|
502
510
|
Mastra supports the following providers:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.13-alpha.0",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"uuid": "^11.1.0",
|
|
33
33
|
"zod": "^3.25.67",
|
|
34
34
|
"zod-to-json-schema": "^3.24.5",
|
|
35
|
-
"@mastra/core": "0.14.0",
|
|
35
|
+
"@mastra/core": "0.14.1-alpha.0",
|
|
36
36
|
"@mastra/mcp": "^0.10.12"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"tsx": "^4.19.4",
|
|
49
49
|
"typescript": "^5.8.3",
|
|
50
50
|
"vitest": "^3.2.4",
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
51
|
+
"@internal/lint": "0.0.30",
|
|
52
|
+
"@mastra/core": "0.14.1-alpha.0"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"prepare-docs": "cross-env PREPARE=true node dist/prepare-docs/prepare.js",
|