@mastra/mcp-docs-server 1.2.15 → 1.2.16-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.
Files changed (141) hide show
  1. package/.docs/docs/agents/agent-approval.md +5 -5
  2. package/.docs/docs/agents/overview.md +4 -4
  3. package/.docs/docs/browser/overview.md +1 -1
  4. package/.docs/docs/capabilities/channels.md +5 -5
  5. package/.docs/docs/capabilities/subagents.md +1 -1
  6. package/.docs/docs/connections/overview.md +1 -1
  7. package/.docs/docs/datasets/overview.md +1 -1
  8. package/.docs/docs/deployment/cloud-providers.md +4 -2
  9. package/.docs/docs/deployment/mastra-server.md +1 -1
  10. package/.docs/docs/deployment/monorepo.md +1 -1
  11. package/.docs/docs/deployment/overview.md +4 -1
  12. package/.docs/docs/deployment/sandbox.md +1 -1
  13. package/.docs/docs/deployment/web-framework.md +1 -1
  14. package/.docs/docs/deployment/workers.md +248 -2
  15. package/.docs/docs/evals/overview.md +1 -1
  16. package/.docs/docs/evals/quick-checks.md +1 -1
  17. package/.docs/docs/guides/multi-agent-systems.md +1 -1
  18. package/.docs/docs/harness/agent-controller.md +5 -5
  19. package/.docs/docs/harness/overview.md +1 -1
  20. package/.docs/docs/index.md +3 -3
  21. package/.docs/docs/long-running-agents/signal-providers.md +2 -2
  22. package/.docs/docs/mastra-platform/deploy.md +1 -1
  23. package/.docs/docs/mastra-platform/observability.md +63 -18
  24. package/.docs/docs/mastra-platform/overview.md +1 -1
  25. package/.docs/docs/mcp/overview.md +1 -1
  26. package/.docs/docs/memory/working-memory.md +1 -1
  27. package/.docs/docs/observability/integrations/exporters/mastra-storage.md +2 -2
  28. package/.docs/docs/observability/logging.md +1 -1
  29. package/.docs/docs/observability/metrics/overview.md +1 -1
  30. package/.docs/docs/observability/overview.md +1 -5
  31. package/.docs/docs/observability/tracing/overview.md +3 -6
  32. package/.docs/docs/server/auth/workers.md +1 -1
  33. package/.docs/docs/server/auth.md +5 -5
  34. package/.docs/docs/server/mastra-client.md +1 -1
  35. package/.docs/docs/server/mastra-server.md +1 -1
  36. package/.docs/docs/storage/overview.md +7 -6
  37. package/.docs/docs/workflows/human-in-the-loop.md +2 -2
  38. package/.docs/docs/workflows/overview.md +2 -2
  39. package/.docs/docs/workspace/lsp.md +27 -0
  40. package/.docs/docs/workspace/sandbox.md +11 -12
  41. package/.docs/integrations/agentic-ui/ai-sdk-ui.md +1 -1
  42. package/.docs/integrations/agentic-ui/assistant-ui.md +1 -1
  43. package/.docs/integrations/agentic-ui/copilotkit.md +1 -1
  44. package/.docs/integrations/agentic-ui/openui.md +1 -1
  45. package/.docs/integrations/databases/postgresql.md +8 -8
  46. package/.docs/integrations/deploy/amazon-ec2.md +2 -2
  47. package/.docs/integrations/deploy/aws-bedrock-agentcore.md +1 -1
  48. package/.docs/integrations/deploy/aws-lambda.md +2 -2
  49. package/.docs/integrations/deploy/azure-app-services.md +2 -2
  50. package/.docs/integrations/deploy/cloudflare.md +2 -2
  51. package/.docs/integrations/deploy/digital-ocean.md +2 -2
  52. package/.docs/integrations/deploy/inngest.md +1 -1
  53. package/.docs/integrations/deploy/kubernetes.md +2 -3
  54. package/.docs/integrations/deploy/netlify.md +2 -2
  55. package/.docs/integrations/deploy/temporal.md +1 -1
  56. package/.docs/integrations/deploy/vercel.md +2 -2
  57. package/.docs/integrations/file-storage/agentfs.md +1 -1
  58. package/.docs/integrations/file-storage/amazon-s3.md +1 -1
  59. package/.docs/integrations/file-storage/archil.md +1 -1
  60. package/.docs/integrations/file-storage/azure-blob.md +1 -1
  61. package/.docs/integrations/file-storage/google-cloud-storage.md +1 -1
  62. package/.docs/integrations/file-storage/google-drive.md +1 -1
  63. package/.docs/integrations/file-storage/mesa.md +1 -1
  64. package/.docs/integrations/file-storage/vercel-files.md +1 -1
  65. package/.docs/integrations/frameworks/astro.md +1 -1
  66. package/.docs/integrations/frameworks/electron.md +1 -1
  67. package/.docs/integrations/frameworks/express.md +1 -1
  68. package/.docs/integrations/frameworks/hono.md +1 -1
  69. package/.docs/integrations/frameworks/nestjs.md +1 -1
  70. package/.docs/integrations/frameworks/next-js.md +1 -1
  71. package/.docs/integrations/frameworks/nuxt.md +1 -1
  72. package/.docs/integrations/frameworks/sveltekit.md +1 -1
  73. package/.docs/integrations/frameworks/vite-react.md +1 -1
  74. package/.docs/integrations/sandboxes/agentcore.md +1 -1
  75. package/.docs/integrations/sandboxes/apple-container.md +1 -1
  76. package/.docs/integrations/sandboxes/blaxel.md +1 -1
  77. package/.docs/integrations/sandboxes/daytona.md +1 -1
  78. package/.docs/integrations/sandboxes/docker.md +1 -1
  79. package/.docs/integrations/sandboxes/e2b.md +1 -1
  80. package/.docs/integrations/sandboxes/modal.md +1 -1
  81. package/.docs/integrations/sandboxes/railway.md +1 -1
  82. package/.docs/integrations/sandboxes/vercel.md +3 -1
  83. package/.docs/integrations/tools/firecrawl.md +2 -2
  84. package/.docs/integrations/voice/livekit.md +3 -3
  85. package/.docs/integrations.md +108 -108
  86. package/.docs/models/environment-variables.md +2 -0
  87. package/.docs/models/gateways/openrouter.md +5 -1
  88. package/.docs/models/gateways/vercel.md +3 -2
  89. package/.docs/models/index.md +1 -1
  90. package/.docs/models/providers/aiand.md +3 -2
  91. package/.docs/models/providers/digitalocean.md +3 -2
  92. package/.docs/models/providers/edenai.md +88 -0
  93. package/.docs/models/providers/hyper.md +3 -3
  94. package/.docs/models/providers/inceptron.md +8 -9
  95. package/.docs/models/providers/kilo.md +11 -6
  96. package/.docs/models/providers/llmgateway.md +3 -1
  97. package/.docs/models/providers/merge-gateway.md +262 -0
  98. package/.docs/models/providers/nano-gpt.md +13 -37
  99. package/.docs/models/providers/opencode.md +2 -2
  100. package/.docs/models/providers/tinfoil.md +9 -8
  101. package/.docs/models/providers/xai.md +2 -1
  102. package/.docs/models/providers.md +2 -0
  103. package/.docs/reference/agents/getVoice.md +1 -1
  104. package/.docs/reference/configuration.md +1 -1
  105. package/.docs/reference/index.md +5 -1
  106. package/.docs/reference/manual-install.md +1 -1
  107. package/.docs/reference/migrations/network-to-supervisor.md +1 -1
  108. package/.docs/reference/migrations/upgrade-to-v1/tracing.md +1 -3
  109. package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +0 -1
  110. package/.docs/reference/observability/tracing/exporters/console-exporter.md +0 -1
  111. package/.docs/reference/observability/tracing/exporters/default-exporter.md +0 -1
  112. package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +0 -1
  113. package/.docs/reference/observability/tracing/exporters/mastra-storage-exporter.md +0 -1
  114. package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +111 -99
  115. package/.docs/reference/observability/tracing/span-filtering.md +1 -1
  116. package/.docs/reference/storage/overview.md +1 -1
  117. package/.docs/reference/templates/overview.md +1 -1
  118. package/.docs/{guides → reference}/voice/overview.md +3 -3
  119. package/.docs/{guides → reference}/voice/speech-to-speech.md +1 -1
  120. package/.docs/{guides → reference}/voice/speech-to-text.md +1 -1
  121. package/.docs/{guides → reference}/voice/text-to-speech.md +2 -2
  122. package/CHANGELOG.md +14 -0
  123. package/package.json +4 -4
  124. package/.docs/docs/observability/integrations/exporters/mastra-platform.md +0 -201
  125. package/.docs/docs/observability/integrations/overview.md +0 -47
  126. package/.docs/docs/observability/integrations/processors/sensitive-data-filter.md +0 -302
  127. package/.docs/guides/deployment/mastra-workers.md +0 -578
  128. package/.docs/guides/getting-started/quickstart.md +0 -88
  129. package/.docs/guides/guide/ai-recruiter.md +0 -228
  130. package/.docs/guides/guide/code-review-bot.md +0 -228
  131. package/.docs/guides/guide/coding-agent.md +0 -392
  132. package/.docs/guides/guide/dev-assistant.md +0 -309
  133. package/.docs/guides/guide/docs-manager.md +0 -240
  134. package/.docs/guides/guide/github-actions-pr-description.md +0 -238
  135. package/.docs/guides/guide/notes-mcp-server.md +0 -418
  136. package/.docs/guides/guide/research-assistant.md +0 -350
  137. package/.docs/guides/guide/research-coordinator.md +0 -418
  138. package/.docs/guides/guide/signal-provider.md +0 -221
  139. package/.docs/guides/index.md +0 -24
  140. /package/.docs/{reference → docs}/mastra-platform/api.md +0 -0
  141. /package/.docs/{guides/agent-frameworks/ai-sdk.md → reference/ai-sdk/overview.md} +0 -0
@@ -1,201 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # Mastra platform exporter
4
-
5
- The `MastraPlatformExporter` sends traces, logs, metrics, scores, and feedback to the Mastra platform. Use it to route observability data from any Mastra app to a hosted project in the Mastra platform.
6
-
7
- > **Note:** `MastraPlatformExporter` was previously called `CloudExporter`. The original `CloudExporter` class is still exported from `@mastra/observability` for backward compatibility, but it's deprecated. New code should use `MastraPlatformExporter`.
8
-
9
- > **Self-hosted or standalone apps:** If you host your Mastra application on your own infrastructure (not on Mastra platform), you still need a deployed Studio project to view traces, logs, and metrics. `MastraPlatformExporter` sends data to a Studio project, so one must exist before you can use it.
10
- >
11
- > 1. [Create a Mastra project](https://mastra.ai/guides/getting-started/quickstart) if you don't have one yet.
12
- > 2. [Deploy Studio](https://mastra.ai/docs/studio/deployment) to the Mastra platform with `mastra studio deploy`.
13
- > 3. Follow the [quickstart steps below](#quickstart) to create an access token and find your project ID.
14
-
15
- ## Version compatibility
16
-
17
- - `MastraPlatformExporter` is available starting in `@mastra/observability@1.12.0`. In `1.8.0` through `1.11.x` the same exporter includes only as `CloudExporter`. The constructor signature and environment variables are identical.
18
- - In `@mastra/observability@1.8.0` through `1.9.1`, set `MASTRA_PLATFORM_OBSERVABILITY_ENDPOINT=https://observability.mastra.ai` in addition to `MASTRA_PLATFORM_ACCESS_TOKEN` and `MASTRA_PROJECT_ID`.
19
- - Starting in `@mastra/observability@1.9.2`, the exporter defaults to `https://observability.mastra.ai`, so `MASTRA_PLATFORM_OBSERVABILITY_ENDPOINT` is only required when you want to send telemetry to a different collector.
20
-
21
- ## Quickstart
22
-
23
- To connect `MastraPlatformExporter`, create an access token, find the destination `projectId`, and add the exporter to your observability config.
24
-
25
- ### 1. Create an access token
26
-
27
- Run the following command:
28
-
29
- ```bash
30
- mastra auth tokens create exporter-token
31
- ```
32
-
33
- This command prints a token secret that you can use as `MASTRA_PLATFORM_ACCESS_TOKEN`.
34
-
35
- If you already have an access token, copy the **Observability** value from the Mastra platform instead. You can find it in either of these places:
36
-
37
- - On the **Projects** page, open the project list and find the **Observability** row on the project card.
38
- - On the project **Overview** page, find the **Observability** row directly below the deployment URL.
39
-
40
- Set the token as an environment variable:
41
-
42
- ```bash
43
- MASTRA_PLATFORM_ACCESS_TOKEN=<your-platform-access-token>
44
- ```
45
-
46
- ### 2. Find your `projectId`
47
-
48
- Run the following command:
49
-
50
- ```bash
51
- mastra studio deploy list
52
- ```
53
-
54
- The output looks similar to this:
55
-
56
- ```text
57
- ✅ <your-project-name> (<your-project-id>)
58
- Latest: 00000000-0000-0000-0000-000000000000 — running
59
- URL: https://260407.studio.mastra.cloud
60
- ```
61
-
62
- In this output, the value in parentheses is the `projectId`:
63
-
64
- ```text
65
- <your-project-id>
66
- ```
67
-
68
- Set it as an environment variable:
69
-
70
- ```bash
71
- MASTRA_PROJECT_ID=<your-project-id>
72
- ```
73
-
74
- ### 3. Set your environment variables
75
-
76
- Set both values in your environment so `MastraPlatformExporter` can authenticate and route telemetry to the correct project:
77
-
78
- ```bash
79
- MASTRA_PLATFORM_ACCESS_TOKEN=<your-platform-access-token>
80
- MASTRA_PROJECT_ID=<your-project-id>
81
- ```
82
-
83
- If you use `@mastra/observability@1.8.0` through `1.9.1`, also set the Mastra platform collector explicitly:
84
-
85
- ```bash
86
- MASTRA_PLATFORM_OBSERVABILITY_ENDPOINT=https://observability.mastra.ai
87
- ```
88
-
89
- If you want to send telemetry somewhere other than Mastra platform, set `MASTRA_PLATFORM_OBSERVABILITY_ENDPOINT` as well. Pass either a base origin or a full traces publish URL ending in `/spans/publish`.
90
-
91
- ```bash
92
- MASTRA_PLATFORM_OBSERVABILITY_ENDPOINT=https://collector.example.com
93
- ```
94
-
95
- When you pass a base origin, `MastraPlatformExporter` derives the matching publish URLs for traces, logs, metrics, scores, and feedback automatically.
96
-
97
- ### 4. Enable `MastraPlatformExporter`
98
-
99
- The following example demonstrates how to add `MastraPlatformExporter` to your observability config:
100
-
101
- ```ts
102
- import { Mastra } from '@mastra/core'
103
- import { Observability, MastraPlatformExporter } from '@mastra/observability'
104
-
105
- export const mastra = new Mastra({
106
- observability: new Observability({
107
- configs: {
108
- production: {
109
- serviceName: 'api-server',
110
- exporters: [new MastraPlatformExporter()],
111
- },
112
- },
113
- }),
114
- })
115
- ```
116
-
117
- Set `serviceName` on the observability config, not on `MastraPlatformExporter` itself.
118
-
119
- Use a stable `serviceName` value. In Studio, traces can be filtered by **Deployments → Service Name**, so a consistent name makes traces easier to find.
120
-
121
- Visit [Observability configuration reference](https://mastra.ai/reference/observability/tracing/configuration) for the full observability config shape.
122
-
123
- If you prefer, rely entirely on environment variables:
124
-
125
- ```ts
126
- new MastraPlatformExporter()
127
- ```
128
-
129
- With `MASTRA_PLATFORM_ACCESS_TOKEN` and `MASTRA_PROJECT_ID` set, `MastraPlatformExporter` sends data to the Mastra platform project you configured. If you also set `MASTRA_PLATFORM_OBSERVABILITY_ENDPOINT`, it sends data to that collector instead. Visit [MastraPlatformExporter reference](https://mastra.ai/reference/observability/tracing/exporters/mastra-platform-exporter) for the full list of configuration options.
130
-
131
- ## Recommended configuration
132
-
133
- Include `MastraStorageExporter` if you also want to inspect local traces in Studio or persist observability data to your configured storage.
134
-
135
- ```ts
136
- import { Mastra } from '@mastra/core'
137
- import {
138
- Observability,
139
- MastraStorageExporter,
140
- MastraPlatformExporter,
141
- SensitiveDataFilter,
142
- } from '@mastra/observability'
143
-
144
- export const mastra = new Mastra({
145
- observability: new Observability({
146
- configs: {
147
- default: {
148
- serviceName: 'mastra',
149
- exporters: [new MastraStorageExporter(), new MastraPlatformExporter()],
150
- spanOutputProcessors: [new SensitiveDataFilter()],
151
- },
152
- },
153
- }),
154
- })
155
- ```
156
-
157
- ## Complete configuration
158
-
159
- `MastraPlatformExporter` defaults to Mastra platform. If you want to send telemetry to a different collector, set `MASTRA_PLATFORM_OBSERVABILITY_ENDPOINT` in your environment or pass `endpoint` in code.
160
-
161
- ```bash
162
- MASTRA_PLATFORM_OBSERVABILITY_ENDPOINT=https://collector.example.com
163
- ```
164
-
165
- The following example demonstrates how to override the collector endpoint and batching behavior in code:
166
-
167
- ```ts
168
- new MastraPlatformExporter({
169
- endpoint: 'https://collector.example.com',
170
- maxBatchSize: 1000,
171
- maxBatchWaitMs: 5000,
172
- logLevel: 'info',
173
- })
174
- ```
175
-
176
- ## Viewing data in Mastra Studio
177
-
178
- After you enable `MastraPlatformExporter`, open your project in [Mastra Studio](https://projects.mastra.ai) to inspect the exported data.
179
-
180
- - Open the project you set `MASTRA_PROJECT_ID` to and select **Open Studio**.
181
- - In Studio, go to **Traces** to inspect agent and workflow traces.
182
- - Open the filter menu and use **Deployments → Service Name** to isolate traces from a specific app or deployment.
183
- - Use the **Logs** page in the project dashboard to inspect exported logs.
184
-
185
- When you deploy with Mastra Studio, set **Deployment → Service Name** to a stable value and keep it aligned with the `serviceName` in your observability config. This makes traces easier to filter in Studio through **Deployments → Service Name** when multiple services or deployments send data to the same project.
186
-
187
- ## Performance
188
-
189
- > **Note:** MastraPlatformExporter uses batching to optimize network usage. Events are buffered and sent in batches, reducing overhead while maintaining near real-time visibility.
190
-
191
- ### Batching behavior
192
-
193
- - Events are batched up to `maxBatchSize` (default: 1000).
194
- - Batches are sent when full or after `maxBatchWaitMs` (default: 5 seconds).
195
- - Failed batches are retried with exponential backoff.
196
- - The exporter degrades gracefully if Mastra Studio is unreachable.
197
-
198
- ## Related
199
-
200
- - [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
201
- - [MastraStorageExporter](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage)
@@ -1,47 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # Integrations overview
4
-
5
- Mastra observability integrations control where observability data goes and how it's transformed on the way out. Use integrations to store data in Mastra storage, send it to Mastra platform, connect to external observability providers, or redact exported span data.
6
-
7
- ## When to use integrations
8
-
9
- - Keep observability available in Studio with `MastraStorageExporter`.
10
- - Send hosted observability data to Mastra platform with `MastraPlatformExporter`.
11
- - Forward traces to external providers such as Datadog, Langfuse, or OpenTelemetry backends.
12
- - Redact sensitive values before they leave the runtime.
13
-
14
- ## Choose an integration path
15
-
16
- - Studio workflow: Start with [Mastra Storage](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage).
17
- - Hosted Mastra workflow: Add [Mastra platform](https://mastra.ai/docs/observability/integrations/exporters/mastra-platform).
18
- - External observability stack: Choose one or more exporter pages under the sidebar `Exporters` section.
19
- - Existing distributed trace context: Use a bridge, then add exporters as needed.
20
-
21
- ## Exporters
22
-
23
- Exporters send observability data to a destination:
24
-
25
- - [Mastra Storage](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage): Persist observability data for Studio.
26
- - [Mastra platform](https://mastra.ai/docs/observability/integrations/exporters/mastra-platform): Send hosted observability data to Mastra platform.
27
- - External providers: Use exporter pages for Datadog, Langfuse, OpenTelemetry, and other supported platforms.
28
-
29
- ## Bridges
30
-
31
- Bridges connect Mastra to an existing distributed tracing context:
32
-
33
- - [OpenTelemetry bridge](https://mastra.ai/integrations/observability/opentelemetry): Integrate Mastra with an existing OpenTelemetry trace.
34
- - [Datadog bridge](https://mastra.ai/integrations/observability/datadog): Send Mastra traces to Datadog and its LLM Observability product.
35
-
36
- ## Processors
37
-
38
- Processors transform or redact spans before export:
39
-
40
- - [Sensitive Data Filter](https://mastra.ai/docs/observability/integrations/processors/sensitive-data-filter): Redact sensitive fields before spans leave the runtime.
41
-
42
- ## Next steps
43
-
44
- - [Configuration](https://mastra.ai/docs/observability/overview)
45
- - [Tracing](https://mastra.ai/docs/observability/tracing/overview)
46
- - [Mastra Storage](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage)
47
- - [OpenTelemetry bridge](https://mastra.ai/integrations/observability/opentelemetry)
@@ -1,302 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # Sensitive data filter
4
-
5
- The Sensitive Data Filter is a span processor that redacts sensitive information from your traces during the processing pipeline before export. This ensures that passwords, API keys, tokens, and other confidential data never leave your application or get stored in observability platforms.
6
-
7
- ## Default configuration
8
-
9
- The Sensitive Data Filter is included in the recommended observability configuration:
10
-
11
- ```ts
12
- import {
13
- Observability,
14
- MastraStorageExporter,
15
- MastraPlatformExporter,
16
- SensitiveDataFilter,
17
- } from '@mastra/observability'
18
-
19
- export const mastra = new Mastra({
20
- observability: new Observability({
21
- configs: {
22
- default: {
23
- serviceName: 'mastra',
24
- exporters: [new MastraStorageExporter(), new MastraPlatformExporter()],
25
- spanOutputProcessors: [
26
- new SensitiveDataFilter(), // Redacts sensitive fields before export
27
- ],
28
- },
29
- },
30
- }),
31
- storage: new LibSQLStore({
32
- id: 'mastra-storage',
33
- url: 'file:./mastra.db',
34
- }),
35
- })
36
- ```
37
-
38
- With the default configuration, the filter redacts these common sensitive field names:
39
-
40
- - `password`
41
- - `token`
42
- - `secret`
43
- - `key`
44
- - `apikey`
45
- - `auth`
46
- - `authorization`
47
- - `bearer`
48
- - `bearertoken`
49
- - `jwt`
50
- - `credential`
51
- - `clientsecret`
52
- - `privatekey`
53
- - `refresh`
54
- - `ssn`
55
-
56
- > **Note:** Field matching is case-insensitive and normalizes separators. For example, `api-key`, `api_key`, and `Api Key` are all treated as `apikey`.
57
-
58
- ## How it works
59
-
60
- The Sensitive Data Filter processes spans before they're sent to exporters, scanning through:
61
-
62
- - **Attributes** - Span metadata and properties
63
- - **Metadata** - Custom metadata attached to spans
64
- - **Input** - Data sent to agents, tools, and LLMs
65
- - **Output** - Responses and results
66
- - **Error Information** - Stack traces and error details
67
-
68
- When a sensitive field is detected, its value is replaced with `[REDACTED]` by default. The filter handles nested objects, arrays, and circular references safely.
69
-
70
- ## Custom configuration
71
-
72
- You can customize which fields are redacted and how redaction displays:
73
-
74
- ```ts
75
- import { SensitiveDataFilter, MastraStorageExporter, Observability } from '@mastra/observability'
76
-
77
- export const mastra = new Mastra({
78
- observability: new Observability({
79
- configs: {
80
- production: {
81
- serviceName: 'my-service',
82
- exporters: [new MastraStorageExporter()],
83
- spanOutputProcessors: [
84
- new SensitiveDataFilter({
85
- // Add custom sensitive fields
86
- sensitiveFields: [
87
- // Default fields
88
- 'password',
89
- 'token',
90
- 'secret',
91
- 'key',
92
- 'apikey',
93
- // Custom fields for your application
94
- 'creditCard',
95
- 'bankAccount',
96
- 'routingNumber',
97
- 'email',
98
- 'phoneNumber',
99
- 'dateOfBirth',
100
- ],
101
- // Custom redaction token
102
- redactionToken: '***SENSITIVE***',
103
- // Redaction style
104
- redactionStyle: 'full', // or 'partial'
105
- }),
106
- ],
107
- },
108
- },
109
- }),
110
- })
111
- ```
112
-
113
- ## Redaction styles
114
-
115
- The filter supports two redaction styles:
116
-
117
- ### Full Redaction (Default)
118
-
119
- Replaces the entire value with a fixed token:
120
-
121
- ```jsonc
122
- // Before
123
- {
124
- "apiKey": "sk-abc123xyz789def456",
125
- "userId": "user_12345"
126
- }
127
-
128
- // After
129
- {
130
- "apiKey": "[REDACTED]",
131
- "userId": "user_12345"
132
- }
133
- ```
134
-
135
- ### Partial Redaction
136
-
137
- Shows the first and last 3 characters, useful for debugging without exposing full values:
138
-
139
- ```ts
140
- new SensitiveDataFilter({
141
- redactionStyle: 'partial',
142
- })
143
- ```
144
-
145
- ```json
146
- // Before
147
- {
148
- "apiKey": "sk-abc123xyz789def456",
149
- "creditCard": "4111111111111111"
150
- }
151
-
152
- // After
153
- {
154
- "apiKey": "sk-…456",
155
- "creditCard": "411…111"
156
- }
157
- ```
158
-
159
- Values shorter than 7 characters are fully redacted to prevent information leakage.
160
-
161
- ## Field matching rules
162
-
163
- The filter uses intelligent field matching:
164
-
165
- 1. **Case-Insensitive**: `APIKey`, `apikey`, and `ApiKey` are all matched
166
-
167
- 2. **Separator-Agnostic**: `api-key`, `api_key`, and `apiKey` are treated identically
168
-
169
- 3. **Exact Matching**: After normalization, fields must match exactly
170
-
171
- - `token` matches `token`, `Token`, `TOKEN`
172
- - `token` doesn't match `promptTokens` or `tokenCount`
173
-
174
- ## Nested object handling
175
-
176
- The filter recursively processes nested structures:
177
-
178
- ```json
179
- // Before
180
- {
181
- "user": {
182
- "id": "12345",
183
- "credentials": {
184
- "password": "SuperSecret123!",
185
- "apiKey": "sk-production-key"
186
- }
187
- },
188
- "config": {
189
- "auth": {
190
- "jwt": "eyJhbGciOiJIUzI1NiIs..."
191
- }
192
- }
193
- }
194
-
195
- // After
196
- {
197
- "user": {
198
- "id": "12345",
199
- "credentials": {
200
- "password": "[REDACTED]",
201
- "apiKey": "[REDACTED]"
202
- }
203
- },
204
- "config": {
205
- "auth": {
206
- "jwt": "[REDACTED]"
207
- }
208
- }
209
- }
210
- ```
211
-
212
- ## Performance considerations
213
-
214
- The Sensitive Data Filter is designed to be lightweight and efficient:
215
-
216
- - **Synchronous Processing**: No async operations, minimal latency impact
217
- - **Circular Reference Handling**: Safely handles complex object graphs
218
- - **Error Recovery**: If filtering fails, the field is replaced with an error marker rather than crashing
219
-
220
- ## Disabling the filter
221
-
222
- If you need to disable sensitive data filtering (not recommended for production):
223
-
224
- ```ts
225
- export const mastra = new Mastra({
226
- observability: new Observability({
227
- configs: {
228
- debug: {
229
- serviceName: 'debug-service',
230
- spanOutputProcessors: [], // No processors, including no SensitiveDataFilter
231
- exporters: [new MastraStorageExporter()],
232
- },
233
- },
234
- }),
235
- })
236
- ```
237
-
238
- > **Warning:** Only disable sensitive data filtering in controlled environments. Never disable it when sending traces to external services or shared storage.
239
-
240
- ## Common use cases
241
-
242
- ### Healthcare Applications
243
-
244
- ```ts
245
- new SensitiveDataFilter({
246
- sensitiveFields: [
247
- // HIPAA-related fields
248
- 'ssn',
249
- 'socialSecurityNumber',
250
- 'medicalRecordNumber',
251
- 'mrn',
252
- 'healthInsuranceNumber',
253
- 'diagnosisCode',
254
- 'icd10',
255
- 'prescription',
256
- 'medication',
257
- ],
258
- })
259
- ```
260
-
261
- ### Financial Services
262
-
263
- ```ts
264
- new SensitiveDataFilter({
265
- sensitiveFields: [
266
- // PCI compliance fields
267
- 'creditCard',
268
- 'ccNumber',
269
- 'cardNumber',
270
- 'cvv',
271
- 'cvc',
272
- 'securityCode',
273
- 'expirationDate',
274
- 'expiry',
275
- 'bankAccount',
276
- 'accountNumber',
277
- 'routingNumber',
278
- 'iban',
279
- 'swift',
280
- ],
281
- })
282
- ```
283
-
284
- ## Error handling
285
-
286
- If the filter encounters an error while processing a field, it replaces the field with a safe error marker:
287
-
288
- ```json
289
- {
290
- "problematicField": {
291
- "error": {
292
- "processor": "sensitive-data-filter"
293
- }
294
- }
295
- }
296
- ```
297
-
298
- As a result, processing errors don't prevent traces from being exported or cause application crashes.
299
-
300
- ## Related
301
-
302
- - [SensitiveDataFilter API](https://mastra.ai/reference/observability/tracing/processors/sensitive-data-filter)