@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.
Files changed (46) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +8 -8
  2. package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
  3. package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +8 -0
  4. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +29 -29
  5. package/.docs/organized/changelogs/%40mastra%2Fcloud.md +12 -12
  6. package/.docs/organized/changelogs/%40mastra%2Fcore.md +81 -81
  7. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +21 -21
  8. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +17 -17
  9. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +18 -18
  10. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +17 -17
  11. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +54 -54
  12. package/.docs/organized/changelogs/%40mastra%2Fevals.md +12 -12
  13. package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +9 -9
  14. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +19 -19
  15. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +17 -17
  16. package/.docs/organized/changelogs/%40mastra%2Fmem0.md +10 -10
  17. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +9 -9
  18. package/.docs/organized/changelogs/%40mastra%2Fpg.md +10 -10
  19. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +29 -29
  20. package/.docs/organized/changelogs/%40mastra%2Frag.md +10 -10
  21. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
  22. package/.docs/organized/changelogs/%40mastra%2Fserver.md +25 -25
  23. package/.docs/organized/changelogs/create-mastra.md +17 -17
  24. package/.docs/organized/changelogs/mastra.md +29 -29
  25. package/.docs/organized/code-examples/heads-up-game.md +4 -4
  26. package/.docs/raw/memory/memory-processors.mdx +5 -0
  27. package/.docs/raw/memory/overview.mdx +159 -104
  28. package/.docs/raw/memory/semantic-recall.mdx +5 -0
  29. package/.docs/raw/memory/working-memory.mdx +5 -0
  30. package/.docs/raw/reference/agents/agent.mdx +6 -0
  31. package/.docs/raw/reference/agents/generateVNext.mdx +2 -1
  32. package/.docs/raw/reference/agents/listAgents.mdx +68 -0
  33. package/.docs/raw/reference/agents/streamVNext.mdx +1 -1
  34. package/.docs/raw/reference/client-js/agents.mdx +54 -1
  35. package/.docs/raw/reference/client-js/workflows.mdx +36 -17
  36. package/.docs/raw/reference/core/mastra-class.mdx +2 -2
  37. package/.docs/raw/reference/memory/Memory.mdx +91 -239
  38. package/.docs/raw/reference/memory/createThread.mdx +36 -16
  39. package/.docs/raw/reference/memory/deleteMessages.mdx +39 -74
  40. package/.docs/raw/reference/memory/getThreadById.mdx +11 -11
  41. package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +26 -29
  42. package/.docs/raw/reference/memory/getThreadsByResourceIdPaginated.mdx +46 -124
  43. package/.docs/raw/reference/memory/query.mdx +76 -90
  44. package/CHANGELOG.md +7 -0
  45. package/README.md +8 -0
  46. package/package.json +4 -4
@@ -1,95 +1,60 @@
1
1
  ---
2
- section: Memory
3
- title: deleteMessages
4
- slug: reference/memory/deleteMessages
5
- categorySlug: reference
6
- layout: guide
2
+ title: "Reference: Memory.deleteMessages() | Memory | Mastra Docs"
3
+ description: "Documentation for the `Memory.deleteMessages()` method in Mastra, which deletes multiple messages by their IDs."
7
4
  ---
8
5
 
9
- # `deleteMessages`
6
+ # Memory.deleteMessages()
10
7
 
11
- Deletes one or more messages from the memory storage. This method accepts arrays to delete multiple messages in a single operation.
8
+ The `.deleteMessages()` method deletes multiple messages by their IDs.
12
9
 
13
- ## Syntax
10
+ ## Usage Example
14
11
 
15
- ```typescript
16
- memory.deleteMessages(input: MessageDeleteInput): Promise<void>
17
-
18
- type MessageDeleteInput =
19
- | string[] // Array of message IDs
20
- | { id: string }[] // Array of message objects
12
+ ```typescript copy
13
+ await memory?.deleteMessages(["671ae63f-3a91-4082-a907-fe7de78e10ec"]);
21
14
  ```
22
15
 
23
16
  ## Parameters
24
17
 
25
- - `input` (required): An array of messages to delete. Must be either:
26
- - An array of message IDs (strings)
27
- - An array of message objects with `id` properties
18
+ <PropertiesTable
19
+ content={[
20
+ {
21
+ name: "messageIds",
22
+ type: "string[]",
23
+ description: "Array of message IDs to delete",
24
+ isOptional: false,
25
+ },
26
+ ]}
27
+ />
28
28
 
29
29
  ## Returns
30
30
 
31
- A Promise that resolves when all messages have been successfully deleted.
32
-
33
- ## Examples
31
+ <PropertiesTable
32
+ content={[
33
+ {
34
+ name: "void",
35
+ type: "Promise<void>",
36
+ description: "A promise that resolves when all messages are deleted",
37
+ },
38
+ ]}
39
+ />
34
40
 
35
- ### Delete a single message
41
+ ## Extended usage example
36
42
 
37
- ```typescript
38
- // Using an array with a single string ID
39
- await memory.deleteMessages(['msg-123']);
40
-
41
- // Using an array with a single message object
42
- await memory.deleteMessages([{ id: 'msg-123' }]);
43
- ```
43
+ ```typescript filename="src/test-memory.ts" showLineNumbers copy
44
+ import { mastra } from "./mastra";
45
+ import { UIMessageWithMetadata } from "@mastra/core/agent";
44
46
 
45
- ### Delete multiple messages
46
-
47
- ```typescript
48
- // Using an array of string IDs
49
- await memory.deleteMessages(['msg-1', 'msg-2', 'msg-3']);
50
-
51
- // Using an array of message objects
52
- await memory.deleteMessages([
53
- { id: 'msg-1' },
54
- { id: 'msg-2' },
55
- { id: 'msg-3' }
56
- ]);
57
- ```
58
-
59
- ### Using with client SDK
60
-
61
- ```typescript
62
- // Get a thread instance
63
- const thread = client.getAgent('my-agent').getThread('thread-123');
64
-
65
- // Delete a single message
66
- await thread.deleteMessages(['msg-123']);
67
-
68
- // Delete multiple messages
69
- await thread.deleteMessages(['msg-1', 'msg-2', 'msg-3']);
70
-
71
- // Delete using message objects (useful when you have message data)
72
- const messagesToDelete = messages.map(msg => ({ id: msg.id }));
73
- await thread.deleteMessages(messagesToDelete);
74
- ```
47
+ const agent = mastra.getAgent("agent");
48
+ const memory = await agent.getMemory();
75
49
 
76
- ### Error handling
50
+ const { uiMessages } = await memory!.query({ threadId: "thread-123" });
77
51
 
78
- ```typescript
79
- try {
80
- await memory.deleteMessages(['msg-1', 'msg-2', 'msg-3']);
81
- console.log('Messages deleted successfully');
82
- } catch (error) {
83
- console.error('Failed to delete messages:', error);
84
- }
52
+ const messageIds = uiMessages.map((message: UIMessageWithMetadata) => message.id);
53
+ await memory?.deleteMessages([...messageIds]);
85
54
  ```
86
55
 
87
- ## Notes
56
+ ## Related
88
57
 
89
- - This method requires an array as input, even when deleting a single message
90
- - Thread timestamps are automatically updated when messages are deleted
91
- - The method automatically extracts message IDs from message objects
92
- - All message IDs must be non-empty strings
93
- - An empty array will result in no operation (no error thrown)
94
- - Messages from different threads can be deleted in the same operation
95
- - When using message objects, only the `id` property is required
58
+ - [Memory Class Reference](/reference/memory/Memory.mdx)
59
+ - [query](/reference/memory/query.mdx)
60
+ - [Getting Started with Memory](/docs/memory/overview.mdx)
@@ -1,15 +1,16 @@
1
- # getThreadById Reference
1
+ ---
2
+ title: "Reference: Memory.getThreadById() | Memory | Mastra Docs"
3
+ description: "Documentation for the `Memory.getThreadById()` method in Mastra, which retrieves a specific thread by its ID."
4
+ ---
2
5
 
3
- The `getThreadById` function retrieves a specific thread by its ID from storage.
6
+ # Memory.getThreadById()
7
+
8
+ The `.getThreadById()` method retrieves a specific thread by its ID.
4
9
 
5
10
  ## Usage Example
6
11
 
7
12
  ```typescript
8
- import { Memory } from "@mastra/core/memory";
9
-
10
- const memory = new Memory(config);
11
-
12
- const thread = await memory.getThreadById({ threadId: "thread-123" });
13
+ await memory?.getThreadById({ threadId: "thread-123" });
13
14
  ```
14
15
 
15
16
  ## Parameters
@@ -30,10 +31,9 @@ const thread = await memory.getThreadById({ threadId: "thread-123" });
30
31
  <PropertiesTable
31
32
  content={[
32
33
  {
33
- name: "StorageThreadType | null",
34
- type: "Promise",
35
- description:
36
- "A promise that resolves to the thread associated with the given ID, or null if not found.",
34
+ name: "thread",
35
+ type: "Promise<StorageThreadType | null>",
36
+ description: "A promise that resolves to the thread associated with the given ID, or null if not found.",
37
37
  },
38
38
  ]}
39
39
  />
@@ -1,25 +1,16 @@
1
- # getThreadsByResourceId Reference
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
- 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.
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
- import { Memory } from "@mastra/core/memory";
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
- # getThreadsByResourceIdPaginated Reference
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
- The `getThreadsByResourceIdPaginated` function retrieves threads associated with a specific resource ID with pagination support. This method addresses performance and memory usage concerns when dealing with large numbers of threads by returning results in manageable chunks with metadata for navigation.
6
+ # Memory.getThreadsByResourceIdPaginated()
4
7
 
5
- ## Usage Example
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
- const memory = new Memory(config);
10
+ ## Usage Example
11
11
 
12
- // Basic usage with default parameters
13
- const result = await memory.getThreadsByResourceIdPaginated({
14
- resourceId: "resource-123",
12
+ ```typescript copy
13
+ await memory.getThreadsByResourceIdPaginated({
14
+ resourceId: "user-123",
15
15
  page: 0,
16
- perPage: 100,
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. Must be a positive integer.",
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. Must be a positive integer.",
39
+ description: "Number of threads to return per page",
75
40
  isOptional: false,
76
41
  },
77
42
  {
78
43
  name: "orderBy",
79
- type: "ThreadOrderBy",
80
- description: "Field to sort threads by. Accepts 'createdAt' or 'updatedAt'. Default: 'createdAt'",
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: "ThreadSortDirection",
86
- description: "Sort order direction. Accepts 'ASC' or 'DESC'. Default: 'DESC'",
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: "threads",
117
- type: "StorageThreadType[]",
118
- description: "Array of threads for the current page, sorted according to the specified criteria.",
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
- ## Technical Notes
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
- - `orderBy`: Defaults to `"createdAt"`
152
- - `sortDirection`: Defaults to `"DESC"` (newest first)
71
+ ```typescript filename="src/test-memory.ts" showLineNumbers copy
72
+ import { mastra } from "./mastra";
153
73
 
154
- ### Relationship to getThreadsByResourceId
74
+ const agent = mastra.getAgent("agent");
75
+ const memory = await agent.getMemory();
155
76
 
156
- The paginated version (`getThreadsByResourceIdPaginated`) complements the existing `getThreadsByResourceId` method:
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
- Both methods support the same sorting options for consistency.
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
- ### Error Handling
89
+ if (!threads) {
90
+ console.log("No threads");
91
+ break;
92
+ }
164
93
 
165
- ```typescript
166
- try {
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
- if (result.threads.length === 0) {
174
- console.log("No threads found for this resource");
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
- ### Related
103
+ ## Related
182
104
 
183
105
  - [Memory Class Reference](/reference/memory/Memory.mdx)
184
106
  - [getThreadsByResourceId](/reference/memory/getThreadsByResourceId.mdx) - Non-paginated version