@mastra/mcp-docs-server 1.0.0-beta.6 → 1.0.0-beta.7

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 (74) hide show
  1. package/.docs/organized/changelogs/%40mastra%2Fastra.md +10 -10
  2. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +12 -12
  3. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +33 -33
  4. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +58 -58
  5. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +32 -32
  6. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +32 -32
  7. package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +6 -0
  8. package/.docs/organized/changelogs/%40mastra%2Fconvex.md +31 -0
  9. package/.docs/organized/changelogs/%40mastra%2Fcore.md +176 -176
  10. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +11 -11
  11. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +10 -10
  12. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +15 -15
  13. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +32 -32
  14. package/.docs/organized/changelogs/%40mastra%2Felasticsearch.md +9 -0
  15. package/.docs/organized/changelogs/%40mastra%2Flance.md +33 -33
  16. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +32 -32
  17. package/.docs/organized/changelogs/%40mastra%2Floggers.md +12 -12
  18. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +9 -9
  19. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +43 -43
  20. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +32 -32
  21. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +32 -32
  22. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +10 -10
  23. package/.docs/organized/changelogs/%40mastra%2Fpg.md +32 -32
  24. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +10 -10
  25. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +31 -31
  26. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +10 -10
  27. package/.docs/organized/changelogs/%40mastra%2Freact.md +7 -0
  28. package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -0
  29. package/.docs/organized/changelogs/%40mastra%2Fserver.md +58 -58
  30. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +10 -10
  31. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +33 -33
  32. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +10 -10
  33. package/.docs/organized/changelogs/create-mastra.md +7 -7
  34. package/.docs/organized/changelogs/mastra.md +14 -14
  35. package/.docs/organized/code-examples/ai-elements.md +1 -1
  36. package/.docs/organized/code-examples/ai-sdk-useChat.md +1 -1
  37. package/.docs/organized/code-examples/ai-sdk-v5.md +1 -1
  38. package/.docs/organized/code-examples/assistant-ui.md +1 -1
  39. package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +1 -1
  40. package/.docs/organized/code-examples/bird-checker-with-nextjs.md +1 -1
  41. package/.docs/organized/code-examples/crypto-chatbot.md +1 -1
  42. package/.docs/organized/code-examples/mcp-server-adapters.md +2 -2
  43. package/.docs/organized/code-examples/server-app-access.md +2 -2
  44. package/.docs/organized/code-examples/server-express-adapter.md +87 -0
  45. package/.docs/organized/code-examples/server-hono-adapter.md +85 -0
  46. package/.docs/raw/agents/overview.mdx +2 -111
  47. package/.docs/raw/agents/processors.mdx +1 -1
  48. package/.docs/raw/agents/structured-output.mdx +224 -0
  49. package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +10 -2
  50. package/.docs/raw/memory/working-memory.mdx +1 -0
  51. package/.docs/raw/observability/tracing/bridges/otel.mdx +25 -1
  52. package/.docs/raw/observability/tracing/exporters/arize.mdx +19 -0
  53. package/.docs/raw/observability/tracing/exporters/langfuse.mdx +63 -0
  54. package/.docs/raw/observability/tracing/exporters/otel.mdx +30 -19
  55. package/.docs/raw/observability/tracing/exporters/posthog.mdx +20 -0
  56. package/.docs/raw/observability/tracing/overview.mdx +6 -1
  57. package/.docs/raw/reference/observability/tracing/bridges/otel.mdx +27 -0
  58. package/.docs/raw/reference/observability/tracing/exporters/arize.mdx +25 -0
  59. package/.docs/raw/reference/observability/tracing/exporters/langfuse.mdx +43 -0
  60. package/.docs/raw/reference/observability/tracing/exporters/otel.mdx +27 -43
  61. package/.docs/raw/reference/server/create-route.mdx +314 -0
  62. package/.docs/raw/reference/server/express-adapter.mdx +193 -0
  63. package/.docs/raw/reference/server/hono-adapter.mdx +174 -0
  64. package/.docs/raw/reference/server/mastra-server.mdx +316 -0
  65. package/.docs/raw/reference/server/routes.mdx +250 -0
  66. package/.docs/raw/reference/streaming/workflows/timeTravelStream.mdx +170 -0
  67. package/.docs/raw/reference/tools/mcp-client.mdx +54 -1
  68. package/.docs/raw/reference/workflows/run-methods/timeTravel.mdx +310 -0
  69. package/.docs/raw/reference/workflows/run.mdx +14 -0
  70. package/.docs/raw/server-db/custom-adapters.mdx +380 -0
  71. package/.docs/raw/server-db/mastra-server.mdx +11 -32
  72. package/.docs/raw/server-db/server-adapters.mdx +286 -0
  73. package/CHANGELOG.md +8 -0
  74. package/package.json +4 -4
@@ -0,0 +1,286 @@
1
+ ---
2
+ title: "Server Adapters | Server & DB"
3
+ description: "Manually configure a Mastra server using Hono or Express adapters."
4
+ ---
5
+
6
+ import PropertiesTable from "@site/src/components/PropertiesTable";
7
+ import Tabs from "@theme/Tabs";
8
+ import TabItem from "@theme/TabItem";
9
+
10
+ # Server Adapters
11
+
12
+ Server adapters let you run Mastra with your own HTTP server instead of using `mastra build`. While `mastra build` generates a standalone server for you, adapters give you full control over the server setup, letting you integrate Mastra into any Node.js application.
13
+
14
+ Use adapters when you need to:
15
+
16
+ - **Integrate Mastra into an existing application** - Add Mastra endpoints to an Express or Hono app you already have running
17
+ - **Control middleware ordering** - Insert your own middleware before or after Mastra's authentication and routing
18
+ - **Deploy to platforms requiring specific server setup** - Some platforms like Cloudflare Workers or custom Docker setups need direct access to the server instance
19
+ - **Use Express instead of Hono** - `mastra build` uses Hono internally, but you may prefer Express for its ecosystem or team familiarity
20
+
21
+ :::info
22
+
23
+ For simple deployments without custom server requirements, use `mastra build` instead. It configures server setup, registers middleware, and applies deployment settings based on your project configuration. See [Server Configuration](/docs/v1/server-db/mastra-server).
24
+
25
+ :::
26
+
27
+ ## Available adapters
28
+
29
+ - **[@mastra/hono](/reference/v1/server/hono-adapter)** - Hono framework adapter
30
+ - **[@mastra/express](/reference/v1/server/express-adapter)** - Express framework adapter
31
+
32
+ ## Basic setup
33
+
34
+ Both adapters follow the same pattern. The adapter wraps your framework's app instance and registers Mastra's routes and middleware onto it.
35
+
36
+ 1. **Create your framework's app instance** - Initialize Hono or Express as you normally would
37
+ 2. **Create a `MastraServer`** - Pass your app and Mastra instance to the adapter
38
+ 3. **Call `init()`** - This registers context middleware, authentication, and all API routes
39
+
40
+ After `init()`, your app has all the Mastra endpoints (`/api/agents`, `/api/workflows`, etc.) and you can add your own routes before or after.
41
+
42
+ See the [Hono Adapter](/reference/v1/server/hono-adapter) or [Express Adapter](/reference/v1/server/express-adapter) docs for framework-specific setup and code examples.
43
+
44
+ ## Constructor options
45
+
46
+ Both adapters accept the same options:
47
+
48
+ <PropertiesTable
49
+ content={[
50
+ {
51
+ name: "app",
52
+ type: "Hono | Application",
53
+ description: "Framework app instance",
54
+ isOptional: false,
55
+ },
56
+ {
57
+ name: "mastra",
58
+ type: "Mastra",
59
+ description: "Mastra instance",
60
+ isOptional: false,
61
+ },
62
+ {
63
+ name: "prefix",
64
+ type: "string",
65
+ description: "Route path prefix (e.g., `/api/v2`)",
66
+ isOptional: true,
67
+ defaultValue: "''",
68
+ },
69
+ {
70
+ name: "openapiPath",
71
+ type: "string",
72
+ description: "Path to serve OpenAPI spec (e.g., `/openapi.json`)",
73
+ isOptional: true,
74
+ },
75
+ {
76
+ name: "bodyLimitOptions",
77
+ type: "{ maxSize: number, onError: (err) => unknown }",
78
+ description: "Request body size limits",
79
+ isOptional: true,
80
+ },
81
+ {
82
+ name: "streamOptions",
83
+ type: "{ redact?: boolean }",
84
+ description: "Stream redaction config. When true, redacts sensitive data from streams.",
85
+ isOptional: true,
86
+ defaultValue: "{ redact: true }",
87
+ },
88
+ {
89
+ name: "customRouteAuthConfig",
90
+ type: "Map<string, boolean>",
91
+ description: "Per-route auth overrides. Keys are `METHOD:PATH` (e.g., `GET:/api/health`). Value `false` makes route public, `true` requires auth.",
92
+ isOptional: true,
93
+ },
94
+ ]}
95
+ />
96
+
97
+ ## Initialization flow
98
+
99
+ Calling `init()` runs three steps in order. Understanding this flow helps when you need to insert your own middleware at specific points.
100
+
101
+ 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.
102
+ 2. **`registerAuthMiddleware()`** - Adds authentication and authorization middleware, but only if `server.auth` is configured in your Mastra instance. Skipped entirely if no auth is configured.
103
+ 3. **`registerRoutes()`** - Registers all Mastra API routes for agents, workflows, and other features. Also registers MCP routes if MCP servers are configured.
104
+
105
+ ### Manual initialization
106
+
107
+ For custom middleware ordering, call each method separately instead of `init()`. This is useful when you need middleware that runs before Mastra's context is set up, or when you need to insert logic between the initialization steps.
108
+
109
+ ```typescript title="server.ts" copy showLineNumbers
110
+ const server = new MastraServer({ app, mastra });
111
+
112
+ // Your middleware first
113
+ app.use(loggingMiddleware);
114
+
115
+ server.registerContextMiddleware();
116
+
117
+ // Middleware that needs Mastra context
118
+ app.use(customMiddleware);
119
+
120
+ server.registerAuthMiddleware();
121
+ await server.registerRoutes();
122
+
123
+ // Routes after Mastra
124
+ app.get('/health', ...);
125
+ ```
126
+
127
+ :::tip
128
+
129
+ Use manual initialization when you need middleware that runs before Mastra's context is available, or when you need to insert middleware between the context and auth steps.
130
+
131
+ :::
132
+
133
+ ## Adding custom routes
134
+
135
+ You can add your own routes to the app alongside Mastra's routes. Routes added after `init()` have access to the Mastra context (the Mastra instance, request context, authenticated user, etc.) through framework-specific mechanisms.
136
+
137
+ The timing matters: routes added before `init()` won't have Mastra context available, while routes added after `init()` will. See the framework-specific docs for syntax and examples:
138
+
139
+ - [Hono: Adding custom routes](/reference/v1/server/hono-adapter#adding-custom-routes)
140
+ - [Express: Adding custom routes](/reference/v1/server/express-adapter#adding-custom-routes)
141
+
142
+ ## Route prefixes
143
+
144
+ By default, Mastra routes are registered at `/api/agents`, `/api/workflows`, etc. Use the `prefix` option to change this, which is useful for API versioning or when integrating with an existing app that has its own `/api` routes.
145
+
146
+ ```typescript copy showLineNumbers
147
+ const server = new MastraServer({
148
+ app,
149
+ mastra,
150
+ prefix: '/api/v2',
151
+ });
152
+ ```
153
+
154
+ With this prefix, Mastra routes become `/api/v2/agents`, `/api/v2/workflows`, etc. Custom routes you add directly to the app are not affected by this prefix.
155
+
156
+ ## OpenAPI spec
157
+
158
+ Mastra can generate an OpenAPI specification for all registered routes. This is useful for documentation, client generation, or integration with API tools. Enable it by setting the `openapiPath` option:
159
+
160
+ ```typescript copy showLineNumbers
161
+ const server = new MastraServer({
162
+ app,
163
+ mastra,
164
+ openapiPath: '/openapi.json',
165
+ });
166
+ ```
167
+
168
+ The spec is generated from the Zod schemas defined on each route and served at the specified path. It includes all Mastra routes as well as any custom routes created with `createRoute()`.
169
+
170
+ ## Stream data redaction
171
+
172
+ When streaming agent responses over HTTP, the HTTP streaming layer redacts sensitive information from stream chunks before sending them to clients. This prevents accidental exposure of:
173
+
174
+ - System prompts and agent instructions
175
+ - Tool definitions and their parameters
176
+ - API keys and other credentials in request bodies
177
+ - Internal configuration data
178
+
179
+ This redaction happens at the HTTP boundary, so internal callbacks like `onStepFinish` still have access to the full request data for debugging and observability purposes.
180
+
181
+ By default, redaction is enabled. Configure this behavior via `streamOptions`:
182
+
183
+ ```typescript copy showLineNumbers
184
+ const server = new MastraServer({
185
+ app,
186
+ mastra,
187
+ streamOptions: {
188
+ redact: true, // Default
189
+ },
190
+ });
191
+ ```
192
+
193
+ Set `redact: false` only for internal services or debugging scenarios where you need access to the full request data in stream responses.
194
+
195
+ ## Per-route auth overrides
196
+
197
+ When authentication is configured on your Mastra instance, all routes require authentication by default. Sometimes you need exceptions: public health check endpoints, webhook receivers, or admin routes that need stricter controls.
198
+
199
+ Use `customRouteAuthConfig` to override authentication behavior for specific routes:
200
+
201
+ ```typescript copy showLineNumbers
202
+ const server = new MastraServer({
203
+ app,
204
+ mastra,
205
+ customRouteAuthConfig: new Map([
206
+ ['GET:/api/health', false], // Public health check
207
+ ['GET:/api/openapi.json', false], // Public API spec
208
+ ['POST:/api/webhooks/*', false], // Public webhook endpoints
209
+ ['POST:/api/admin/reset', true], // Require auth even if globally disabled
210
+ ['ALL:/api/internal/*', true], // Protect all methods on internal routes
211
+ ]),
212
+ });
213
+ ```
214
+
215
+ Keys follow the format `METHOD:PATH` where method is `GET`, `POST`, `PUT`, `DELETE`, or `ALL`. Paths support wildcards (`*`) for matching multiple routes. Setting a value to `false` makes the route public, while `true` requires authentication.
216
+
217
+ ## Accessing the app
218
+
219
+ After creating the adapter, you may need to access the underlying framework app instance—for example, to pass it to a platform's serve function or to add routes programmatically from another module.
220
+
221
+ ```typescript copy showLineNumbers
222
+ // Via the MastraServer instance
223
+ const app = server.getApp();
224
+
225
+ // Via the Mastra instance (available after adapter construction)
226
+ const app = mastra.getServerApp();
227
+ ```
228
+
229
+ Both methods return the same app instance. Use whichever is more convenient based on what's in scope.
230
+
231
+ ## Server config vs adapter options
232
+
233
+ When using server adapters, configuration comes from two places: the Mastra `server` config (passed to the `Mastra` constructor) and the adapter constructor options. Understanding which options come from where helps avoid confusion when settings don't seem to take effect.
234
+
235
+ ### Used by adapters
236
+
237
+ The adapter reads these settings from `mastra.getServer()`:
238
+
239
+ | Option | Description |
240
+ |--------|-------------|
241
+ | `auth` | Authentication config, used by `registerAuthMiddleware()`. |
242
+ | `bodySizeLimit` | Default body size limit in bytes. Can be overridden per-adapter via `bodyLimitOptions`. |
243
+
244
+ ### Adapter constructor only
245
+
246
+ These options are passed directly to the adapter constructor and are not read from the Mastra config:
247
+
248
+ | Option | Description |
249
+ |--------|-------------|
250
+ | `prefix` | Route path prefix |
251
+ | `openapiPath` | OpenAPI spec endpoint |
252
+ | `bodyLimitOptions` | Body size limit with custom error handler |
253
+ | `streamOptions` | Stream redaction settings |
254
+ | `customRouteAuthConfig` | Per-route auth overrides |
255
+
256
+ ### Not used by adapters
257
+
258
+ These `server` config options are only used by `mastra build` and have no effect when using adapters directly:
259
+
260
+ | Option | Used by |
261
+ |--------|---------|
262
+ | `port`, `host` | `mastra dev`, `mastra build` |
263
+ | `cors` | `mastra build` adds CORS middleware |
264
+ | `timeout` | `mastra build` |
265
+ | `apiRoutes` | `registerApiRoute()` for `mastra build` |
266
+ | `middleware` | Middleware config for `mastra build` |
267
+
268
+ 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.
269
+
270
+ ## MCP support
271
+
272
+ 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.
273
+
274
+ The adapter registers routes for both HTTP and SSE (Server-Sent Events) transports, enabling different client connection patterns.
275
+
276
+ See [MCP](/docs/v1/mcp/overview) for configuration details and how to set up MCP servers.
277
+
278
+ ## Related
279
+
280
+ - [Hono Adapter](/reference/v1/server/hono-adapter) - Hono-specific setup
281
+ - [Express Adapter](/reference/v1/server/express-adapter) - Express-specific setup
282
+ - [Custom Adapters](/docs/v1/server-db/custom-adapters) - Building adapters for other frameworks
283
+ - [Server Configuration](/docs/v1/server-db/mastra-server) - Using `mastra build` instead
284
+ - [Authentication](/docs/v1/auth) - Configuring auth for your server
285
+ - [MastraServer Reference](/reference/v1/server/mastra-server) - Full API reference
286
+ - [createRoute() Reference](/reference/v1/server/create-route) - Creating type-safe custom routes
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @mastra/mcp-docs-server
2
2
 
3
+ ## 1.0.0-beta.7
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`7a3c1b4`](https://github.com/mastra-ai/mastra/commit/7a3c1b41815496da2a8cfff4cfb0c712b4ebf535), [`3076c67`](https://github.com/mastra-ai/mastra/commit/3076c6778b18988ae7d5c4c5c466366974b2d63f), [`85d7ee1`](https://github.com/mastra-ai/mastra/commit/85d7ee18ff4e14d625a8a30ec6656bb49804989b), [`c6c1092`](https://github.com/mastra-ai/mastra/commit/c6c1092f8fbf76109303f69e000e96fd1960c4ce), [`81dc110`](https://github.com/mastra-ai/mastra/commit/81dc11008d147cf5bdc8996ead1aa61dbdebb6fc), [`bfe1de6`](https://github.com/mastra-ai/mastra/commit/bfe1de659a279e6b2204a1c540a1fb9919299c0a), [`7aedb74`](https://github.com/mastra-ai/mastra/commit/7aedb74883adf66af38e270e4068fd42e7a37036), [`8f02d80`](https://github.com/mastra-ai/mastra/commit/8f02d800777397e4b45d7f1ad041988a8b0c6630), [`d7aad50`](https://github.com/mastra-ai/mastra/commit/d7aad501ce61646b76b4b511e558ac4eea9884d0), [`def4a85`](https://github.com/mastra-ai/mastra/commit/def4a856057db7d79d1d7c64894a2236be8b4ddd), [`ce0a73a`](https://github.com/mastra-ai/mastra/commit/ce0a73abeaa75b10ca38f9e40a255a645d50ebfb), [`a02e542`](https://github.com/mastra-ai/mastra/commit/a02e542d23179bad250b044b17ff023caa61739f), [`a372c64`](https://github.com/mastra-ai/mastra/commit/a372c640ad1fd12e8f0613cebdc682fc156b4d95), [`8846867`](https://github.com/mastra-ai/mastra/commit/8846867ffa9a3746767618e314bebac08eb77d87), [`42a42cf`](https://github.com/mastra-ai/mastra/commit/42a42cf3132b9786feecbb8c13c583dce5b0e198), [`ae08bf0`](https://github.com/mastra-ai/mastra/commit/ae08bf0ebc6a4e4da992b711c4a389c32ba84cf4), [`21735a7`](https://github.com/mastra-ai/mastra/commit/21735a7ef306963554a69a89b44f06c3bcd85141), [`1d877b8`](https://github.com/mastra-ai/mastra/commit/1d877b8d7b536a251c1a7a18db7ddcf4f68d6f8b)]:
8
+ - @mastra/mcp@1.0.0-beta.5
9
+ - @mastra/core@1.0.0-beta.7
10
+
3
11
  ## 1.0.0-beta.6
4
12
 
5
13
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mcp-docs-server",
3
- "version": "1.0.0-beta.6",
3
+ "version": "1.0.0-beta.7",
4
4
  "description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -28,8 +28,8 @@
28
28
  "@modelcontextprotocol/sdk": "^1.17.5",
29
29
  "jsdom": "^26.1.0",
30
30
  "zod": "^3.25.76",
31
- "@mastra/mcp": "^1.0.0-beta.4",
32
- "@mastra/core": "1.0.0-beta.6"
31
+ "@mastra/core": "1.0.0-beta.7",
32
+ "@mastra/mcp": "^1.0.0-beta.5"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@hono/node-server": "^1.19.6",
@@ -46,7 +46,7 @@
46
46
  "typescript": "^5.8.3",
47
47
  "vitest": "4.0.12",
48
48
  "@internal/lint": "0.0.53",
49
- "@mastra/core": "1.0.0-beta.6"
49
+ "@mastra/core": "1.0.0-beta.7"
50
50
  },
51
51
  "homepage": "https://mastra.ai",
52
52
  "repository": {