@mastra/mcp-docs-server 0.13.21 → 0.13.22-alpha.1
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/organized/changelogs/%40internal%2Fstorage-test-utils.md +8 -8
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +8 -0
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +36 -36
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +87 -87
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +29 -29
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +62 -62
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +9 -9
- package/.docs/organized/changelogs/%40mastra%2Flance.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +28 -28
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +24 -24
- package/.docs/organized/changelogs/%40mastra%2Fmem0.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +9 -9
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +29 -29
- package/.docs/organized/changelogs/%40mastra%2Frag.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +32 -32
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +11 -11
- package/.docs/organized/changelogs/create-mastra.md +17 -17
- package/.docs/organized/changelogs/mastra.md +29 -29
- package/.docs/organized/code-examples/agent.md +36 -0
- package/.docs/organized/code-examples/heads-up-game.md +4 -4
- package/.docs/raw/memory/memory-processors.mdx +5 -0
- package/.docs/raw/memory/overview.mdx +159 -104
- package/.docs/raw/memory/semantic-recall.mdx +5 -0
- package/.docs/raw/memory/working-memory.mdx +5 -0
- package/.docs/raw/reference/agents/agent.mdx +6 -0
- package/.docs/raw/reference/agents/generateVNext.mdx +2 -1
- package/.docs/raw/reference/agents/listAgents.mdx +68 -0
- package/.docs/raw/reference/agents/streamVNext.mdx +1 -1
- package/.docs/raw/reference/client-js/agents.mdx +54 -1
- package/.docs/raw/reference/client-js/workflows.mdx +36 -17
- package/.docs/raw/reference/core/mastra-class.mdx +2 -2
- package/.docs/raw/reference/memory/Memory.mdx +91 -239
- package/.docs/raw/reference/memory/createThread.mdx +36 -16
- package/.docs/raw/reference/memory/deleteMessages.mdx +39 -74
- package/.docs/raw/reference/memory/getThreadById.mdx +11 -11
- package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +26 -29
- package/.docs/raw/reference/memory/getThreadsByResourceIdPaginated.mdx +46 -124
- package/.docs/raw/reference/memory/query.mdx +76 -90
- package/CHANGELOG.md +14 -0
- package/README.md +8 -0
- package/package.json +4 -4
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Memory.getThreadsByResourceId() | Memory | Mastra Docs"
|
|
3
|
+
description: "Documentation for the `Memory.getThreadsByResourceId()` method in Mastra, which retrieves all threads that belong to a specific resource."
|
|
4
|
+
---
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
# Memory.getThreadsByResourceId()
|
|
7
|
+
|
|
8
|
+
The `.getThreadsByResourceId()` function retrieves all threads associated with a specific resource ID from storage. Threads can be sorted by creation or modification time in ascending or descending order.
|
|
4
9
|
|
|
5
10
|
## Usage Example
|
|
6
11
|
|
|
7
12
|
```typescript
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const memory = new Memory(config);
|
|
11
|
-
|
|
12
|
-
// Basic usage - returns threads sorted by createdAt DESC (default)
|
|
13
|
-
const threads = await memory.getThreadsByResourceId({
|
|
14
|
-
resourceId: "resource-123",
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
// Custom sorting by updatedAt in ascending order
|
|
18
|
-
const threadsByUpdate = await memory.getThreadsByResourceId({
|
|
19
|
-
resourceId: "resource-123",
|
|
20
|
-
orderBy: "updatedAt",
|
|
21
|
-
sortDirection: "ASC",
|
|
22
|
-
});
|
|
13
|
+
await memory?.getThreadsByResourceId({ resourceId: "user-123" });
|
|
23
14
|
```
|
|
24
15
|
|
|
25
16
|
## Parameters
|
|
@@ -40,24 +31,13 @@ const threadsByUpdate = await memory.getThreadsByResourceId({
|
|
|
40
31
|
},
|
|
41
32
|
{
|
|
42
33
|
name: "sortDirection",
|
|
43
|
-
type: "ThreadSortDirection",
|
|
34
|
+
type: "ThreadSortDirection",
|
|
44
35
|
description: "Sort order direction. Accepts 'ASC' or 'DESC'. Default: 'DESC'",
|
|
45
36
|
isOptional: true,
|
|
46
37
|
},
|
|
47
38
|
]}
|
|
48
39
|
/>
|
|
49
40
|
|
|
50
|
-
## Type Definitions
|
|
51
|
-
|
|
52
|
-
```typescript
|
|
53
|
-
type ThreadOrderBy = 'createdAt' | 'updatedAt';
|
|
54
|
-
type ThreadSortDirection = 'ASC' | 'DESC';
|
|
55
|
-
|
|
56
|
-
interface ThreadSortOptions {
|
|
57
|
-
orderBy?: ThreadOrderBy;
|
|
58
|
-
sortDirection?: ThreadSortDirection;
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
41
|
|
|
62
42
|
## Returns
|
|
63
43
|
|
|
@@ -72,6 +52,23 @@ interface ThreadSortOptions {
|
|
|
72
52
|
]}
|
|
73
53
|
/>
|
|
74
54
|
|
|
55
|
+
## Extended usage example
|
|
56
|
+
|
|
57
|
+
```typescript filename="src/test-memory.ts" showLineNumbers copy
|
|
58
|
+
import { mastra } from "./mastra";
|
|
59
|
+
|
|
60
|
+
const agent = mastra.getAgent("agent");
|
|
61
|
+
const memory = await agent.getMemory();
|
|
62
|
+
|
|
63
|
+
const thread = await memory?.getThreadsByResourceId({
|
|
64
|
+
resourceId: "user-123",
|
|
65
|
+
orderBy: "updatedAt",
|
|
66
|
+
sortDirection: "ASC"
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
console.log(thread);
|
|
70
|
+
```
|
|
71
|
+
|
|
75
72
|
### Related
|
|
76
73
|
|
|
77
74
|
- [Memory Class Reference](/reference/memory/Memory.mdx)
|
|
@@ -1,55 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Memory.getThreadsByResourceIdPaginated() | Memory | Mastra Docs"
|
|
3
|
+
description: "Documentation for the `Memory.getThreadsByResourceIdPaginated()` method in Mastra, which retrieves threads associated with a specific resource ID with pagination support."
|
|
4
|
+
---
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
# Memory.getThreadsByResourceIdPaginated()
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
import { Memory } from "@mastra/core/memory";
|
|
8
|
+
The `.getThreadsByResourceIdPaginated()` method retrieves threads associated with a specific resource ID with pagination support.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## Usage Example
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
resourceId: "
|
|
12
|
+
```typescript copy
|
|
13
|
+
await memory.getThreadsByResourceIdPaginated({
|
|
14
|
+
resourceId: "user-123",
|
|
15
15
|
page: 0,
|
|
16
|
-
perPage:
|
|
16
|
+
perPage: 10
|
|
17
17
|
});
|
|
18
|
-
|
|
19
|
-
console.log(result.threads);
|
|
20
|
-
console.log(result.total);
|
|
21
|
-
console.log(result.hasMore);
|
|
22
|
-
|
|
23
|
-
// Custom pagination with sorting
|
|
24
|
-
const customResult = await memory.getThreadsByResourceIdPaginated({
|
|
25
|
-
resourceId: "resource-123",
|
|
26
|
-
page: 2,
|
|
27
|
-
perPage: 50,
|
|
28
|
-
orderBy: "updatedAt",
|
|
29
|
-
sortDirection: "ASC",
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Process paginated results
|
|
33
|
-
let currentPage = 0;
|
|
34
|
-
let hasMorePages = true;
|
|
35
|
-
|
|
36
|
-
while (hasMorePages) {
|
|
37
|
-
const pageResult = await memory.getThreadsByResourceIdPaginated({
|
|
38
|
-
resourceId: "user-456",
|
|
39
|
-
page: currentPage,
|
|
40
|
-
perPage: 25,
|
|
41
|
-
orderBy: "createdAt",
|
|
42
|
-
sortDirection: "DESC",
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// Process threads
|
|
46
|
-
pageResult.threads.forEach(thread => {
|
|
47
|
-
console.log(`Thread: ${thread.id}, Created: ${thread.createdAt}`);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
hasMorePages = pageResult.hasMore;
|
|
51
|
-
currentPage++;
|
|
52
|
-
}
|
|
53
18
|
```
|
|
54
19
|
|
|
55
20
|
## Parameters
|
|
@@ -59,126 +24,83 @@ while (hasMorePages) {
|
|
|
59
24
|
{
|
|
60
25
|
name: "resourceId",
|
|
61
26
|
type: "string",
|
|
62
|
-
description: "The ID of the resource whose threads are to be retrieved
|
|
27
|
+
description: "The ID of the resource whose threads are to be retrieved",
|
|
63
28
|
isOptional: false,
|
|
64
29
|
},
|
|
65
30
|
{
|
|
66
31
|
name: "page",
|
|
67
32
|
type: "number",
|
|
68
|
-
description: "Page number to retrieve
|
|
33
|
+
description: "Page number to retrieve",
|
|
69
34
|
isOptional: false,
|
|
70
35
|
},
|
|
71
36
|
{
|
|
72
37
|
name: "perPage",
|
|
73
38
|
type: "number",
|
|
74
|
-
description: "Number of threads to return per page
|
|
39
|
+
description: "Number of threads to return per page",
|
|
75
40
|
isOptional: false,
|
|
76
41
|
},
|
|
77
42
|
{
|
|
78
43
|
name: "orderBy",
|
|
79
|
-
type: "
|
|
80
|
-
description: "Field to sort threads by
|
|
44
|
+
type: "'createdAt' | 'updatedAt'",
|
|
45
|
+
description: "Field to sort threads by",
|
|
81
46
|
isOptional: true,
|
|
82
47
|
},
|
|
83
48
|
{
|
|
84
49
|
name: "sortDirection",
|
|
85
|
-
type: "
|
|
86
|
-
description: "Sort order direction
|
|
50
|
+
type: "'ASC' | 'DESC'",
|
|
51
|
+
description: "Sort order direction",
|
|
87
52
|
isOptional: true,
|
|
88
53
|
},
|
|
89
54
|
]}
|
|
90
55
|
/>
|
|
91
56
|
|
|
92
|
-
## Type Definitions
|
|
93
|
-
|
|
94
|
-
```typescript
|
|
95
|
-
type ThreadOrderBy = 'createdAt' | 'updatedAt';
|
|
96
|
-
type ThreadSortDirection = 'ASC' | 'DESC';
|
|
97
|
-
|
|
98
|
-
interface ThreadSortOptions {
|
|
99
|
-
orderBy?: ThreadOrderBy;
|
|
100
|
-
sortDirection?: ThreadSortDirection;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
interface PaginationInfo {
|
|
104
|
-
total: number; // Total number of threads across all pages
|
|
105
|
-
page: number; // Current page number
|
|
106
|
-
perPage: number; // Number of threads per page
|
|
107
|
-
hasMore: boolean; // Whether additional pages exist
|
|
108
|
-
}
|
|
109
|
-
```
|
|
110
|
-
|
|
111
57
|
## Returns
|
|
112
58
|
|
|
113
59
|
<PropertiesTable
|
|
114
60
|
content={[
|
|
115
61
|
{
|
|
116
|
-
name: "
|
|
117
|
-
type: "StorageThreadType[]",
|
|
118
|
-
description: "
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
name: "total",
|
|
122
|
-
type: "number",
|
|
123
|
-
description: "Total number of threads associated with the resource ID across all pages.",
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
name: "page",
|
|
127
|
-
type: "number",
|
|
128
|
-
description: "Current page number.",
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
name: "perPage",
|
|
132
|
-
type: "number",
|
|
133
|
-
description: "Number of threads returned per page as specified in the request.",
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
name: "hasMore",
|
|
137
|
-
type: "boolean",
|
|
138
|
-
description: "Indicates whether additional pages of results are available.",
|
|
62
|
+
name: "result",
|
|
63
|
+
type: "Promise<PaginationInfo & { threads: StorageThreadType[] }>",
|
|
64
|
+
description: "A promise that resolves to paginated thread results with metadata",
|
|
139
65
|
},
|
|
140
66
|
]}
|
|
141
67
|
/>
|
|
142
68
|
|
|
143
|
-
##
|
|
144
|
-
|
|
145
|
-
### Performance Considerations
|
|
146
|
-
|
|
147
|
-
This method executes database-level pagination using LIMIT/OFFSET operations (or equivalent), which provides better performance and memory usage compared to retrieving all threads and paginating in application code.
|
|
148
|
-
|
|
149
|
-
### Default Values
|
|
69
|
+
## Extended usage example
|
|
150
70
|
|
|
151
|
-
-
|
|
152
|
-
|
|
71
|
+
```typescript filename="src/test-memory.ts" showLineNumbers copy
|
|
72
|
+
import { mastra } from "./mastra";
|
|
153
73
|
|
|
154
|
-
|
|
74
|
+
const agent = mastra.getAgent("agent");
|
|
75
|
+
const memory = await agent.getMemory();
|
|
155
76
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
- Use `getThreadsByResourceId` when you need all threads for a resource
|
|
159
|
-
- Use `getThreadsByResourceIdPaginated` when working with potentially large thread collections or implementing UI pagination
|
|
77
|
+
let currentPage = 0;
|
|
78
|
+
let hasMorePages = true;
|
|
160
79
|
|
|
161
|
-
|
|
80
|
+
while (hasMorePages) {
|
|
81
|
+
const threads = await memory?.getThreadsByResourceIdPaginated({
|
|
82
|
+
resourceId: "user-123",
|
|
83
|
+
page: currentPage,
|
|
84
|
+
perPage: 25,
|
|
85
|
+
orderBy: "createdAt",
|
|
86
|
+
sortDirection: "ASC"
|
|
87
|
+
});
|
|
162
88
|
|
|
163
|
-
|
|
89
|
+
if (!threads) {
|
|
90
|
+
console.log("No threads");
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
164
93
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const result = await memory.getThreadsByResourceIdPaginated({
|
|
168
|
-
resourceId: "resource-123",
|
|
169
|
-
page: 0,
|
|
170
|
-
perPage: 100,
|
|
94
|
+
threads.threads.forEach((thread) => {
|
|
95
|
+
console.log(`Thread: ${thread.id}, Created: ${thread.createdAt}`);
|
|
171
96
|
});
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
} catch (error) {
|
|
177
|
-
console.error("Failed to retrieve paginated threads:", error);
|
|
97
|
+
|
|
98
|
+
hasMorePages = threads.hasMore;
|
|
99
|
+
currentPage++;
|
|
178
100
|
}
|
|
179
101
|
```
|
|
180
102
|
|
|
181
|
-
|
|
103
|
+
## Related
|
|
182
104
|
|
|
183
105
|
- [Memory Class Reference](/reference/memory/Memory.mdx)
|
|
184
106
|
- [getThreadsByResourceId](/reference/memory/getThreadsByResourceId.mdx) - Non-paginated version
|
|
@@ -1,51 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Memory.query() | Memory | Mastra Docs"
|
|
3
|
+
description: "Documentation for the `Memory.query()` method in Mastra, which retrieves messages from a specific thread with support for pagination, filtering options, and semantic search."
|
|
4
|
+
---
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
# Memory.query()
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
import { Memory } from "@mastra/memory";
|
|
9
|
-
|
|
10
|
-
const memory = new Memory({
|
|
11
|
-
/* config */
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
// Get last 50 messages
|
|
15
|
-
const { messages, uiMessages, messagesV2 } = await memory.query({
|
|
16
|
-
threadId: "thread-123",
|
|
17
|
-
selectBy: {
|
|
18
|
-
last: 50,
|
|
19
|
-
},
|
|
20
|
-
});
|
|
8
|
+
the `.query()` method retrieves messages from a specific thread, with support for pagination, filtering options, and semantic search.
|
|
21
9
|
|
|
22
|
-
|
|
23
|
-
const { messages: contextMessages } = await memory.query({
|
|
24
|
-
threadId: "thread-123",
|
|
25
|
-
selectBy: {
|
|
26
|
-
include: [
|
|
27
|
-
{
|
|
28
|
-
id: "msg-123", // Get just this message (no context)
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
id: "msg-456", // Get this message with custom context
|
|
32
|
-
withPreviousMessages: 3, // 3 messages before
|
|
33
|
-
withNextMessages: 1, // 1 message after
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
});
|
|
10
|
+
## Usage Example
|
|
38
11
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
threadId: "thread-123",
|
|
42
|
-
selectBy: {
|
|
43
|
-
vectorSearchString: "What was discussed about deployment?",
|
|
44
|
-
},
|
|
45
|
-
threadConfig: {
|
|
46
|
-
semanticRecall: true,
|
|
47
|
-
},
|
|
48
|
-
});
|
|
12
|
+
```typescript copy
|
|
13
|
+
await memory?.query({ threadId: "user-123" });
|
|
49
14
|
```
|
|
50
15
|
|
|
51
16
|
## Parameters
|
|
@@ -55,15 +20,13 @@ const { messages } = await memory.query({
|
|
|
55
20
|
{
|
|
56
21
|
name: "threadId",
|
|
57
22
|
type: "string",
|
|
58
|
-
description:
|
|
59
|
-
"The unique identifier of the thread to retrieve messages from",
|
|
23
|
+
description: "The unique identifier of the thread to retrieve messages from",
|
|
60
24
|
isOptional: false,
|
|
61
25
|
},
|
|
62
26
|
{
|
|
63
27
|
name: "resourceId",
|
|
64
28
|
type: "string",
|
|
65
|
-
description:
|
|
66
|
-
"Optional ID of the resource that owns the thread. If provided, validates thread ownership",
|
|
29
|
+
description: "Optional ID of the resource that owns the thread. If provided, validates thread ownership",
|
|
67
30
|
isOptional: true,
|
|
68
31
|
},
|
|
69
32
|
{
|
|
@@ -78,10 +41,16 @@ const { messages } = await memory.query({
|
|
|
78
41
|
description: "Configuration options for message retrieval and semantic search",
|
|
79
42
|
isOptional: true,
|
|
80
43
|
},
|
|
44
|
+
{
|
|
45
|
+
name: "format",
|
|
46
|
+
type: "'v1' | 'v2'",
|
|
47
|
+
description: "Message format to return. Defaults to 'v2' for current format, 'v1' for backwards compatibility",
|
|
48
|
+
isOptional: true,
|
|
49
|
+
},
|
|
81
50
|
]}
|
|
82
51
|
/>
|
|
83
52
|
|
|
84
|
-
### selectBy
|
|
53
|
+
### selectBy parameters
|
|
85
54
|
|
|
86
55
|
<PropertiesTable
|
|
87
56
|
content={[
|
|
@@ -94,49 +63,55 @@ const { messages } = await memory.query({
|
|
|
94
63
|
{
|
|
95
64
|
name: "last",
|
|
96
65
|
type: "number | false",
|
|
97
|
-
description:
|
|
98
|
-
"Number of most recent messages to retrieve. Set to false to disable limit. Note: threadConfig.lastMessages (default: 40) will override this if smaller.",
|
|
66
|
+
description: "Number of most recent messages to retrieve. Set to false to disable limit. Note: threadConfig.lastMessages (default: 10) will override this if smaller.",
|
|
99
67
|
isOptional: true,
|
|
100
|
-
defaultValue: "40",
|
|
101
68
|
},
|
|
102
69
|
{
|
|
103
70
|
name: "include",
|
|
104
|
-
type: "
|
|
105
|
-
description: "Array of specific message IDs to include with optional context messages",
|
|
71
|
+
type: "{ id: string; threadId?: string; withPreviousMessages?: number; withNextMessages?: number }[]",
|
|
72
|
+
description: "Array of specific message IDs to include with optional context messages. Each item has an `id` (required), optional `threadId` (defaults to main threadId), `withPreviousMessages` (number of messages before, defaults to 2 for vector search, 0 otherwise), and `withNextMessages` (number of messages after, defaults to 2 for vector search, 0 otherwise).",
|
|
106
73
|
isOptional: true,
|
|
107
|
-
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "pagination",
|
|
77
|
+
type: "{ dateRange?: { start?: Date; end?: Date }; page?: number; perPage?: number }",
|
|
78
|
+
description: "Pagination options for retrieving messages in batches. Includes `dateRange` (filter by date range), `page` (0-based page number), and `perPage` (messages per page).",
|
|
79
|
+
isOptional: true,
|
|
80
|
+
},
|
|
108
81
|
]}
|
|
109
82
|
/>
|
|
110
83
|
|
|
111
|
-
###
|
|
84
|
+
### threadConfig parameters
|
|
112
85
|
|
|
113
86
|
<PropertiesTable
|
|
114
87
|
content={[
|
|
115
88
|
{
|
|
116
|
-
name: "
|
|
117
|
-
type: "
|
|
118
|
-
description: "
|
|
119
|
-
isOptional:
|
|
89
|
+
name: "lastMessages",
|
|
90
|
+
type: "number | false",
|
|
91
|
+
description: "Number of most recent messages to retrieve. Set to false to disable.",
|
|
92
|
+
isOptional: true,
|
|
93
|
+
defaultValue: "10",
|
|
120
94
|
},
|
|
121
95
|
{
|
|
122
|
-
name: "
|
|
123
|
-
type: "
|
|
124
|
-
description: "
|
|
96
|
+
name: "semanticRecall",
|
|
97
|
+
type: "boolean | { topK: number; messageRange: number | { before: number; after: number }; scope?: 'thread' | 'resource' }",
|
|
98
|
+
description: "Enable semantic search in message history. Can be a boolean or an object with configuration options. When enabled, requires both vector store and embedder to be configured.",
|
|
125
99
|
isOptional: true,
|
|
100
|
+
defaultValue: "false",
|
|
126
101
|
},
|
|
127
102
|
{
|
|
128
|
-
name: "
|
|
129
|
-
type: "
|
|
130
|
-
description:
|
|
131
|
-
"Number of messages to include before this message. Defaults to 2 when using vector search, 0 otherwise.",
|
|
103
|
+
name: "workingMemory",
|
|
104
|
+
type: "WorkingMemory",
|
|
105
|
+
description: "Configuration for working memory feature. Can be `{ enabled: boolean; template?: string; schema?: ZodObject<any> | JSONSchema7; scope?: 'thread' | 'resource' }` or `{ enabled: boolean }` to disable.",
|
|
132
106
|
isOptional: true,
|
|
107
|
+
defaultValue: "{ enabled: false, template: '# User Information\\n- **First Name**:\\n- **Last Name**:\\n...' }",
|
|
133
108
|
},
|
|
134
109
|
{
|
|
135
|
-
name: "
|
|
136
|
-
type: "
|
|
137
|
-
description:
|
|
138
|
-
"Number of messages to include after this message. Defaults to 2 when using vector search, 0 otherwise.",
|
|
110
|
+
name: "threads",
|
|
111
|
+
type: "{ generateTitle?: boolean | { model: DynamicArgument<MastraLanguageModel>; instructions?: DynamicArgument<string> } }",
|
|
112
|
+
description: "Settings related to memory thread creation. `generateTitle` controls automatic thread title generation from the user's first message. Can be a boolean or an object with custom model and instructions.",
|
|
139
113
|
isOptional: true,
|
|
114
|
+
defaultValue: "{ generateTitle: false }",
|
|
140
115
|
},
|
|
141
116
|
]}
|
|
142
117
|
/>
|
|
@@ -148,37 +123,48 @@ const { messages } = await memory.query({
|
|
|
148
123
|
{
|
|
149
124
|
name: "messages",
|
|
150
125
|
type: "CoreMessage[]",
|
|
151
|
-
description: "Array of retrieved messages in their core format
|
|
126
|
+
description: "Array of retrieved messages in their core format",
|
|
152
127
|
},
|
|
153
128
|
{
|
|
154
129
|
name: "uiMessages",
|
|
155
|
-
type: "
|
|
130
|
+
type: "UIMessageWithMetadata[]",
|
|
156
131
|
description: "Array of messages formatted for UI display, including proper threading of tool calls and results",
|
|
157
132
|
},
|
|
158
|
-
{
|
|
159
|
-
name: "messagesV2",
|
|
160
|
-
type: "MastraMessageV2[]",
|
|
161
|
-
description: "Array of messages in the v2 format, the current internal message format",
|
|
162
|
-
},
|
|
163
133
|
]}
|
|
164
134
|
/>
|
|
165
135
|
|
|
166
|
-
##
|
|
167
|
-
|
|
168
|
-
The `query` function returns three different message formats:
|
|
136
|
+
## Extended usage example
|
|
169
137
|
|
|
170
|
-
-
|
|
171
|
-
|
|
172
|
-
- `messagesV2`: The current internal message format with enhanced structure and metadata
|
|
138
|
+
```typescript filename="src/test-memory.ts" showLineNumbers copy
|
|
139
|
+
import { mastra } from "./mastra";
|
|
173
140
|
|
|
174
|
-
|
|
141
|
+
const agent = mastra.getAgent("agent");
|
|
142
|
+
const memory = await agent.getMemory();
|
|
175
143
|
|
|
176
|
-
|
|
177
|
-
-
|
|
178
|
-
|
|
179
|
-
|
|
144
|
+
const { messages, uiMessages } = await memory!.query({
|
|
145
|
+
threadId: "thread-123",
|
|
146
|
+
selectBy: {
|
|
147
|
+
last: 50,
|
|
148
|
+
vectorSearchString: "What messages are there?",
|
|
149
|
+
include: [
|
|
150
|
+
{
|
|
151
|
+
id: "msg-123"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
id: "msg-456",
|
|
155
|
+
withPreviousMessages: 3,
|
|
156
|
+
withNextMessages: 1
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
},
|
|
160
|
+
threadConfig: {
|
|
161
|
+
semanticRecall: true
|
|
162
|
+
}
|
|
163
|
+
});
|
|
180
164
|
|
|
181
|
-
|
|
165
|
+
console.log(messages);
|
|
166
|
+
console.log(uiMessages);
|
|
167
|
+
```
|
|
182
168
|
|
|
183
169
|
### Related
|
|
184
170
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 0.13.22-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`547c621`](https://github.com/mastra-ai/mastra/commit/547c62104af3f7a551b3754e9cbdf0a3fbba15e4)]:
|
|
8
|
+
- @mastra/core@0.16.4-alpha.1
|
|
9
|
+
|
|
10
|
+
## 0.13.22-alpha.0
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`5802bf5`](https://github.com/mastra-ai/mastra/commit/5802bf57f6182e4b67c28d7d91abed349a8d14f3), [`5bda53a`](https://github.com/mastra-ai/mastra/commit/5bda53a9747bfa7d876d754fc92c83a06e503f62), [`f26a8fd`](https://github.com/mastra-ai/mastra/commit/f26a8fd99fcb0497a5d86c28324430d7f6a5fb83), [`1a1fbe6`](https://github.com/mastra-ai/mastra/commit/1a1fbe66efb7d94abc373ed0dd9676adb8122454), [`36f39c0`](https://github.com/mastra-ai/mastra/commit/36f39c00dc794952dc3c11aab91c2fa8bca74b11)]:
|
|
15
|
+
- @mastra/core@0.16.4-alpha.0
|
|
16
|
+
|
|
3
17
|
## 0.13.21
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -71,6 +71,14 @@ This will make all Mastra documentation tools available in your Windsurf workspa
|
|
|
71
71
|
Note that Windsurf MCP tool calling doesn't work very well. You will need to fully quit and re-open Windsurf after adding this.
|
|
72
72
|
If a tool call fails you will need to go into Windsurf MCP settings and re-start the MCP server.
|
|
73
73
|
|
|
74
|
+
### In Claude Code
|
|
75
|
+
|
|
76
|
+
After installing Claude Code run:
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
claude mcp add mastra-docs -- npx -y @mastra/mcp-docs-server
|
|
80
|
+
```
|
|
81
|
+
|
|
74
82
|
### In a Mastra Agent
|
|
75
83
|
|
|
76
84
|
```typescript
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.22-alpha.1",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"uuid": "^11.1.0",
|
|
34
34
|
"zod": "^3.25.76",
|
|
35
35
|
"zod-to-json-schema": "^3.24.6",
|
|
36
|
-
"@mastra/core": "0.16.
|
|
36
|
+
"@mastra/core": "0.16.4-alpha.1",
|
|
37
37
|
"@mastra/mcp": "^0.12.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@hono/node-server": "^1.
|
|
40
|
+
"@hono/node-server": "^1.19.1",
|
|
41
41
|
"@types/jsdom": "^21.1.7",
|
|
42
42
|
"@types/node": "^20.19.0",
|
|
43
43
|
"@types/turndown": "^5.0.5",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"typescript": "^5.8.3",
|
|
51
51
|
"vitest": "^3.2.4",
|
|
52
52
|
"@internal/lint": "0.0.39",
|
|
53
|
-
"@mastra/core": "0.16.
|
|
53
|
+
"@mastra/core": "0.16.4-alpha.1"
|
|
54
54
|
},
|
|
55
55
|
"homepage": "https://mastra.ai",
|
|
56
56
|
"repository": {
|