@mastra/mcp-docs-server 1.2.17-alpha.14 → 1.2.17-alpha.16
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 +26 -0
- package/.docs/reference/agents/durable-agent.md +1 -1
- package/.docs/reference/agents/generate.md +1 -1
- package/.docs/reference/auth/fga.md +2 -0
- package/.docs/reference/index.md +1 -0
- package/.docs/reference/memory/memory-class.md +1 -0
- package/.docs/reference/memory/settled.md +57 -0
- package/.docs/reference/rag/graph-rag.md +71 -8
- package/.docs/reference/streaming/agents/stream.md +4 -3
- package/CHANGELOG.md +7 -0
- package/package.json +4 -4
package/.docs/docs/auth/fga.md
CHANGED
|
@@ -284,6 +284,32 @@ class MyFGAProvider implements IFGAProvider {
|
|
|
284
284
|
}
|
|
285
285
|
```
|
|
286
286
|
|
|
287
|
+
### Propagating an actor into workflow steps
|
|
288
|
+
|
|
289
|
+
A workflow run's `actor` reaches each step's execute context, but it isn't passed to the agent and tool calls that step makes. Steps that call an agent without an `actor` fall back to user membership resolution, which fails on system runs that have no user.
|
|
290
|
+
|
|
291
|
+
Set `propagate: true` on the actor to have the framework forward it into the agent and tool calls it makes for declarative `.then(agent)` and `.then(tool)` steps in the run:
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
await run.start({
|
|
295
|
+
inputData: { city: 'London' },
|
|
296
|
+
actor: { actorKind: 'system', sourceWorkflow: 'nightly-report', propagate: true },
|
|
297
|
+
})
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Propagation is opt-in and deliberately narrow:
|
|
301
|
+
|
|
302
|
+
- The `true` shorthand never propagates. Use the object form to opt in.
|
|
303
|
+
- Custom step `execute` functions are never covered. Read `actor` from the step context and pass it explicitly, so a step that acts on a user's behalf can't silently inherit system trust.
|
|
304
|
+
- Pass `actor` when creating the step to override the run actor for that step, including `actor: undefined` to drop back to user authorization mid-run.
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
// Runs as the system actor even though it loads user-supplied data.
|
|
308
|
+
workflow.then(createStep(reportAgent))
|
|
309
|
+
// Explicitly runs as the user instead.
|
|
310
|
+
workflow.then(createStep(summaryAgent, { actor: undefined }))
|
|
311
|
+
```
|
|
312
|
+
|
|
287
313
|
### Trust requirements
|
|
288
314
|
|
|
289
315
|
The actor signal is trusted input, so construct it server-side:
|
|
@@ -338,7 +338,7 @@ Returns: [`Promise<DurableAgentStreamResult>`](#durableagentstreamresult)
|
|
|
338
338
|
|
|
339
339
|
**onSuspended** (`(data: AgentSuspendedEventData) => void | Promise<void>`): Called when the run suspends, for example for tool approval.
|
|
340
340
|
|
|
341
|
-
**onAbort** (`AgentExecutionOptions['onAbort']`): Called when the run is aborted via abortSignal or result.abort().
|
|
341
|
+
**onAbort** (`AgentExecutionOptions['onAbort']`): Called when the run is aborted via abortSignal or result.abort(). Receives the steps completed before the abort and, in text, the assistant text streamed so far.
|
|
342
342
|
|
|
343
343
|
**onIterationComplete** (`AgentExecutionOptions['onIterationComplete']`): Called after every agentic-loop iteration with the latest messageList, finishReason, and isFinal flag. Observation-only on durable agents: returning continue: false or feedback does not influence the loop.
|
|
344
344
|
|
|
@@ -78,7 +78,7 @@ const result = await agent.generate('message for agent')
|
|
|
78
78
|
|
|
79
79
|
**options.onError** (`({ error }: { error: Error | string }) => Promise<void> | void`): Callback function called when an error occurs during generation.
|
|
80
80
|
|
|
81
|
-
**options.onAbort** (`(event: any) => Promise<void> | void`): Callback function called when the generation is aborted.
|
|
81
|
+
**options.onAbort** (`(event: { steps: any[]; text?: string }) => Promise<void> | void`): Callback function called when the generation is aborted. steps contains the steps that completed before the abort, and text contains the assistant text generated so far for the step that was in flight.
|
|
82
82
|
|
|
83
83
|
**options.activeTools** (`Array<keyof ToolSet> | undefined`): Array of tool names that should be active during execution. If undefined, all available tools are active.
|
|
84
84
|
|
|
@@ -122,6 +122,8 @@ Identifies a call made by a trusted non-user actor rather than an authenticated
|
|
|
122
122
|
|
|
123
123
|
**sourceWorkflow** (`string`): Name of the workflow that started the actor run, when applicable.
|
|
124
124
|
|
|
125
|
+
**propagate** (`boolean`): Forwards this actor into the agent and tool calls the framework makes for the run's declarative .then(agent) and .then(tool) steps. Custom step execute functions aren't covered and must pass actor explicitly. Ignored by authorization itself. (Default: `false`)
|
|
126
|
+
|
|
125
127
|
## `FGADeniedError`
|
|
126
128
|
|
|
127
129
|
Thrown when an authorization check is denied. `require` and `requireActor` throw it to deny, and Mastra surfaces it as an HTTP `403`.
|
package/.docs/reference/index.md
CHANGED
|
@@ -211,6 +211,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
211
211
|
- [.getThreadById()](https://mastra.ai/reference/memory/getThreadById)
|
|
212
212
|
- [.listThreads()](https://mastra.ai/reference/memory/listThreads)
|
|
213
213
|
- [.recall()](https://mastra.ai/reference/memory/recall)
|
|
214
|
+
- [.settled()](https://mastra.ai/reference/memory/settled)
|
|
214
215
|
- [.summarizeThread()](https://mastra.ai/reference/memory/summarizeThread)
|
|
215
216
|
- [AgentNetwork to .network()](https://mastra.ai/reference/migrations/agentnetwork)
|
|
216
217
|
- [AI SDK v4 to v5](https://mastra.ai/reference/migrations/ai-sdk-v4-to-v5)
|
|
@@ -145,4 +145,5 @@ export const agent = new Agent({
|
|
|
145
145
|
- [listThreads](https://mastra.ai/reference/memory/listThreads)
|
|
146
146
|
- [deleteMessages](https://mastra.ai/reference/memory/deleteMessages)
|
|
147
147
|
- [cloneThread](https://mastra.ai/reference/memory/cloneThread)
|
|
148
|
+
- [settled](https://mastra.ai/reference/memory/settled)
|
|
148
149
|
- [Clone Utility Methods](https://mastra.ai/reference/memory/clone-utilities)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Memory.settled()
|
|
4
|
+
|
|
5
|
+
The `.settled()` method resolves once all background work the `Memory` instance started has finished. Some memory work continues after an agent run returns:
|
|
6
|
+
|
|
7
|
+
- Observational memory cycles (buffered observation and reflection, including the nested agent runs they spawn)
|
|
8
|
+
- Vector cleanup started by `deleteThread()` and `deleteMessages()`
|
|
9
|
+
|
|
10
|
+
Await this method before closing a storage connection you own. Without it, background statements can run against a closed connection.
|
|
11
|
+
|
|
12
|
+
The method is declared on the base memory class, so it's also available on the `MastraMemory` instance returned by `agent.getMemory()`.
|
|
13
|
+
|
|
14
|
+
## Usage example
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
await agent.generate('Hello', {
|
|
18
|
+
memory: { thread: 'thread-123', resource: 'user-456' },
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
await memory.settled()
|
|
22
|
+
await store.close()
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Parameters
|
|
26
|
+
|
|
27
|
+
This method takes no parameters.
|
|
28
|
+
|
|
29
|
+
## Returns
|
|
30
|
+
|
|
31
|
+
**void** (`Promise<void>`): A promise that resolves when all background memory work has finished. Background work that fails does not reject this promise.
|
|
32
|
+
|
|
33
|
+
## Extended usage example
|
|
34
|
+
|
|
35
|
+
Test suites and short-lived processes are the most common places to need this, since they close the store immediately after a run finishes.
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { Memory } from '@mastra/memory'
|
|
39
|
+
import { PostgresStore } from '@mastra/pg'
|
|
40
|
+
|
|
41
|
+
const store = new PostgresStore({ connectionString })
|
|
42
|
+
const memory = new Memory({ storage: store })
|
|
43
|
+
|
|
44
|
+
// ... run your agent ...
|
|
45
|
+
|
|
46
|
+
// Wait for observational memory and vector cleanup to finish before closing.
|
|
47
|
+
await memory.settled()
|
|
48
|
+
await store.close()
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
> **Note:** `settled()` joins the work that had started by the time you called it, plus any work that work enqueues. It does not prevent new work from starting afterwards, so call it once the agent runs you care about have returned.
|
|
52
|
+
|
|
53
|
+
## Related
|
|
54
|
+
|
|
55
|
+
- [Memory Class Reference](https://mastra.ai/reference/memory/memory-class)
|
|
56
|
+
- [Observational Memory](https://mastra.ai/docs/memory/observational-memory)
|
|
57
|
+
- [deleteMessages](https://mastra.ai/reference/memory/deleteMessages)
|
|
@@ -9,10 +9,7 @@ The `GraphRAG` class implements a graph-based approach to retrieval augmented ge
|
|
|
9
9
|
```typescript
|
|
10
10
|
import { GraphRAG } from '@mastra/rag'
|
|
11
11
|
|
|
12
|
-
const graphRag = new GraphRAG(
|
|
13
|
-
dimension: 1536,
|
|
14
|
-
threshold: 0.7,
|
|
15
|
-
})
|
|
12
|
+
const graphRag = new GraphRAG(1536, 0.7)
|
|
16
13
|
|
|
17
14
|
// Create the graph from chunks and embeddings
|
|
18
15
|
graphRag.createGraph(documentChunks, embeddings)
|
|
@@ -88,13 +85,79 @@ Returns an array of `RankedNode` objects, where each node contains:
|
|
|
88
85
|
|
|
89
86
|
**score** (`number`): Combined relevance score from graph traversal
|
|
90
87
|
|
|
88
|
+
### `serialize`
|
|
89
|
+
|
|
90
|
+
Returns a JSON-safe snapshot of the graph so it can be persisted and restored later instead of rebuilt with `createGraph`.
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
serialize(): GraphRAGSnapshot
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### Returns
|
|
97
|
+
|
|
98
|
+
Returns a `GraphRAGSnapshot` object containing:
|
|
99
|
+
|
|
100
|
+
**version** (`number`): Snapshot format version, used to reject snapshots this version of the class can't load
|
|
101
|
+
|
|
102
|
+
**dimension** (`number`): Dimension of the embedding vectors the graph was built with
|
|
103
|
+
|
|
104
|
+
**threshold** (`number`): Similarity threshold the graph was built with
|
|
105
|
+
|
|
106
|
+
**nodes** (`GraphNode[]`): All nodes in the graph, each including its full embedding
|
|
107
|
+
|
|
108
|
+
**edges** (`GraphEdge[]`): All edges in the graph
|
|
109
|
+
|
|
110
|
+
The snapshot is a deep copy, so mutating it doesn't affect the graph it came from. Every node carries its full embedding, so snapshots are large: a 1,000-node graph built with 1536-dimension embeddings serializes to about 20 MB of JSON. Size your storage column accordingly.
|
|
111
|
+
|
|
112
|
+
### `deserialize`
|
|
113
|
+
|
|
114
|
+
Rebuilds a `GraphRAG` instance from a snapshot produced by `serialize`.
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
static deserialize(snapshot: GraphRAGSnapshot): GraphRAG
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### Parameters
|
|
121
|
+
|
|
122
|
+
**snapshot** (`GraphRAGSnapshot`): A snapshot previously returned by serialize
|
|
123
|
+
|
|
124
|
+
Throws if the snapshot version is unsupported, if a node embedding doesn't match the snapshot dimension, or if an edge references a node that isn't in the snapshot. A bad snapshot therefore fails at load time instead of during a later query.
|
|
125
|
+
|
|
126
|
+
## Persisting a graph
|
|
127
|
+
|
|
128
|
+
Building a graph is O(n²) in the number of chunks, so rebuilding it on every process start is wasteful. Serialize the graph once and store the snapshot wherever you already keep state. A snapshot is plain JSON, so any store works (a file, a blob column, a key-value cache), and `GraphRAG` doesn't depend on a storage backend.
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { readFile, writeFile } from 'node:fs/promises'
|
|
132
|
+
import { GraphRAG } from '@mastra/rag'
|
|
133
|
+
import type { GraphRAGSnapshot } from '@mastra/rag'
|
|
134
|
+
|
|
135
|
+
const SNAPSHOT_PATH = './docs-graph.json'
|
|
136
|
+
|
|
137
|
+
async function loadOrBuildGraph() {
|
|
138
|
+
try {
|
|
139
|
+
const snapshot = JSON.parse(await readFile(SNAPSHOT_PATH, 'utf8')) as GraphRAGSnapshot
|
|
140
|
+
return GraphRAG.deserialize(snapshot)
|
|
141
|
+
} catch {
|
|
142
|
+
// No usable snapshot yet, so build the graph from scratch
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const graphRag = new GraphRAG(1536, 0.7)
|
|
146
|
+
graphRag.createGraph(documentChunks, embeddings)
|
|
147
|
+
|
|
148
|
+
await writeFile(SNAPSHOT_PATH, JSON.stringify(graphRag.serialize()))
|
|
149
|
+
|
|
150
|
+
return graphRag
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
A snapshot reflects the chunks it was built from and isn't updated incrementally. When the underlying documents change, build the graph again and store a new snapshot.
|
|
155
|
+
|
|
91
156
|
## Advanced example
|
|
92
157
|
|
|
93
158
|
```typescript
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
threshold: 0.8, // Stricter similarity threshold
|
|
97
|
-
})
|
|
159
|
+
// Stricter similarity threshold
|
|
160
|
+
const graphRag = new GraphRAG(1536, 0.8)
|
|
98
161
|
|
|
99
162
|
// Create graph from chunks and embeddings
|
|
100
163
|
graphRag.createGraph(documentChunks, embeddings)
|
|
@@ -80,7 +80,7 @@ const stream = await agent.stream('message for agent')
|
|
|
80
80
|
|
|
81
81
|
**options.onError** (`({ error }: { error: Error | string }) => Promise<void> | void`): Callback function called when an error occurs during streaming.
|
|
82
82
|
|
|
83
|
-
**options.onAbort** (`(event: any) => Promise<void> | void`): Callback function called when the stream is aborted.
|
|
83
|
+
**options.onAbort** (`(event: { steps: any[]; text?: string }) => Promise<void> | void`): Callback function called when the stream is aborted. steps contains the steps that completed before the abort, and text contains the assistant text streamed so far for the step that was in flight.
|
|
84
84
|
|
|
85
85
|
**options.abortSignal** (`AbortSignal`): Signal object that allows you to abort the agent's execution. When the signal is aborted, all ongoing operations will be terminated, including any in-flight subagent runs the agent delegated to.
|
|
86
86
|
|
|
@@ -303,8 +303,9 @@ const stream = await agent.stream('Tell me a story', {
|
|
|
303
303
|
onError: ({ error }) => {
|
|
304
304
|
console.error('Streaming error:', error)
|
|
305
305
|
},
|
|
306
|
-
onAbort:
|
|
307
|
-
console.log('Stream aborted
|
|
306
|
+
onAbort: ({ steps, text }) => {
|
|
307
|
+
console.log('Stream aborted after', steps.length, 'steps')
|
|
308
|
+
console.log('Partial text:', text)
|
|
308
309
|
},
|
|
309
310
|
})
|
|
310
311
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.2.17-alpha.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`b0a2a07`](https://github.com/mastra-ai/mastra/commit/b0a2a07800d42bd9823292e7db832374ed084c9c), [`ccbbcd9`](https://github.com/mastra-ai/mastra/commit/ccbbcd974eedff4367a54ed0e24c9ee742ab2f61), [`3f5c6f7`](https://github.com/mastra-ai/mastra/commit/3f5c6f728ea35da344248de9aa070f12849f3aa0), [`77e6b1b`](https://github.com/mastra-ai/mastra/commit/77e6b1bc4c46ce94fe501023fb4393c812ec6be3), [`2e1d098`](https://github.com/mastra-ai/mastra/commit/2e1d0984e325fd319d32ea182f596b3170be3847)]:
|
|
8
|
+
- @mastra/core@1.60.0-alpha.9
|
|
9
|
+
|
|
3
10
|
## 1.2.17-alpha.14
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.2.17-alpha.
|
|
3
|
+
"version": "1.2.17-alpha.16",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"jsdom": "^26.1.0",
|
|
29
29
|
"local-pkg": "^1.1.2",
|
|
30
30
|
"zod": "^4.4.3",
|
|
31
|
-
"@mastra/core": "1.60.0-alpha.
|
|
31
|
+
"@mastra/core": "1.60.0-alpha.9",
|
|
32
32
|
"@mastra/mcp": "^1.17.0-alpha.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"tsx": "^4.23.1",
|
|
46
46
|
"typescript": "^6.0.3",
|
|
47
47
|
"vitest": "4.1.10",
|
|
48
|
+
"@internal/lint": "0.0.123",
|
|
48
49
|
"@internal/types-builder": "0.0.98",
|
|
49
|
-
"@mastra/core": "1.60.0-alpha.
|
|
50
|
-
"@internal/lint": "0.0.123"
|
|
50
|
+
"@mastra/core": "1.60.0-alpha.9"
|
|
51
51
|
},
|
|
52
52
|
"homepage": "https://mastra.ai",
|
|
53
53
|
"repository": {
|