@mastra/mcp-docs-server 1.3.13-alpha.9 → 1.3.13

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 (55) hide show
  1. package/.docs/docs/agents/code-mode.md +4 -0
  2. package/.docs/docs/agents/tools.md +10 -2
  3. package/.docs/docs/auth/custom-auth-provider.md +66 -0
  4. package/.docs/docs/auth/jwt.md +1 -1
  5. package/.docs/docs/connections/mcp.md +4 -65
  6. package/.docs/docs/evals/overview.md +4 -0
  7. package/.docs/docs/harness/schedules.md +1 -1
  8. package/.docs/docs/memory/multi-user-threads.md +57 -127
  9. package/.docs/docs/memory/observational-memory.md +196 -756
  10. package/.docs/docs/memory/overview.md +4 -0
  11. package/.docs/docs/observability/feedback.md +5 -7
  12. package/.docs/docs/sandbox/overview.md +2 -0
  13. package/.docs/docs/sandbox/search.md +25 -0
  14. package/.docs/docs/server/mcp.md +315 -0
  15. package/.docs/docs/server/request-context.md +35 -0
  16. package/.docs/docs/studio/deployment.md +0 -1
  17. package/.docs/docs/studio/overview.md +4 -4
  18. package/.docs/docs/workflows/scheduled-workflows.md +26 -5
  19. package/.docs/integrations/sandboxes/docker.md +39 -0
  20. package/.docs/integrations/sandboxes/e2b.md +1 -1
  21. package/.docs/integrations/voice/openai.md +2 -2
  22. package/.docs/models/gateways/custom-gateways.md +74 -44
  23. package/.docs/reference/agents/generate.md +1 -1
  24. package/.docs/reference/agents/generateLegacy.md +7 -23
  25. package/.docs/reference/auth/jwt.md +26 -2
  26. package/.docs/reference/cli/mastra.md +74 -6
  27. package/.docs/reference/client-js/observability.md +13 -5
  28. package/.docs/reference/configuration.md +64 -0
  29. package/.docs/reference/connect/tools.md +59 -0
  30. package/.docs/reference/editor/mastra-editor.md +1 -1
  31. package/.docs/reference/index.md +1 -0
  32. package/.docs/reference/memory/observational-memory.md +350 -151
  33. package/.docs/reference/observability/feedback.md +57 -14
  34. package/.docs/reference/observability/tracing/advanced-queries.md +3 -1
  35. package/.docs/reference/observability/tracing/exporters/langfuse.md +24 -1
  36. package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +19 -16
  37. package/.docs/reference/observability/tracing/exporters/otel.md +1 -1
  38. package/.docs/reference/observability/tracing/interfaces.md +2 -2
  39. package/.docs/reference/observability/tracing/spans.md +7 -1
  40. package/.docs/reference/processors/processor-interface.md +23 -0
  41. package/.docs/reference/rag/chunk.md +1 -1
  42. package/.docs/reference/rag/graph-rag-guide.md +3 -1
  43. package/.docs/reference/schedules/overview.md +25 -5
  44. package/.docs/reference/server/dispatch-route.md +124 -0
  45. package/.docs/reference/server/elysia-adapter.md +1 -1
  46. package/.docs/reference/server/express-adapter.md +17 -11
  47. package/.docs/reference/server/fastify-adapter.md +1 -1
  48. package/.docs/reference/server/hono-adapter.md +1 -1
  49. package/.docs/reference/server/invoke-route.md +10 -0
  50. package/.docs/reference/server/koa-adapter.md +1 -1
  51. package/.docs/reference/server/nestjs-adapter.md +1 -1
  52. package/.docs/reference/streaming/agents/stream.md +1 -1
  53. package/.docs/reference/workspace/factory-sandbox.md +20 -1
  54. package/.docs/reference/workspace/platform-sandbox.md +1 -1
  55. package/package.json +5 -5
@@ -74,7 +74,7 @@ Express requires `express.json()` middleware for JSON body parsing. Add it befor
74
74
 
75
75
  **taskStore** (`InMemoryTaskStore`): Task store for A2A (Agent-to-Agent) operations
76
76
 
77
- **mcpOptions** (`MCPOptions`): MCP transport options, such as setRequestAuth to control what tools see as context.mcp.extra.authInfo.
77
+ **mcpOptions** (`MCPOptions`): MCP transport options, such as setRequestAuth to control what tools see as context.mcp.extra.authInfo. Defaults to server.mcpOptions from your Mastra config.
78
78
 
79
79
  ## Differences from Hono
80
80
 
@@ -126,7 +126,10 @@ const server = new MastraServer({ app, mastra })
126
126
  await server.init()
127
127
 
128
128
  app.get('/custom/protected', createAuthMiddleware({ mastra }), (req, res) => {
129
- const user = res.locals.requestContext.get('user')
129
+ const user = res.locals.requestContext?.get('mastra__user')
130
+ if (!user) {
131
+ return res.status(401).json({ error: 'Unauthorized' })
132
+ }
130
133
  res.json({ user })
131
134
  })
132
135
 
@@ -135,6 +138,8 @@ app.get('/custom/public', createAuthMiddleware({ mastra, requiresAuth: false }),
135
138
  })
136
139
  ```
137
140
 
141
+ `createAuthMiddleware()` calls the next handler without authenticating when the Mastra server has no `auth` config, or when the route matches a public pattern. Public patterns include the built-in defaults (`/api` and `/api/auth/*`) and any `auth.public` patterns you configure. In those cases `mastra__user` isn't set, so protected handlers should reject requests without it, as the example above does.
142
+
138
143
  ## Accessing context
139
144
 
140
145
  In Express middleware and routes, access Mastra context via `res.locals`:
@@ -152,15 +157,16 @@ app.get('/custom', (req, res) => {
152
157
 
153
158
  Available properties on `res.locals`:
154
159
 
155
- | Key | Description |
156
- | ----------------------- | --------------------------------------- |
157
- | `mastra` | Mastra instance |
158
- | `requestContext` | Request context map |
159
- | `abortSignal` | Request cancellation signal |
160
- | `registeredTools` | Tools registered with the adapter |
161
- | `taskStore` | Task store for A2A operations |
162
- | `customRouteAuthConfig` | Per-route auth overrides |
163
- | `user` | Authenticated user (if auth configured) |
160
+ | Key | Description |
161
+ | ----------------------- | --------------------------------- |
162
+ | `mastra` | Mastra instance |
163
+ | `requestContext` | Request context map |
164
+ | `abortSignal` | Request cancellation signal |
165
+ | `registeredTools` | Tools registered with the adapter |
166
+ | `taskStore` | Task store for A2A operations |
167
+ | `customRouteAuthConfig` | Per-route auth overrides |
168
+
169
+ When auth is configured, read the authenticated user with `res.locals.requestContext.get('mastra__user')`. Clients can't set the reserved `mastra__user` key through the `requestContext` query parameter or body. On raw Express routes, the value is only populated after [`createAuthMiddleware()`](#adding-custom-routes) runs, so apply it before trusting the user. Don't rely on the legacy `user` key for authorization. A client can supply it on routes without auth middleware.
164
170
 
165
171
  ## Adding middleware
166
172
 
@@ -77,7 +77,7 @@ app.listen({ port: 3000 }, (err, address) => {
77
77
 
78
78
  **taskStore** (`InMemoryTaskStore`): Task store for A2A (Agent-to-Agent) operations
79
79
 
80
- **mcpOptions** (`MCPOptions`): MCP transport options, such as setRequestAuth to control what tools see as context.mcp.extra.authInfo.
80
+ **mcpOptions** (`MCPOptions`): MCP transport options, such as setRequestAuth to control what tools see as context.mcp.extra.authInfo. Defaults to server.mcpOptions from your Mastra config.
81
81
 
82
82
  ## Protecting raw routes
83
83
 
@@ -71,7 +71,7 @@ export default app
71
71
 
72
72
  **taskStore** (`InMemoryTaskStore`): Task store for A2A (Agent-to-Agent) operations
73
73
 
74
- **mcpOptions** (`MCPOptions`): MCP transport options, such as setRequestAuth to control what tools see as context.mcp.extra.authInfo.
74
+ **mcpOptions** (`MCPOptions`): MCP transport options, such as setRequestAuth to control what tools see as context.mcp.extra.authInfo. Defaults to server.mcpOptions from your Mastra config.
75
75
 
76
76
  ## Adding custom routes
77
77
 
@@ -79,8 +79,18 @@ Failed checks and errors thrown by the handler are returned as a status and body
79
79
  - **Only JSON routes are supported.** `invokeRoute()` throws for routes with any other `responseType`, such as streaming or MCP transport routes.
80
80
  - **HTTP-only handler parameters aren't supplied.** The handler receives the parsed parameters, `mastra`, `requestContext`, and `abortSignal`, but not `request`, `registeredTools`, `taskStore`, or `routePrefix`. Routes that read those aren't suitable.
81
81
 
82
+ ## Differences from `dispatchRoute()`
83
+
84
+ [`dispatchRoute()`](https://mastra.ai/reference/server/dispatch-route) runs the same checks for any route, including streaming routes, and differs in these ways:
85
+
86
+ - `invokeRoute()` always needs an authenticated user when auth is configured. `dispatchRoute()` lets a caller without a user reach paths your auth config declares public.
87
+ - `invokeRoute()` builds the path for `authorize()` and `rules` from the server's `apiPrefix`. `dispatchRoute()` uses the prefix of the server adapter that serves the route.
88
+ - `invokeRoute()` lets a body field override a path parameter with the same name, as the HTTP adapters do. `dispatchRoute()` lets the path parameter win.
89
+ - `invokeRoute()` returns `{ status, body }`. `dispatchRoute()` returns the handler's raw result, or a status and error body when a check fails.
90
+
82
91
  ## Related
83
92
 
93
+ - [`dispatchRoute()`](https://mastra.ai/reference/server/dispatch-route)
84
94
  - [`createRoute()`](https://mastra.ai/reference/server/create-route)
85
95
  - [Server routes](https://mastra.ai/reference/server/routes)
86
96
  - [Build MCP Apps](https://mastra.ai/docs/connections/mcp)
@@ -76,7 +76,7 @@ app.listen(3000, () => {
76
76
 
77
77
  **taskStore** (`InMemoryTaskStore`): Task store for A2A (Agent-to-Agent) operations
78
78
 
79
- **mcpOptions** (`MCPOptions`): MCP transport options, such as setRequestAuth to control what tools see as context.mcp.extra.authInfo.
79
+ **mcpOptions** (`MCPOptions`): MCP transport options, such as setRequestAuth to control what tools see as context.mcp.extra.authInfo. Defaults to server.mcpOptions from your Mastra config.
80
80
 
81
81
  ## Error handling
82
82
 
@@ -93,7 +93,7 @@ By default, Mastra routes mount under `/api`. Use `prefix` to change it.
93
93
 
94
94
  **taskStore** (`InMemoryTaskStore`): Task store for A2A (Agent-to-Agent) operations
95
95
 
96
- **mcpOptions** (`{ serverless?: boolean; sessionIdGenerator?: () => string }`): MCP transport options
96
+ **mcpOptions** (`MCPOptions`): MCP transport options, such as setRequestAuth to control what tools see as context.mcp.extra.authInfo. Defaults to server.mcpOptions from your Mastra config.
97
97
 
98
98
  **auth** (`{ enabled?: boolean; allowQueryApiKey?: boolean }`): Controls Mastra auth for Mastra routes. When server.auth is configured on your Mastra instance, it runs automatically (the same pipeline as other adapters: bearer tokens, cookie sessions, session refresh, and mapUserToResourceId). Set enabled: false to rely only on your own NestJS guards. Query-string apiKey auth is opt-in for backward compatibility.
99
99
 
@@ -172,7 +172,7 @@ const stream = await agent.stream('message for agent')
172
172
 
173
173
  **options.clientTools** (`ToolsInput`): Tools that are executed on the 'client' side of the request. These tools do not have execute functions in the definition.
174
174
 
175
- **options.hooks** (`ToolHooks`): Per-execution hooks that run before and after tool calls. Overrides matching agent-level hooks for this execution. beforeToolCall can return { proceed: false, output } to skip the tool call.
175
+ **options.hooks** (`ToolHooks`): Per-execution hooks that run before and after tool calls, for example to log or save audit records. afterToolCall: (context) => void | Promise\<void> receives toolName, input, and output or error. beforeToolCall can return { proceed: false, output } to skip the tool call. Overrides matching agent-level hooks for this execution. See Run logic around tool calls.
176
176
 
177
177
  **options.savePerStep** (`boolean`): Save messages incrementally after each stream step completes (default: false).
178
178
 
@@ -180,6 +180,10 @@ Everything Factory knows about the session, passed to `create`, `template` and t
180
180
 
181
181
  **resolveHead** (`(cloneUrl, token?) => Promise<string | undefined>`): Resolves the commit a repository template pins, given its clone URL and the credential minted for it. When absent, the provider resolves the default branch head itself.
182
182
 
183
+ **buildEnv** (`Record<string, string>`): Environment for template builds and setup steps only, never for runtime commands. Keep it out of the template identity and the image. A provider whose builder can't do that may ignore it. If you spread the context into a repository template, take this field out of the spread so it doesn't reach the template's own buildEnv. Factory sets it from the factory's Build variables.
184
+
185
+ **buildEnvRevision** (`string`): Opaque id that changes whenever buildEnv changes. Include it in the template identity so an edit rebuilds the template. It is a random id, never derived from the values.
186
+
183
187
  ## Build status
184
188
 
185
189
  `FactorySandboxBuild.status` is one of `pending`, `building`, `ready`, `failed` or `unknown`. `unknown` means the provider can't read the status of a build it didn't start in this process.
@@ -191,8 +195,23 @@ When the sandbox declares `builds`, factory builds the environment template ahea
191
195
  - on `POST /web/factory/projects/:id/environment/build` (the Environment page's Build now, or `mastra api factory project environment build <project-id>`)
192
196
  - on a cron schedule kept in core `Schedules`, enabled through `PATCH { buildTriggers: { schedule: { enabled: true, cron, timezone } } }`; needs a storage adapter with the schedules domain, otherwise the route reports `scheduleAvailable: false`
193
197
  - after a push to a linked repository's default branch when `buildTriggers.push.enabled` is set, at most once per `debounceMinutes`
198
+ - after saving a change to a template input, once the project has a template; a change saved while a build runs is built when that build ends
199
+
200
+ A save that leaves every template input unchanged doesn't start a build. Scheduled and push builds skip when the last build is ready, no repository head moved and no template input changed (settings, repositories and their order, setup commands, the working directory or the factory's Build variables). Factory stores only the last build id and the active template. Status and history come from the provider through `GET …/environment/builds/:buildId` and `GET …/environment/builds` (404 `no_history` when the provider keeps none).
201
+
202
+ When a build start was never recorded and the provider can't list its builds, Factory can't tell whether that build is still running. Triggers skip with reason `unresolved` for 30 minutes after the start's lease lapsed, then Factory treats the start as failed and the next trigger builds.
203
+
204
+ ## Environment variables
205
+
206
+ Factory members add environment variables for every sandbox of a factory in **Settings › Manage Factory › Environment variables**. Each variable applies to one of:
207
+
208
+ - **Runtime**: Every command in every session sandbox. Adding, editing or deleting one takes effect on the next command in a running sandbox, without a restart. Other Factory servers see the change when the factory's `pubsub` delivers it, or within a second when no cross-process `pubsub` is configured. A process that's already running keeps the environment it started with.
209
+ - **Build**: The template build and the setup commands Factory runs itself, never runtime commands. Factory passes them to the provider as `buildEnv` and `buildEnvRevision`. An edit rebuilds the template on the next build. A running sandbox doesn't rerun setup. New sandboxes start from the rebuilt template, which holds whatever setup produced with the new values, while their own commands never see the values. On Docker, template builds don't receive Build variables yet and an edit doesn't rebuild the image, so only a setup that Factory runs itself sees them.
210
+ - **Both**: Runtime and build.
211
+
212
+ A runtime variable with the same name as a key from the provider's `env` option replaces it, and deleting the variable restores the host value. Names that Factory sets itself, such as `GH_TOKEN`, are reserved.
194
213
 
195
- Saving environment settings never starts a build. Scheduled and push builds skip when the last build is ready, no repository head moved and no template input changed (settings, repositories and their order, setup commands or the working directory). Factory stores only the last build id and the active template. Status and history come from the provider through `GET …/environment/builds/:buildId` and `GET …/environment/builds` (404 `no_history` when the provider keeps none).
214
+ Values are encrypted at rest with the factory's credential encryption key and can't be read back through the API or the UI. Anything running in the sandbox can read them. When sign-in is on and no encryption key is configured, Factory refuses to save variables and the settings page explains why. The routes are `GET /web/factory/projects/:id/sandbox-envs` and `PUT`, `PATCH` and `DELETE /web/factory/projects/:id/sandbox-envs/:name`.
196
215
 
197
216
  ## Related
198
217
 
@@ -203,7 +203,7 @@ await sandbox.start()
203
203
 
204
204
  `createRepoTemplate()` accepts the same `cpuCount`, `memoryMB`, and `docker` settings as the `Template()` builder methods, as plain options. They carry the identity and stale-fallback semantics described above. Omit them for the provider defaults.
205
205
 
206
- `setupCommand` also accepts an array. Each entry runs as its own cached build step. `workingDirectory` sets the cwd for the build and the sandbox, and the repository is cloned to `<workingDirectory>/<repo>`. `buildEnv` passes environment variables to the build steps only. They never enter the serialized definition.
206
+ `setupCommand` also accepts an array. Each entry runs as its own cached build step. `workingDirectory` sets the cwd for the build and the sandbox, and the repository is cloned to `<workingDirectory>/<repo>`. `buildEnv` passes environment variables to the build steps only. They never enter the serialized definition. `buildEnvRevision` is an opaque id written ahead of the clone and setup steps. A new revision rebuilds them. Change it whenever `buildEnv` changes and never derive it from the values.
207
207
 
208
208
  `getRepositoryAccess` mirrors the resolver a Factory sandbox context carries, so a host can pass its context straight through; when it's absent, `createRepoTemplate()` returns `undefined` and the sandbox boots the provider default. The resolver skips reattachment to an existing `sandboxId`; on a fresh start, it resolves the repository's default-branch head before Platform starts or reuses the corresponding template build. If the repository head can't be resolved or the provider build fails, sandbox creation continues with the provider's default template so runtime setup can perform a cold checkout. For private repositories, the short-lived authorization token is sent as an ephemeral build environment value that stays out of the serialized definition and the persisted template record. It has no effect on content identity.
209
209
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mcp-docs-server",
3
- "version": "1.3.13-alpha.9",
3
+ "version": "1.3.13",
4
4
  "description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -26,8 +26,8 @@
26
26
  "@mastra/mcp-legacy": "npm:@mastra/mcp@^1.18.0",
27
27
  "local-pkg": "^1.2.1",
28
28
  "zod": "^4.6.7",
29
- "@mastra/core": "1.83.0-alpha.6",
30
- "@mastra/mcp": "^2.9.0-alpha.3"
29
+ "@mastra/core": "1.83.0",
30
+ "@mastra/mcp": "^2.9.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@hono/node-server": "^2.1.3",
@@ -42,8 +42,8 @@
42
42
  "tsx": "^4.23.15",
43
43
  "typescript": "^7.0.2",
44
44
  "vitest": "5.1.0",
45
- "@internal/lint": "0.0.148",
46
- "@internal/types-builder": "0.0.123"
45
+ "@internal/lint": "0.0.149",
46
+ "@internal/types-builder": "0.0.124"
47
47
  },
48
48
  "homepage": "https://mastra.ai",
49
49
  "repository": {