@mastra/mcp-docs-server 1.3.14-alpha.3 → 1.3.14-alpha.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.
- package/.docs/docs/auth/fga.md +1 -0
- package/.docs/docs/knowledge/search.md +14 -5
- 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/reference/agents/durable-agent.md +6 -0
- package/.docs/reference/knowledge/knowledge-class.md +45 -2
- package/.docs/reference/server/builtin-mcp-tools.md +13 -13
- package/.docs/reference/tools/create-tool.md +1 -1
- 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 +2 -2
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
|
|
|
@@ -43,18 +43,27 @@ Pass both or neither. [`embedderOptions`](https://mastra.ai/reference/knowledge/
|
|
|
43
43
|
|
|
44
44
|
Pages and notes are embedded when they're written. Scope pages aren't embedded, but notes on them are. Long pages are embedded in parts, and search still returns each page once. See [Limits](https://mastra.ai/reference/knowledge/limits) for the sizes.
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
Pages and notes written before you add `vector` and `embedder` stay keyword-only until they change. To embed them, run [`reembed()`](https://mastra.ai/reference/knowledge/knowledge-class) in batches until it returns no cursor. It doesn't change the pages. If the embedder keeps rate limiting, a call stops early with `rateLimited: true`, so wait before going on:
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
```typescript
|
|
49
|
+
let cursor: string | undefined
|
|
50
|
+
do {
|
|
51
|
+
const result = await knowledge.reembed({ cursor })
|
|
52
|
+
if (result.rateLimited) await new Promise(resolve => setTimeout(resolve, 60_000))
|
|
53
|
+
cursor = result.nextCursor
|
|
54
|
+
} while (cursor)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Run it again after you switch embedders. Until it finishes, search works less well:
|
|
49
58
|
|
|
50
|
-
- **Different dimension:** search uses a new index, so
|
|
51
|
-
- **Same dimension:** search
|
|
59
|
+
- **Different dimension:** search uses a new index, so content not yet embedded again is keyword-only.
|
|
60
|
+
- **Same dimension:** search compares the new model's queries with vectors from the old model, which gives poor matches.
|
|
52
61
|
|
|
53
62
|
### When embedding fails
|
|
54
63
|
|
|
55
64
|
If embedding or the vector write fails when a page or note is written, Knowledge tries again after about half a second, 2 seconds and 7.5 seconds. That covers a database that scales to zero and takes a few seconds to wake. Errors the provider marks as not retryable, such as a bad API key, aren't tried again.
|
|
56
65
|
|
|
57
|
-
If every attempt fails, the write still succeeds and Mastra logs a warning. A new page or note stays keyword-only. An updated one keeps its previous vectors, so meaning search matches its old content. Both last until it's written again with a change. An `upsertPage()` call that comes back `unchanged` writes nothing, so it doesn't embed the page either.
|
|
66
|
+
If every attempt fails, the write still succeeds and Mastra logs a warning. A new page or note stays keyword-only. An updated one keeps its previous vectors, so meaning search matches its old content. Both last until it's written again with a change, or until [`reembed()`](https://mastra.ai/reference/knowledge/knowledge-class) embeds it. An `upsertPage()` call that comes back `unchanged` writes nothing, so it doesn't embed the page either.
|
|
58
67
|
|
|
59
68
|
If the embedder or vector store fails during a search, the search returns keyword results and logs a warning.
|
|
60
69
|
|
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:
|
|
@@ -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
|
|
@@ -162,7 +162,7 @@ Returns the `displayLabel` for a scope address with its `$params` filled in: `'$
|
|
|
162
162
|
|
|
163
163
|
### Host writes
|
|
164
164
|
|
|
165
|
-
`upsertPage()`, `removePage()`, `addNote()`, `updateNote()` and `removeNote()` are host-only: they check no run scopes or access rules. Don't expose them through an agent tool, or through a server route without admin-level auth.
|
|
165
|
+
`upsertPage()`, `removePage()`, `movePage()`, `addNote()`, `updateNote()` and `removeNote()` are host-only: they check no run scopes or access rules. Don't expose them through an agent tool, or through a server route without admin-level auth.
|
|
166
166
|
|
|
167
167
|
#### `upsertPage()`
|
|
168
168
|
|
|
@@ -187,6 +187,23 @@ removePage(input: { scope: string; path: string; author?: string }): Promise<Kno
|
|
|
187
187
|
|
|
188
188
|
Removes the page at `path` and resolves to it, or to `null` when no page is there. Throws `"<scope>#<path>" has child pages; remove them first.` for a page with children, and `"<scope>#<path>" is declared in config; change the scope's pages to remove it.` for a template page. Throws without retrying when another write changed the page first.
|
|
189
189
|
|
|
190
|
+
#### `movePage()`
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
movePage(input: {
|
|
194
|
+
scope: string
|
|
195
|
+
path: string
|
|
196
|
+
parent?: string
|
|
197
|
+
toScope?: string
|
|
198
|
+
expectedVersion?: number
|
|
199
|
+
author?: string
|
|
200
|
+
}): Promise<KnowledgePage>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Moves the page at `path` in `scope`, with its child pages, under the page at `parent` and resolves to the moved page. `parent` is a key path in the destination scope. Leave it out to move the page to the top of the scope. `toScope` moves the page to another scope, creating that scope on first write like `upsertPage()`. The page keeps its ID, notes, pins and embeddings, so use it instead of removing and re-creating a page when its source moves. Paths below the page change, and links by path are re-resolved.
|
|
204
|
+
|
|
205
|
+
Throws `KnowledgeNotFoundError` when the page or the parent doesn't exist, `"<scope>#<path>" is declared in config; change the scope's pages to move it.` for a template page, `"<scope>#<path>" can't move under itself or its own subtree.`, and `"<parent>" already has a page with key "<key>"; move or rename that one first.` It also throws when the move would put pages more than 10 levels below the scope, and without retrying when another write changed the page first or when `expectedVersion` is stale.
|
|
206
|
+
|
|
190
207
|
#### `addNote()`
|
|
191
208
|
|
|
192
209
|
```typescript
|
|
@@ -235,13 +252,39 @@ const [scope] = await store.getScopesByAddress(['team:acme:support'])
|
|
|
235
252
|
const page = await store.getPageByPath({ scopeId: scope.id, path: ['handbook', 'refunds'], read })
|
|
236
253
|
```
|
|
237
254
|
|
|
255
|
+
#### `reembed()`
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
reembed(options?: { scope?: string; limit?: number; cursor?: string }): Promise<KnowledgeReembedResult>
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Embeds pages and notes that already exist, without changing them. Use it for content written before you added `vector` and `embedder`, or after you switch embedders. Each call handles up to `limit` pages (default 50, at most 500) with their notes, and resolves to:
|
|
262
|
+
|
|
263
|
+
- `embedded`: how many pages and notes this call embedded.
|
|
264
|
+
- `failed`: pages and notes whose embed still failed after Knowledge's own retries, each with its `kind`, `id` and `error`. The rest of the batch carries on, and a later run tries them again.
|
|
265
|
+
- `overChunkCap`: pages longer than the [chunk limit](https://mastra.ai/reference/knowledge/limits), with how many chunks they'd need. They're embedded up to the limit.
|
|
266
|
+
- `rateLimited`: `true` when the embedder kept rate limiting, so the call stopped early. Wait before you resume from `nextCursor`, or the next call is rate limited too.
|
|
267
|
+
- `nextCursor`: pass it as `cursor` to the next call. It's absent when everything has been handled.
|
|
268
|
+
|
|
269
|
+
`scope` limits the run to one scope's pages and the notes on them, such as `org:acme`. Without it, the run covers every page, then the notes on scope pages, where each scope counts toward `limit` like a page. Embedding a page again overwrites its vectors, so you can stop a run and resume it from the last cursor, or rerun it. The cursor isn't a snapshot. Pages added or removed during a run can be missed or handled twice, and a page read before a concurrent edit can overwrite the vectors that edit wrote. Run `reembed()` again after concurrent writes finish. Throws without `vector` and `embedder`.
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
let cursor: string | undefined
|
|
273
|
+
do {
|
|
274
|
+
const result = await knowledge.reembed({ cursor })
|
|
275
|
+
for (const failure of result.failed) console.warn(failure)
|
|
276
|
+
if (result.rateLimited) await new Promise(resolve => setTimeout(resolve, 60_000))
|
|
277
|
+
cursor = result.nextCursor
|
|
278
|
+
} while (cursor)
|
|
279
|
+
```
|
|
280
|
+
|
|
238
281
|
#### `reindexLinks()`
|
|
239
282
|
|
|
240
283
|
```typescript
|
|
241
284
|
reindexLinks(): Promise<number>
|
|
242
285
|
```
|
|
243
286
|
|
|
244
|
-
Rebuilds the page link index from every page body, and resolves to how many pages it indexed. Writes keep the index current, so this is for pages that predate it or were written straight to the store. It needs no vector store.
|
|
287
|
+
Rebuilds the page link index from every page body, and resolves to how many pages it indexed. Writes keep the index current, so this is for pages that predate it or were written straight to the store, and for links a write left as they were. A write re-resolves at most 100 linking pages, and checks at most 99 pages sharing a name. Past either limit it logs a warning that names `reindexLinks()`. It needs no vector store.
|
|
245
288
|
|
|
246
289
|
#### `renameScopeDeclaration()`
|
|
247
290
|
|
|
@@ -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
|
|
|
@@ -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.5",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
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.
|
|
29
|
+
"@mastra/core": "1.84.0-alpha.5",
|
|
30
30
|
"@mastra/mcp": "^2.10.0-alpha.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|