@mastra/mcp-docs-server 1.2.19-alpha.4 → 1.2.19

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 (100) hide show
  1. package/.docs/docs/channels.md +28 -1
  2. package/.docs/docs/deployment/cloud-providers.md +1 -0
  3. package/.docs/docs/deployment/mastra-server.md +19 -0
  4. package/.docs/docs/deployment/overview.md +1 -0
  5. package/.docs/docs/deployment/workers.md +2 -2
  6. package/.docs/docs/harness/durable-agents.md +1 -1
  7. package/.docs/docs/mastra-platform/api.md +54 -0
  8. package/.docs/docs/mastra-platform/deploy.md +101 -0
  9. package/.docs/docs/mastra-platform/observability.md +3 -1
  10. package/.docs/docs/mastra-platform/server.md +6 -11
  11. package/.docs/docs/mastra-platform/studio.md +8 -10
  12. package/.docs/docs/memory/semantic-recall.md +19 -0
  13. package/.docs/docs/observability/feedback.md +14 -0
  14. package/.docs/docs/observability/integrations/exporters/mastra-storage.md +19 -14
  15. package/.docs/docs/observability/metrics/overview.md +31 -44
  16. package/.docs/docs/sandbox/overview.md +43 -0
  17. package/.docs/docs/server/middleware.md +30 -0
  18. package/.docs/docs/server/server-adapters.md +109 -34
  19. package/.docs/docs/storage.md +2 -0
  20. package/.docs/docs/subagents.md +6 -6
  21. package/.docs/integrations/channels/github.md +56 -9
  22. package/.docs/integrations/channels/imessage.md +150 -8
  23. package/.docs/integrations/databases/elasticsearch.md +156 -0
  24. package/.docs/integrations/databases/libsql.md +16 -0
  25. package/.docs/integrations/databases/mongodb.md +1 -1
  26. package/.docs/integrations/databases/postgresql.md +26 -0
  27. package/.docs/integrations/databases/valkey.md +99 -0
  28. package/.docs/integrations/deploy/kubernetes-helm.md +332 -0
  29. package/.docs/integrations/deploy/kubernetes.md +1 -1
  30. package/.docs/integrations/deploy/render.md +47 -61
  31. package/.docs/integrations/sandboxes/daytona.md +52 -0
  32. package/.docs/integrations/sandboxes/e2b-desktop.md +128 -0
  33. package/.docs/integrations/sandboxes/e2b.md +6 -0
  34. package/.docs/integrations/sandboxes/vercel.md +2 -2
  35. package/.docs/integrations/tools/parallel.md +240 -0
  36. package/.docs/integrations.md +5 -0
  37. package/.docs/models/environment-variables.md +9 -0
  38. package/.docs/models/gateways/netlify.md +12 -5
  39. package/.docs/models/gateways/openrouter.md +5 -10
  40. package/.docs/models/gateways/vercel.md +5 -5
  41. package/.docs/models/index.md +1 -1
  42. package/.docs/models/providers/agentrouter.md +17 -34
  43. package/.docs/models/providers/agnes.md +75 -0
  44. package/.docs/models/providers/aixy.md +73 -0
  45. package/.docs/models/providers/aki-io.md +14 -13
  46. package/.docs/models/providers/chutes.md +2 -2
  47. package/.docs/models/providers/cline-pass.md +4 -2
  48. package/.docs/models/providers/crof.md +3 -8
  49. package/.docs/models/providers/deepseek.md +4 -6
  50. package/.docs/models/providers/edenai.md +14 -14
  51. package/.docs/models/providers/evroc.md +3 -2
  52. package/.docs/models/providers/gmicloud.md +6 -4
  53. package/.docs/models/providers/huggingface.md +2 -1
  54. package/.docs/models/providers/hyper.md +5 -5
  55. package/.docs/models/providers/inceptron.md +2 -2
  56. package/.docs/models/providers/iteracompute.md +73 -0
  57. package/.docs/models/providers/kilo.md +26 -27
  58. package/.docs/models/providers/llmgateway-providers.md +18 -9
  59. package/.docs/models/providers/llmgateway.md +3 -5
  60. package/.docs/models/providers/llmtech.md +73 -0
  61. package/.docs/models/providers/nano-gpt.md +22 -13
  62. package/.docs/models/providers/neosmith.md +104 -0
  63. package/.docs/models/providers/nvidia.md +3 -1
  64. package/.docs/models/providers/ofox.md +2 -1
  65. package/.docs/models/providers/openai.md +2 -2
  66. package/.docs/models/providers/opencode-go.md +3 -2
  67. package/.docs/models/providers/opper.md +112 -0
  68. package/.docs/models/providers/pendra.md +78 -0
  69. package/.docs/models/providers/requesty.md +1 -1
  70. package/.docs/models/providers/standardcompute.md +73 -0
  71. package/.docs/models/providers/vivgrid.md +2 -1
  72. package/.docs/models/providers/wandb.md +2 -1
  73. package/.docs/models/providers/zai.md +2 -1
  74. package/.docs/models/providers.md +9 -0
  75. package/.docs/reference/agents/channels.md +1 -1
  76. package/.docs/reference/ai-sdk/handle-chat-stream.md +11 -0
  77. package/.docs/reference/ai-sdk/with-sse-heartbeat.md +47 -0
  78. package/.docs/reference/cli/mastra.md +10 -4
  79. package/.docs/reference/client-js/observability.md +1 -1
  80. package/.docs/reference/index.md +5 -0
  81. package/.docs/reference/observability/feedback.md +4 -0
  82. package/.docs/reference/observability/metrics/automatic-metrics.md +1 -1
  83. package/.docs/reference/observability/metrics/queries.md +462 -0
  84. package/.docs/reference/pubsub/valkey-streams.md +84 -0
  85. package/.docs/reference/rag/vector-databases.md +4 -4
  86. package/.docs/reference/server/elysia-adapter.md +184 -0
  87. package/.docs/reference/server/express-adapter.md +6 -8
  88. package/.docs/reference/server/hono-adapter.md +19 -6
  89. package/.docs/reference/storage/turso.md +88 -0
  90. package/.docs/reference/streaming/ChunkType.md +29 -1
  91. package/.docs/reference/streaming/agents/stream.md +1 -3
  92. package/.docs/reference/tools/mcp-client.md +41 -9
  93. package/.docs/reference/vectors/mongodb.md +11 -11
  94. package/.docs/reference/vectors/pg.md +2 -0
  95. package/.docs/reference/workspace/local-sandbox.md +2 -0
  96. package/.docs/reference/workspace/platform-sandbox.md +3 -1
  97. package/.docs/reference/workspace/sandbox.md +143 -3
  98. package/CHANGELOG.md +81 -0
  99. package/package.json +6 -6
  100. package/.docs/docs/observability/metrics/querying.md +0 -314
@@ -2,30 +2,38 @@
2
2
 
3
3
  # Metrics
4
4
 
5
- Mastra automatically emits performance and usage metrics from traced execution. There's no manual instrumentation needed. Metrics are derived from spans as they complete.
5
+ Mastra automatically derives metrics from spans as traced operations complete. No separate metric instrumentation is required.
6
6
 
7
- These categories of metrics are emitted automatically:
7
+ Mastra emits:
8
8
 
9
- - **Duration metrics**: Execution time for agents, workflows, tools, model calls, and processors.
10
- - **Token usage metrics**: Input and output token counts broken down by type (text, cache, audio, image, reasoning).
11
- - **Cost estimation**: Estimated cost per model call based on an embedded pricing registry.
9
+ - **Duration metrics** for agent runs, workflows, tools, model calls, and processors
10
+ - **Token usage metrics** for model input and output, including detailed token categories when the provider reports them
11
+ - **Cost estimates** calculated from token usage, provider, model, and an embedded pricing registry
12
12
 
13
- > **Note:** Metrics require an analytics-capable store for observability. Most relational databases (LibSQL, MSSQL) aren't supported for metrics. In-memory storage resets on restart.
14
- >
15
- > For local development, use [DuckDB](https://duckdb.org/) through `@mastra/duckdb`. For production, use [ClickHouse](https://clickhouse.com/) through `@mastra/clickhouse`. `PostgresStoreVNext` with the observability domain enabled also supports metrics, but always provide a time range to avoid full partition scans.
16
- >
17
- > Google Cloud Spanner supports metrics, but it's not recommended for heavy metrics workloads. The Spanner adapter disables metrics by default because metrics are write-heavy and scan-heavy. Set `disableMetrics: false` only for light workloads, or route metrics to an OLAP store.
13
+ Metrics retain trace correlation context, so you can investigate a change in a chart by finding the related span. See the [Automatic metrics reference](https://mastra.ai/reference/observability/metrics/automatic-metrics) for metric names, labels, and cost fields.
18
14
 
19
15
  ## When to use metrics
20
16
 
21
17
  - Monitor latency across agents, tools, workflows, and model calls
22
- - Track token consumption and cost trends over time
23
- - Identify error-heavy agents or tools by comparing success and error rates
24
- - Compare performance before and after prompt, model, or code changes
18
+ - Track token consumption and estimated cost over time
19
+ - Compare success and error rates across agents or tools
20
+ - Measure the effect of prompt, model, or code changes
25
21
 
26
- ## Get started
22
+ ## Storage support
27
23
 
28
- Install the required packages:
24
+ Metrics require an analytics-capable observability store:
25
+
26
+ - **DuckDB** through `@mastra/duckdb` is recommended for local development.
27
+ - **ClickHouse** through `@mastra/clickhouse` is recommended for high-volume production workloads.
28
+ - **PostgresStoreVNext** supports metrics when its observability domain is enabled.
29
+ - **In-memory storage** supports metrics, but its data is lost when the process restarts.
30
+ - **Google Cloud Spanner** disables metrics by default. Set `disableMetrics: false` only for light workloads, or route metrics to a dedicated OLAP store.
31
+
32
+ Other storage adapters, including LibSQL, MSSQL, and MongoDB, can store other observability signals but don't implement metric storage and queries.
33
+
34
+ ## Set up local metrics
35
+
36
+ Install the observability, application storage, and DuckDB packages:
29
37
 
30
38
  **npm**:
31
39
 
@@ -51,7 +59,7 @@ yarn add @mastra/observability @mastra/libsql @mastra/duckdb
51
59
  bun add @mastra/observability @mastra/libsql @mastra/duckdb
52
60
  ```
53
61
 
54
- Then configure observability with a composite store that routes the observability domain to DuckDB:
62
+ Configure a composite store that routes the observability domain to DuckDB:
55
63
 
56
64
  ```ts
57
65
  import { Mastra } from '@mastra/core/mastra'
@@ -83,37 +91,16 @@ export const mastra = new Mastra({
83
91
  })
84
92
  ```
85
93
 
86
- ## Studio
87
-
88
- The Studio metrics dashboard visualizes all automatic metrics with KPI cards, detailed breakdowns, token usage timelines, and configurable time ranges. See [Studio observability](https://mastra.ai/docs/studio/observability) for a full walkthrough.
89
-
90
- ## What Mastra measures
91
-
92
- Mastra emits three categories of metrics automatically:
94
+ `MastraStorageExporter` persists metrics to the configured observability store and makes them available to Studio. Use `MastraPlatformExporter` instead, or alongside it, to send metrics to Mastra Platform.
93
95
 
94
- - **Duration**: Execution time in milliseconds for agents, workflows, tools, model calls, and processors.
95
- - **Token usage**: Input and output token counts, broken down by type (text, cache, audio, image, reasoning).
96
- - **Cost estimation**: Estimated cost per model call, based on an embedded pricing registry.
96
+ ## View and query metrics
97
97
 
98
- Each metric carries trace correlation context so you can drill from a dashboard spike to the exact span that caused it.
98
+ Use the [Studio observability dashboard](https://mastra.ai/docs/studio/observability) to inspect KPI cards, breakdowns, and time-series charts. For custom dashboards and analysis, use the observability store, `@mastra/client-js`, HTTP endpoints, or CLI described in the [Metric queries reference](https://mastra.ai/reference/observability/metrics/queries).
99
99
 
100
- For the full list of metric names, labels, and cost fields, see the [Automatic metrics reference](https://mastra.ai/reference/observability/metrics/automatic-metrics).
100
+ In production, always include a timestamp range in metric queries. Time bounds limit the data scanned and allow partitioned backends to skip unrelated partitions or chunks.
101
101
 
102
- ## How automatic metrics work
102
+ ## Related
103
103
 
104
- Mastra auto-instruments agent runs, workflow steps, tool calls, and model generations as spans. When a span ends, the observability layer extracts metrics from it:
105
-
106
- 1. **Duration**: Calculated from the span's start and end timestamps.
107
- 2. **Token usage**: Extracted from the `usage` attribute on model generation spans.
108
- 3. **Cost estimation**: Runs each token metric through an embedded pricing registry that matches by provider and model name.
109
-
110
- Before storage, all metric labels pass through a cardinality filter that blocks known high-cardinality values (such as trace IDs and UUIDs) to keep storage efficient. Metrics are then batched by an internal event buffer and flushed to storage by the `MastraStorageExporter`.
111
-
112
- ## Next steps
113
-
114
- - [Automatic metrics reference](https://mastra.ai/reference/observability/metrics/automatic-metrics)
115
- - [Querying metrics](https://mastra.ai/docs/observability/metrics/querying)
116
- - [Tracing overview](https://mastra.ai/docs/observability/tracing/overview)
117
- - [Studio observability](https://mastra.ai/docs/studio/observability)
118
104
  - [Observability overview](https://mastra.ai/docs/observability/overview)
119
- - [MastraStorageExporter reference](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage)
105
+ - [Tracing overview](https://mastra.ai/docs/observability/tracing/overview)
106
+ - [MastraStorageExporter](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage)
@@ -73,6 +73,48 @@ Set `{ enabled: false }` on one tool to remove it, or set the top-level `enabled
73
73
 
74
74
  See the [sandbox tools reference](https://mastra.ai/reference/workspace/workspace-class) for all generated tools and the [tool configuration reference](https://mastra.ai/reference/workspace/workspace-class) for approvals, output limits, and hooks.
75
75
 
76
+ ### Computer-use tools
77
+
78
+ Sandboxes that run a desktop environment can expose screenshot, mouse, and keyboard control. The workspace registers these tools when a statically configured sandbox supports the computer capability:
79
+
80
+ | Tool | Does |
81
+ | -------------------------- | -------------------------------------------------------------------------------- |
82
+ | `computer_screenshot` | Captures the desktop as a PNG image and returns it to the model as native media. |
83
+ | `computer_click` | Presses and releases the left mouse button at pixel coordinates. |
84
+ | `computer_double_click` | Presses the left mouse button twice at pixel coordinates. |
85
+ | `computer_right_click` | Presses and releases the right mouse button at pixel coordinates. |
86
+ | `computer_move_mouse` | Moves the cursor to pixel coordinates without pressing a button. |
87
+ | `computer_drag` | Presses, drags, and releases between two points. |
88
+ | `computer_type` | Types text into the focused element. |
89
+ | `computer_press_key` | Presses a key or key combination, such as `Enter` or `ctrl+s`. |
90
+ | `computer_scroll` | Scrolls up or down. |
91
+ | `computer_get_screen_info` | Gets the screen dimensions and cursor position. |
92
+ | `computer_wait` | Waits for the interface to settle. |
93
+
94
+ [`DaytonaSandbox`](https://mastra.ai/integrations/sandboxes/daytona) and [`E2BDesktopSandbox`](https://mastra.ai/integrations/sandboxes/e2b-desktop) support this capability. Other sandbox backends don't register the computer tools. Resolver-backed sandboxes don't register them because the workspace can't inspect the resolved sandbox's capabilities when it creates the tool list.
95
+
96
+ Action tools take a screenshot after each action by default. Configure the screenshot behavior for each tool:
97
+
98
+ ```typescript
99
+ import { Workspace, WORKSPACE_TOOLS } from '@mastra/core/workspace'
100
+ import { E2BDesktopSandbox } from '@mastra/e2b-desktop'
101
+
102
+ const workspace = new Workspace({
103
+ sandbox: new E2BDesktopSandbox(),
104
+ tools: {
105
+ [WORKSPACE_TOOLS.COMPUTER.CLICK]: {
106
+ screenshotAfterAction: true,
107
+ screenshotDelayMs: 1000,
108
+ },
109
+ [WORKSPACE_TOOLS.COMPUTER.TYPE]: {
110
+ requireApproval: true,
111
+ },
112
+ },
113
+ })
114
+ ```
115
+
116
+ Computer tools accept the same per-tool `enabled` and `requireApproval` configuration as other workspace tools.
117
+
76
118
  Authored runtime functions, including tools and workflow steps, can get the live sandbox from their execution context. Use it to execute commands, install dependencies, process files, or spawn a long-running process.
77
119
 
78
120
  ```typescript
@@ -136,6 +178,7 @@ Use a remote or container sandbox when commands need a stronger boundary from th
136
178
  - [Daytona](https://mastra.ai/integrations/sandboxes/daytona)
137
179
  - [Docker](https://mastra.ai/integrations/sandboxes/docker)
138
180
  - [E2B](https://mastra.ai/integrations/sandboxes/e2b)
181
+ - [E2B Desktop](https://mastra.ai/integrations/sandboxes/e2b-desktop)
139
182
  - [Mastra](https://mastra.ai/reference/workspace/platform-sandbox)
140
183
  - [Modal](https://mastra.ai/integrations/sandboxes/modal)
141
184
  - [Railway](https://mastra.ai/integrations/sandboxes/railway)
@@ -6,6 +6,10 @@ Mastra servers can execute custom middleware functions before or after an API ro
6
6
 
7
7
  A middleware receives the [Hono](https://hono.dev) `Context` (`c`) and a `next` function. If it returns a `Response` the request is short-circuited. Calling `next()` continues processing the next middleware or route handler.
8
8
 
9
+ > **Note:** Middleware handlers use Hono's signature, so they run on Hono-based serving paths: `mastra dev` and `mastra build`, the [Hono adapter](https://mastra.ai/reference/server/hono-adapter), and adapters built on it such as `@mastra/next` and `@mastra/tanstack-start`. Adapters for other frameworks (Express, Fastify, Koa) can't run Hono handlers and log a warning at startup when middleware is configured. Register middleware through the framework's own API there instead.
10
+ >
11
+ > User middleware never runs on routes declared public with `requiresAuth: false`, so it can't block endpoints the framework needs to keep reachable, such as the Studio sign-in routes.
12
+
9
13
  ```typescript
10
14
  import { Mastra } from '@mastra/core'
11
15
 
@@ -54,6 +58,32 @@ registerApiRoute('/my-custom-route', {
54
58
 
55
59
  ## Common examples
56
60
 
61
+ ### Block built-in route groups
62
+
63
+ Mastra doesn't provide a configuration option to remove or allowlist built-in routes. On Hono-based serving paths, you can make selected route groups unavailable by returning a response without calling `next()`:
64
+
65
+ ```typescript
66
+ import { Mastra } from '@mastra/core'
67
+
68
+ const notFound = async () => new Response('Not Found', { status: 404 })
69
+
70
+ export const mastra = new Mastra({
71
+ server: {
72
+ middleware: [
73
+ { path: '/api/memory/*', handler: notFound },
74
+ { path: '/api/logs/*', handler: notFound },
75
+ { path: '/api/observability/*', handler: notFound },
76
+ ],
77
+ },
78
+ })
79
+ ```
80
+
81
+ Each wildcard pattern blocks both the route group itself and its nested routes. For example, `/api/logs/*` blocks `/api/logs` and `/api/logs/transports`. Other route groups remain available.
82
+
83
+ Generated servers pass `server.apiPrefix` to the Hono adapter's [`prefix` constructor option](https://mastra.ai/reference/server/hono-adapter), which prefixes built-in routes. Middleware paths are registered unchanged, so they must explicitly include the configured prefix. For example, with `apiPrefix: '/api/v2'`, use `/api/v2/memory/*`. Custom API routes must live outside the configured API prefix and aren't blocked by these patterns.
84
+
85
+ This approach can't block routes declared public with `requiresAuth: false`, because Mastra skips user middleware for those routes. With a non-Hono server adapter, register equivalent middleware through the server framework instead.
86
+
57
87
  ### Using `RequestContext`
58
88
 
59
89
  You can populate `RequestContext` in a runtime server middleware by extracting information from the request. In this example, the `temperature-unit` is set based on the Cloudflare `CF-IPCountry` header to ensure responses match the user's locale.
@@ -20,6 +20,7 @@ Server adapters let you run Mastra with your own HTTP server instead of the Hono
20
20
 
21
21
  Mastra currently provides these official server adapters:
22
22
 
23
+ - [@mastra/elysia](https://mastra.ai/reference/server/elysia-adapter)
23
24
  - [@mastra/express](https://mastra.ai/reference/server/express-adapter)
24
25
  - [@mastra/hono](https://mastra.ai/reference/server/hono-adapter)
25
26
  - [@mastra/fastify](https://mastra.ai/reference/server/fastify-adapter)
@@ -32,8 +33,58 @@ You can build your own adapter, read [custom adapters](https://mastra.ai/docs/se
32
33
 
33
34
  Install the adapter for the framework of your choice.
34
35
 
36
+ **Elysia**:
37
+
38
+ **npm**:
39
+
40
+ ```bash
41
+ npm install @mastra/elysia@latest elysia
42
+ ```
43
+
44
+ **pnpm**:
45
+
46
+ ```bash
47
+ pnpm add @mastra/elysia@latest elysia
48
+ ```
49
+
50
+ **Yarn**:
51
+
52
+ ```bash
53
+ yarn add @mastra/elysia@latest elysia
54
+ ```
55
+
56
+ **Bun**:
57
+
58
+ ```bash
59
+ bun add @mastra/elysia@latest elysia
60
+ ```
61
+
35
62
  **Express**:
36
63
 
64
+ ```bash
65
+ npm install @mastra/elysia@latest elysia
66
+ ```
67
+
68
+ **Hono**:
69
+
70
+ ```bash
71
+ pnpm add @mastra/elysia@latest elysia
72
+ ```
73
+
74
+ **Fastify**:
75
+
76
+ ```bash
77
+ yarn add @mastra/elysia@latest elysia
78
+ ```
79
+
80
+ **Koa**:
81
+
82
+ ```bash
83
+ bun add @mastra/elysia@latest elysia
84
+ ```
85
+
86
+ **NestJS**:
87
+
37
88
  **npm**:
38
89
 
39
90
  ```bash
@@ -58,31 +109,31 @@ yarn add @mastra/express@latest
58
109
  bun add @mastra/express@latest
59
110
  ```
60
111
 
61
- **Hono**:
112
+ **Tab 7**:
62
113
 
63
114
  ```bash
64
115
  npm install @mastra/express@latest
65
116
  ```
66
117
 
67
- **Fastify**:
118
+ **Tab 8**:
68
119
 
69
120
  ```bash
70
121
  pnpm add @mastra/express@latest
71
122
  ```
72
123
 
73
- **Koa**:
124
+ **Tab 9**:
74
125
 
75
126
  ```bash
76
127
  yarn add @mastra/express@latest
77
128
  ```
78
129
 
79
- **NestJS**:
130
+ **Tab 10**:
80
131
 
81
132
  ```bash
82
133
  bun add @mastra/express@latest
83
134
  ```
84
135
 
85
- **Tab 6**:
136
+ **Tab 11**:
86
137
 
87
138
  **npm**:
88
139
 
@@ -108,31 +159,31 @@ yarn add @mastra/hono@latest
108
159
  bun add @mastra/hono@latest
109
160
  ```
110
161
 
111
- **Tab 7**:
162
+ **Tab 12**:
112
163
 
113
164
  ```bash
114
165
  npm install @mastra/hono@latest
115
166
  ```
116
167
 
117
- **Tab 8**:
168
+ **Tab 13**:
118
169
 
119
170
  ```bash
120
171
  pnpm add @mastra/hono@latest
121
172
  ```
122
173
 
123
- **Tab 9**:
174
+ **Tab 14**:
124
175
 
125
176
  ```bash
126
177
  yarn add @mastra/hono@latest
127
178
  ```
128
179
 
129
- **Tab 10**:
180
+ **Tab 15**:
130
181
 
131
182
  ```bash
132
183
  bun add @mastra/hono@latest
133
184
  ```
134
185
 
135
- **Tab 11**:
186
+ **Tab 16**:
136
187
 
137
188
  **npm**:
138
189
 
@@ -158,31 +209,31 @@ yarn add @mastra/fastify@latest
158
209
  bun add @mastra/fastify@latest
159
210
  ```
160
211
 
161
- **Tab 12**:
212
+ **Tab 17**:
162
213
 
163
214
  ```bash
164
215
  npm install @mastra/fastify@latest
165
216
  ```
166
217
 
167
- **Tab 13**:
218
+ **Tab 18**:
168
219
 
169
220
  ```bash
170
221
  pnpm add @mastra/fastify@latest
171
222
  ```
172
223
 
173
- **Tab 14**:
224
+ **Tab 19**:
174
225
 
175
226
  ```bash
176
227
  yarn add @mastra/fastify@latest
177
228
  ```
178
229
 
179
- **Tab 15**:
230
+ **Tab 20**:
180
231
 
181
232
  ```bash
182
233
  bun add @mastra/fastify@latest
183
234
  ```
184
235
 
185
- **Tab 16**:
236
+ **Tab 21**:
186
237
 
187
238
  **npm**:
188
239
 
@@ -208,31 +259,31 @@ yarn add @mastra/koa@latest
208
259
  bun add @mastra/koa@latest
209
260
  ```
210
261
 
211
- **Tab 17**:
262
+ **Tab 22**:
212
263
 
213
264
  ```bash
214
265
  npm install @mastra/koa@latest
215
266
  ```
216
267
 
217
- **Tab 18**:
268
+ **Tab 23**:
218
269
 
219
270
  ```bash
220
271
  pnpm add @mastra/koa@latest
221
272
  ```
222
273
 
223
- **Tab 19**:
274
+ **Tab 24**:
224
275
 
225
276
  ```bash
226
277
  yarn add @mastra/koa@latest
227
278
  ```
228
279
 
229
- **Tab 20**:
280
+ **Tab 25**:
230
281
 
231
282
  ```bash
232
283
  bun add @mastra/koa@latest
233
284
  ```
234
285
 
235
- **Tab 21**:
286
+ **Tab 26**:
236
287
 
237
288
  **npm**:
238
289
 
@@ -258,25 +309,25 @@ yarn add @mastra/nestjs@latest
258
309
  bun add @mastra/nestjs@latest
259
310
  ```
260
311
 
261
- **Tab 22**:
312
+ **Tab 27**:
262
313
 
263
314
  ```bash
264
315
  npm install @mastra/nestjs@latest
265
316
  ```
266
317
 
267
- **Tab 23**:
318
+ **Tab 28**:
268
319
 
269
320
  ```bash
270
321
  pnpm add @mastra/nestjs@latest
271
322
  ```
272
323
 
273
- **Tab 24**:
324
+ **Tab 29**:
274
325
 
275
326
  ```bash
276
327
  yarn add @mastra/nestjs@latest
277
328
  ```
278
329
 
279
- **Tab 25**:
330
+ **Tab 30**:
280
331
 
281
332
  ```bash
282
333
  bun add @mastra/nestjs@latest
@@ -286,6 +337,25 @@ bun add @mastra/nestjs@latest
286
337
 
287
338
  Initialize your app as usual, then create a `MastraServer` by passing in the `app` and your main `mastra` instance from `src/mastra/index.ts`. Calling `init()` automatically registers Mastra middleware and all available endpoints. You can continue adding your own routes as normal, either before or after `init()`, and they’ll run alongside Mastra’s endpoints.
288
339
 
340
+ **Elysia**:
341
+
342
+ ```typescript
343
+ import { Elysia } from 'elysia'
344
+ import { MastraServer } from '@mastra/elysia'
345
+ import { mastra } from './mastra'
346
+
347
+ const app = new Elysia()
348
+ const server = new MastraServer({ app, mastra })
349
+
350
+ await server.init()
351
+
352
+ app.listen(4111)
353
+
354
+ console.log('Server running on http://localhost:4111')
355
+ ```
356
+
357
+ > **Note:** See the [Elysia Adapter](https://mastra.ai/reference/server/elysia-adapter) documentation for full configuration options.
358
+
289
359
  **Express**:
290
360
 
291
361
  ```typescript
@@ -424,11 +494,12 @@ See the [NestJS Adapter](https://mastra.ai/reference/server/nestjs-adapter) docu
424
494
 
425
495
  ## Initialization flow
426
496
 
427
- Calling `init()` runs three steps in order. Understanding this flow helps when you need to insert your own middleware at specific points.
497
+ Calling `init()` runs four steps in order. Understanding this flow helps when you need to insert your own middleware at specific points.
428
498
 
429
499
  1. `registerContextMiddleware()`: Attaches the Mastra instance, request context, tools, and abort signal to every request. This makes Mastra available to all subsequent middleware and route handlers.
430
500
  2. `registerAuthMiddleware()`: Runs the adapter auth hook during initialization. Official adapters enforce auth inline when Mastra registers built-in routes and `registerApiRoute()` routes, so raw framework routes should use the adapter's exported `createAuthMiddleware()` helper when they need Mastra auth.
431
- 3. `registerRoutes()`: Registers all Mastra API routes for agents, workflows, and other features. Also registers MCP routes if MCP servers are configured.
501
+ 3. `registerUserMiddleware()`: Registers [middleware](https://mastra.ai/docs/server/middleware) from the `server.middleware` config and `mastra.setServerMiddleware()`. Middleware handlers use Hono's signature, so Hono-based adapters (`@mastra/hono` and the adapters built on it) mount them; other adapters log a warning instead of silently ignoring the config.
502
+ 4. `registerRoutes()`: Registers all Mastra API routes for agents, workflows, and other features. Also registers MCP routes if MCP servers are configured.
432
503
 
433
504
  ### Manual initialization
434
505
 
@@ -445,6 +516,9 @@ server.registerContextMiddleware();
445
516
  // Middleware that needs Mastra context
446
517
  app.use(customMiddleware);
447
518
 
519
+ // Registers `server.middleware` and `setServerMiddleware()` middleware
520
+ server.registerUserMiddleware();
521
+
448
522
  await server.registerRoutes();
449
523
 
450
524
  // Routes after Mastra
@@ -462,7 +536,7 @@ You can add your own routes to the app alongside Mastra's routes.
462
536
  - When you want Mastra-managed auth and route metadata such as `requiresAuth`, prefer `registerApiRoute()`.
463
537
  - When you mount routes directly on the framework app, use the adapter's exported `createAuthMiddleware()` helper if those routes need Mastra auth.
464
538
 
465
- Visit "Adding custom routes" for [Express](https://mastra.ai/reference/server/express-adapter) and [Hono](https://mastra.ai/reference/server/hono-adapter) for more information.
539
+ Visit "Adding custom routes" for [Elysia](https://mastra.ai/reference/server/elysia-adapter), [Express](https://mastra.ai/reference/server/express-adapter), and [Hono](https://mastra.ai/reference/server/hono-adapter) for more information.
466
540
 
467
541
  ## Route prefixes
468
542
 
@@ -566,11 +640,12 @@ When using server adapters, configuration comes from two places: the Mastra `ser
566
640
 
567
641
  The adapter reads these settings from `mastra.getServer()`:
568
642
 
569
- | Option | Description |
570
- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
571
- | `auth` | Authentication config, used by `registerAuthMiddleware()`. |
572
- | `bodySizeLimit` | Default body size limit in bytes. Can be overridden per-adapter via `bodyLimitOptions`. |
573
- | `onError` | Custom error handler called when an unhandled error occurs in a route handler. See [server.onError](https://mastra.ai/reference/configuration). |
643
+ | Option | Description |
644
+ | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
645
+ | `auth` | Authentication config, used by `registerAuthMiddleware()`. |
646
+ | `bodySizeLimit` | Default body size limit in bytes. Can be overridden per-adapter via `bodyLimitOptions`. |
647
+ | `onError` | Custom error handler called when an unhandled error occurs in a route handler. See [server.onError](https://mastra.ai/reference/configuration). |
648
+ | `middleware` | User [middleware](https://mastra.ai/docs/server/middleware), registered by `registerUserMiddleware()`. Hono-based adapters run it; Express, Fastify, and Koa log a warning because Hono handlers can't run there. |
574
649
 
575
650
  ### Adapter constructor only
576
651
 
@@ -595,7 +670,6 @@ These `server` config options are only used by `mastra build` and have no effect
595
670
  | `cors` | `mastra build` adds CORS middleware |
596
671
  | `timeout` | `mastra build` |
597
672
  | `apiRoutes` | `registerApiRoute()` for `mastra build` |
598
- | `middleware` | Middleware config for `mastra build` |
599
673
 
600
674
  When using adapters, configure these features directly with your framework. For example, add CORS middleware using Hono's or Express's built-in CORS packages, and set the port when calling your framework's listen function.
601
675
 
@@ -603,7 +677,7 @@ When using adapters, configure these features directly with your framework. For
603
677
 
604
678
  Server adapters register MCP (Model Context Protocol) routes during `registerRoutes()` when MCP servers are configured in your Mastra instance. MCP allows external tools and services to connect to your Mastra server and interact with your agents.
605
679
 
606
- The adapter registers routes for both HTTP and SSE (Server-Sent Events) transports, enabling different client connection patterns.
680
+ Most adapters register routes for both HTTP and SSE (Server-Sent Events) transports, enabling different client connection patterns. The Elysia adapter currently supports MCP HTTP transport only.
607
681
 
608
682
  ### Serverless mode
609
683
 
@@ -639,6 +713,7 @@ See [MCP](https://mastra.ai/docs/connections/mcp) for configuration details and
639
713
 
640
714
  ## Related
641
715
 
716
+ - [Elysia Adapter](https://mastra.ai/reference/server/elysia-adapter) - Elysia-specific setup
642
717
  - [Hono Adapter](https://mastra.ai/reference/server/hono-adapter) - Hono-specific setup
643
718
  - [Express Adapter](https://mastra.ai/reference/server/express-adapter) - Express-specific setup
644
719
  - [NestJS Adapter](https://mastra.ai/reference/server/nestjs-adapter) - NestJS-specific setup
@@ -197,6 +197,7 @@ Each provider page includes installation instructions, configuration parameters,
197
197
  - [Convex](https://mastra.ai/integrations/databases/convex)
198
198
  - [DuckDB](https://mastra.ai/integrations/databases/duckdb)
199
199
  - [DynamoDB](https://mastra.ai/integrations/databases/dynamodb)
200
+ - [Elasticsearch](https://mastra.ai/integrations/databases/elasticsearch)
200
201
  - [Google Cloud Spanner](https://mastra.ai/integrations/databases/spanner)
201
202
  - [LanceDB](https://mastra.ai/integrations/databases/lancedb)
202
203
  - [libSQL](https://mastra.ai/integrations/databases/libsql)
@@ -207,6 +208,7 @@ Each provider page includes installation instructions, configuration parameters,
207
208
  - [OracleDB](https://mastra.ai/integrations/databases/oracledb)
208
209
  - [PostgreSQL](https://mastra.ai/integrations/databases/postgresql)
209
210
  - [Redis](https://mastra.ai/integrations/databases/redis)
211
+ - [Valkey](https://mastra.ai/integrations/databases/valkey)
210
212
  - [Upstash](https://mastra.ai/integrations/databases/upstash)
211
213
 
212
214
  ## Next steps
@@ -159,12 +159,12 @@ const stream = await parentAgent.stream('Research AI trends', {
159
159
 
160
160
  The `context` object includes:
161
161
 
162
- | Property | Description |
163
- | ------------- | ---------------------------------------- |
164
- | `primitiveId` | The ID of the subagent that ran |
165
- | `result` | The subagent's response |
166
- | `error` | Error if the delegation failed |
167
- | `bail()` | Function to stop the parent agent's loop |
162
+ | Property | Description |
163
+ | ------------- | --------------------------------------------------------------------------------------------- |
164
+ | `primitiveId` | The ID of the subagent that ran |
165
+ | `result` | The subagent's response, including `text`, `usage`, `finishReason`, and `subAgentToolResults` |
166
+ | `error` | Error if the delegation failed |
167
+ | `bail()` | Function to stop the parent agent's loop |
168
168
 
169
169
  ### Hook errors
170
170