@mastra/mcp-docs-server 0.13.21 → 0.13.22-alpha.0
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%2Fclient-js.md +29 -29
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +81 -81
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +21 -21
- 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 +54 -54
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +9 -9
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fmem0.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +9 -9
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +10 -10
- 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 +25 -25
- package/.docs/organized/changelogs/create-mastra.md +17 -17
- package/.docs/organized/changelogs/mastra.md +29 -29
- 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 +7 -0
- package/README.md +8 -0
- package/package.json +4 -4
|
@@ -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,12 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 0.13.22-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 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)]:
|
|
8
|
+
- @mastra/core@0.16.4-alpha.0
|
|
9
|
+
|
|
3
10
|
## 0.13.21
|
|
4
11
|
|
|
5
12
|
### 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.0",
|
|
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.0",
|
|
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.0"
|
|
54
54
|
},
|
|
55
55
|
"homepage": "https://mastra.ai",
|
|
56
56
|
"repository": {
|