@mastra/mcp-docs-server 1.2.14-alpha.1 → 1.2.14-alpha.4

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 (127) hide show
  1. package/.docs/docs/agents/a2a.md +1 -1
  2. package/.docs/docs/agents/acp.md +1 -1
  3. package/.docs/docs/agents/agent-approval.md +1 -1
  4. package/.docs/docs/agents/networks.md +2 -2
  5. package/.docs/docs/agents/overview.md +2 -2
  6. package/.docs/docs/agents/processors.md +25 -1
  7. package/.docs/docs/agents/using-tools.md +2 -2
  8. package/.docs/docs/capabilities/channels/overview.md +1 -1
  9. package/.docs/docs/{agents/supervisor-agents.md → capabilities/subagents.md} +58 -58
  10. package/.docs/docs/deployment/sandbox.md +95 -1
  11. package/.docs/docs/getting-started/develop.md +2 -0
  12. package/.docs/docs/harness/agent-controller.md +370 -0
  13. package/.docs/docs/long-running-agents/background-tasks.md +1 -1
  14. package/.docs/docs/long-running-agents/goals.md +3 -3
  15. package/.docs/docs/mcp/overview.md +222 -281
  16. package/.docs/docs/memory/overview.md +2 -2
  17. package/.docs/docs/observability/integrations/exporters/confident-ai.md +140 -0
  18. package/.docs/docs/observability/integrations/overview.md +1 -1
  19. package/.docs/docs/observability/overview.md +122 -8
  20. package/.docs/docs/observability/tracing/overview.md +2 -2
  21. package/.docs/docs/server/mastra-client.md +1 -1
  22. package/.docs/docs/server/server-adapters.md +2 -0
  23. package/.docs/docs/storage/overview.md +2 -2
  24. package/.docs/docs/workflows/agents-and-tools.md +29 -0
  25. package/.docs/docs/workflows/stored-workflows.md +146 -0
  26. package/.docs/guides/build-your-ui/copilotkit/channels.md +49 -39
  27. package/.docs/guides/concepts/multi-agent-systems.md +7 -7
  28. package/.docs/guides/guide/coding-agent.md +2 -2
  29. package/.docs/guides/guide/research-coordinator.md +1 -1
  30. package/.docs/guides/migrations/network-to-supervisor.md +1 -1
  31. package/.docs/models/environment-variables.md +1 -1
  32. package/.docs/models/gateways/neon.md +71 -0
  33. package/.docs/models/gateways/netlify.md +6 -6
  34. package/.docs/models/gateways/openrouter.md +6 -6
  35. package/.docs/models/gateways/vercel.md +6 -6
  36. package/.docs/models/gateways.md +1 -0
  37. package/.docs/models/index.md +96 -97
  38. package/.docs/models/providers/alibaba-cn.md +23 -25
  39. package/.docs/models/providers/alibaba-token-plan-cn.md +24 -24
  40. package/.docs/models/providers/alibaba-token-plan.md +23 -25
  41. package/.docs/models/providers/alibaba.md +23 -25
  42. package/.docs/models/providers/ambient.md +23 -25
  43. package/.docs/models/providers/baseten.md +23 -25
  44. package/.docs/models/providers/chutes.md +23 -25
  45. package/.docs/models/providers/cortecs.md +23 -25
  46. package/.docs/models/providers/crof.md +23 -25
  47. package/.docs/models/providers/crossmodel.md +23 -25
  48. package/.docs/models/providers/deepinfra.md +22 -24
  49. package/.docs/models/providers/digitalocean.md +32 -34
  50. package/.docs/models/providers/empiriolabs.md +23 -25
  51. package/.docs/models/providers/fireworks-ai.md +24 -24
  52. package/.docs/models/providers/greenpt.md +23 -25
  53. package/.docs/models/providers/groq.md +23 -25
  54. package/.docs/models/providers/huggingface.md +23 -25
  55. package/.docs/models/providers/hyper.md +23 -25
  56. package/.docs/models/providers/impossibl.md +23 -25
  57. package/.docs/models/providers/infomaniak.md +24 -24
  58. package/.docs/models/providers/kilo.md +24 -26
  59. package/.docs/models/providers/llmgateway.md +24 -26
  60. package/.docs/models/providers/mistral.md +23 -25
  61. package/.docs/models/providers/modal.md +23 -25
  62. package/.docs/models/providers/modelis.md +23 -25
  63. package/.docs/models/providers/nano-gpt.md +23 -25
  64. package/.docs/models/providers/neuralwatt.md +23 -25
  65. package/.docs/models/providers/ofox.md +23 -25
  66. package/.docs/models/providers/ollama-cloud.md +23 -25
  67. package/.docs/models/providers/opencode-go.md +23 -25
  68. package/.docs/models/providers/opencode.md +25 -26
  69. package/.docs/models/providers/pioneer.md +23 -25
  70. package/.docs/models/providers/requesty.md +23 -25
  71. package/.docs/models/providers/routing-run.md +23 -25
  72. package/.docs/models/providers/scx.md +23 -25
  73. package/.docs/models/providers/tensorx.md +23 -25
  74. package/.docs/models/providers/togetherai.md +22 -24
  75. package/.docs/models/providers/umans-ai-coding-plan.md +24 -24
  76. package/.docs/models/providers/umans-ai.md +23 -25
  77. package/.docs/models/providers/wandb.md +23 -25
  78. package/.docs/models/providers/xai.md +26 -28
  79. package/.docs/models/providers/zai-coding-plan.md +23 -25
  80. package/.docs/models/providers/zhipuai-coding-plan.md +23 -25
  81. package/.docs/models/providers.md +0 -1
  82. package/.docs/reference/acp/acp-agent.md +1 -1
  83. package/.docs/reference/agent-controller/agent-controller-class.md +195 -506
  84. package/.docs/reference/agent-controller/session.md +274 -111
  85. package/.docs/reference/agents/network.md +1 -1
  86. package/.docs/reference/ai-sdk/handle-network-stream.md +1 -1
  87. package/.docs/reference/ai-sdk/network-route.md +1 -1
  88. package/.docs/reference/cli/create-mastra.md +1 -1
  89. package/.docs/reference/client-js/workflows.md +92 -0
  90. package/.docs/reference/core/addStoredWorkflow.md +62 -0
  91. package/.docs/reference/core/addStoredWorkflows.md +40 -0
  92. package/.docs/reference/editor/versioning.md +1 -1
  93. package/.docs/reference/evals/rubric.md +1 -1
  94. package/.docs/reference/file-based-agents/observability.md +2 -2
  95. package/.docs/reference/file-based-agents/storage.md +1 -1
  96. package/.docs/reference/file-based-agents/subagents.md +1 -1
  97. package/.docs/reference/file-based-agents/tools.md +1 -1
  98. package/.docs/reference/index.md +5 -0
  99. package/.docs/reference/observability/tracing/configuration.md +1 -1
  100. package/.docs/reference/observability/tracing/exporters/confident-ai.md +138 -0
  101. package/.docs/reference/observability/tracing/interfaces.md +29 -0
  102. package/.docs/reference/processors/processor-interface.md +121 -10
  103. package/.docs/reference/server/routes.md +13 -0
  104. package/.docs/reference/signals/signal-provider.md +2 -0
  105. package/.docs/reference/storage/overview.md +9 -8
  106. package/.docs/reference/streaming/workflows/observeStream.md +1 -1
  107. package/.docs/reference/streaming/workflows/resumeStream.md +1 -1
  108. package/.docs/reference/streaming/workflows/stream.md +1 -1
  109. package/.docs/reference/tools/mcp-server.md +1 -1
  110. package/.docs/reference/tools/submit-plan-tool.md +1 -1
  111. package/.docs/reference/workflows/stored-workflow-definition.md +292 -0
  112. package/.docs/reference/workflows/workflow-methods/agent.md +62 -0
  113. package/.docs/reference/workflows/workflow-methods/tool.md +43 -0
  114. package/.docs/reference/workspace/railway-sandbox.md +5 -5
  115. package/CHANGELOG.md +14 -0
  116. package/package.json +4 -4
  117. package/.docs/docs/agent-controller/channels.md +0 -111
  118. package/.docs/docs/agent-controller/modes.md +0 -147
  119. package/.docs/docs/agent-controller/overview.md +0 -136
  120. package/.docs/docs/agent-controller/session.md +0 -161
  121. package/.docs/docs/agent-controller/subagents.md +0 -110
  122. package/.docs/docs/agent-controller/threads-and-state.md +0 -148
  123. package/.docs/docs/agent-controller/tool-approvals.md +0 -147
  124. package/.docs/docs/mcp/mcp-apps.md +0 -306
  125. package/.docs/docs/observability/config.md +0 -140
  126. package/.docs/docs/observability/storage.md +0 -81
  127. package/.docs/models/providers/neon.md +0 -109
@@ -0,0 +1,140 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Confident AI exporter
4
+
5
+ [Confident AI](https://www.confident-ai.com/) is an LLM observability and evaluation platform for teams to build reliable AI applications in both development and production.
6
+
7
+ The `@mastra/deepeval` package sends your Mastra traces to Confident AI, where you can run metrics against them and track quality over time. It builds on [DeepEval](https://www.confident-ai.com/docs), the open-source evaluation SDK behind the platform.
8
+
9
+ ## Installation
10
+
11
+ **npm**:
12
+
13
+ ```bash
14
+ npm install @mastra/deepeval@latest
15
+ ```
16
+
17
+ **pnpm**:
18
+
19
+ ```bash
20
+ pnpm add @mastra/deepeval@latest
21
+ ```
22
+
23
+ **Yarn**:
24
+
25
+ ```bash
26
+ yarn add @mastra/deepeval@latest
27
+ ```
28
+
29
+ **Bun**:
30
+
31
+ ```bash
32
+ bun add @mastra/deepeval@latest
33
+ ```
34
+
35
+ ## Configuration
36
+
37
+ ### Prerequisites
38
+
39
+ 1. **Confident AI account**: Sign up at [confident-ai.com](https://www.confident-ai.com/)
40
+ 2. **API key**: Generate one in your Confident AI project settings
41
+ 3. **Environment variables**: Set your credentials:
42
+
43
+ ```bash
44
+ CONFIDENT_API_KEY=confident_proj_xxxxxxxxxxxxx
45
+
46
+ # Optional
47
+ CONFIDENT_TRACE_ENVIRONMENT=production # Defaults to "development"
48
+ ```
49
+
50
+ ### Zero-Config Setup
51
+
52
+ With environment variables set, use the exporter with no configuration:
53
+
54
+ ```typescript
55
+ import { Mastra } from '@mastra/core'
56
+ import { Observability } from '@mastra/observability'
57
+ import { DeepEvalExporter } from '@mastra/deepeval'
58
+
59
+ export const mastra = new Mastra({
60
+ observability: new Observability({
61
+ configs: {
62
+ deepeval: {
63
+ serviceName: 'my-service',
64
+ exporters: [new DeepEvalExporter()],
65
+ },
66
+ },
67
+ }),
68
+ })
69
+ ```
70
+
71
+ ### Explicit Configuration
72
+
73
+ You can also pass credentials directly (takes precedence over environment variables):
74
+
75
+ ```typescript
76
+ import { Mastra } from '@mastra/core'
77
+ import { Observability } from '@mastra/observability'
78
+ import { DeepEvalExporter } from '@mastra/deepeval'
79
+
80
+ export const mastra = new Mastra({
81
+ observability: new Observability({
82
+ configs: {
83
+ deepeval: {
84
+ serviceName: 'my-service',
85
+ exporters: [
86
+ new DeepEvalExporter({
87
+ apiKey: process.env.CONFIDENT_API_KEY,
88
+ environment: 'production',
89
+ }),
90
+ ],
91
+ },
92
+ },
93
+ }),
94
+ })
95
+ ```
96
+
97
+ ### Metric collections
98
+
99
+ Confident AI evaluates incoming traces against metric collections defined in your project. Attach them at the trace level or per span type. Trace-level metrics run against the whole trace, and per-type metrics run against matching spans.
100
+
101
+ ```typescript
102
+ new DeepEvalExporter({
103
+ metricCollection: 'trace-metrics', // trace-level
104
+ llmMetricCollection: 'llm-metrics', // applied to LLM spans
105
+ agentMetricCollection: 'agent-metrics', // applied to agent spans
106
+ toolMetricCollectionMap: {
107
+ search: 'search-tool-metrics', // applied to the "search" tool
108
+ },
109
+ })
110
+ ```
111
+
112
+ ### Complete Configuration
113
+
114
+ ```typescript
115
+ new DeepEvalExporter({
116
+ apiKey: process.env.CONFIDENT_API_KEY,
117
+ environment: 'production', // Default: "development"
118
+ name: 'my-trace', // Default: the Mastra serviceName
119
+ tags: ['production'],
120
+ metadata: { team: 'growth' },
121
+ })
122
+ ```
123
+
124
+ ## Span type mapping
125
+
126
+ Mastra spans map to the span types shown in Confident AI:
127
+
128
+ | Mastra span type | Confident AI span type |
129
+ | ---------------------------------------------------------------------- | ---------------------- |
130
+ | `AGENT_RUN`, `WORKFLOW_RUN` | `AGENT` |
131
+ | `MODEL_GENERATION` | `LLM` |
132
+ | `TOOL_CALL`, `MCP_TOOL_CALL`, `PROVIDER_TOOL_CALL`, `CLIENT_TOOL_CALL` | `TOOL` |
133
+ | `RAG_EMBEDDING`, `RAG_VECTOR_OPERATION` | `RETRIEVER` |
134
+ | All other exported span types | `CUSTOM` |
135
+
136
+ ## Related
137
+
138
+ - [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
139
+ - [DeepEvalExporter reference](https://mastra.ai/reference/observability/tracing/exporters/confident-ai)
140
+ - [Confident AI documentation](https://www.confident-ai.com/docs)
@@ -41,7 +41,7 @@ Processors transform or redact spans before export:
41
41
 
42
42
  ## Next steps
43
43
 
44
- - [Configuration](https://mastra.ai/docs/observability/config)
44
+ - [Configuration](https://mastra.ai/docs/observability/overview)
45
45
  - [Tracing](https://mastra.ai/docs/observability/tracing/overview)
46
46
  - [Mastra Storage](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage)
47
47
  - [OpenTelemetry bridge](https://mastra.ai/docs/observability/integrations/bridges/otel)
@@ -4,8 +4,8 @@
4
4
 
5
5
  Mastra's observability system gives you visibility into every agent run, workflow step, tool call, and model interaction. Agent behavior depends on model responses, prompts, tools, memory, and workflow state, so observability helps you inspect runtime decisions from day one. It captures complementary signals that work together to help you understand what your application is doing and why.
6
6
 
7
- - [**Configuration**](https://mastra.ai/docs/observability/config): Configure observability once for traces, logs, metrics, and feedback.
8
- - [**Storage**](https://mastra.ai/docs/observability/storage): Choose storage backends for persisted traces, logs, metrics aggregation, and feedback queries.
7
+ - [**Configuration**](#configuration): Configure observability once for traces, logs, metrics, and feedback.
8
+ - [**Storage**](#storage): Choose storage backends for persisted traces, logs, metrics aggregation, and feedback queries.
9
9
  - [**Tracing**](https://mastra.ai/docs/observability/tracing/overview): Records every operation as a hierarchical timeline of spans, capturing inputs, outputs, token usage, and timing.
10
10
  - [**Logging**](https://mastra.ai/docs/observability/logging): Forwards structured log entries from your application and Mastra internals to observability storage, correlated to traces automatically.
11
11
  - [**Metrics**](https://mastra.ai/docs/observability/metrics/overview): Extracts trace usage and cost data. No additional instrumentation is required.
@@ -96,21 +96,137 @@ export const mastra = new Mastra({
96
96
  spanOutputProcessors: [
97
97
  new SensitiveDataFilter(), // Redacts sensitive data like passwords, tokens, keys
98
98
  ],
99
+ logging: {
100
+ enabled: true,
101
+ level: 'info',
102
+ },
99
103
  },
100
104
  },
101
105
  }),
102
106
  })
103
107
  ```
104
108
 
105
- It enables tracing, log forwarding, and metrics. Mastra also supports external tracing providers like Langfuse, Datadog, and any OpenTelemetry-compatible platform. Use [Configuration](https://mastra.ai/docs/observability/config), [Storage](https://mastra.ai/docs/observability/storage), and [Integrations overview](https://mastra.ai/docs/observability/integrations/overview) to set up observability.
109
+ It enables tracing, log forwarding, and metrics. Mastra also supports external tracing providers like Langfuse, Datadog, and any OpenTelemetry-compatible platform. See [Maintaining Studio access](#maintaining-studio-access) to keep Mastra Studio access while sending data to an external provider.
106
110
 
107
- ## Mastra platform
111
+ ## Configuration
108
112
 
109
- For hosted traces, logs, and metrics across projects and deploys, see [Observability on Mastra platform](https://mastra.ai/docs/mastra-platform/observability).
113
+ Observability is configured once on your Mastra instance and applies across traces, logs, and metrics.
114
+
115
+ ### Basic config
116
+
117
+ An observability config usually contains:
118
+
119
+ - `serviceName`: The service identifier attached to exported observability data.
120
+ - `exporters`: One or more destinations for traces, logs, and derived metrics.
121
+ - `spanOutputProcessors`: Transformations that run before spans are exported.
122
+ - `logging`: Log forwarding settings for observability storage.
123
+
124
+ For destinations and processors, see [Integrations overview](https://mastra.ai/docs/observability/integrations/overview).
125
+
126
+ ### Maintaining Studio access
127
+
128
+ When you add external exporters, keep `MastraStorageExporter` for Studio observability and/or `MastraPlatformExporter` for hosted Mastra platform observability.
129
+
130
+ The following example shows only the observability config. Configure storage separately.
131
+
132
+ ```ts
133
+ import { Observability, MastraStorageExporter, MastraPlatformExporter } from '@mastra/observability'
134
+ import { ArizeExporter } from '@mastra/arize'
135
+
136
+ export const observability = new Observability({
137
+ configs: {
138
+ production: {
139
+ serviceName: 'my-service',
140
+ exporters: [
141
+ new ArizeExporter({
142
+ endpoint: process.env.PHOENIX_COLLECTOR_ENDPOINT,
143
+ apiKey: process.env.PHOENIX_API_KEY,
144
+ }),
145
+ new MastraStorageExporter(),
146
+ new MastraPlatformExporter(),
147
+ ],
148
+ },
149
+ },
150
+ })
151
+ ```
152
+
153
+ ### Flushing in serverless environments
154
+
155
+ In serverless environments, flush observability exporters before the runtime pauses or exits:
156
+
157
+ ```ts
158
+ await mastra.observability.flush()
159
+ ```
160
+
161
+ Use external storage in serverless environments instead of local file storage. See [Storage](#storage) for storage selection and routing.
162
+
163
+ ### Multi-config setup
164
+
165
+ Use multiple configs when different environments or request types need different exporters or sampling behavior. Select the active config at runtime with `configSelector`.
166
+
167
+ ```ts
168
+ import { Mastra } from '@mastra/core'
169
+ import { Observability, MastraStorageExporter } from '@mastra/observability'
170
+ import { LangfuseExporter } from '@mastra/langfuse'
171
+
172
+ const storageExporter = new MastraStorageExporter()
173
+ const langfuseExporter = new LangfuseExporter()
174
+
175
+ export const mastra = new Mastra({
176
+ observability: new Observability({
177
+ configs: {
178
+ development: {
179
+ serviceName: 'my-service-dev',
180
+ exporters: [storageExporter],
181
+ },
182
+ production: {
183
+ serviceName: 'my-service-prod',
184
+ exporters: [storageExporter, langfuseExporter],
185
+ },
186
+ },
187
+ configSelector: () => process.env.NODE_ENV || 'development',
188
+ }),
189
+ })
190
+ ```
191
+
192
+ For trace sampling, see [Tracing](https://mastra.ai/docs/observability/tracing/overview).
110
193
 
111
194
  ## Storage
112
195
 
113
- Not all storage backends support every signal. Traces work with most backends, but metrics and logs require an OLAP-capable store like DuckDB (development) or ClickHouse (production). For setup guidance, see [Storage](https://mastra.ai/docs/observability/storage).
196
+ Storage determines which observability signals persist, which queries are available, and whether metrics aggregation works. Use a dedicated observability store instead of your primary application store.
197
+
198
+ ### Signal support
199
+
200
+ Storage support depends on the signal and workload. `MastraStorageExporter` can persist traces to ClickHouse, PostgreSQL, MSSQL, MongoDB, and LibSQL. Metrics require an analytics-capable store:
201
+
202
+ - DuckDB: Recommended for local testing and development.
203
+ - ClickHouse: Recommended for high-volume production observability.
204
+ - `PostgresStoreVNext`: Supports metrics when the observability domain is enabled. Always provide a time range to avoid full partition scans.
205
+ - Mastra platform: Use `MastraPlatformExporter` for hosted observability without managing the backend yourself.
206
+
207
+ For the complete provider list and supported tracing strategies, see [Mastra Storage exporter](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage). Use composite storage to route the `observability` domain separately when your primary store doesn't support observability or when the workload needs independent scaling.
208
+
209
+ ### Local development
210
+
211
+ For local development, use:
212
+
213
+ - `LibSQLStore` for primary application storage
214
+ - `DuckDBStore` for the `observability` domain
215
+ - `MastraStorageExporter` for local Studio access
216
+
217
+ ### Production deployment
218
+
219
+ Observability traffic is usually more write-heavy than the rest of the application. In production:
220
+
221
+ - Use `MastraStorageExporter` with ClickHouse for the `observability` domain when you keep observability in your own storage.
222
+ - Use `MastraPlatformExporter` for hosted Mastra platform observability instead of managing the backend yourself.
223
+ - Use composite storage when observability needs a different backend or scaling policy from your primary application data.
224
+
225
+ For backend compatibility details and exporter batching behavior, see [Mastra Storage exporter](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage).
226
+
227
+ ## Mastra platform
228
+
229
+ For hosted traces, logs, and metrics across projects and deploys, see [Observability on Mastra platform](https://mastra.ai/docs/mastra-platform/observability).
114
230
 
115
231
  ## Next steps
116
232
 
@@ -118,8 +234,6 @@ Not all storage backends support every signal. Traces work with most backends, b
118
234
  - [Logging](https://mastra.ai/docs/observability/logging)
119
235
  - [Metrics](https://mastra.ai/docs/observability/metrics/overview)
120
236
  - [Feedback](https://mastra.ai/docs/observability/feedback)
121
- - [Configuration](https://mastra.ai/docs/observability/config)
122
- - [Storage](https://mastra.ai/docs/observability/storage)
123
237
  - [Integrations overview](https://mastra.ai/docs/observability/integrations/overview)
124
238
  - [Mastra Studio](https://mastra.ai/docs/studio/observability)
125
239
  - [Automatic metrics reference](https://mastra.ai/reference/observability/metrics/automatic-metrics)
@@ -19,8 +19,8 @@ This page focuses on trace-specific concepts: span hierarchy, sampling, metadata
19
19
 
20
20
  To get started with tracing, configure observability in your Mastra instance and run an agent or workflow. You can configure behavior through the following features:
21
21
 
22
- - [Configuration](https://mastra.ai/docs/observability/config): Base observability config and multiple configs, plus serverless flushing
23
- - [Storage](https://mastra.ai/docs/observability/storage): Storage routing for traces, logs, and metrics
22
+ - [Configuration](https://mastra.ai/docs/observability/overview): Base observability config and multiple configs, plus serverless flushing
23
+ - [Storage](https://mastra.ai/docs/observability/overview): Storage routing for traces, logs, and metrics
24
24
  - [Integrations overview](https://mastra.ai/docs/observability/integrations/overview): Exporters, bridges, and processors
25
25
 
26
26
  ## Sampling strategies
@@ -73,7 +73,7 @@ The Mastra Client SDK exposes all resources served by the Mastra Server.
73
73
 
74
74
  Use `upsertStoredWorkflow()` to create or replace a persisted workflow definition. A successful upsert validates the complete definition, registers it with the running Mastra instance, and makes it available through the standard workflow execution API.
75
75
 
76
- The following example creates a mapping workflow, reads the stored definition, runs it, and then deletes it:
76
+ The following example shows the full lifecycle of a mapping workflow, from creation and inspection through execution and deletion:
77
77
 
78
78
  ```typescript
79
79
  import { MastraClient } from '@mastra/client-js'
@@ -4,6 +4,8 @@
4
4
 
5
5
  Server adapters let you run Mastra with your own HTTP server instead of the Hono server generated by `mastra build`. They provide more control over the server setup, including custom middleware ordering, authentication, logging, and deployment configuration. You can still integrate Mastra into any Node.js application without changing how agents or workflows execute.
6
6
 
7
+ > **Warning:** Server adapters use the `mastra` instance you pass them and don't run file-based discovery. Register agents on that instance in code. To use file-based agents, run Mastra as a separate server with `mastra dev` or `mastra build`.
8
+
7
9
  ## When to use server adapters
8
10
 
9
11
  - You want Mastra’s endpoints added automatically to an existing application
@@ -184,7 +184,7 @@ export const mastra = new Mastra({
184
184
  })
185
185
  ```
186
186
 
187
- You can also route `observability` to a dedicated analytics backend. See [observability storage](https://mastra.ai/docs/observability/storage) for an observability-specific example.
187
+ You can also route `observability` to a dedicated analytics backend. See the [observability quickstart](https://mastra.ai/docs/observability/overview) for an observability-specific example.
188
188
 
189
189
  ## Supported providers
190
190
 
@@ -211,4 +211,4 @@ Each provider page includes installation instructions, configuration parameters,
211
211
  - [Storage retention](https://mastra.ai/reference/storage/retention)
212
212
  - [Storage schemas](https://mastra.ai/reference/storage/overview)
213
213
  - [Memory](https://mastra.ai/docs/memory/overview)
214
- - [Observability storage](https://mastra.ai/docs/observability/storage)
214
+ - [Observability storage](https://mastra.ai/docs/observability/overview)
@@ -108,6 +108,23 @@ export const testWorkflow = createWorkflow({})
108
108
 
109
109
  The `structuredOutput.schema` option accepts any Standard JSON Schema. The agent will generate output conforming to this schema, and the step's `outputSchema` will be automatically set to match. Visit [Structured Output](https://mastra.ai/docs/agents/structured-output) for more options like error handling strategies and streaming with structured output.
110
110
 
111
+ ### The `.agent()` shorthand
112
+
113
+ Add an agent directly with `.agent()` instead of wrapping it in `createStep()`. It accepts the same options as `createStep(agent, options)`, plus an agent ID string in place of the instance:
114
+
115
+ ```typescript
116
+ import { testAgent } from '../agents/test-agent'
117
+
118
+ export const testWorkflow = createWorkflow({})
119
+ .map(async ({ inputData }) => ({
120
+ prompt: `Generate an article about: ${inputData.topic}`,
121
+ }))
122
+ .agent(testAgent, { structuredOutput: { schema: articleSchema } })
123
+ .commit()
124
+ ```
125
+
126
+ `.agent()` records a declarative entry in the workflow graph rather than an opaque step, so workflows built this way can be persisted as [stored workflows](https://mastra.ai/docs/workflows/stored-workflows). Visit [Workflow.agent()](https://mastra.ai/reference/workflows/workflow-methods/agent) for all parameters.
127
+
111
128
  ## Using tools in workflows
112
129
 
113
130
  Use tools in workflow steps to use existing tool logic. Call from a step's `.execute()` function when you need to prepare context or process responses. Compose tools as steps when you don't need to modify how the tool is used.
@@ -157,6 +174,18 @@ export const testWorkflow = createWorkflow({})
157
174
 
158
175
  Visit [Input Data Mapping](https://mastra.ai/docs/workflows/control-flow) for more information.
159
176
 
177
+ ### The `.tool()` shorthand
178
+
179
+ Add a tool directly with `.tool()` instead of wrapping it in `createStep()`. It accepts a tool instance or a registered tool ID string, plus step-level `retries` and `metadata`:
180
+
181
+ ```typescript
182
+ import { testTool } from '../tools/test-tool'
183
+
184
+ export const testWorkflow = createWorkflow({}).then(step1).tool(testTool).commit()
185
+ ```
186
+
187
+ Like `.agent()`, `.tool()` records a declarative entry, so the workflow can be persisted as a [stored workflow](https://mastra.ai/docs/workflows/stored-workflows). Visit [Workflow.tool()](https://mastra.ai/reference/workflows/workflow-methods/tool) for all parameters.
188
+
160
189
  ## Related
161
190
 
162
191
  - [Using Agents](https://mastra.ai/docs/agents/overview)
@@ -0,0 +1,146 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Stored workflows
4
+
5
+ > **Beta:** This feature is in beta. Breaking changes may occur without a major version bump until the API is stable.
6
+
7
+ Stored workflows are workflow definitions expressed as data instead of code. A definition is a JSON document that describes the workflow's schemas and step graph. Mastra validates the definition and registers it as a runnable workflow, then persists it in storage so it survives process restarts.
8
+
9
+ Because a definition contains no JavaScript closures, anything that can produce JSON can author a workflow: an HTTP client, an LLM, a visual editor, or your own tooling. Once registered, a stored workflow runs through the same execution API as a code-defined workflow.
10
+
11
+ ## When to use stored workflows
12
+
13
+ Use stored workflows when users, agents, visual editors, or external systems need to create workflows without changing application code or deploying again.
14
+
15
+ Keep defining workflows with [`createWorkflow()`](https://mastra.ai/docs/workflows/overview) when the workflow belongs in your application source or needs custom step functions. Stored workflows can invoke agents, tools, and workflows that are already registered on the `Mastra` instance.
16
+
17
+ ## Quickstart
18
+
19
+ The following example registers a tool and invokes it from a stored workflow. It then runs the workflow. `LibSQLStore` persists the definition in `mastra.db`, so Mastra can restore it after a restart.
20
+
21
+ ```typescript
22
+ import { Mastra } from '@mastra/core/mastra'
23
+ import { createTool } from '@mastra/core/tools'
24
+ import { LibSQLStore } from '@mastra/libsql'
25
+ import { z } from 'zod'
26
+
27
+ const greetingTool = createTool({
28
+ id: 'create-greeting',
29
+ description: 'Create a greeting for a name',
30
+ inputSchema: z.object({
31
+ name: z.string(),
32
+ }),
33
+ outputSchema: z.object({
34
+ message: z.string(),
35
+ }),
36
+ execute: async ({ name }) => ({
37
+ message: `Hello, ${name}!`,
38
+ }),
39
+ })
40
+
41
+ const mastra = new Mastra({
42
+ storage: new LibSQLStore({
43
+ id: 'mastra-storage',
44
+ url: 'file:./mastra.db',
45
+ }),
46
+ tools: { 'create-greeting': greetingTool },
47
+ })
48
+
49
+ await mastra.addStoredWorkflow({
50
+ id: 'greeting-workflow',
51
+ description: 'Create a greeting for the supplied name',
52
+ inputSchema: {
53
+ type: 'object',
54
+ properties: {
55
+ name: { type: 'string' },
56
+ },
57
+ required: ['name'],
58
+ },
59
+ outputSchema: {
60
+ type: 'object',
61
+ properties: {
62
+ message: { type: 'string' },
63
+ },
64
+ required: ['message'],
65
+ },
66
+ graph: [
67
+ {
68
+ type: 'tool',
69
+ id: 'greet',
70
+ toolId: 'create-greeting',
71
+ },
72
+ ],
73
+ })
74
+
75
+ const workflow = mastra.getWorkflow('greeting-workflow')
76
+ const run = await workflow.createRun()
77
+ const result = await run.start({
78
+ inputData: { name: 'Ada' },
79
+ })
80
+
81
+ if (result.status === 'success') {
82
+ console.log(result.result.message)
83
+ }
84
+ ```
85
+
86
+ The workflow prints `Hello, Ada!`. Calling [`addStoredWorkflow()`](https://mastra.ai/reference/core/addStoredWorkflow) validates the definition before it changes storage or the live workflow registry.
87
+
88
+ The definition uses JSON Schema because it must survive a JSON round trip. The `graph` describes which registered components to invoke and how data moves between them. See the [stored workflow definition reference](https://mastra.ai/reference/workflows/stored-workflow-definition) for every field and graph entry.
89
+
90
+ ## Build and update definitions
91
+
92
+ A definition can come from any source that produces JSON. For example, an API route can accept a definition created by a visual editor and register it directly:
93
+
94
+ ```typescript
95
+ const definition = await request.json()
96
+ await mastra.addStoredWorkflow(definition)
97
+ ```
98
+
99
+ ### Register dependencies first
100
+
101
+ Register referenced components on the same `Mastra` instance before adding the stored workflow. Agent and nested workflow entries use their intrinsic IDs. A tool entry uses its key from the `Mastra` `tools` object, so the quickstart registers the tool under `create-greeting` before referencing that key with `toolId`.
102
+
103
+ Use a `mapping` entry when one step's output doesn't match the next step's input. Mapping entries can read data from the workflow input and previous step results, along with workflow state and request context. The [definition reference](https://mastra.ai/reference/workflows/stored-workflow-definition) lists the supported mapping descriptors.
104
+
105
+ ### Replace a workflow
106
+
107
+ Add a new definition with the same `id` to replace the persisted definition and live registration:
108
+
109
+ ```typescript
110
+ await mastra.addStoredWorkflow(updatedDefinition)
111
+ ```
112
+
113
+ New runs use the updated graph. Runs that already started continue with their original graph.
114
+
115
+ ### Add nested workflows together
116
+
117
+ When a root workflow references helper workflows that aren't registered yet, add the full set with [`addStoredWorkflows()`](https://mastra.ai/reference/core/addStoredWorkflows):
118
+
119
+ ```typescript
120
+ await mastra.addStoredWorkflows([rootDefinition, helperDefinition])
121
+ ```
122
+
123
+ Mastra validates the bundle as a unit and determines the registration order from the dependencies. If validation fails, none of the definitions are registered.
124
+
125
+ ### Manage definitions over HTTP
126
+
127
+ Applications don't need direct access to the `Mastra` instance to manage stored workflows. Use one of these interfaces:
128
+
129
+ - [Client SDK workflows API](https://mastra.ai/reference/client-js/workflows): Call `upsertStoredWorkflow()` from a JavaScript or TypeScript client.
130
+ - [Server routes](https://mastra.ai/reference/server/routes): Send definitions to `POST /api/stored/workflows`.
131
+
132
+ On authenticated servers, stored-workflow management requires the `stored-workflows:read` and `stored-workflows:write` permissions. Running the registered workflow requires `workflows:execute`.
133
+
134
+ ### Persist definitions
135
+
136
+ Stored definitions use the `workflowDefinitions` storage domain. On startup, Mastra loads active definitions from storage and registers them in dependency order.
137
+
138
+ Without a storage adapter that supports this domain, `addStoredWorkflow()` still registers the workflow in memory, but the definition is lost when the process restarts. See the [storage reference](https://mastra.ai/reference/storage/overview) for adapter support.
139
+
140
+ ## Related
141
+
142
+ - [Stored workflow definition](https://mastra.ai/reference/workflows/stored-workflow-definition)
143
+ - [`Mastra.addStoredWorkflow()`](https://mastra.ai/reference/core/addStoredWorkflow)
144
+ - [`Mastra.addStoredWorkflows()`](https://mastra.ai/reference/core/addStoredWorkflows)
145
+ - [Client SDK workflows API](https://mastra.ai/reference/client-js/workflows)
146
+ - [Server routes](https://mastra.ai/reference/server/routes)