@mastra/mcp-docs-server 1.0.0-beta.8 → 1.0.0-beta.9

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 (40) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fchangeset-cli.md +1 -15
  2. package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +1 -7
  3. package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +1 -55
  4. package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +39 -39
  5. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +10 -10
  6. package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +6 -0
  7. package/.docs/organized/changelogs/%40mastra%2Fcore.md +58 -58
  8. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +9 -9
  9. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +11 -11
  10. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +49 -49
  11. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +9 -9
  12. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +12 -12
  13. package/.docs/organized/changelogs/%40mastra%2Fpg.md +49 -49
  14. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +21 -21
  15. package/.docs/organized/changelogs/%40mastra%2Freact.md +7 -0
  16. package/.docs/organized/changelogs/%40mastra%2Fserver.md +49 -49
  17. package/.docs/organized/changelogs/create-mastra.md +13 -13
  18. package/.docs/organized/changelogs/mastra.md +21 -21
  19. package/.docs/organized/code-examples/mcp-server-adapters.md +1 -2
  20. package/.docs/organized/code-examples/processors-with-ai-sdk.md +14 -0
  21. package/.docs/organized/code-examples/server-app-access.md +1 -1
  22. package/.docs/organized/code-examples/server-hono-adapter.md +1 -1
  23. package/.docs/raw/getting-started/studio.mdx +4 -2
  24. package/.docs/raw/guides/agent-frameworks/ai-sdk.mdx +161 -0
  25. package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +4 -4
  26. package/.docs/raw/guides/migrations/upgrade-to-v1/tools.mdx +3 -3
  27. package/.docs/raw/reference/client-js/agents.mdx +251 -67
  28. package/.docs/raw/reference/client-js/mastra-client.mdx +2 -2
  29. package/.docs/raw/reference/client-js/memory.mdx +4 -1
  30. package/.docs/raw/reference/core/getMemory.mdx +73 -0
  31. package/.docs/raw/reference/core/getStoredAgentById.mdx +183 -0
  32. package/.docs/raw/reference/core/listMemory.mdx +70 -0
  33. package/.docs/raw/reference/core/listStoredAgents.mdx +151 -0
  34. package/.docs/raw/reference/core/mastra-class.mdx +8 -0
  35. package/.docs/raw/reference/server/express-adapter.mdx +52 -0
  36. package/.docs/raw/reference/server/hono-adapter.mdx +54 -0
  37. package/.docs/raw/server-db/server-adapters.mdx +94 -91
  38. package/.docs/raw/streaming/tool-streaming.mdx +10 -14
  39. package/CHANGELOG.md +8 -0
  40. package/package.json +4 -4
@@ -0,0 +1,183 @@
1
+ ---
2
+ title: "Reference: Mastra.getStoredAgentById() | Core"
3
+ description: "Documentation for the `Mastra.getStoredAgentById()` method in Mastra, which retrieves an agent from storage and creates an executable Agent instance."
4
+ ---
5
+
6
+ # Mastra.getStoredAgentById()
7
+
8
+ The `.getStoredAgentById()` method retrieves an agent configuration from storage by its ID and creates an executable `Agent` instance. Stored agents allow you to persist agent configurations in a database and dynamically load them at runtime.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript copy
13
+ // Get an Agent instance from storage
14
+ const agent = await mastra.getStoredAgentById("my-stored-agent");
15
+
16
+ if (agent) {
17
+ const response = await agent.generate({ messages: "Hello!" });
18
+ console.log(response.text);
19
+ }
20
+ ```
21
+
22
+ ```typescript copy
23
+ // Get the raw storage data instead of an Agent instance
24
+ const storedConfig = await mastra.getStoredAgentById("my-stored-agent", { raw: true });
25
+
26
+ if (storedConfig) {
27
+ console.log(storedConfig.instructions);
28
+ console.log(storedConfig.createdAt);
29
+ }
30
+ ```
31
+
32
+ ## Parameters
33
+
34
+ <PropertiesTable
35
+ content={[
36
+ {
37
+ name: "id",
38
+ type: "string",
39
+ description:
40
+ "The unique identifier of the stored agent to retrieve.",
41
+ },
42
+ {
43
+ name: "options",
44
+ type: "{ raw?: boolean }",
45
+ description:
46
+ "Optional configuration object.",
47
+ isOptional: true,
48
+ },
49
+ ]}
50
+ />
51
+
52
+ ### Options
53
+
54
+ <PropertiesTable
55
+ content={[
56
+ {
57
+ name: "raw",
58
+ type: "boolean",
59
+ description:
60
+ "When `true`, returns the raw `StorageAgentType` object from storage instead of creating an `Agent` instance. Useful for inspecting stored configuration or metadata.",
61
+ isOptional: true,
62
+ defaultValue: "false",
63
+ },
64
+ ]}
65
+ />
66
+
67
+ ## Returns
68
+
69
+ <PropertiesTable
70
+ content={[
71
+ {
72
+ name: "result",
73
+ type: "Agent | StorageAgentType | null",
74
+ description:
75
+ "Returns an `Agent` instance by default, or `StorageAgentType` when `raw: true`. Returns `null` if no agent with the given ID exists.",
76
+ },
77
+ ]}
78
+ />
79
+
80
+ ## Primitive Resolution
81
+
82
+ When creating an `Agent` instance from stored configuration, the method resolves references to registered primitives:
83
+
84
+ - **Tools**: Resolved from `tools` registered in Mastra config
85
+ - **Workflows**: Resolved from `workflows` registered in Mastra config
86
+ - **Sub-agents**: Resolved from `agents` registered in Mastra config
87
+ - **Memory**: Resolved from `memory` registered in Mastra config
88
+ - **Scorers**: Resolved from `scorers` registered in Mastra config, including sampling configuration
89
+
90
+ If a referenced primitive is not found in the registry, a warning is logged but the agent is still created.
91
+
92
+ ## StorageAgentType
93
+
94
+ When using `raw: true`, the returned object has the following structure:
95
+
96
+ <PropertiesTable
97
+ content={[
98
+ {
99
+ name: "id",
100
+ type: "string",
101
+ description: "Unique identifier for the agent.",
102
+ },
103
+ {
104
+ name: "name",
105
+ type: "string",
106
+ description: "Display name of the agent.",
107
+ },
108
+ {
109
+ name: "description",
110
+ type: "string",
111
+ description: "Optional description of the agent.",
112
+ isOptional: true,
113
+ },
114
+ {
115
+ name: "instructions",
116
+ type: "string",
117
+ description: "System instructions for the agent.",
118
+ },
119
+ {
120
+ name: "model",
121
+ type: "Record<string, unknown>",
122
+ description: "Model configuration with provider and name.",
123
+ },
124
+ {
125
+ name: "tools",
126
+ type: "Record<string, unknown>",
127
+ description: "Tool references to resolve from registry.",
128
+ isOptional: true,
129
+ },
130
+ {
131
+ name: "workflows",
132
+ type: "Record<string, unknown>",
133
+ description: "Workflow references to resolve from registry.",
134
+ isOptional: true,
135
+ },
136
+ {
137
+ name: "agents",
138
+ type: "Record<string, unknown>",
139
+ description: "Sub-agent references to resolve from registry.",
140
+ isOptional: true,
141
+ },
142
+ {
143
+ name: "memory",
144
+ type: "Record<string, unknown>",
145
+ description: "Memory reference to resolve from registry.",
146
+ isOptional: true,
147
+ },
148
+ {
149
+ name: "scorers",
150
+ type: "Record<string, unknown>",
151
+ description: "Scorer references with optional sampling config.",
152
+ isOptional: true,
153
+ },
154
+ {
155
+ name: "defaultOptions",
156
+ type: "Record<string, unknown>",
157
+ description: "Default options passed to agent execution.",
158
+ isOptional: true,
159
+ },
160
+ {
161
+ name: "metadata",
162
+ type: "Record<string, unknown>",
163
+ description: "Custom metadata stored with the agent.",
164
+ isOptional: true,
165
+ },
166
+ {
167
+ name: "createdAt",
168
+ type: "Date",
169
+ description: "Timestamp when the agent was created.",
170
+ },
171
+ {
172
+ name: "updatedAt",
173
+ type: "Date",
174
+ description: "Timestamp when the agent was last updated.",
175
+ },
176
+ ]}
177
+ />
178
+
179
+ ## Related
180
+
181
+ - [Mastra.listStoredAgents()](/reference/v1/core/listStoredAgents)
182
+ - [Storage overview](/docs/v1/server-db/storage)
183
+ - [Agents overview](/docs/v1/agents/overview)
@@ -0,0 +1,70 @@
1
+ ---
2
+ title: "Reference: Mastra.listMemory() | Core"
3
+ description: "Documentation for the `Mastra.listMemory()` method in Mastra, which returns all registered memory instances."
4
+ ---
5
+
6
+ # Mastra.listMemory()
7
+
8
+ The `.listMemory()` method returns all memory instances registered with the Mastra instance.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript copy
13
+ const memoryInstances = mastra.listMemory();
14
+
15
+ for (const [key, memory] of Object.entries(memoryInstances)) {
16
+ console.log(`Memory "${key}": ${memory.id}`);
17
+ }
18
+ ```
19
+
20
+ ## Parameters
21
+
22
+ This method takes no parameters.
23
+
24
+ ## Returns
25
+
26
+ <PropertiesTable
27
+ content={[
28
+ {
29
+ name: "memory",
30
+ type: "Record<string, MastraMemory>",
31
+ description:
32
+ "An object containing all registered memory instances, keyed by their registry keys.",
33
+ },
34
+ ]}
35
+ />
36
+
37
+ ## Example: Checking Registered Memory
38
+
39
+ ```typescript copy
40
+ import { Mastra } from "@mastra/core";
41
+ import { Memory } from "@mastra/memory";
42
+ import { LibSQLStore } from "@mastra/libsql";
43
+
44
+ const conversationMemory = new Memory({
45
+ id: "conversation-memory",
46
+ storage: new LibSQLStore({ url: ":memory:" }),
47
+ });
48
+
49
+ const analyticsMemory = new Memory({
50
+ id: "analytics-memory",
51
+ storage: new LibSQLStore({ url: ":memory:" }),
52
+ });
53
+
54
+ const mastra = new Mastra({
55
+ memory: {
56
+ conversationMemory,
57
+ analyticsMemory,
58
+ },
59
+ });
60
+
61
+ // List all registered memory instances
62
+ const allMemory = mastra.listMemory();
63
+ console.log(Object.keys(allMemory)); // ["conversationMemory", "analyticsMemory"]
64
+ ```
65
+
66
+ ## Related
67
+
68
+ - [Mastra.getMemory()](/reference/v1/core/getMemory)
69
+ - [Memory overview](/docs/v1/memory/overview)
70
+ - [Agent Memory](/docs/v1/agents/agent-memory)
@@ -0,0 +1,151 @@
1
+ ---
2
+ title: "Reference: Mastra.listStoredAgents() | Core"
3
+ description: "Documentation for the `Mastra.listStoredAgents()` method in Mastra, which retrieves a paginated list of agents from storage."
4
+ ---
5
+
6
+ # Mastra.listStoredAgents()
7
+
8
+ The `.listStoredAgents()` method retrieves a paginated list of agent configurations from storage. By default, it returns executable `Agent` instances, but can also return raw storage data.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript copy
13
+ // Get Agent instances from storage
14
+ const { agents, total, hasMore } = await mastra.listStoredAgents();
15
+
16
+ for (const agent of agents) {
17
+ console.log(agent.id, agent.name);
18
+ // Each agent is ready to use
19
+ // const response = await agent.generate({ messages: "Hello!" });
20
+ }
21
+ ```
22
+
23
+ ```typescript copy
24
+ // Get paginated results with raw storage data
25
+ const result = await mastra.listStoredAgents({
26
+ page: 0,
27
+ perPage: 10,
28
+ raw: true,
29
+ });
30
+
31
+ console.log(`Showing ${result.agents.length} of ${result.total} agents`);
32
+ console.log(`Has more: ${result.hasMore}`);
33
+
34
+ for (const config of result.agents) {
35
+ console.log(config.id, config.name, config.createdAt);
36
+ }
37
+ ```
38
+
39
+ ## Parameters
40
+
41
+ <PropertiesTable
42
+ content={[
43
+ {
44
+ name: "args",
45
+ type: "object",
46
+ description:
47
+ "Optional configuration object for pagination and output format.",
48
+ isOptional: true,
49
+ },
50
+ ]}
51
+ />
52
+
53
+ ### Args Options
54
+
55
+ <PropertiesTable
56
+ content={[
57
+ {
58
+ name: "page",
59
+ type: "number",
60
+ description: "Zero-indexed page number for pagination.",
61
+ isOptional: true,
62
+ defaultValue: "0",
63
+ },
64
+ {
65
+ name: "perPage",
66
+ type: "number | false",
67
+ description:
68
+ "Number of items per page. Set to `false` to fetch all records without pagination.",
69
+ isOptional: true,
70
+ defaultValue: "100",
71
+ },
72
+ {
73
+ name: "raw",
74
+ type: "boolean",
75
+ description:
76
+ "When `true`, returns raw `StorageAgentType` objects instead of `Agent` instances.",
77
+ isOptional: true,
78
+ defaultValue: "false",
79
+ },
80
+ ]}
81
+ />
82
+
83
+ ## Returns
84
+
85
+ <PropertiesTable
86
+ content={[
87
+ {
88
+ name: "agents",
89
+ type: "Agent[] | StorageAgentType[]",
90
+ description:
91
+ "Array of `Agent` instances by default, or `StorageAgentType` objects when `raw: true`.",
92
+ },
93
+ {
94
+ name: "total",
95
+ type: "number",
96
+ description: "Total number of stored agents across all pages.",
97
+ },
98
+ {
99
+ name: "page",
100
+ type: "number",
101
+ description: "Current page number (zero-indexed).",
102
+ },
103
+ {
104
+ name: "perPage",
105
+ type: "number | false",
106
+ description: "Number of items per page, or `false` if fetching all.",
107
+ },
108
+ {
109
+ name: "hasMore",
110
+ type: "boolean",
111
+ description: "Whether there are more pages available.",
112
+ },
113
+ ]}
114
+ />
115
+
116
+ ## Primitive Resolution
117
+
118
+ When creating `Agent` instances (default behavior), each stored agent's configuration is resolved against registered primitives:
119
+
120
+ - **Tools**: Resolved from `tools` registered in Mastra config
121
+ - **Workflows**: Resolved from `workflows` registered in Mastra config
122
+ - **Sub-agents**: Resolved from `agents` registered in Mastra config
123
+ - **Memory**: Resolved from `memory` registered in Mastra config
124
+ - **Scorers**: Resolved from `scorers` registered in Mastra config
125
+
126
+ If a referenced primitive is not found, a warning is logged but the agent is still created.
127
+
128
+ ## Example: Iterating Through All Stored Agents
129
+
130
+ ```typescript copy
131
+ async function getAllStoredAgents(mastra: Mastra) {
132
+ const allAgents: Agent[] = [];
133
+ let page = 0;
134
+ let hasMore = true;
135
+
136
+ while (hasMore) {
137
+ const result = await mastra.listStoredAgents({ page, perPage: 50 });
138
+ allAgents.push(...result.agents);
139
+ hasMore = result.hasMore;
140
+ page++;
141
+ }
142
+
143
+ return allAgents;
144
+ }
145
+ ```
146
+
147
+ ## Related
148
+
149
+ - [Mastra.getStoredAgentById()](/reference/v1/core/getStoredAgentById)
150
+ - [Storage overview](/docs/v1/server-db/storage)
151
+ - [Agents overview](/docs/v1/agents/overview)
@@ -148,5 +148,13 @@ export const mastra = new Mastra({
148
148
  isOptional: true,
149
149
  defaultValue: "{}",
150
150
  },
151
+ {
152
+ name: "memory",
153
+ type: "Record<string, MastraMemory>",
154
+ description:
155
+ "Memory instances to register. These can be referenced by stored agents and resolved at runtime. Structured as a key-value pair, with keys being the registry key and values being memory instances.",
156
+ isOptional: true,
157
+ defaultValue: "{}",
158
+ },
151
159
  ]}
152
160
  />
@@ -5,6 +5,7 @@ description: "API reference for the @mastra/express server adapter."
5
5
 
6
6
  import Steps from "@site/src/components/Steps";
7
7
  import StepItem from "@site/src/components/StepItem";
8
+ import PropertiesTable from "@site/src/components/PropertiesTable";
8
9
 
9
10
  # Express Adapter
10
11
 
@@ -87,6 +88,57 @@ await server.init();
87
88
  app.listen(4111);
88
89
  ```
89
90
 
91
+ ## Constructor parameters
92
+
93
+ <PropertiesTable
94
+ content={[
95
+ {
96
+ name: "app",
97
+ type: "Application",
98
+ description: "Express app instance",
99
+ isOptional: false,
100
+ },
101
+ {
102
+ name: "mastra",
103
+ type: "Mastra",
104
+ description: "Mastra instance",
105
+ isOptional: false,
106
+ },
107
+ {
108
+ name: "prefix",
109
+ type: "string",
110
+ description: "Route path prefix (e.g., `/api/v2`)",
111
+ isOptional: true,
112
+ defaultValue: "''",
113
+ },
114
+ {
115
+ name: "openapiPath",
116
+ type: "string",
117
+ description: "Path to serve OpenAPI spec (e.g., `/openapi.json`)",
118
+ isOptional: true,
119
+ },
120
+ {
121
+ name: "bodyLimitOptions",
122
+ type: "{ maxSize: number, onError: (err) => unknown }",
123
+ description: "Request body size limits",
124
+ isOptional: true,
125
+ },
126
+ {
127
+ name: "streamOptions",
128
+ type: "{ redact?: boolean }",
129
+ description: "Stream redaction config. When true, redacts sensitive data from streams.",
130
+ isOptional: true,
131
+ defaultValue: "{ redact: true }",
132
+ },
133
+ {
134
+ name: "customRouteAuthConfig",
135
+ type: "Map<string, boolean>",
136
+ description: "Per-route auth overrides. Keys are `METHOD:PATH` (e.g., `GET:/api/health`). Value `false` makes route public, `true` requires auth.",
137
+ isOptional: true,
138
+ },
139
+ ]}
140
+ />
141
+
90
142
  ## Differences from Hono
91
143
 
92
144
  | Aspect | Express | Hono |
@@ -5,6 +5,7 @@ description: "API reference for the @mastra/hono server adapter."
5
5
 
6
6
  import Steps from "@site/src/components/Steps";
7
7
  import StepItem from "@site/src/components/StepItem";
8
+ import PropertiesTable from "@site/src/components/PropertiesTable";
8
9
 
9
10
  # Hono Adapter
10
11
 
@@ -77,6 +78,59 @@ await server.init();
77
78
  export default app;
78
79
  ```
79
80
 
81
+
82
+ ## Constructor parameters
83
+
84
+ <PropertiesTable
85
+ content={[
86
+ {
87
+ name: "app",
88
+ type: "Hono",
89
+ description: "Hono app instance",
90
+ isOptional: false,
91
+ },
92
+ {
93
+ name: "mastra",
94
+ type: "Mastra",
95
+ description: "Mastra instance",
96
+ isOptional: false,
97
+ },
98
+ {
99
+ name: "prefix",
100
+ type: "string",
101
+ description: "Route path prefix (e.g., `/api/v2`)",
102
+ isOptional: true,
103
+ defaultValue: "''",
104
+ },
105
+ {
106
+ name: "openapiPath",
107
+ type: "string",
108
+ description: "Path to serve OpenAPI spec (e.g., `/openapi.json`)",
109
+ isOptional: true,
110
+ },
111
+ {
112
+ name: "bodyLimitOptions",
113
+ type: "{ maxSize: number, onError: (err) => unknown }",
114
+ description: "Request body size limits",
115
+ isOptional: true,
116
+ },
117
+ {
118
+ name: "streamOptions",
119
+ type: "{ redact?: boolean }",
120
+ description: "Stream redaction config. When true, redacts sensitive data from streams.",
121
+ isOptional: true,
122
+ defaultValue: "{ redact: true }",
123
+ },
124
+ {
125
+ name: "customRouteAuthConfig",
126
+ type: "Map<string, boolean>",
127
+ description: "Per-route auth overrides. Keys are `METHOD:PATH` (e.g., `GET:/api/health`). Value `false` makes route public, `true` requires auth.",
128
+ isOptional: true,
129
+ },
130
+ ]}
131
+ />
132
+
133
+
80
134
  ## Adding custom routes
81
135
 
82
136
  Add routes directly to the Hono app: