@mastra/mcp-docs-server 1.3.14-alpha.2 → 1.3.14-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/auth/fga.md +1 -0
- package/.docs/docs/memory/observational-memory.md +8 -0
- package/.docs/docs/server/mastra-client.md +2 -0
- package/.docs/docs/server/mcp.md +2 -2
- package/.docs/docs/workflows/overview.md +1 -1
- package/.docs/docs/workflows/workflow-state.md +29 -0
- package/.docs/integrations/file-storage/amazon-s3.md +2 -0
- package/.docs/integrations/file-storage/google-cloud-storage.md +2 -0
- package/.docs/integrations/sandboxes/e2b.md +23 -0
- package/.docs/integrations/vectors/couchbase.md +3 -2
- package/.docs/models/gateways/mastra.md +4 -0
- package/.docs/reference/agents/durable-agent.md +6 -0
- package/.docs/reference/client-js/mastra-client.md +1 -1
- package/.docs/reference/rag/chunk.md +1 -1
- package/.docs/reference/server/builtin-mcp-tools.md +13 -13
- package/.docs/reference/tools/create-tool.md +1 -1
- package/.docs/reference/tools/mcp-server.md +2 -0
- package/.docs/reference/workflows/step.md +6 -2
- package/.docs/reference/workflows/workflow-methods/dountil.md +1 -1
- package/.docs/reference/workflows/workflow-methods/dowhile.md +1 -1
- package/.docs/reference/workflows/workflow.md +1 -1
- package/package.json +3 -3
package/.docs/docs/auth/fga.md
CHANGED
|
@@ -213,6 +213,7 @@ When an FGA provider is configured, Mastra automatically checks authorization at
|
|
|
213
213
|
| Agent tool execution | `tools:execute` | `tool` | `${agentId}:${toolName}` |
|
|
214
214
|
| MCP tool execution | `tools:execute` | `tool` by default, or the server-level `fga.resourceMapping` override | `JSON.stringify([serverName, toolName])` by default, or the server-level derived ID |
|
|
215
215
|
| Thread and memory access | `memory:read`, `memory:write`, `memory:delete` | `thread` | `threadId` |
|
|
216
|
+
| Resource working memory (`GET /memory/working-memory`) | `memory:read` | `resource` | The caller's mapped `resourceId`, or the requested `resourceId` |
|
|
216
217
|
| Stored resource routes | Stored resource permission for the route action | Stored resource type | Route record ID, or the stored-resource scope for collection routes |
|
|
217
218
|
| HTTP resource routes | Configured per route | Configured per route | Configured per route |
|
|
218
219
|
|
|
@@ -146,6 +146,14 @@ Token counts are local `tokenx` estimates. The provider's own count is often hig
|
|
|
146
146
|
|
|
147
147
|
A provider can reject a request for exceeding its context window before OM's estimate reaches the threshold. When that happens, OM activates any prepared observations, observes everything still pending, and retries the request once with the smaller context. This is on by default; set `observation.observeOnContextOverflow: false` to let the error reach your code instead.
|
|
148
148
|
|
|
149
|
+
### Gateway models
|
|
150
|
+
|
|
151
|
+
A [Mastra Gateway](https://mastra.ai/models/gateways/mastra) model can keep a thread's observations on the gateway instead of your storage adapter. The gateway only does that for a Gateway project key (`msk_...`) that it serves with its own provider keys and with memory enabled for the project. An organization key (`msk-gateway-...` or `mskv2_...`) is served by a gateway without the memory API, so OM keeps running locally against the `Memory` you configured.
|
|
152
|
+
|
|
153
|
+
Keep `Memory` configured with `observationalMemory: true` in both cases. With a project key the gateway owns the thread, which means your storage adapter stays empty and `memory.recall()` doesn't return those messages.
|
|
154
|
+
|
|
155
|
+
> **Warning:** A project key alone doesn't mean the gateway stores the thread. When the request is routed with your own provider key, or memory is disabled for the project, the gateway proxies it without storing observations, while Mastra still skips local OM for a `mastra/` model on a project key. Neither the gateway nor your storage adapter keeps the conversation in that case. Use gateway-managed provider keys with project memory enabled, or a directly configured provider model, when the thread has to be stored.
|
|
156
|
+
|
|
149
157
|
## Choosing models
|
|
150
158
|
|
|
151
159
|
The Observer and Reflector are model calls that run beside your agent. By default both use `model: 'auto'`, which resolves each time a role runs:
|
|
@@ -183,6 +183,8 @@ const testAgent = async () => {
|
|
|
183
183
|
|
|
184
184
|
`MastraClient` accepts optional parameters like `retries`, `backoffMs`, and `headers` to control request behavior. These parameters are useful for controlling retry behavior and including diagnostic metadata.
|
|
185
185
|
|
|
186
|
+
By default, retries apply to read requests only. `GET`, `HEAD`, and `OPTIONS` are retried on failure, while `POST`, `PUT`, `PATCH`, and `DELETE` are sent once unless you set `retries` explicitly, so a failed write can't repeat a state-changing request such as an agent generation or workflow start. The observability queries that travel as `POST` only read server state, so `aggregateTraces()`, `aggregateSpans()`, `queryTraceThreads()`, and `querySpans()` keep the read default.
|
|
187
|
+
|
|
186
188
|
```typescript
|
|
187
189
|
import { MastraClient } from '@mastra/client-js'
|
|
188
190
|
|
package/.docs/docs/server/mcp.md
CHANGED
|
@@ -193,7 +193,7 @@ These toolsets are on by default. Each is served only when the server can back i
|
|
|
193
193
|
|
|
194
194
|
| Toolset | Tools | Served when |
|
|
195
195
|
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
|
|
196
|
-
| `memory` | `list_threads`, `get_thread`, `list_messages`, `
|
|
196
|
+
| `memory` | `list_threads`, `get_thread`, `list_messages`, `get_memory_status`, `get_observations`, `get_working_memory`, `create_thread`, `update_thread`, `clone_thread` | An agent has memory, or stored agents are configured |
|
|
197
197
|
| `observability` | `query_traces`, `aggregate_traces`, `query_spans`, `aggregate_spans`, `query_threads`, `get_trace_query_fields`, `get_trace_query_values`, `get_trace`, `get_span`, `get_trace_trajectory`, `list_logs`, `list_traces` | Storage has an observability domain |
|
|
198
198
|
| `observability_analytics` | `analyze_metrics`, `analyze_scores`, `analyze_feedback`, `list_metric_names`, `list_scores`, `list_feedback` | Storage has an observability domain |
|
|
199
199
|
| `stored_agents` | `list_available_models`, `list_stored_agents`, `get_stored_agent`, `create_stored_agent`, `update_stored_agent` | The [editor](https://mastra.ai/docs/studio/editor) and an agents storage domain are configured |
|
|
@@ -220,7 +220,7 @@ In read-only mode, the query and aggregate tools stay available because their ro
|
|
|
220
220
|
|
|
221
221
|
### Agents creating agents
|
|
222
222
|
|
|
223
|
-
`create_stored_agent` lets an MCP client create agents that other clients can then call. It needs `stored-agents:write`. A created agent is owned by the caller and is private by default. Without a caller identity, such as when `server.auth` isn't configured, the agent has no owner and is public, even with `visibility: 'private'`.
|
|
223
|
+
`create_stored_agent` lets an MCP client create agents that other clients can then call. It needs `stored-agents:write`. A created agent is owned by the caller and is private by default. Without a caller identity, such as when `server.auth` isn't configured, the agent has no owner and is public, even with `visibility: 'private'`. A private agent is hidden from other users in `list_agents` and `list_stored_agents`, and calling it answers as if it doesn't exist unless the caller is an admin or was granted that agent by id, the same as over HTTP. Set `visibility: 'public'` to let every user call it. Only the owner, admins, and users granted that agent by id can edit it either way. An agent with no owner can be edited by any user with `stored-agents:write`. See [stored agent visibility](https://mastra.ai/docs/studio/editor). When the agent builder restricts models, the MCP tools accept only allowed models for the agent's model (the `provider` and `name` it runs, in each conditional variant), for any model named in `defaultOptions` (such as `structuredOutput.model`), for each enabled entry of the fallback `modelList`, for the memory models (the Observational Memory observer and reflector models and the title model), and for the `model` of every input and output processor step, at any depth of the processor graph. They also reject anything that would run on a default model the policy can't check: `observationalMemory: true`, an Observational Memory config without a `model`, memory left out on create (which the agent builder fills with Observational Memory on its default model), or a processor that needs a model, such as `moderation`, without one. Set an allowed `model` instead. A stored `model` takes only `provider`, `name`, and model settings such as `temperature`. Other keys, such as `modelId` or `providerId`, are rejected. If the agent builder's policy can't be loaded, the tools return an error instead of saving unchecked. `list_available_models` returns the allowed models. The HTTP route doesn't apply this check, so a user who can call `POST /stored/agents` directly can still save any model. Embedding models (`memory.embedder`) aren't on the builder's model list and aren't checked. Tool allowlists aren't checked when an agent is saved, so a created agent can use any tool the server has. Its tools run with the permissions of the user who calls it.
|
|
224
224
|
|
|
225
225
|
Observational Memory starts observing only after a thread reaches its token threshold, 30,000 tokens by default. For a short demo, set a lower `observation.messageTokens` so the agent learns from a few messages. Observational Memory processes messages in the background, so right after `call_agent`, call `get_observations` with `waitForPending: true` to wait (up to 30 seconds) for it to finish before reading.
|
|
226
226
|
|
|
@@ -210,7 +210,7 @@ const step1 = createStep({
|
|
|
210
210
|
console.log(state.counter)
|
|
211
211
|
|
|
212
212
|
// Update state for subsequent steps
|
|
213
|
-
setState({
|
|
213
|
+
await setState({ counter: state.counter + 1 })
|
|
214
214
|
|
|
215
215
|
return { formatted: inputData.message.toUpperCase() }
|
|
216
216
|
},
|
|
@@ -93,6 +93,35 @@ export const testWorkflow = createWorkflow({
|
|
|
93
93
|
.commit()
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
+
## Updating state
|
|
97
|
+
|
|
98
|
+
Steps write state with `setState` or `updateState`.
|
|
99
|
+
|
|
100
|
+
`setState` takes the whole state and is validated on its own against the step's `stateSchema`, so it has to contain every field that schema requires. Keys you leave out keep their current value, and a second call in the same step replaces the first:
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
execute: async ({ getState, setState }) => {
|
|
104
|
+
const state = await getState()
|
|
105
|
+
await setState({ ...state, status: 'done' })
|
|
106
|
+
return {}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
On the evented engine, `setState` instead merges the keys you pass into the state without validating them. A partial state works there, and a second call adds to the first.
|
|
111
|
+
|
|
112
|
+
`updateState` takes only the keys that change. It merges them into the state the step sees and validates the merged result, so a partial update is fine, and keys other steps changed stay as they are. A key set to `undefined` is removed:
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
execute: async ({ updateState }) => {
|
|
116
|
+
await updateState({ status: 'done', count: 1 })
|
|
117
|
+
return {}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Both return a promise. Await them: the update is applied before the step returns, and a value that fails `stateSchema` fails the step.
|
|
122
|
+
|
|
123
|
+
On runs stored with `storageVersion: 2`, reading `state` throws. Use `await getState()`, optionally with top-level keys, to read the state including this step's own updates.
|
|
124
|
+
|
|
96
125
|
## Setting initial state
|
|
97
126
|
|
|
98
127
|
Pass `initialState` when starting a workflow run to set the starting values:
|
|
@@ -210,6 +210,8 @@ Tigris uses virtual-hosted-style addressing, so `forcePathStyle` must be set to
|
|
|
210
210
|
|
|
211
211
|
**readOnly** (`boolean`): When true, all write operations are blocked (Default: `false`)
|
|
212
212
|
|
|
213
|
+
**owner** (`{ uid: number; gid: number }`): Owner of the files inside a FUSE mount when this filesystem is mounted in a sandbox, as numeric uid and gid. Set it when sandbox commands run as a user other than the one that mounts, so that user can read and write the mounted files. When unset, the sandbox probes the default user's uid and gid.
|
|
214
|
+
|
|
213
215
|
## Properties
|
|
214
216
|
|
|
215
217
|
**id** (`string`): Filesystem instance identifier
|
|
@@ -110,6 +110,8 @@ const filesystem = new GCSFilesystem({
|
|
|
110
110
|
|
|
111
111
|
**readOnly** (`boolean`): When true, all write operations are blocked (Default: `false`)
|
|
112
112
|
|
|
113
|
+
**owner** (`{ uid: number; gid: number }`): Owner of the files inside a FUSE mount when this filesystem is mounted in a sandbox, as numeric uid and gid. Set it when sandbox commands run as a user other than the one that mounts, so that user can read and write the mounted files. When unset, the sandbox probes the default user's uid and gid.
|
|
114
|
+
|
|
113
115
|
**endpoint** (`string`): Custom API endpoint URL. Used for local development with emulators.
|
|
114
116
|
|
|
115
117
|
## Properties
|
|
@@ -68,6 +68,8 @@ const agent = new Agent({
|
|
|
68
68
|
|
|
69
69
|
**env** (`Record<string, string>`): Environment variables to set in the sandbox
|
|
70
70
|
|
|
71
|
+
**user** (`string`): OS user to run sandbox commands as, by name. Defaults to the template's own user. Use it to run agent commands as a second, unprivileged user: mounting still runs as the default user, which needs sudo. Set owner on a mount to give the command user read and write access to it. The user must already exist in the template.
|
|
72
|
+
|
|
71
73
|
**workingDirectory** (`string`): Default directory for command execution when no per-command cwd is given. A per-command cwd always wins; when neither is set, commands run from the sandbox home directory. Use an absolute path.
|
|
72
74
|
|
|
73
75
|
**id** (`string`): Unique identifier for this sandbox instance (Default: `Auto-generated`)
|
|
@@ -197,6 +199,27 @@ E2B sandboxes use FUSE (Filesystem in Userspace) to mount cloud storage:
|
|
|
197
199
|
|
|
198
200
|
The E2B sandbox automatically installs the required FUSE tools when mounting is used. For best performance, pre-build a custom template with the tools installed.
|
|
199
201
|
|
|
202
|
+
### Running commands as another user
|
|
203
|
+
|
|
204
|
+
Mounting needs `sudo`, so the template's default user is privileged: any command it runs can read the credentials staged for a mount and become root. To give agent commands less privilege, run them as a second user and set the owner of each mount to that user's uid and gid:
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
const workspace = new Workspace({
|
|
208
|
+
mounts: {
|
|
209
|
+
'/s3-data': new S3Filesystem({
|
|
210
|
+
bucket: 'my-s3-bucket',
|
|
211
|
+
region: 'us-east-1',
|
|
212
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
213
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
214
|
+
owner: { uid: 1001, gid: 1001 },
|
|
215
|
+
}),
|
|
216
|
+
},
|
|
217
|
+
sandbox: new E2BSandbox({ id: 'dev-sandbox', user: 'agent' }),
|
|
218
|
+
})
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
`owner` sets the uid and gid of the files inside the mount, so the `user` running commands can read and write them. Without it, the mount is owned by the user that mounted it. Create the user in the template first; E2B runs a command as that user but doesn't create it.
|
|
222
|
+
|
|
200
223
|
## Custom templates
|
|
201
224
|
|
|
202
225
|
By default, when no template is specified, E2BSandbox automatically builds a template with `s3fs` installed for S3 mounting support, a current Node.js LTS installed over the base image's older runtime, and corepack enabled so `pnpm` and `yarn` resolve to whatever a repository's `packageManager` field pins. This template is cached and reused across sandbox instances.
|
|
@@ -101,7 +101,7 @@ Adds or updates vectors and their metadata in the collection.
|
|
|
101
101
|
|
|
102
102
|
Searches for similar vectors.
|
|
103
103
|
|
|
104
|
-
> **Warning:** The `filter` and `includeVector` parameters aren't currently supported.
|
|
104
|
+
> **Warning:** The `filter` and `includeVector` parameters aren't currently supported. A `filter` is ignored, and the store logs a warning the first time one is passed. Passing `includeVector: true` throws a `MastraError`. Filter results client-side after retrieving them, or use the Couchbase SDK's Search capabilities. Retrieve the vector embedding by fetching the full document by ID with the Couchbase SDK.
|
|
105
105
|
|
|
106
106
|
**indexName** (`string`): Name of the index to search in
|
|
107
107
|
|
|
@@ -109,7 +109,7 @@ Searches for similar vectors.
|
|
|
109
109
|
|
|
110
110
|
**topK** (`number`): Number of results to return (Default: `10`)
|
|
111
111
|
|
|
112
|
-
**filter** (`Record<string, any>`): Not supported. Filters passed here are ignored.
|
|
112
|
+
**filter** (`Record<string, any>`): Not supported. Filters passed here are ignored, and a warning is logged the first time one is passed.
|
|
113
113
|
|
|
114
114
|
**includeVector** (`boolean`): Not supported. Setting this to true throws an error. (Default: `false`)
|
|
115
115
|
|
|
@@ -225,6 +225,7 @@ try {
|
|
|
225
225
|
- Index creation delays may impact immediate querying after creation.
|
|
226
226
|
- Vector dimension is enforced at ingest only after `createIndex()` creates a new index on the same `CouchbaseVector` instance. Calling `createIndex()` for an index that already exists doesn't turn on the ingest check. When the check is on, `upsert()` and `updateVector()` throw on a dimension mismatch. `query()` always checks the query vector against the index dimension.
|
|
227
227
|
- `deleteVectors()` supports deletion by ID only. Metadata-filter deletion isn't supported.
|
|
228
|
+
- `query()` can't filter by metadata. When Couchbase is Mastra memory's vector store, semantic recall still stays within the current thread or resource, because Memory checks each result itself. Results from other threads or resources still count toward `topK`, so recall may return fewer messages than `topK`.
|
|
228
229
|
- Vector insertion and index updates are eventually consistent. Strong consistency isn't guaranteed immediately after writes.
|
|
229
230
|
|
|
230
231
|
## Related
|
|
@@ -60,6 +60,10 @@ for await (const chunk of result.textStream) {
|
|
|
60
60
|
}
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
+
A gateway with a Gateway project key (`msk_...`) stores each thread's observations when it serves the request with its own provider keys and memory is enabled for the project. A gateway with an organization key (`msk-gateway-...` or `mskv2_...`) is served without the memory API, so it doesn't. Configure [`Memory`](https://mastra.ai/docs/memory/observational-memory) with `observationalMemory: true` in that case: Observational Memory then runs against your storage adapter instead of the gateway.
|
|
64
|
+
|
|
65
|
+
When a request is routed with your own provider key, or memory is disabled for the project, the gateway proxies it without storing observations while Mastra skips local Observational Memory for a `mastra/` model on a project key. Use gateway-managed provider keys with project memory enabled when the thread has to be stored.
|
|
66
|
+
|
|
63
67
|
## Configuration
|
|
64
68
|
|
|
65
69
|
```bash
|
|
@@ -75,6 +75,8 @@ Returns: `DurableAgent`
|
|
|
75
75
|
|
|
76
76
|
**shouldPersistSnapshot** (`(params: { stepResults, workflowStatus }) => boolean`): Predicate controlling which workflow snapshots the durable run persists. The default always persists pending, paused, and suspended (required for human-in-the-loop resume) and persists running checkpoints only when the Mastra instance is configured with recovery.durableAgents: 'auto'. Pass a predicate that includes running to keep crash-recovery checkpoints for manual listActiveRuns() / recoverActiveRuns() without enabling automatic recovery. Mastra logs a warning when a predicate excludes suspended or paused, or excludes running while recovery.durableAgents is 'auto'.
|
|
77
77
|
|
|
78
|
+
**storageVersion** (`1 | 2`): Experimental. How new runs of this agent are stored. 1 rewrites the whole run on every save. 2 saves only what changed at each step, which cuts storage writes for long runs. Version 2 needs a storage adapter that supports it: in-memory, @mastra/pg, or @mastra/libsql. On another adapter, the agent logs a warning and stores new runs as version 1. A run keeps the version it was stored with, so a run resumed after changing this option continues in that version. (Default: `1`)
|
|
79
|
+
|
|
78
80
|
## `createEventedAgent(options)`
|
|
79
81
|
|
|
80
82
|
Wraps an `Agent` with fire-and-forget durable execution on the built-in evented workflow engine. Like `createDurableAgent`, it returns a result you stream from, but the run is started without being awaited: events on the Mastra instance's PubSub drive execution independently of the caller. Register the agent on a `Mastra` instance with storage to get evented execution; without one, the agent falls back to the default in-process engine and logs a warning. It doesn't accept `id` or `name` overrides.
|
|
@@ -101,6 +103,8 @@ Returns: `EventedAgent` (a subclass of `DurableAgent`)
|
|
|
101
103
|
|
|
102
104
|
**shouldPersistSnapshot** (`(params: { stepResults, workflowStatus }) => boolean`): Accepted for API symmetry with createDurableAgent, but ignored: the evented engine requires the full snapshot set (pending, paused, suspended, running) because the initial running write creates the base row that suspend-merges and multi-worker coordination build on. A warning is logged if set.
|
|
103
105
|
|
|
106
|
+
**storageVersion** (`1 | 2`): Experimental. How new runs of this agent are stored. 1 rewrites the whole run on every save. 2 saves only what changed at each step, which cuts storage writes for long runs. Version 2 needs a storage adapter that supports it: in-memory, @mastra/pg, or @mastra/libsql. On another adapter, the agent logs a warning and stores new runs as version 1. A run keeps the version it was stored with, so a run resumed after changing this option continues in that version. (Default: `1`)
|
|
107
|
+
|
|
104
108
|
## Constructor parameters
|
|
105
109
|
|
|
106
110
|
The `DurableAgent` class accepts the same options as `createDurableAgent`, plus `cleanupTimeoutMs`. Prefer the factory unless you need to subclass.
|
|
@@ -121,6 +125,8 @@ The `DurableAgent` class accepts the same options as `createDurableAgent`, plus
|
|
|
121
125
|
|
|
122
126
|
**shouldPersistSnapshot** (`(params: { stepResults, workflowStatus }) => boolean`): Predicate controlling which workflow snapshots the durable run persists. The default always persists pending, paused, and suspended (required for human-in-the-loop resume) and persists running checkpoints only when the Mastra instance is configured with recovery.durableAgents: 'auto'.
|
|
123
127
|
|
|
128
|
+
**storageVersion** (`1 | 2`): Experimental. How new runs of this agent are stored. See storageVersion on createDurableAgent. (Default: `1`)
|
|
129
|
+
|
|
124
130
|
**cleanupTimeoutMs** (`number`): Grace period in milliseconds before registry entries are cleaned up automatically after a stream finishes or errors. Set to 0 to disable auto-cleanup and require a manual cleanup() call. Auto-cleanup does not fire on suspended events. (Default: `30000`)
|
|
125
131
|
|
|
126
132
|
## Methods
|
|
@@ -43,7 +43,7 @@ You can also pass `requestContext` as a `Record<string, any>`.
|
|
|
43
43
|
|
|
44
44
|
**baseUrl** (`string`): The base URL for the Mastra API. All requests will be sent relative to this URL.
|
|
45
45
|
|
|
46
|
-
**retries** (`number`): The number of times a request will be retried on failure before throwing an error. (Default: `3`)
|
|
46
|
+
**retries** (`number`): The number of times a request will be retried on failure before throwing an error. Retries apply to read requests (GET, HEAD, OPTIONS) by default, and to the observability queries that read server state even though they are sent as POST (aggregateTraces, aggregateSpans, queryTraceThreads, querySpans). Write requests (POST, PUT, PATCH, DELETE) are sent once unless you set this explicitly, so a server error can't repeat a state-changing request. (Default: `3 for read requests, 0 for write requests`)
|
|
47
47
|
|
|
48
48
|
**backoffMs** (`number`): The initial delay in milliseconds before retrying a failed request. This value is doubled with each retry (exponential backoff). (Default: `300`)
|
|
49
49
|
|
|
@@ -200,7 +200,7 @@ When using the `headers` option, the markdown strategy ignores all general optio
|
|
|
200
200
|
|
|
201
201
|
### JSON
|
|
202
202
|
|
|
203
|
-
**maxSize** (`number`): Target maximum size of each JSON chunk. Must be at least 21. Long values
|
|
203
|
+
**maxSize** (`number`): Target maximum size of each JSON chunk. Must be at least 21. Long string values are split so chunks stay within this limit, and no content is discarded. A chunk can exceed the limit when a field path leaves no room for a single character, when ensureAscii escaping expands a value (the default), or when a long value is nested in an object.
|
|
204
204
|
|
|
205
205
|
**minSize** (`number`): Accepted for compatibility. Has no effect on JSON chunking: chunks smaller than this are kept, so no data is discarded.
|
|
206
206
|
|
|
@@ -59,22 +59,22 @@ A `tool_<id>` entry uses the tool's own `mcp.annotations` when the tool defines
|
|
|
59
59
|
|
|
60
60
|
## `memory`
|
|
61
61
|
|
|
62
|
-
| Tool
|
|
63
|
-
|
|
|
64
|
-
| `list_threads`
|
|
65
|
-
| `get_thread`
|
|
66
|
-
| `list_messages`
|
|
67
|
-
| `
|
|
68
|
-
| `
|
|
69
|
-
| `
|
|
70
|
-
| `create_thread`
|
|
71
|
-
| `update_thread`
|
|
72
|
-
| `clone_thread`
|
|
73
|
-
| `save_messages` | `agentId*`, `messages*` | `POST /memory/save-messages` | `memory:write` |
|
|
62
|
+
| Tool | Arguments | Route | Permission |
|
|
63
|
+
| -------------------- | --------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------- |
|
|
64
|
+
| `list_threads` | `agentId`, `resourceId`, `page`, `perPage` | `GET /memory/threads` | `memory:read` |
|
|
65
|
+
| `get_thread` | `threadId*`, `agentId` | `GET /memory/threads/:threadId` | `memory:read` |
|
|
66
|
+
| `list_messages` | `threadId*`, `agentId`, `page`, `perPage` | `GET /memory/threads/:threadId/messages` | `memory:read` |
|
|
67
|
+
| `get_memory_status` | `agentId*`, `resourceId`, `threadId` | `GET /memory/status`, `GET /memory/config` | `memory:read` |
|
|
68
|
+
| `get_observations` | `agentId*`, `threadId`, `resourceId`, `waitForPending` | `GET /memory/observational-memory` | `memory:read` |
|
|
69
|
+
| `get_working_memory` | `agentId*`, `threadId`, `resourceId` | `GET /memory/threads/:threadId/working-memory`, `GET /memory/working-memory` | `memory:read` |
|
|
70
|
+
| `create_thread` | `agentId*`, `resourceId`, `title`, `metadata`, `threadId` | `POST /memory/threads` | `memory:write` |
|
|
71
|
+
| `update_thread` | `threadId*`, `agentId*`, `title`, `metadata` | `PATCH /memory/threads/:threadId` | `memory:write` |
|
|
72
|
+
| `clone_thread` | `threadId*`, `agentId*`, `newThreadId`, `title`, `metadata`, `messageLimit` | `POST /memory/threads/:threadId/clone` | `memory:execute` |
|
|
74
73
|
|
|
75
74
|
- `resourceId` defaults to the caller when `server.auth` sets `mapUserToResourceId`, and a caller can't read or write another resource's threads, messages, or Observational Memory. Without `mapUserToResourceId`, the tools use the `resourceId` the client sends, so set `mapUserToResourceId` to keep memory private. [FGA](https://mastra.ai/docs/auth/fga) protects threads, but `get_observations` called with only a `resourceId` isn't covered by the default FGA routes.
|
|
76
75
|
- `get_observations` reads resource-scoped Observational Memory when `threadId` is left out. `waitForPending: true` waits up to 30 seconds for pending observations, and is only offered when the caller may call `POST /memory/observational-memory/buffer-status`, which needs `memory:write`.
|
|
77
|
-
- `
|
|
76
|
+
- `get_working_memory` reads working memory without changing it. With a thread, it reads `GET /memory/threads/:threadId/working-memory`. A thread set in the request context takes precedence over the `threadId` argument. Unless the agent's working memory uses `scope: 'thread'`, a thread read with a resource ID still returns the resource's working memory, shared by all of that resource's threads, and the result has `source: 'resource'`. Without a thread, it reads the resource's working memory from `GET /memory/working-memory`, which needs a `resourceId` from the argument or the caller's mapped resource, and returns a 400 when the agent's working memory is thread-scoped. With [FGA](https://mastra.ai/docs/auth/fga), the resource read checks `memory:read` on resource type `resource`, using the caller's mapped resource before the `resourceId` argument.
|
|
77
|
+
- The memory toolset doesn't save messages or run semantic search. Use the HTTP routes `POST /memory/save-messages` and `GET /memory/search` for those.
|
|
78
78
|
|
|
79
79
|
## `observability`
|
|
80
80
|
|
|
@@ -102,7 +102,7 @@ Mastra streams the tool call and returns `{ acknowledged: true }` as its result,
|
|
|
102
102
|
|
|
103
103
|
**execute.context.agent** (`AgentToolExecutionContext`): Agent-specific context, available when the tool is executed by an agent.
|
|
104
104
|
|
|
105
|
-
**execute.context.workflow** (`WorkflowToolExecutionContext`): Workflow-specific context (state, setState, suspend, etc.)
|
|
105
|
+
**execute.context.workflow** (`WorkflowToolExecutionContext`): Workflow-specific context (state, getState, setState, suspend, etc.)
|
|
106
106
|
|
|
107
107
|
**execute.context.mcp** (`MCPToolExecutionContext`): MCP-specific context (elicitation, etc.)
|
|
108
108
|
|
|
@@ -97,6 +97,8 @@ The constructor accepts an `MCPServerConfig` object with the following propertie
|
|
|
97
97
|
|
|
98
98
|
**legacy** (`'reject' | 'stateless'`): How HTTP requests from 2025-era clients (those that open with initialize, such as VS Code and Cursor) are served. 'reject' (default) answers them with an unsupported-protocol-version error. 'stateless' answers each request without a session: listing and calling tools, reading resources and getting prompts work, GET and DELETE session requests get 405, and features that need 2026-07-28 (suspend/resume, subscriptions/listen, events) aren't available to these clients.
|
|
99
99
|
|
|
100
|
+
**maxRequestBodySize** (`number`): Upper bound, in bytes, on the HTTP request body the server reads from the request stream. A larger body is answered with a 413 JSON-RPC error before it is parsed, so no tool runs. It bounds only the body the server reads itself: when body-parsing middleware supplies the parsed body, this bound does not apply, so set the size limit on that parser as well. Defaults to 4194304 (4 MiB). Raise it on servers that receive large tools/call payloads, such as base64-encoded documents. Must be a positive number. Not applied to stdio, which has no request bodies.
|
|
101
|
+
|
|
100
102
|
**toolResult** (`MCPServerToolResultOptions`): Controls how completed tool calls become MCP results. modelOutput: true builds the result content from each tool's toModelOutput, so tools can return images, audio, and files. transform rewrites a result before it's sent. See Tool results for details.
|
|
101
103
|
|
|
102
104
|
**jsonSchemaValidator** (`jsonSchemaValidator`): Custom JSON Schema validator used for tool input, output and continuation answers, for runtimes where the SDK default is unavailable.
|
|
@@ -232,9 +232,13 @@ A classifier without constructor-configured questions can't be used as a workflo
|
|
|
232
232
|
|
|
233
233
|
**execute.suspend** (`(suspendPayload: any, suspendOptions?: { resumeLabel?: string }) => Promise<void>`): Function to pause workflow execution
|
|
234
234
|
|
|
235
|
-
**execute.state** (`z.infer<TState>`): The current workflow state. Contains shared values that persist across all steps and suspend/resume cycles. The structure is defined by the step's stateSchema.
|
|
235
|
+
**execute.state** (`z.infer<TState>`): The current workflow state. Contains shared values that persist across all steps and suspend/resume cycles. The structure is defined by the step's stateSchema. Reading it in a run stored with storageVersion: 2 throws; use await getState() instead.
|
|
236
236
|
|
|
237
|
-
**execute.
|
|
237
|
+
**execute.getState** (`(keys?: string[]) => Promise<z.infer<TState>>`): Resolves to the current workflow state, including this step's own setState changes. Pass top-level keys to get only those keys. Works on every engine and storage version.
|
|
238
|
+
|
|
239
|
+
**execute.setState** (`(state: z.infer<TState>) => Promise<void>`): Replaces the step's pending state with the value you pass, which is validated on its own against the step's stateSchema, so it must contain every field that schema requires. Top-level keys you leave out keep their current value. A second call in the same step replaces the first. On the evented engine, setState instead merges the keys you pass into the state without validating them, and a second call adds to the first. Await it, so the update is applied before the step returns and a validation error fails the step.
|
|
240
|
+
|
|
241
|
+
**execute.updateState** (`(state: Partial<z.infer<TState>>) => Promise<void>`): Merges the top-level keys it's given into the workflow state and validates the merged state against the step's stateSchema. Pass only the keys that change: spreading a state you read earlier can overwrite changes that parallel steps made. A key set to undefined is removed. Await it, so the update is applied before the step returns and a validation error fails the step.
|
|
238
242
|
|
|
239
243
|
**execute.runId** (`string`): Current run id
|
|
240
244
|
|
|
@@ -16,7 +16,7 @@ workflow.dountil(step1, async ({ inputData }) => true)
|
|
|
16
16
|
|
|
17
17
|
**step** (`Step`): The step instance to execute in the loop
|
|
18
18
|
|
|
19
|
-
**condition** (`((params: ConditionFunctionParams & { iterationCount: number }) => Promise<boolean>) | { predicate: Predicate }`): A function that returns a boolean indicating whether the loop is done. When it returns true the loop ends; when it returns false the step runs again. The function receives the execution parameters (excluding setState and suspend) and the iteration count. A declarative { predicate } object is also accepted.
|
|
19
|
+
**condition** (`((params: ConditionFunctionParams & { iterationCount: number }) => Promise<boolean>) | { predicate: Predicate }`): A function that returns a boolean indicating whether the loop is done. When it returns true the loop ends; when it returns false the step runs again. The function receives the execution parameters (excluding setState, updateState, and suspend) and the iteration count. A declarative { predicate } object is also accepted.
|
|
20
20
|
|
|
21
21
|
**options** (`StepFlowEntryOptions`): Optional identity and display metadata for this graph entry. Preserved through serialization and storage; has no effect on execution.
|
|
22
22
|
|
|
@@ -16,7 +16,7 @@ workflow.dowhile(step1, async ({ inputData }) => true)
|
|
|
16
16
|
|
|
17
17
|
**step** (`Step`): The step instance to execute in the loop
|
|
18
18
|
|
|
19
|
-
**condition** (`((params: ConditionFunctionParams & { iterationCount: number }) => Promise<boolean>) | { predicate: Predicate }`): A function that returns a boolean indicating whether to continue the loop. The function receives the execution parameters (excluding setState and suspend) and the iteration count. A declarative { predicate } object is also accepted.
|
|
19
|
+
**condition** (`((params: ConditionFunctionParams & { iterationCount: number }) => Promise<boolean>) | { predicate: Predicate }`): A function that returns a boolean indicating whether to continue the loop. The function receives the execution parameters (excluding setState, updateState, and suspend) and the iteration count. A declarative { predicate } object is also accepted.
|
|
20
20
|
|
|
21
21
|
**options** (`StepFlowEntryOptions`): Optional identity and display metadata for this graph entry. Preserved through serialization and storage; has no effect on execution.
|
|
22
22
|
|
|
@@ -131,7 +131,7 @@ export const testWorkflow = createWorkflow({
|
|
|
131
131
|
|
|
132
132
|
**options.pruneSnapshot** (`(params: { snapshot: WorkflowRunState; workflowStatus: WorkflowRunStatus }) => WorkflowRunState`): Optional hook to transform the workflow snapshot immediately before it is persisted. Must return JSON-serializable data and preserve everything the workflow needs to resume (suspended step suspendPayloads, suspendedPaths, executionPath, etc.). On the evented engine it must also keep the status, startedAt and endedAt of each step result, metadata.iterationCount on a loop step result, suspendPayload.\_\_workflow_meta.foreachOutput on a foreach step result, and activePaths. Without them, a step delivered again after it finished can run a second time. Used internally by agent runs to keep snapshots minimal; user workflows persist full snapshots by default.
|
|
133
133
|
|
|
134
|
-
**options.storageVersion** (`1 | 2`): Experimental. How runs of this workflow are stored. 1 rewrites the whole run on every save. 2 saves only what changed at each step, which cuts storage writes for long workflows and loops. Version 2 requires the default execution engine and a storage adapter that supports it: in-memory, @mastra/pg, or @mastra/libsql. Creating a run on another adapter throws. It can't be combined with pruneSnapshot. Inside a version 2 run, read earlier steps with await getStepResultAsync(step) instead of getStepResult(step), and a shouldPersistSnapshot predicate sees earlier successful steps without their output. Workflow state is stored as JSON, so values such as Date are read back as strings. A run keeps the version it was stored with, so a run resumed after changing this option continues in that version. A nested workflow's runs use their parent run's version, so this option applies only when the workflow runs on its own.
|
|
134
|
+
**options.storageVersion** (`1 | 2`): Experimental. How runs of this workflow are stored. 1 rewrites the whole run on every save. 2 saves only what changed at each step, which cuts storage writes for long workflows and loops. Version 2 requires the default or evented execution engine and a storage adapter that supports it: in-memory, @mastra/pg, or @mastra/libsql. Creating a run on another adapter throws. It can't be combined with pruneSnapshot. Inside a version 2 run, read earlier steps with await getStepResultAsync(step) instead of getStepResult(step), and a shouldPersistSnapshot predicate sees earlier successful steps without their output. A version 2 run's result, and the onFinish and onError callbacks, get steps as an async function: call await result.steps() to read them. Workflow state is stored as JSON, so values such as Date are read back as strings. A run keeps the version it was stored with, so a run resumed after changing this option continues in that version. A nested workflow's runs use their parent run's version, so this option applies only when the workflow runs on its own.
|
|
135
135
|
|
|
136
136
|
**options.onStart** (`(info: WorkflowStartCallbackInfo) => void | Promise<void>`): Callback awaited before a run starts executing, and before any step runs. Fires only on initial start, not on resume, restart, or time travel. Unlike onFinish and onError, errors thrown here are propagated: they reject the start() or stream() call and the run never executes, so this can be used as a pre-flight gate such as a quota check. The run record created by createRun() stays at status pending.
|
|
137
137
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.3.14-alpha.
|
|
3
|
+
"version": "1.3.14-alpha.4",
|
|
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.84.0-alpha.
|
|
30
|
-
"@mastra/mcp": "^2.
|
|
29
|
+
"@mastra/core": "1.84.0-alpha.4",
|
|
30
|
+
"@mastra/mcp": "^2.10.0-alpha.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@hono/node-server": "^2.1.3",
|