@mastra/mcp-docs-server 0.13.38 → 0.13.39

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 (139) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fchangeset-cli.md +2 -0
  2. package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +2 -0
  3. package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +9 -9
  4. package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
  5. package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +21 -21
  6. package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +31 -31
  7. package/.docs/organized/changelogs/%40mastra%2Fastra.md +19 -19
  8. package/.docs/organized/changelogs/%40mastra%2Fauth.md +12 -0
  9. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +19 -19
  10. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +19 -19
  11. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +31 -31
  12. package/.docs/organized/changelogs/%40mastra%2Fcloud.md +19 -19
  13. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +19 -19
  14. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +19 -19
  15. package/.docs/organized/changelogs/%40mastra%2Fcore.md +39 -39
  16. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +19 -19
  17. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +23 -23
  18. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +21 -21
  19. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +21 -21
  20. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +21 -21
  21. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +69 -69
  22. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +20 -20
  23. package/.docs/organized/changelogs/%40mastra%2Fevals.md +20 -20
  24. package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +12 -0
  25. package/.docs/organized/changelogs/%40mastra%2Flance.md +19 -19
  26. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +20 -20
  27. package/.docs/organized/changelogs/%40mastra%2Floggers.md +19 -19
  28. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +21 -21
  29. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +19 -19
  30. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +20 -20
  31. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +21 -21
  32. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +19 -19
  33. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +20 -20
  34. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +19 -19
  35. package/.docs/organized/changelogs/%40mastra%2Fpg.md +19 -19
  36. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +19 -19
  37. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +43 -43
  38. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +19 -19
  39. package/.docs/organized/changelogs/%40mastra%2Frag.md +19 -19
  40. package/.docs/organized/changelogs/%40mastra%2Freact.md +19 -19
  41. package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +18 -0
  42. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +12 -0
  43. package/.docs/organized/changelogs/%40mastra%2Fserver.md +35 -35
  44. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +19 -19
  45. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +19 -19
  46. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +19 -19
  47. package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +20 -20
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +19 -19
  49. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +19 -19
  50. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +19 -19
  51. package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +19 -19
  52. package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +19 -9
  53. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +19 -19
  54. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +19 -19
  55. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +19 -19
  56. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +19 -19
  57. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +19 -19
  58. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +19 -19
  59. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +19 -19
  60. package/.docs/organized/changelogs/create-mastra.md +13 -13
  61. package/.docs/organized/changelogs/mastra.md +35 -35
  62. package/.docs/raw/agents/overview.mdx +2 -2
  63. package/.docs/raw/auth/jwt.mdx +2 -2
  64. package/.docs/raw/auth/supabase.mdx +2 -2
  65. package/.docs/raw/auth/workos.mdx +2 -2
  66. package/.docs/raw/course/02-agent-tools-mcp/04-initializing-mcp-tools.md +2 -2
  67. package/.docs/raw/course/03-agent-memory/18-advanced-configuration-semantic-recall.md +1 -1
  68. package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +24 -8
  69. package/.docs/raw/frameworks/agentic-uis/openrouter.mdx +1 -1
  70. package/.docs/raw/frameworks/servers/express.mdx +1 -1
  71. package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +34 -18
  72. package/.docs/raw/getting-started/installation.mdx +7 -7
  73. package/.docs/raw/getting-started/mcp-docs-server.mdx +1 -1
  74. package/.docs/raw/getting-started/studio.mdx +27 -17
  75. package/.docs/raw/getting-started/templates.mdx +12 -4
  76. package/.docs/raw/index.mdx +1 -1
  77. package/.docs/raw/mastra-cloud/dashboard.mdx +6 -6
  78. package/.docs/raw/mastra-cloud/observability.mdx +2 -2
  79. package/.docs/raw/mastra-cloud/overview.mdx +1 -1
  80. package/.docs/raw/mastra-cloud/setting-up.mdx +1 -1
  81. package/.docs/raw/memory/overview.mdx +1 -1
  82. package/.docs/raw/memory/semantic-recall.mdx +2 -4
  83. package/.docs/raw/memory/threads-and-resources.mdx +1 -1
  84. package/.docs/raw/memory/working-memory.mdx +1 -1
  85. package/.docs/raw/observability/ai-tracing/exporters/default.mdx +6 -6
  86. package/.docs/raw/observability/ai-tracing/overview.mdx +7 -7
  87. package/.docs/raw/observability/overview.mdx +1 -1
  88. package/.docs/raw/reference/agents/agent.mdx +2 -2
  89. package/.docs/raw/reference/agents/listScorers.mdx +69 -0
  90. package/.docs/raw/reference/agents/listTools.mdx +69 -0
  91. package/.docs/raw/reference/agents/listWorkflows.mdx +69 -0
  92. package/.docs/raw/reference/cli/mastra.mdx +1 -1
  93. package/.docs/raw/reference/client-js/agents.mdx +1 -1
  94. package/.docs/raw/reference/client-js/logs.mdx +1 -1
  95. package/.docs/raw/reference/client-js/mastra-client.mdx +7 -7
  96. package/.docs/raw/reference/client-js/memory.mdx +1 -1
  97. package/.docs/raw/reference/client-js/tools.mdx +1 -1
  98. package/.docs/raw/reference/client-js/workflows.mdx +1 -1
  99. package/.docs/raw/reference/core/getScorerByName.mdx +1 -1
  100. package/.docs/raw/reference/core/listAgents.mdx +35 -0
  101. package/.docs/raw/reference/core/listLogs.mdx +96 -0
  102. package/.docs/raw/reference/core/listLogsByRunId.mdx +87 -0
  103. package/.docs/raw/reference/core/listScorers.mdx +43 -0
  104. package/.docs/raw/reference/core/listWorkflows.mdx +45 -0
  105. package/.docs/raw/reference/memory/memory-class.mdx +2 -1
  106. package/.docs/raw/reference/observability/ai-tracing/ai-tracing.mdx +0 -1
  107. package/.docs/raw/reference/observability/ai-tracing/interfaces.mdx +1 -1
  108. package/.docs/raw/reference/observability/otel-tracing/providers/keywordsai.mdx +1 -1
  109. package/.docs/raw/reference/processors/batch-parts-processor.mdx +10 -14
  110. package/.docs/raw/reference/processors/language-detector.mdx +20 -32
  111. package/.docs/raw/reference/processors/moderation-processor.mdx +46 -30
  112. package/.docs/raw/reference/processors/pii-detector.mdx +47 -32
  113. package/.docs/raw/reference/processors/prompt-injection-detector.mdx +20 -30
  114. package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +24 -29
  115. package/.docs/raw/reference/processors/token-limiter-processor.mdx +14 -23
  116. package/.docs/raw/reference/processors/unicode-normalizer.mdx +12 -14
  117. package/.docs/raw/reference/rag/document.mdx +1 -1
  118. package/.docs/raw/reference/scorers/run-experiment.mdx +1 -1
  119. package/.docs/raw/reference/storage/mssql.mdx +3 -3
  120. package/.docs/raw/reference/streaming/workflows/resumeStreamVNext.mdx +1 -1
  121. package/.docs/raw/reference/streaming/workflows/stream.mdx +1 -1
  122. package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +1 -1
  123. package/.docs/raw/reference/tools/mcp-client.mdx +8 -8
  124. package/.docs/raw/reference/voice/google-gemini-live.mdx +1 -1
  125. package/.docs/raw/reference/workflows/step.mdx +1 -1
  126. package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +1 -1
  127. package/.docs/raw/reference/workflows/workflow-methods/map.mdx +72 -2
  128. package/.docs/raw/reference/workflows/workflow.mdx +0 -14
  129. package/.docs/raw/scorers/overview.mdx +5 -5
  130. package/.docs/raw/server-db/middleware.mdx +4 -4
  131. package/.docs/raw/tools-mcp/overview.mdx +2 -2
  132. package/.docs/raw/workflows/agents-and-tools.mdx +2 -6
  133. package/.docs/raw/workflows/control-flow.mdx +208 -165
  134. package/.docs/raw/workflows/inngest-workflow.mdx +2 -2
  135. package/.docs/raw/workflows/overview.mdx +106 -54
  136. package/.docs/raw/workflows/suspend-and-resume.mdx +1 -9
  137. package/CHANGELOG.md +20 -0
  138. package/package.json +5 -5
  139. package/.docs/raw/workflows/input-data-mapping.mdx +0 -107
@@ -0,0 +1,87 @@
1
+ ---
2
+ title: "Reference: Mastra.listLogsByRunId() | Core | Mastra Docs"
3
+ description: "Documentation for the `Mastra.listLogsByRunId()` method in Mastra, which retrieves logs for a specific run ID and transport ID."
4
+ ---
5
+
6
+ # Mastra.listLogsByRunId()
7
+
8
+ The `.listLogsByRunId()` method is used to retrieve logs for a specific run ID and transport ID. This method requires a configured logger that supports the `listLogsByRunId` operation.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript copy
13
+ mastra.listLogsByRunId({ runId: "123", transportId: "456" });
14
+ ```
15
+
16
+ ## Parameters
17
+
18
+ <PropertiesTable
19
+ content={[
20
+ {
21
+ name: "runId",
22
+ type: "string",
23
+ description: "The run ID to retrieve logs for.",
24
+ },
25
+ {
26
+ name: "transportId",
27
+ type: "string",
28
+ description: "The transport ID to retrieve logs from.",
29
+ },
30
+ {
31
+ name: "fromDate",
32
+ type: "Date",
33
+ description:
34
+ "Optional start date for filtering logs. e.g., new Date('2024-01-01').",
35
+ optional: true,
36
+ },
37
+ {
38
+ name: "toDate",
39
+ type: "Date",
40
+ description:
41
+ "Optional end date for filtering logs. e.g., new Date('2024-01-31').",
42
+ optional: true,
43
+ },
44
+ {
45
+ name: "logLevel",
46
+ type: "LogLevel",
47
+ description: "Optional log level to filter by.",
48
+ optional: true,
49
+ },
50
+ {
51
+ name: "filters",
52
+ type: "Record<string, any>",
53
+ description: "Optional additional filters to apply to the log query.",
54
+ optional: true,
55
+ },
56
+ {
57
+ name: "page",
58
+ type: "number",
59
+ description: "Optional page number for pagination.",
60
+ optional: true,
61
+ },
62
+ {
63
+ name: "perPage",
64
+ type: "number",
65
+ description: "Optional number of logs per page for pagination.",
66
+ optional: true,
67
+ },
68
+ ]}
69
+ />
70
+
71
+ ## Returns
72
+
73
+ <PropertiesTable
74
+ content={[
75
+ {
76
+ name: "logs",
77
+ type: "Promise<any>",
78
+ description:
79
+ "A promise that resolves to the logs for the specified run ID and transport ID.",
80
+ },
81
+ ]}
82
+ />
83
+
84
+ ## Related
85
+
86
+ - [Logging overview](/docs/observability/logging)
87
+ - [Logger reference](/reference/observability/logging/pino-logger)
@@ -0,0 +1,43 @@
1
+ ---
2
+ title: "Reference: listScorers() | Core | Mastra Docs"
3
+ description: "Documentation for the `listScorers()` method in Mastra, which returns all registered scorers for evaluating AI outputs."
4
+ ---
5
+
6
+ # listScorers()
7
+
8
+ The `listScorers()` method returns all scorers that have been registered with the Mastra instance. Scorers are used for evaluating AI outputs and can override default scorers during agent generation or workflow execution.
9
+
10
+ ## Usage Example
11
+
12
+ ```typescript
13
+ import { mastra } from "./mastra";
14
+
15
+ // Get all registered scorers
16
+ const allScorers = mastra.listScorers();
17
+
18
+ // Access a specific scorer
19
+ const myScorer = allScorers.relevancyScorer;
20
+ ```
21
+
22
+ ## Parameters
23
+
24
+ This method takes no parameters.
25
+
26
+ ## Returns
27
+
28
+ <PropertiesTable
29
+ content={[
30
+ {
31
+ name: "scorers",
32
+ type: "Record<string, MastraScorer> | undefined",
33
+ description:
34
+ "An object containing all registered scorers, where keys are scorer names and values are MastraScorer instances. Returns undefined if no scorers are registered.",
35
+ },
36
+ ]}
37
+ />
38
+
39
+ ## Related
40
+
41
+ - [getScorer()](../../reference/core/getScorer) - Get a specific scorer by key
42
+ - [getScorerByName()](../../reference/core/getScorerByName) - Get a scorer by its name property
43
+ - [Scorers Overview](../../docs/scorers/overview) - Learn about creating and using scorers
@@ -0,0 +1,45 @@
1
+ ---
2
+ title: "Reference: Mastra.getWorkflows() | Core | Mastra Docs"
3
+ description: "Documentation for the `Mastra.getWorkflows()` method in Mastra, which retrieves all configured workflows."
4
+ ---
5
+
6
+ # Mastra.getWorkflows()
7
+
8
+ The `.getWorkflows()` method is used to retrieve all workflows that have been configured in the Mastra instance. The method accepts an optional options object.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript copy
13
+ mastra.getWorkflows();
14
+ ```
15
+
16
+ ## Parameters
17
+
18
+ <PropertiesTable
19
+ content={[
20
+ {
21
+ name: "options",
22
+ type: "{ serialized?: boolean }",
23
+ description:
24
+ "Optional configuration object. When `serialized` is true, returns simplified workflow objects with only the name property instead of full workflow instances.",
25
+ optional: true,
26
+ },
27
+ ]}
28
+ />
29
+
30
+ ## Returns
31
+
32
+ <PropertiesTable
33
+ content={[
34
+ {
35
+ name: "workflows",
36
+ type: "Record<string, Workflow>",
37
+ description:
38
+ "A record of all configured workflows, where keys are workflow IDs and values are workflow instances (or simplified objects if serialized is true).",
39
+ },
40
+ ]}
41
+ />
42
+
43
+ ## Related
44
+
45
+ - [Workflows overview](/docs/workflows/overview)
@@ -86,7 +86,8 @@ export const agent = new Agent({
86
86
  {
87
87
  name: "semanticRecall",
88
88
  type: "boolean | { topK: number; messageRange: number | { before: number; after: number }; scope?: 'thread' | 'resource' }",
89
- description: "Enable semantic search in message history. Can be a boolean or an object with configuration options. When enabled, requires both vector store and embedder to be configured.",
89
+ description:
90
+ "Enable semantic search in message history. Can be a boolean or an object with configuration options. When enabled, requires both vector store and embedder to be configured. Default topK is 4, default messageRange is {before: 1, after: 1}.",
90
91
  isOptional: true,
91
92
  defaultValue: "false",
92
93
  },
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  title: "Reference: AITracing | Observability | Mastra Docs"
3
3
  description: Core AI Tracing classes and methods
4
- asIndexPage: true
5
4
  ---
6
5
 
7
6
  import PropertiesTable from "@site/src/components/PropertiesTable";
@@ -635,7 +635,7 @@ Options passed when using a custom tracing config selector.
635
635
 
636
636
  ```typescript
637
637
  interface ConfigSelectorOptions {
638
- /** Runtime context */
638
+ /** Request Context */
639
639
  runtimeContext?: RuntimeContext;
640
640
  }
641
641
  ```
@@ -66,7 +66,7 @@ telemetry: {
66
66
  mastra dev
67
67
  ```
68
68
 
69
- This opens the Mastra playground where you can interact with the weather agent.
69
+ This opens Studio where you can interact with the weather agent.
70
70
 
71
71
  ## Observability
72
72
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: "Reference: BatchPartsProcessor | Processors | Mastra Docs"
2
+ title: "Reference: Batch Parts Processor | Processors | Mastra Docs"
3
3
  description: "Documentation for the BatchPartsProcessor in Mastra, which batches multiple stream parts together to reduce frequency of emissions."
4
4
  ---
5
5
 
@@ -15,7 +15,7 @@ import { BatchPartsProcessor } from "@mastra/core/processors";
15
15
  const processor = new BatchPartsProcessor({
16
16
  batchSize: 5,
17
17
  maxWaitTime: 100,
18
- emitOnNonText: true,
18
+ emitOnNonText: true
19
19
  });
20
20
  ```
21
21
 
@@ -46,16 +46,14 @@ const processor = new BatchPartsProcessor({
46
46
  {
47
47
  name: "maxWaitTime",
48
48
  type: "number",
49
- description:
50
- "Maximum time to wait before emitting a batch (in milliseconds). If set, will emit the current batch even if it hasn't reached batchSize",
49
+ description: "Maximum time to wait before emitting a batch (in milliseconds). If set, will emit the current batch even if it hasn't reached batchSize",
51
50
  isOptional: true,
52
51
  default: "undefined (no timeout)",
53
52
  },
54
53
  {
55
54
  name: "emitOnNonText",
56
55
  type: "boolean",
57
- description:
58
- "Whether to emit immediately when a non-text part is encountered",
56
+ description: "Whether to emit immediately when a non-text part is encountered",
59
57
  isOptional: true,
60
58
  default: "true",
61
59
  },
@@ -81,8 +79,7 @@ const processor = new BatchPartsProcessor({
81
79
  {
82
80
  name: "flush",
83
81
  type: "(state?: BatchPartsState) => ChunkType | null",
84
- description:
85
- "Force flush any remaining batched parts when the stream ends",
82
+ description: "Force flush any remaining batched parts when the stream ends",
86
83
  isOptional: false,
87
84
  },
88
85
  ]}
@@ -91,24 +88,23 @@ const processor = new BatchPartsProcessor({
91
88
  ## Extended usage example
92
89
 
93
90
  ```typescript title="src/mastra/agents/batched-agent.ts" showLineNumbers copy
94
- import { openai } from "@ai-sdk/openai";
95
91
  import { Agent } from "@mastra/core/agent";
96
92
  import { BatchPartsProcessor } from "@mastra/core/processors";
97
93
 
98
94
  export const agent = new Agent({
99
95
  name: "batched-agent",
100
96
  instructions: "You are a helpful assistant",
101
- model: openai("gpt-4o-mini"),
97
+ model: "openai/gpt-4o-mini",
102
98
  outputProcessors: [
103
99
  new BatchPartsProcessor({
104
100
  batchSize: 5,
105
101
  maxWaitTime: 100,
106
- emitOnNonText: true,
107
- }),
108
- ],
102
+ emitOnNonText: true
103
+ })
104
+ ]
109
105
  });
110
106
  ```
111
107
 
112
108
  ## Related
113
109
 
114
- - [Output Processors documentation](/docs/agents/guardrails)
110
+ - [Guardrails](/docs/agents/guardrails)
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: "Reference: LanguageDetector | Processors | Mastra Docs"
2
+ title: "Reference: Language Detector | Processors | Mastra Docs"
3
3
  description: "Documentation for the LanguageDetector in Mastra, which detects language and can translate content in AI responses."
4
4
  ---
5
5
 
@@ -10,14 +10,13 @@ The `LanguageDetector` is an **input processor** that identifies the language of
10
10
  ## Usage example
11
11
 
12
12
  ```typescript copy
13
- import { openai } from "@ai-sdk/openai";
14
13
  import { LanguageDetector } from "@mastra/core/processors";
15
14
 
16
15
  const processor = new LanguageDetector({
17
- model: openai("gpt-4.1-nano"),
16
+ model: "openai/gpt-4.1-nano",
18
17
  targetLanguages: ["English", "en"],
19
18
  threshold: 0.8,
20
- strategy: "translate",
19
+ strategy: "translate"
21
20
  });
22
21
  ```
23
22
 
@@ -28,8 +27,7 @@ const processor = new LanguageDetector({
28
27
  {
29
28
  name: "options",
30
29
  type: "Options",
31
- description:
32
- "Configuration options for language detection and translation",
30
+ description: "Configuration options for language detection and translation",
33
31
  isOptional: false,
34
32
  },
35
33
  ]}
@@ -41,55 +39,49 @@ const processor = new LanguageDetector({
41
39
  content={[
42
40
  {
43
41
  name: "model",
44
- type: "MastraLanguageModel",
42
+ type: "MastraModelConfig",
45
43
  description: "Model configuration for the detection/translation agent",
46
44
  isOptional: false,
47
45
  },
48
46
  {
49
47
  name: "targetLanguages",
50
48
  type: "string[]",
51
- description:
52
- "Target language(s) for the project. If content is detected in a different language, it may be translated. Can be language name ('English') or ISO code ('en')",
49
+ description: "Target language(s) for the project. If content is detected in a different language, it may be translated. Can be language name ('English') or ISO code ('en')",
53
50
  isOptional: true,
54
51
  default: "['English', 'en']",
55
52
  },
56
53
  {
57
54
  name: "threshold",
58
55
  type: "number",
59
- description:
60
- "Confidence threshold for language detection (0-1). Only process when detection confidence exceeds this threshold",
56
+ description: "Confidence threshold for language detection (0-1). Only process when detection confidence exceeds this threshold",
61
57
  isOptional: true,
62
58
  default: "0.7",
63
59
  },
64
60
  {
65
61
  name: "strategy",
66
62
  type: "'detect' | 'translate' | 'block' | 'warn'",
67
- description:
68
- "Strategy when non-target language is detected: 'detect' only detects language, 'translate' automatically translates to target language, 'block' rejects content not in target language, 'warn' logs warning but allows through",
63
+ description: "Strategy when non-target language is detected: 'detect' only detects language, 'translate' automatically translates to target language, 'block' rejects content not in target language, 'warn' logs warning but allows through",
69
64
  isOptional: true,
70
65
  default: "'detect'",
71
66
  },
72
67
  {
73
68
  name: "preserveOriginal",
74
69
  type: "boolean",
75
- description:
76
- "Whether to preserve original content in message metadata. Useful for audit trails and debugging",
70
+ description: "Whether to preserve original content in message metadata. Useful for audit trails and debugging",
77
71
  isOptional: true,
78
72
  default: "true",
79
73
  },
80
74
  {
81
75
  name: "instructions",
82
76
  type: "string",
83
- description:
84
- "Custom detection instructions for the agent. If not provided, uses default instructions",
77
+ description: "Custom detection instructions for the agent. If not provided, uses default instructions",
85
78
  isOptional: true,
86
79
  default: "undefined",
87
80
  },
88
81
  {
89
82
  name: "minTextLength",
90
83
  type: "number",
91
- description:
92
- "Minimum text length to perform detection. Short text is often unreliable for language detection",
84
+ description: "Minimum text length to perform detection. Short text is often unreliable for language detection",
93
85
  isOptional: true,
94
86
  default: "10",
95
87
  },
@@ -103,8 +95,7 @@ const processor = new LanguageDetector({
103
95
  {
104
96
  name: "translationQuality",
105
97
  type: "'speed' | 'quality' | 'balanced'",
106
- description:
107
- "Translation quality preference: 'speed' prioritizes fast translation, 'quality' prioritizes accuracy, 'balanced' balances between speed and quality",
98
+ description: "Translation quality preference: 'speed' prioritizes fast translation, 'quality' prioritizes accuracy, 'balanced' balances between speed and quality",
108
99
  isOptional: true,
109
100
  default: "'quality'",
110
101
  },
@@ -124,8 +115,7 @@ const processor = new LanguageDetector({
124
115
  {
125
116
  name: "processInput",
126
117
  type: "(args: { messages: MastraMessageV2[]; abort: (reason?: string) => never; tracingContext?: TracingContext }) => Promise<MastraMessageV2[]>",
127
- description:
128
- "Processes input messages to detect language and optionally translate content before sending to LLM",
118
+ description: "Processes input messages to detect language and optionally translate content before sending to LLM",
129
119
  isOptional: false,
130
120
  },
131
121
  ]}
@@ -134,31 +124,29 @@ const processor = new LanguageDetector({
134
124
  ## Extended usage example
135
125
 
136
126
  ```typescript title="src/mastra/agents/multilingual-agent.ts" showLineNumbers copy
137
- import { openai } from "@ai-sdk/openai";
138
127
  import { Agent } from "@mastra/core/agent";
139
128
  import { LanguageDetector } from "@mastra/core/processors";
140
129
 
141
130
  export const agent = new Agent({
142
131
  name: "multilingual-agent",
143
132
  instructions: "You are a helpful assistant",
144
- model: openai("gpt-4o-mini"),
133
+ model: "openai/gpt-4o-mini",
145
134
  inputProcessors: [
146
135
  new LanguageDetector({
147
- model: openai("gpt-4.1-nano"),
136
+ model: "openai/gpt-4.1-nano",
148
137
  targetLanguages: ["English", "en"],
149
138
  threshold: 0.8,
150
139
  strategy: "translate",
151
140
  preserveOriginal: true,
152
- instructions:
153
- "Detect language and translate non-English content to English while preserving original intent",
141
+ instructions: "Detect language and translate non-English content to English while preserving original intent",
154
142
  minTextLength: 10,
155
143
  includeDetectionDetails: true,
156
- translationQuality: "quality",
157
- }),
158
- ],
144
+ translationQuality: "quality"
145
+ })
146
+ ]
159
147
  });
160
148
  ```
161
149
 
162
150
  ## Related
163
151
 
164
- - [Input Processors](/docs/agents/guardrails)
152
+ - [Guardrails](/docs/agents/guardrails)
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: "Reference: ModerationProcessor | Processors | Mastra Docs"
2
+ title: "Reference: Moderation Processor | Processors | Mastra Docs"
3
3
  description: "Documentation for the ModerationProcessor in Mastra, which provides content moderation using LLM to detect inappropriate content across multiple categories."
4
4
  ---
5
5
 
@@ -10,14 +10,13 @@ The `ModerationProcessor` is a **hybrid processor** that can be used for both in
10
10
  ## Usage example
11
11
 
12
12
  ```typescript copy
13
- import { openai } from "@ai-sdk/openai";
14
13
  import { ModerationProcessor } from "@mastra/core/processors";
15
14
 
16
15
  const processor = new ModerationProcessor({
17
- model: openai("gpt-4.1-nano"),
16
+ model: "openai/gpt-4.1-nano",
18
17
  threshold: 0.7,
19
18
  strategy: "block",
20
- categories: ["hate", "harassment", "violence"],
19
+ categories: ["hate", "harassment", "violence"]
21
20
  });
22
21
  ```
23
22
 
@@ -40,56 +39,49 @@ const processor = new ModerationProcessor({
40
39
  content={[
41
40
  {
42
41
  name: "model",
43
- type: "MastraLanguageModel",
42
+ type: "MastraModelConfig",
44
43
  description: "Model configuration for the moderation agent",
45
44
  isOptional: false,
46
45
  },
47
46
  {
48
47
  name: "categories",
49
48
  type: "string[]",
50
- description:
51
- "Categories to check for moderation. If not specified, uses default OpenAI categories",
49
+ description: "Categories to check for moderation. If not specified, uses default OpenAI categories",
52
50
  isOptional: true,
53
- default:
54
- "['hate', 'hate/threatening', 'harassment', 'harassment/threatening', 'self-harm', 'self-harm/intent', 'self-harm/instructions', 'sexual', 'sexual/minors', 'violence', 'violence/graphic']",
51
+ default: "['hate', 'hate/threatening', 'harassment', 'harassment/threatening', 'self-harm', 'self-harm/intent', 'self-harm/instructions', 'sexual', 'sexual/minors', 'violence', 'violence/graphic']",
55
52
  },
56
53
  {
57
54
  name: "threshold",
58
55
  type: "number",
59
- description:
60
- "Confidence threshold for flagging (0-1). Content is flagged if any category score exceeds this threshold",
56
+ description: "Confidence threshold for flagging (0-1). Content is flagged if any category score exceeds this threshold",
61
57
  isOptional: true,
62
58
  default: "0.5",
63
59
  },
64
60
  {
65
61
  name: "strategy",
66
62
  type: "'block' | 'warn' | 'filter'",
67
- description:
68
- "Strategy when content is flagged: 'block' rejects with error, 'warn' logs warning but allows through, 'filter' removes flagged messages",
63
+ description: "Strategy when content is flagged: 'block' rejects with error, 'warn' logs warning but allows through, 'filter' removes flagged messages",
69
64
  isOptional: true,
70
65
  default: "'block'",
71
66
  },
72
67
  {
73
68
  name: "instructions",
74
69
  type: "string",
75
- description:
76
- "Custom moderation instructions for the agent. If not provided, uses default instructions based on categories",
70
+ description: "Custom moderation instructions for the agent. If not provided, uses default instructions based on categories",
77
71
  isOptional: true,
78
72
  default: "undefined",
79
73
  },
80
74
  {
81
75
  name: "includeScores",
82
76
  type: "boolean",
83
- description:
84
- "Whether to include confidence scores in logs. Useful for tuning thresholds and debugging",
77
+ description: "Whether to include confidence scores in logs. Useful for tuning thresholds and debugging",
85
78
  isOptional: true,
86
79
  default: "false",
87
80
  },
88
81
  {
89
82
  name: "chunkWindow",
90
83
  type: "number",
91
- description:
92
- "Number of previous chunks to include for context when moderating stream chunks. If set to 1, includes the previous part, etc.",
84
+ description: "Number of previous chunks to include for context when moderating stream chunks. If set to 1, includes the previous part, etc.",
93
85
  isOptional: true,
94
86
  default: "0 (no context window)",
95
87
  },
@@ -109,15 +101,13 @@ const processor = new ModerationProcessor({
109
101
  {
110
102
  name: "processInput",
111
103
  type: "(args: { messages: MastraMessageV2[]; abort: (reason?: string) => never; tracingContext?: TracingContext }) => Promise<MastraMessageV2[]>",
112
- description:
113
- "Processes input messages to moderate content before sending to LLM",
104
+ description: "Processes input messages to moderate content before sending to LLM",
114
105
  isOptional: false,
115
106
  },
116
107
  {
117
108
  name: "processOutputStream",
118
109
  type: "(args: { part: ChunkType; streamParts: ChunkType[]; state: Record<string, any>; abort: (reason?: string) => never; tracingContext?: TracingContext }) => Promise<ChunkType | null | undefined>",
119
- description:
120
- "Processes streaming output parts to moderate content during streaming",
110
+ description: "Processes streaming output parts to moderate content during streaming",
121
111
  isOptional: false,
122
112
  },
123
113
  ]}
@@ -125,30 +115,56 @@ const processor = new ModerationProcessor({
125
115
 
126
116
  ## Extended usage example
127
117
 
118
+ ### Input processing
119
+
128
120
  ```typescript title="src/mastra/agents/moderated-agent.ts" showLineNumbers copy
129
- import { openai } from "@ai-sdk/openai";
130
121
  import { Agent } from "@mastra/core/agent";
131
122
  import { ModerationProcessor } from "@mastra/core/processors";
132
123
 
133
124
  export const agent = new Agent({
134
125
  name: "moderated-agent",
135
126
  instructions: "You are a helpful assistant",
136
- model: openai("gpt-4o-mini"),
127
+ model: "openai/gpt-4o-mini",
137
128
  inputProcessors: [
138
129
  new ModerationProcessor({
139
- model: openai("gpt-4.1-nano"),
130
+ model: "openai/gpt-4.1-nano",
140
131
  categories: ["hate", "harassment", "violence"],
141
132
  threshold: 0.7,
142
133
  strategy: "block",
143
134
  instructions: "Detect and flag inappropriate content in user messages",
144
- includeScores: true,
135
+ includeScores: true
136
+ })
137
+ ]
138
+ });
139
+ ```
140
+
141
+ ### Output processing with batching
142
+
143
+ When using `ModerationProcessor` as an output processor, it's recommended to combine it with `BatchPartsProcessor` to optimize performance. The `BatchPartsProcessor` batches stream chunks together before passing them to the moderator, reducing the number of LLM calls required for moderation.
144
+
145
+ ```typescript title="src/mastra/agents/output-moderated-agent.ts" showLineNumbers copy
146
+ import { Agent } from "@mastra/core/agent";
147
+ import { BatchPartsProcessor, ModerationProcessor } from "@mastra/core/processors";
148
+
149
+ export const agent = new Agent({
150
+ name: "output-moderated-agent",
151
+ instructions: "You are a helpful assistant",
152
+ model: "openai/gpt-4o-mini",
153
+ outputProcessors: [
154
+ // Batch stream parts first to reduce LLM calls
155
+ new BatchPartsProcessor({
156
+ batchSize: 10,
157
+ }),
158
+ // Then apply moderation on batched content
159
+ new ModerationProcessor({
160
+ model: "openai/gpt-4.1-nano",
161
+ strategy: "filter",
145
162
  chunkWindow: 1,
146
163
  }),
147
- ],
164
+ ]
148
165
  });
149
166
  ```
150
167
 
151
168
  ## Related
152
169
 
153
- - [Input Processors](/docs/agents/guardrails)
154
- - [Output Processors](/docs/agents/guardrails)
170
+ - [Guardrails](/docs/agents/guardrails)