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

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 (97) hide show
  1. package/.docs/docs/agents/code-mode.md +0 -2
  2. package/.docs/docs/agents/overview.md +1 -1
  3. package/.docs/docs/agents/processors.md +8 -0
  4. package/.docs/docs/agents/tools.md +17 -0
  5. package/.docs/docs/auth/composite-auth.md +1 -1
  6. package/.docs/docs/auth/custom-auth-provider.md +28 -22
  7. package/.docs/docs/auth/jwt.md +1 -1
  8. package/.docs/docs/auth/overview.md +2 -2
  9. package/.docs/docs/auth/simple-auth.md +6 -1
  10. package/.docs/docs/browser.md +1 -2
  11. package/.docs/docs/deployment/overview.md +1 -1
  12. package/.docs/docs/deployment/web-framework.md +1 -1
  13. package/.docs/docs/develop.md +1 -3
  14. package/.docs/docs/evals/built-in-scorers.md +2 -2
  15. package/.docs/docs/guides/context-engineering.md +0 -2
  16. package/.docs/docs/guides/overview.md +15 -0
  17. package/.docs/docs/harness/agent-controller.md +7 -12
  18. package/.docs/docs/harness/goals.md +1 -3
  19. package/.docs/docs/harness/schedules.md +0 -2
  20. package/.docs/docs/harness/signal-providers.md +1 -3
  21. package/.docs/docs/harness/signals.md +0 -2
  22. package/.docs/docs/mastra-platform/configuration.md +1 -1
  23. package/.docs/docs/mastra-platform/environments.md +1 -1
  24. package/.docs/docs/mastra-platform/observability.md +1 -1
  25. package/.docs/docs/memory/observational-memory.md +2 -0
  26. package/.docs/docs/observability/overview.md +0 -5
  27. package/.docs/docs/sandbox/filesystem.md +12 -12
  28. package/.docs/docs/studio/observability.md +1 -1
  29. package/.docs/docs/workflows/error-handling.md +2 -0
  30. package/.docs/integrations/voice/livekit.md +449 -2
  31. package/.docs/models/gateways/netlify.md +1 -1
  32. package/.docs/models/gateways/openrouter.md +3 -4
  33. package/.docs/models/gateways/vercel.md +9 -3
  34. package/.docs/models/index.md +1 -1
  35. package/.docs/models/providers/aki-io.md +12 -12
  36. package/.docs/models/providers/edenai.md +15 -12
  37. package/.docs/models/providers/kilo.md +11 -13
  38. package/.docs/models/providers/llmgateway-providers.md +5 -2
  39. package/.docs/models/providers/llmgateway.md +2 -2
  40. package/.docs/models/providers/mistral.md +7 -6
  41. package/.docs/models/providers/nano-gpt.md +12 -3
  42. package/.docs/models/providers/opencode-go.md +2 -2
  43. package/.docs/models/providers/opencode.md +3 -1
  44. package/.docs/models/providers/requesty.md +3 -1
  45. package/.docs/models/providers/the-grid-ai.md +19 -12
  46. package/.docs/models/providers/wandb.md +4 -13
  47. package/.docs/reference/agent-controller/agent-controller-class.md +2 -4
  48. package/.docs/reference/agent-controller/session.md +18 -13
  49. package/.docs/reference/agents/createSkill.md +1 -2
  50. package/.docs/reference/agents/generate.md +2 -0
  51. package/.docs/reference/agents/getModel.md +1 -1
  52. package/.docs/reference/agents/getSkill.md +6 -1
  53. package/.docs/reference/agents/listSkills.md +0 -1
  54. package/.docs/reference/auth/jwt.md +1 -1
  55. package/.docs/reference/auth/supabase.md +1 -1
  56. package/.docs/reference/browser/mastra-browser.md +13 -11
  57. package/.docs/reference/cli/create-mastra.md +1 -1
  58. package/.docs/reference/cli/mastra.md +43 -5
  59. package/.docs/reference/client-js/agent-controller.md +19 -3
  60. package/.docs/reference/client-js/agents.md +1 -1
  61. package/.docs/reference/client-js/conversations.md +1 -1
  62. package/.docs/reference/client-js/mastra-client.md +2 -2
  63. package/.docs/reference/client-js/observability.md +28 -0
  64. package/.docs/reference/client-js/workflows.md +18 -2
  65. package/.docs/reference/code-sdk/mount-agent-controller.md +1 -3
  66. package/.docs/reference/editor/prompt-blocks.md +41 -0
  67. package/.docs/reference/editor/tool-provider.md +19 -0
  68. package/.docs/reference/file-based-agents/config.md +0 -2
  69. package/.docs/reference/file-based-agents/instructions.md +0 -2
  70. package/.docs/reference/file-based-agents/logger.md +0 -2
  71. package/.docs/reference/file-based-agents/memory.md +0 -2
  72. package/.docs/reference/file-based-agents/observability.md +0 -2
  73. package/.docs/reference/file-based-agents/processors.md +0 -2
  74. package/.docs/reference/file-based-agents/schedules.md +0 -2
  75. package/.docs/reference/file-based-agents/scorers.md +0 -2
  76. package/.docs/reference/file-based-agents/server.md +0 -2
  77. package/.docs/reference/file-based-agents/skills.md +0 -2
  78. package/.docs/reference/file-based-agents/storage.md +0 -2
  79. package/.docs/reference/file-based-agents/studio.md +0 -2
  80. package/.docs/reference/file-based-agents/subagents.md +0 -2
  81. package/.docs/reference/file-based-agents/tools.md +0 -2
  82. package/.docs/reference/file-based-agents/workflows.md +0 -2
  83. package/.docs/reference/file-based-agents/workspace.md +0 -2
  84. package/.docs/reference/memory/observational-memory.md +2 -0
  85. package/.docs/reference/observability/tracing/interfaces.md +62 -2
  86. package/.docs/reference/observability/tracing/trace-query.md +65 -4
  87. package/.docs/reference/schedules/overview.md +0 -2
  88. package/.docs/reference/signals/create-notification-inbox-tool.md +0 -2
  89. package/.docs/reference/signals/signal-provider.md +1 -3
  90. package/.docs/reference/signals/task-signal-provider.md +1 -1
  91. package/.docs/reference/signals/webhook-signal-provider.md +1 -3
  92. package/.docs/reference/streaming/ChunkType.md +2 -0
  93. package/.docs/reference/tools/create-code-mode.md +0 -2
  94. package/.docs/reference/tools/create-tool.md +2 -0
  95. package/.docs/reference/tools/mcp-server.md +8 -2
  96. package/.docs/reference/vectors/lance.md +56 -10
  97. package/package.json +6 -6
@@ -4,8 +4,6 @@
4
4
 
5
5
  # AgentController
6
6
 
7
- > **Beta:** Breaking changes may occur without a major version bump until the API is stable.
8
-
9
7
  The `AgentController` class is a shared host for one or more [`Session`](https://mastra.ai/reference/agent-controller/session) instances. Initialize the controller, create a session, then use `session.*` APIs for conversation state and run control.
10
8
 
11
9
  For a guided introduction, see the [AgentController overview](https://mastra.ai/docs/harness/agent-controller).
@@ -58,7 +56,7 @@ A message lifecycle starts with the initial message in `message_start`. Compact
58
56
 
59
57
  **modes.name** (`string`): Display name.
60
58
 
61
- **modes.defaultModelId** (`string`): Model selected when a session enters this mode without a stored selection.
59
+ **modes.defaultModelId** (`string`): Model used when a session starts in this mode without a stored selection. Mode switches do not apply it.
62
60
 
63
61
  **modes.description** (`string`): Text shown in mode selectors.
64
62
 
@@ -96,7 +94,7 @@ A message lifecycle starts with the initial message in `message_start`. Compact
96
94
 
97
95
  **tools** (`DynamicArgument<ToolsInput | undefined>`): Tools shared by controller runs and available to configured subagents.
98
96
 
99
- **workspace** (`DynamicArgument<Workspace | undefined>`): Static workspace or per-session workspace factory. A session must resolve a valid workspace.
97
+ **workspace** (`DynamicArgument<Workspace | undefined>`): Static workspace or per-session workspace factory. A workspace is optional. Sessions without one support threads, state, and agent runs. They have no workspace tools unless the mode's agent has its own workspace.
100
98
 
101
99
  **browser** (`DynamicArgument<MastraBrowser | undefined>`): Static browser or per-session browser factory.
102
100
 
@@ -4,8 +4,6 @@
4
4
 
5
5
  # Session
6
6
 
7
- > **Beta:** Breaking changes may occur without a major version bump until the API is stable.
8
-
9
7
  A `Session` is the isolated runtime for one resource and optional scope. It owns its event bus, thread binding, state, mode and model selections, run control, approvals, suspensions, follow-ups, and display state. The [`AgentController`](https://mastra.ai/reference/agent-controller/agent-controller-class) supplies shared agents, configuration, storage, workspaces, and services.
10
8
 
11
9
  Create sessions through `controller.createSession()`. Direct construction and controller wiring methods aren't application APIs.
@@ -461,7 +459,7 @@ const mode = session.mode.resolve()
461
459
 
462
460
  ### `session.mode.switch({ modeId })`
463
461
 
464
- Switch to another mode. The session saves the outgoing mode's model before persisting the new mode on the active thread. It then restores the incoming mode's selected or default model. The session emits `mode_changed` immediately and `model_changed` after model resolution.
462
+ Switch to another mode and persist the mode on the active thread. The session emits `mode_changed`. Switching modes doesn't change the active model; switch the model separately when your host assigns different models to different modes.
465
463
 
466
464
  ```typescript
467
465
  await session.mode.switch({ modeId: 'build' })
@@ -469,7 +467,7 @@ await session.mode.switch({ modeId: 'build' })
469
467
 
470
468
  ## Model
471
469
 
472
- `session.model` owns the active model selection, including per-mode model memory.
470
+ `session.model` owns the session's single active model selection.
473
471
 
474
472
  ### `session.model.get()`
475
473
 
@@ -497,21 +495,28 @@ if (session.model.hasSelection()) {
497
495
  }
498
496
  ```
499
497
 
500
- ### `session.model.switch({ modelId, scope?, modeId? })`
498
+ ### `session.model.set({ modelId })`
501
499
 
502
- Switch the active model. When `scope` is `'thread'` (the default), the model ID is persisted as the per-mode model so it's restored when switching back. Reports the selection to the controller's `modelUseCountTracker` and emits a `model_changed` event.
500
+ Set the active model in memory without persisting it, reporting model use, or emitting a `model_changed` event.
503
501
 
504
502
  ```typescript
505
- // Set for the current session only
506
- await session.model.switch({
507
- modelId: 'anthropic/claude-sonnet-4-6',
508
- scope: 'global',
509
- })
503
+ session.model.set({ modelId: 'anthropic/claude-sonnet-4-6' })
504
+ ```
505
+
506
+ ### `session.model.switch(modelId, options?)`
507
+
508
+ Switch the session's active model. The model ID is persisted as the thread's `currentModelId` and restored with that thread. Reports the selection to the controller's `modelUseCountTracker` and emits a `model_changed` event.
510
509
 
511
- // Persist to the current thread (default)
512
- await session.model.switch({ modelId: 'anthropic/claude-sonnet-4-6' })
510
+ Pass `{ thinkingLevel }` as the second argument to switch and persist both values in one operation. The level must be `'off'`, `'low'`, `'medium'`, `'high'`, `'xhigh'`, or `'max'`, and the controller's state schema must accept it. Both live values are updated before events are emitted. Omitting the option preserves the existing thinking-level override. Every `model_changed` event includes the current `{ modelId, thinkingLevel }`, even when the thinking level is unchanged. The level is `undefined` when the session has no override.
511
+
512
+ ```typescript
513
+ await session.model.switch('anthropic/claude-sonnet-4-6', {
514
+ thinkingLevel: 'high',
515
+ })
513
516
  ```
514
517
 
518
+ The client SDK exposes the same operation as `session.switchModel(modelId, { thinkingLevel })`.
519
+
515
520
  ## Observational Memory
516
521
 
517
522
  The observational-memory model selection, grouped by role under `session.om.observer` and `session.om.reflector`. Both roles expose the same methods. Reads return the value from session state when set, falling back to the controller's `omConfig` defaults.
@@ -65,12 +65,11 @@ The skill is assigned a synthetic path of `inline/<name>` (e.g., `inline/code-re
65
65
 
66
66
  - `name` is required and must be a valid slug
67
67
  - `description` is required
68
- - `instructions` is required and non-empty
69
68
 
70
69
  If validation fails, an `Error` is thrown with details about the invalid fields.
71
70
 
72
71
  ```typescript
73
- // Throws: Invalid skill "": name is required
72
+ // Throws: Invalid skill "": name: Skill name cannot be empty
74
73
  createSkill({ name: '', description: 'test', instructions: 'test' })
75
74
  ```
76
75
 
@@ -444,6 +444,8 @@ const response = await agent.generate([
444
444
  console.log(response.text)
445
445
  ```
446
446
 
447
+ The `image` value, or `data` for a `type: 'file'` part, should be an absolute URL, a data URL, or base64 content. The model can't see an attachment given as a relative path such as `/api/images/foo.png`, so resolve it to an absolute URL before sending. The agent replaces it with a placeholder and logs a warning. It does the same for inline content that can't be decoded or isn't the image or PDF its media type says, and for any attachment it can't download, instead of failing. See [attachment download failures](https://mastra.ai/docs/agents/processors).
448
+
447
449
  ### Using `maxSteps`
448
450
 
449
451
  The `maxSteps` parameter controls the maximum number of sequential LLM calls an agent can make. Each step generates a response and executes any tool calls before processing the result. Limiting steps helps prevent infinite loops and reduce latency. It also controls token usage for agents that use tools. The default is 5, but can be increased:
@@ -20,7 +20,7 @@ await agent.getModel()
20
20
 
21
21
  ## Returns
22
22
 
23
- **model** (`MastraLanguageModel | Promise<MastraLanguageModel>`): The language model configured for the agent, either as a direct instance or a promise that resolves to the model.
23
+ **model** (`MastraLanguageModel | MastraLegacyLanguageModel | Promise<MastraLanguageModel | MastraLegacyLanguageModel>`): The language model configured for the agent, either as a direct instance or a promise that resolves to the model.
24
24
 
25
25
  ## Extended usage example
26
26
 
@@ -40,7 +40,10 @@ interface Skill {
40
40
  description: string
41
41
  instructions: string
42
42
  path: string
43
- source: { type: string; projectPath: string }
43
+ source:
44
+ | { type: 'external'; packagePath: string }
45
+ | { type: 'local'; projectPath: string }
46
+ | { type: 'managed'; mastraPath: string }
44
47
  references: string[]
45
48
  scripts: string[]
46
49
  assets: string[]
@@ -51,6 +54,8 @@ interface Skill {
51
54
  }
52
55
  ```
53
56
 
57
+ `source` describes where Mastra discovered the skill. Skills from a path with a `node_modules` segment are `external`, skills under `.mastra/skills` are `managed`, and all other skills, including those created with [`createSkill()`](https://mastra.ai/reference/agents/createSkill), are `local`.
58
+
54
59
  ## Merging behavior
55
60
 
56
61
  When both agent-level skills and workspace skills are configured, `.getSkill()` searches the merged set. Agent-level skills take precedence on name conflicts.
@@ -35,7 +35,6 @@ interface SkillMetadata {
35
35
  name: string
36
36
  description: string
37
37
  path: string
38
- source: { type: string; projectPath: string }
39
38
  references: string[]
40
39
  scripts: string[]
41
40
  assets: string[]
@@ -23,7 +23,7 @@ export const mastra = new Mastra({
23
23
 
24
24
  ## Constructor parameters
25
25
 
26
- **secret** (`string`): A unique string used to sign and verify JSON Web Tokens (JWTs) for authenticating incoming requests.
26
+ **secret** (`string`): A unique string used to sign and verify JSON Web Tokens (JWTs) for authenticating incoming requests. Falls back to JWT\_AUTH\_SECRET when omitted. The resolved secret must be non-empty: the constructor throws an error if neither is set, or if this option is an empty string (an empty string does not fall back to JWT\_AUTH\_SECRET). (Default: `process.env.JWT_AUTH_SECRET`)
27
27
 
28
28
  ## Related
29
29
 
@@ -30,7 +30,7 @@ export const mastra = new Mastra({
30
30
 
31
31
  **name** (`string`): Custom name for the auth provider instance.
32
32
 
33
- **authorizeUser** (`(user: User, request: HoneRequest) => Promise<boolean> | boolean`): Custom authorization function to determine if a user should be granted access. Called after token verification. By default, checks the 'isAdmin' column in the 'users' table.
33
+ **authorizeUser** (`(user: User, request: MastraAuthRequest) => Promise<boolean> | boolean`): Custom authorization function to determine if a user should be granted access. Called after token verification. By default, checks the 'isAdmin' column in the 'users' table.
34
34
 
35
35
  ## Related
36
36
 
@@ -157,12 +157,12 @@ const tools = browser.getTools()
157
157
 
158
158
  ### Screencast
159
159
 
160
- #### `startScreencast(options?, threadId?)`
160
+ #### `startScreencast(options?)`
161
161
 
162
162
  Starts streaming browser frames. Returns a `ScreencastStream` that emits frame events.
163
163
 
164
164
  ```typescript
165
- const stream = await browser.startScreencast({ format: 'jpeg', quality: 80 }, 'thread-123')
165
+ const stream = await browser.startScreencast({ format: 'jpeg', quality: 80 })
166
166
 
167
167
  stream.on('frame', frame => {
168
168
  console.log('Frame received:', frame.data.length, 'bytes')
@@ -205,29 +205,31 @@ await browser.injectKeyboardEvent({
205
205
 
206
206
  ### State
207
207
 
208
- #### `getState(threadId?)`
208
+ #### `getBrowserState(threadId?)`
209
209
 
210
- Gets the current browser state including URL and tabs.
210
+ Gets the current browser state, including open tabs and the active tab index. Returns `null` when no state is available.
211
211
 
212
212
  ```typescript
213
- const state = await browser.getState('thread-123')
214
- console.log('Current URL:', state.currentUrl)
215
- console.log('Tabs:', state.tabs)
213
+ const state = await browser.getBrowserState('thread-123')
214
+ if (state) {
215
+ console.log('Active tab:', state.tabs[state.activeTabIndex]?.url)
216
+ console.log('Tabs:', state.tabs)
217
+ }
216
218
  ```
217
219
 
218
- **Returns:** `Promise<BrowserState>`
220
+ **Returns:** `Promise<BrowserState | null>`
219
221
 
220
222
  ```typescript
221
223
  interface BrowserState {
222
- currentUrl: string | null
223
224
  tabs: BrowserTabState[]
224
225
  activeTabIndex: number
226
+ closeReason?: 'agent' | 'user' | 'process_restart' | 'error'
227
+ activeUrlChangeSource?: 'agent' | 'user'
225
228
  }
226
229
 
227
230
  interface BrowserTabState {
228
- id: string
229
231
  url: string
230
- title: string
232
+ title?: string
231
233
  }
232
234
  ```
233
235
 
@@ -187,7 +187,7 @@ Use `--no-skills` or `--no-git` to skip these steps. Skills and Git setup failur
187
187
  - `--llm` and `--llm-api-key` are only valid for the default starter project.
188
188
  - The project name must be a safe, lowercase, single directory name and the target must not already exist.
189
189
 
190
- Invalid input is rejected before templates are fetched or files are created.
190
+ Invalid flags, project names, and GitHub URLs are rejected before any project files are created. An unknown template name is rejected after the template list is fetched, and the CLI prints the available templates.
191
191
 
192
192
  ## Arguments and flags
193
193
 
@@ -428,7 +428,7 @@ mastra deploy --env staging --yes
428
428
 
429
429
  Manages environments on Mastra platform. Environments are deploy targets (for example `production`, `staging`, `preview-42`) that belong to a project. The current organization is resolved from stored credentials.
430
430
 
431
- Every subcommand resolves its project in a fixed order. It first checks the `MASTRA_PROJECT_ID` environment variable and the `--project <name|slug|id>` flag. It then reads the `.mastra-project.json` file written by [`mastra deploy`](#mastra-deploy) in the current directory. Run from your project directory and you never need to name the project.
431
+ Every subcommand resolves its project in a fixed order. It first checks the `--project <name|slug|id>` flag, then the `MASTRA_PROJECT_ID` environment variable. It then reads the `.mastra-project.json` file written by [`mastra deploy`](#mastra-deploy) in the current directory. Run from your project directory and you never need to name the project.
432
432
 
433
433
  ### `mastra env list`
434
434
 
@@ -790,7 +790,7 @@ Organization ID. Can also be set via the `MASTRA_ORG_ID` environment variable.
790
790
 
791
791
  #### `--project`
792
792
 
793
- Project ID or slug when `MASTRA_PROJECT_ID` isn't set. Slugs are resolved against projects in the current organization.
793
+ Project ID or slug. Takes precedence over `MASTRA_PROJECT_ID`. Slugs are resolved against projects in the current organization.
794
794
 
795
795
  #### `-c, --config`
796
796
 
@@ -858,7 +858,7 @@ The file defaults to `.env` when no argument is given. All values are double-quo
858
858
 
859
859
  #### `--project`
860
860
 
861
- Project ID or slug. Overrides the linked project when `MASTRA_PROJECT_ID` isn't set.
861
+ Project ID or slug. Takes precedence over `MASTRA_PROJECT_ID` and the linked project.
862
862
 
863
863
  #### CI usage
864
864
 
@@ -913,6 +913,44 @@ Revokes an API token.
913
913
  mastra auth tokens revoke <token-id>
914
914
  ```
915
915
 
916
+ ## `mastra connect`
917
+
918
+ Manages provider connections for the linked platform project, so agents using `@mastra/connect` pick up provider toolsets without leaving the terminal.
919
+
920
+ The target project resolves from the `--project` flag, the `MASTRA_PROJECT_ID` environment variable, or the `.mastra-project.json` written by `mastra deploy`, in that order. All subcommands accept `--project <name|slug|id>`.
921
+
922
+ ### `mastra connect list`
923
+
924
+ Lists the available providers. Providers already connected to the project are shown in green, and unconnected providers are shown in grey.
925
+
926
+ ```bash
927
+ mastra connect list
928
+ ```
929
+
930
+ ### `mastra connect add`
931
+
932
+ Connects a provider to the project. When the organization already has connections for the provider that aren't attached to the project, the command lists them and lets you attach an existing connection or create a new one. With no existing connections it goes straight to the provider's auth flow.
933
+
934
+ OAuth providers open the provider's consent screen in your browser, while API key and Basic auth providers prompt for credentials in the terminal. Providers with other auth types open a hosted connect page. The command waits until the connection becomes active before exiting.
935
+
936
+ Once a new connection is active, the command offers to set a display name so you can tell connections to the same provider apart. It lists the provider's existing connections, suggests a name that doesn't collide with them, and asks for confirmation if the chosen name duplicates another connection's name. Leave the field blank to skip naming.
937
+
938
+ ```bash
939
+ mastra connect add <provider>
940
+ ```
941
+
942
+ Pass `--yes` to skip all prompts. This always creates a new connection without a display name, even when existing connections could be reused.
943
+
944
+ ### `mastra connect remove`
945
+
946
+ Unlinks a provider's connection from the project. The organization-level connection is kept and can be re-attached later.
947
+
948
+ ```bash
949
+ mastra connect remove <provider>
950
+ ```
951
+
952
+ When a provider has multiple connections, the command prompts for which one to remove. Pass `--yes` to skip confirmation. Without a terminal, or with `--yes`, removing several connections at once requires `--all`, and `--connection <id>` removes a single one.
953
+
916
954
  ## `mastra lint`
917
955
 
918
956
  The `mastra lint` command validates the structure and code of your Mastra project.
@@ -1100,7 +1138,7 @@ See [Import existing traces](https://mastra.ai/docs/mastra-platform/observabilit
1100
1138
 
1101
1139
  #### `--project <name|slug|id>`
1102
1140
 
1103
- Selects the destination Mastra Platform project. `MASTRA_PROJECT_ID` takes precedence when set. Without either value, the command uses the project linked in `.mastra-project.json`.
1141
+ Selects the destination Mastra Platform project. Takes precedence over `MASTRA_PROJECT_ID`. Without either value, the command uses the project linked in `.mastra-project.json`.
1104
1142
 
1105
1143
  #### `--from <date>`
1106
1144
 
@@ -1136,7 +1174,7 @@ The command loads `.env` and `.env.local` from the current directory.
1136
1174
  | `MASTRA_API_TOKEN` | For headless authentication | Mastra Platform API token. Without it, the command uses credentials from `mastra auth login`. |
1137
1175
  | `MASTRA_ORG_ID` | With `MASTRA_API_TOKEN` | Organization that owns the destination project. |
1138
1176
  | `MASTRA_PLATFORM_ACCESS_TOKEN` | For upload and read-back with interactive login | Mastra Platform access token for the destination. Not required for `--dry-run` or when `MASTRA_API_TOKEN` is set. |
1139
- | `MASTRA_PROJECT_ID` | When no project is otherwise linked | Destination project ID. Takes precedence over `--project`. |
1177
+ | `MASTRA_PROJECT_ID` | When no project is otherwise linked | Destination project ID. The `--project` flag takes precedence over it. |
1140
1178
 
1141
1179
  ### Examples
1142
1180
 
@@ -39,12 +39,22 @@ Retrieve the agent controllers hosted on the connected Mastra instance:
39
39
  const controllers = await client.listAgentControllers()
40
40
  ```
41
41
 
42
+ Each entry's `id` is the key the controller is registered under in `new Mastra({ agentControllers })`, not the controller's own `id`.
43
+
42
44
  ## Working with a specific agent controller
43
45
 
44
- Get an instance of an agent controller by the ID it's registered under:
46
+ Get an instance of an agent controller by the key it's registered under in `new Mastra({ agentControllers })`. The key can differ from the controller's `id`. In this example, pass `'coding'`, not `'coding-controller'`:
47
+
48
+ ```typescript
49
+ const codingController = new AgentController({ id: 'coding-controller', agent, modes })
50
+
51
+ export const mastra = new Mastra({
52
+ agentControllers: { coding: codingController },
53
+ })
54
+ ```
45
55
 
46
56
  ```typescript
47
- const controller = client.getAgentController('coding-controller')
57
+ const controller = client.getAgentController('coding')
48
58
  ```
49
59
 
50
60
  ### `listModes()`
@@ -155,7 +165,13 @@ Switches the active mode.
155
165
 
156
166
  ### `switchModel(modelId, options?)`
157
167
 
158
- Switches the model. `options.scope` is `'thread'` (default) or `'global'`. `options.modeId` targets a specific mode.
168
+ Switches the session's active model and persists it as the current model for the active thread. Switching modes doesn't change it. Pass `{ thinkingLevel }` as the second argument to apply and persist a thinking level with the model.
169
+
170
+ ```typescript
171
+ await session.switchModel('anthropic/claude-sonnet-4-6', {
172
+ thinkingLevel: 'high',
173
+ })
174
+ ```
159
175
 
160
176
  ### `listThreads(options?)`
161
177
 
@@ -1040,7 +1040,7 @@ console.log(diff.changes) // Fields that changed between versions
1040
1040
  In the React SDK, pass an `agentVersionId` through `requestContext` when using the `useChat` hook:
1041
1041
 
1042
1042
  ```typescript
1043
- import { useChat } from '@mastra/react'
1043
+ import { useChat } from '@mastra/react/chat'
1044
1044
 
1045
1045
  function Chat() {
1046
1046
  const { messages, input, handleInputChange, handleSubmit } = useChat({
@@ -122,7 +122,7 @@ console.log(items.data)
122
122
  - `data`: Conversation items such as `message`, `function_call`, and `function_call_output`
123
123
  - `first_id`: The first item ID in the page
124
124
  - `last_id`: The last item ID in the page
125
- - `has_more`: Whether more items exist beyond the current page
125
+ - `has_more`: Currently always `false`. `items.list()` returns up to 1000 items in a single response.
126
126
 
127
127
  ## Parameters
128
128
 
@@ -59,9 +59,9 @@ You can also pass `requestContext` as a `Record<string, any>`.
59
59
 
60
60
  **getAgent(agentId)** (`Agent`): Retrieves a specific agent instance by ID.
61
61
 
62
- **listAgentControllers()** (`Promise<AgentControllerInfo[]>`): Returns the agent controllers hosted on the connected Mastra instance.
62
+ **listAgentControllers()** (`Promise<AgentControllerInfo[]>`): Returns the agent controllers hosted on the connected Mastra instance. Each entry's id is the key the controller is registered under in new Mastra({ agentControllers }).
63
63
 
64
- **getAgentController(controllerId)** (`AgentController`): Retrieves a specific agent controller by ID. .session(resourceId) returns a session client; call await session.create() to create or resume the server session.
64
+ **getAgentController(controllerId)** (`AgentController`): Retrieves a specific agent controller by the key it is registered under in new Mastra({ agentControllers }), which can differ from the controller id. .session(resourceId) returns a session client; call await session.create() to create or resume the server session.
65
65
 
66
66
  **listMemoryThreads(params)** (`Promise<StorageThreadType[]>`): Retrieves memory threads for the specified resource and agent. Requires a resourceId and an agentId.
67
67
 
@@ -217,6 +217,34 @@ The API limits predicate depth, nodes, related clauses, set members, literal byt
217
217
 
218
218
  See [Advanced trace queries](https://mastra.ai/reference/observability/tracing/trace-query) for the complete limits, request fields, predicates, thread qualification semantics, cursor pagination, response shapes, and errors.
219
219
 
220
+ ## Querying spans
221
+
222
+ `querySpans()` returns one row per matching completed span across traces. Use it to list the spans themselves. `queryTraces()` with a `spans.some` predicate returns the traces that contain a matching span instead. Every query requires an ISO timestamp range of at most 31 days.
223
+
224
+ ```typescript
225
+ const result = await mastraClient.querySpans({
226
+ timeRange: {
227
+ from: '2026-10-01T00:00:00.000Z',
228
+ to: '2026-10-02T00:00:00.000Z',
229
+ },
230
+ where: {
231
+ op: 'eq',
232
+ left: { path: 'spanType' },
233
+ right: { literal: 'tool_call' },
234
+ },
235
+ orderBy: [{ field: 'startedAt', direction: 'desc' }],
236
+ page: { limit: 50 },
237
+ })
238
+
239
+ // { spans: [{ traceId, spanId, name, spanType, status, durationMs, cost, ... }], page: { next } }
240
+ ```
241
+
242
+ Pass `result.page.next` back as `page.after` with the same time range, filter, and ordering to load the next page. Each row contains identifiers, display fields, input and output previews, and the span's model cost. Use `getSpan()` to load the full span.
243
+
244
+ Span queries are optional for observability stores. Check `capabilities.spanQuery` from `getObservabilityCapabilities()` before calling `querySpans()`, and treat a missing value as unsupported. Unsupported servers reject with `501 SPAN_QUERY_UNSUPPORTED`.
245
+
246
+ See [Query individual spans](https://mastra.ai/reference/observability/tracing/trace-query) for filters, ordering, cursors, cost states, limits, and errors.
247
+
220
248
  ## Deleting traces
221
249
 
222
250
  Delete traces and their associated spans, metrics, logs, scores, and feedback:
@@ -223,9 +223,25 @@ A workflow run result yields the following:
223
223
 
224
224
  **runId** (`string`): Unique identifier for this workflow run instance
225
225
 
226
- **eventTimestamp** (`Date`): The timestamp of the event
226
+ **workflowName** (`string`): Name of the workflow this run belongs to
227
227
 
228
- **payload** (`object`): Contains currentStep (id, status, output, payload) and workflowState (status, steps record)
228
+ **resourceId** (`string`): Resource ID associated with the run, if one was set
229
+
230
+ **createdAt** (`string`): ISO 8601 timestamp of when the run was created
231
+
232
+ **updatedAt** (`string`): ISO 8601 timestamp of when the run was last updated
233
+
234
+ **status** (`WorkflowRunStatus`): Current status of the run, such as 'running', 'success', 'failed', 'suspended', 'waiting', or 'canceled'
235
+
236
+ **payload** (`Record<string, any>`): Input data the run was started with
237
+
238
+ **result** (`Record<string, any>`): Final output of the workflow when the run succeeded
239
+
240
+ **error** (`SerializedError`): Error details when the run failed
241
+
242
+ **steps** (`Record<string, WorkflowStateStepResult>`): Per-step results, including status, output, payload, and timing
243
+
244
+ Use the `fields` option to limit which optional fields are returned. Metadata fields and `status` are always included.
229
245
 
230
246
  ## Dynamic workflows
231
247
 
@@ -4,8 +4,6 @@
4
4
 
5
5
  # mountAgentControllerOnMastra()
6
6
 
7
- > **Beta:** Breaking changes may occur without a major version bump until the API is stable.
8
-
9
7
  The `mountAgentControllerOnMastra()` function builds the Mastra Code agent controller (the coding agent behind [Mastra Code](https://code.mastra.ai), with its modes, tools, memory, and thread management) and registers it on a server-owned [Mastra](https://mastra.ai/reference/core/mastra-class) instance. Use it to serve the Mastra Code agent to your own UI (web app, editor, bot): each client creates or resumes its own isolated session through the returned [`AgentController`](https://mastra.ai/reference/agent-controller/agent-controller-class).
10
8
 
11
9
  To construct the `Mastra` instance yourself (for example in a deployable entry file), use `prepareAgentControllerMount()` from the same package, which returns the constructor args plus a `finalize()` callback.
@@ -60,7 +58,7 @@ const { controller } = await mountAgentControllerOnMastra({ mastra })
60
58
 
61
59
  **mastra** (`Mastra`): Existing Mastra instance to mount onto. When omitted, a Mastra is created that owns the controller storage.
62
60
 
63
- **controllerId** (`string`): Id under which the controller is registered on the Mastra instance.
61
+ **controllerId** (`string`): Key the controller is registered under on the Mastra instance. Clients pass this key to client.getAgentController(). (Default: `controller.id`)
64
62
 
65
63
  **modes** (`AgentControllerMode[]`): Override agent modes (model ids, colors, which modes exist). (Default: `build/plan/fast`)
66
64
 
@@ -92,6 +92,47 @@ Dot paths are supported. An empty group evaluates to `true`, and an unknown oper
92
92
 
93
93
  Blocks without conditions are always included.
94
94
 
95
+ A `prompt_block_ref` can also have its own `rules`. They apply only to that reference in that agent, so you can reuse one stored block under different conditions. If the stored block has rules too, both must pass.
96
+
97
+ ### Runtime slot with a fallback
98
+
99
+ Combine an inline `prompt_block` and a conditional `prompt_block_ref` to insert a value from request context and fall back to a shared stored block when the value is missing:
100
+
101
+ ```typescript
102
+ await editor.agent.update({
103
+ id: 'support-agent',
104
+ instructions: [
105
+ { type: 'text', content: 'Follow the platform safety policy.' },
106
+ {
107
+ type: 'prompt_block',
108
+ content: '{{userPrompt}}',
109
+ rules: {
110
+ operator: 'AND',
111
+ conditions: [
112
+ { field: 'userPrompt', operator: 'exists' },
113
+ { field: 'userPrompt', operator: 'not_equals', value: '' },
114
+ ],
115
+ },
116
+ },
117
+ {
118
+ type: 'prompt_block_ref',
119
+ id: 'default-user-prompt',
120
+ rules: {
121
+ operator: 'OR',
122
+ conditions: [
123
+ { field: 'userPrompt', operator: 'not_exists' },
124
+ { field: 'userPrompt', operator: 'equals', value: '' },
125
+ ],
126
+ },
127
+ },
128
+ ],
129
+ })
130
+ ```
131
+
132
+ When the request context contains a non-empty `userPrompt`, the agent receives that value. Otherwise, it receives the published `default-user-prompt` block. The stored block doesn't need to know about `userPrompt`.
133
+
134
+ > **Note:** The `exists` operator treats an empty string as present. The extra `''` conditions make an empty `userPrompt` use the fallback too.
135
+
95
136
  ## Programmatic API
96
137
 
97
138
  Access prompt blocks through `mastra.getEditor().prompt`. See the [`prompt` namespace](https://mastra.ai/reference/editor/mastra-editor) for complete method signatures.
@@ -81,6 +81,8 @@ const editor = new MastraEditor({
81
81
 
82
82
  **userIdResolver** (`ComposioUserIdResolver`): Server-side resolver that derives the effective Composio userId from authenticated context fields. Used for invoker and caller-supplied execution. The exact connected account always comes from the stored connection pin.
83
83
 
84
+ **sharedConnections** (`{ acl?: ComposioSharedAccountAcl }`): Opt in to Composio SHARED connected accounts. When set, connections authorized with scope: 'shared' are created as Composio SHARED accounts. acl accepts allowAllUsers, allowedUserIds, and notAllowedUserIds. Omit acl to keep Composio's deny-by-default access.
85
+
84
86
  ### Tool slugs
85
87
 
86
88
  Composio tools use uppercase slug format: `GITHUB_CREATE_ISSUE`, `SLACK_SEND_MESSAGE`.
@@ -125,6 +127,23 @@ export const mastra = new Mastra({ editor })
125
127
 
126
128
  Configure the agent with an invoker connection pinned to `ca_alice_salesforce`. When Bob invokes the agent, Mastra sends `bob` as the Composio user and the pinned account ID as the exact connected account. The Memory resource stays `project_123`. Composio then checks whether the account's ACL permits Bob to execute it.
127
129
 
130
+ ### Create shared accounts
131
+
132
+ Set `sharedConnections` to create Composio [SHARED accounts](https://docs.composio.dev/docs/shared-connections) for connections authorized with `scope: 'shared'`:
133
+
134
+ ```typescript
135
+ new ComposioToolProvider({
136
+ apiKey: process.env.COMPOSIO_API_KEY!,
137
+ sharedConnections: {
138
+ acl: { allowAllUsers: true, notAllowedUserIds: ['contractor_1'] },
139
+ },
140
+ })
141
+ ```
142
+
143
+ Without `sharedConnections`, shared-scope connections are Composio PRIVATE accounts under the `shared` user. Composio doesn't support SHARED accounts for toolkits that require custom connection fields, so authorization fails for those toolkits instead of creating a PRIVATE account.
144
+
145
+ `listConnections()` returns the requested users' PRIVATE and SHARED accounts, plus SHARED accounts owned by other users whose ACL grants access to one of the requested users. You can pin these accounts like any other connected account.
146
+
128
147
  ### Map application users to Composio users
129
148
 
130
149
  Use `userIdResolver` when your Composio user IDs differ from the IDs returned by Mastra authentication, or when your application must authorize the stored account pin before execution.
@@ -4,8 +4,6 @@
4
4
 
5
5
  # config.ts
6
6
 
7
- > **Beta:** Breaking changes may occur without a major version bump until the API is stable.
8
-
9
7
  An agent's `config.ts` sets its model and runtime options. Use it for options that belong to the [`Agent`](https://mastra.ai/reference/agents/agent) itself, while sibling files provide instructions, tools, skills, et cetera.
10
8
 
11
9
  ## What belongs in `config.ts`
@@ -4,8 +4,6 @@
4
4
 
5
5
  # Instructions
6
6
 
7
- > **Beta:** Breaking changes may occur without a major version bump until the API is stable.
8
-
9
7
  An agent's instructions hold its always-on system prompt: the model reads it on every turn. Use them to define the agent's identity, tone, role, and standing rules.
10
8
 
11
9
  Write them in one of two files at the agent root. Use `instructions.md` when the prompt is fixed text. Use `instructions.ts` when the prompt needs code, for example when it's built from shared constants or resolved per request.
@@ -4,8 +4,6 @@
4
4
 
5
5
  # Logger
6
6
 
7
- > **Beta:** Breaking changes may occur without a major version bump until the API is stable.
8
-
9
7
  Mastra sets the project's [logger](https://mastra.ai/docs/observability/logging) from a `logger.ts` file directly under `src/mastra/`. The file default-exports a logger, which replaces the built-in `ConsoleLogger` used across agents, workflows, and other components.
10
8
 
11
9
  Use this page for the file-based convention. For log levels, transports, and provider details, see [logging](https://mastra.ai/docs/observability/logging).
@@ -4,8 +4,6 @@
4
4
 
5
5
  # Memory
6
6
 
7
- > **Beta:** Breaking changes may occur without a major version bump until the API is stable.
8
-
9
7
  A file-based agent gets [memory](https://mastra.ai/docs/memory/overview) from a `memory.ts` file that default-exports a [`Memory`](https://mastra.ai/reference/memory/memory-class) instance. Use this page for the file-based convention; use the memory docs for message history, semantic recall, storage, and processors.
10
8
 
11
9
  Without `memory.ts` or `config.memory`, the agent has no memory by default. Each `generate()` or `stream()` call starts without remembered conversation state unless you pass the prior context yourself.
@@ -4,8 +4,6 @@
4
4
 
5
5
  # Observability
6
6
 
7
- > **Beta:** Breaking changes may occur without a major version bump until the API is stable.
8
-
9
7
  Mastra configures [observability](https://mastra.ai/docs/observability/overview) from an `observability.ts` file directly under `src/mastra/`. The file default-exports an `Observability` instance that sets up tracing, logging, metrics, and feedback for the project.
10
8
 
11
9
  Use this page for the file-based convention. For the signal model, exporters, storage, and multi-config setup, see the [observability overview](https://mastra.ai/docs/observability/overview) and [observability configuration](https://mastra.ai/docs/observability/overview).