@mastra/mcp-docs-server 0.13.19-alpha.0 → 0.13.19-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.
Files changed (61) hide show
  1. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +14 -14
  2. package/.docs/organized/changelogs/%40mastra%2Fcore.md +19 -19
  3. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +8 -0
  4. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +11 -11
  5. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +11 -11
  6. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +12 -12
  7. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +10 -10
  8. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +10 -10
  9. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +13 -13
  10. package/.docs/organized/changelogs/%40mastra%2Fserver.md +8 -8
  11. package/.docs/organized/changelogs/create-mastra.md +7 -7
  12. package/.docs/organized/changelogs/mastra.md +14 -14
  13. package/.docs/organized/code-examples/ai-sdk-useChat.md +1 -1
  14. package/.docs/organized/code-examples/workflow-with-suspend-resume.md +1 -0
  15. package/.docs/raw/auth/jwt.mdx +2 -2
  16. package/.docs/raw/auth/supabase.mdx +128 -0
  17. package/.docs/raw/deployment/overview.mdx +7 -7
  18. package/.docs/raw/getting-started/mcp-docs-server.mdx +52 -48
  19. package/.docs/raw/memory/overview.mdx +2 -2
  20. package/.docs/raw/reference/auth/jwt.mdx +2 -3
  21. package/.docs/raw/reference/auth/supabase.mdx +62 -0
  22. package/.docs/raw/reference/{agents → core}/getAgent.mdx +1 -2
  23. package/.docs/raw/reference/core/getAgentById.mdx +43 -0
  24. package/.docs/raw/reference/core/getAgents.mdx +35 -0
  25. package/.docs/raw/reference/core/getDeployer.mdx +35 -0
  26. package/.docs/raw/reference/core/getLogger.mdx +35 -0
  27. package/.docs/raw/reference/core/getLogs.mdx +92 -0
  28. package/.docs/raw/reference/core/getLogsByRunId.mdx +84 -0
  29. package/.docs/raw/reference/core/getMCPServer.mdx +49 -0
  30. package/.docs/raw/reference/core/getMCPServers.mdx +35 -0
  31. package/.docs/raw/reference/core/getMemory.mdx +35 -0
  32. package/.docs/raw/reference/core/getServer.mdx +35 -0
  33. package/.docs/raw/reference/core/getStorage.mdx +35 -0
  34. package/.docs/raw/reference/core/getTelemetry.mdx +35 -0
  35. package/.docs/raw/reference/core/getVector.mdx +43 -0
  36. package/.docs/raw/reference/core/getVectors.mdx +35 -0
  37. package/.docs/raw/reference/core/getWorkflow.mdx +49 -0
  38. package/.docs/raw/reference/core/getWorkflows.mdx +44 -0
  39. package/.docs/raw/reference/core/mastra-class.mdx +14 -178
  40. package/.docs/raw/reference/core/setLogger.mdx +47 -0
  41. package/.docs/raw/reference/core/setStorage.mdx +39 -0
  42. package/.docs/raw/reference/core/setTelemetry.mdx +35 -0
  43. package/.docs/raw/workflows/control-flow.mdx +2 -2
  44. package/.docs/raw/workflows/overview.mdx +8 -8
  45. package/.docs/raw/workflows/suspend-and-resume.mdx +4 -4
  46. package/CHANGELOG.md +10 -0
  47. package/package.json +5 -5
  48. package/.docs/raw/reference/workflows/execute.mdx +0 -131
  49. /package/.docs/raw/reference/workflows/{branch.mdx → workflow-methods/branch.mdx} +0 -0
  50. /package/.docs/raw/reference/workflows/{commit.mdx → workflow-methods/commit.mdx} +0 -0
  51. /package/.docs/raw/reference/workflows/{create-run.mdx → workflow-methods/create-run.mdx} +0 -0
  52. /package/.docs/raw/reference/workflows/{dountil.mdx → workflow-methods/dountil.mdx} +0 -0
  53. /package/.docs/raw/reference/workflows/{dowhile.mdx → workflow-methods/dowhile.mdx} +0 -0
  54. /package/.docs/raw/reference/workflows/{foreach.mdx → workflow-methods/foreach.mdx} +0 -0
  55. /package/.docs/raw/reference/workflows/{map.mdx → workflow-methods/map.mdx} +0 -0
  56. /package/.docs/raw/reference/workflows/{parallel.mdx → workflow-methods/parallel.mdx} +0 -0
  57. /package/.docs/raw/reference/workflows/{sendEvent.mdx → workflow-methods/sendEvent.mdx} +0 -0
  58. /package/.docs/raw/reference/workflows/{sleep.mdx → workflow-methods/sleep.mdx} +0 -0
  59. /package/.docs/raw/reference/workflows/{sleepUntil.mdx → workflow-methods/sleepUntil.mdx} +0 -0
  60. /package/.docs/raw/reference/workflows/{then.mdx → workflow-methods/then.mdx} +0 -0
  61. /package/.docs/raw/reference/workflows/{waitForEvent.mdx → workflow-methods/waitForEvent.mdx} +0 -0
@@ -0,0 +1,49 @@
1
+ ---
2
+ title: "Reference: Mastra.getMCPServer() | Core | Mastra Docs"
3
+ description: "Documentation for the `Mastra.getMCPServer()` method in Mastra, which retrieves a specific MCP server instance by ID and optional version."
4
+ ---
5
+
6
+ # Mastra.getMCPServer()
7
+
8
+ The `.getMCPServer()` method is used to retrieve a specific MCP server instance by its logical ID and optional version. If a version is provided, it attempts to find the server with that exact logical ID and version. If no version is provided, it returns the server with the specified logical ID that has the most recent releaseDate.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript copy
13
+ mastra.getMCPServer("1.2.0");
14
+ ```
15
+
16
+ ## Parameters
17
+
18
+ <PropertiesTable
19
+ content={[
20
+ {
21
+ name: "serverId",
22
+ type: "string",
23
+ description: "The logical ID of the MCP server to retrieve. Should match the `id` property of the MCPServer instance.",
24
+ },
25
+ {
26
+ name: "version",
27
+ type: "string",
28
+ description: "Optional specific version of the MCP server to retrieve. If not provided, returns the server with the most recent releaseDate.",
29
+ optional: true,
30
+ },
31
+ ]}
32
+ />
33
+
34
+ ## Returns
35
+
36
+ <PropertiesTable
37
+ content={[
38
+ {
39
+ name: "server",
40
+ type: "MCPServerBase | undefined",
41
+ description: "The MCP server instance with the specified ID and version, or undefined if not found or if the specific version is not found.",
42
+ },
43
+ ]}
44
+ />
45
+
46
+ ## Related
47
+
48
+ - [MCP overview](../../docs/tools-mcp/mcp-overview.mdx)
49
+ - [MCP server reference](../../reference/tools/mcp-server.mdx)
@@ -0,0 +1,35 @@
1
+ ---
2
+ title: "Reference: Mastra.getMCPServers() | Core | Mastra Docs"
3
+ description: "Documentation for the `Mastra.getMCPServers()` method in Mastra, which retrieves all registered MCP server instances."
4
+ ---
5
+
6
+ # Mastra.getMCPServers()
7
+
8
+ The `.getMCPServers()` method is used to retrieve all MCP server instances that have been registered in the Mastra instance.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript copy
13
+ mastra.getMCPServers();
14
+ ```
15
+
16
+ ## Parameters
17
+
18
+ This method does not accept any parameters.
19
+
20
+ ## Returns
21
+
22
+ <PropertiesTable
23
+ content={[
24
+ {
25
+ name: "servers",
26
+ type: "Record<string, MCPServerBase> | undefined",
27
+ description: "A record of all registered MCP server instances, where keys are server IDs and values are MCPServerBase instances, or undefined if no servers are registered.",
28
+ },
29
+ ]}
30
+ />
31
+
32
+ ## Related
33
+
34
+ - [MCP overview](../../docs/tools-mcp/mcp-overview.mdx)
35
+ - [MCP server reference](../../reference/tools/mcp-server.mdx)
@@ -0,0 +1,35 @@
1
+ ---
2
+ title: "Reference: Mastra.getMemory() | Core | Mastra Docs"
3
+ description: "Documentation for the `Mastra.getMemory()` method in Mastra, which retrieves the configured memory instance."
4
+ ---
5
+
6
+ # Mastra.getMemory()
7
+
8
+ The `.getMemory()` method is used to retrieve the memory instance that has been configured in the Mastra instance.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript copy
13
+ mastra.getMemory();
14
+ ```
15
+
16
+ ## Parameters
17
+
18
+ This method does not accept any parameters.
19
+
20
+ ## Returns
21
+
22
+ <PropertiesTable
23
+ content={[
24
+ {
25
+ name: "memory",
26
+ type: "MastraMemory | undefined",
27
+ description: "The configured memory instance, or undefined if no memory has been configured.",
28
+ },
29
+ ]}
30
+ />
31
+
32
+ ## Related
33
+
34
+ - [Memory overview](../../docs/memory/overview.mdx)
35
+ - [Memory reference](../../reference/memory/Memory.mdx)
@@ -0,0 +1,35 @@
1
+ ---
2
+ title: "Reference: Mastra.getServer() | Core | Mastra Docs"
3
+ description: "Documentation for the `Mastra.getServer()` method in Mastra, which retrieves the configured server configuration."
4
+ ---
5
+
6
+ # Mastra.getServer()
7
+
8
+ The `.getServer()` method is used to retrieve the server configuration that has been configured in the Mastra instance.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript copy
13
+ mastra.getServer();
14
+ ```
15
+
16
+ ## Parameters
17
+
18
+ This method does not accept any parameters.
19
+
20
+ ## Returns
21
+
22
+ <PropertiesTable
23
+ content={[
24
+ {
25
+ name: "server",
26
+ type: "ServerConfig | undefined",
27
+ description: "The configured server configuration including port, timeout, API routes, middleware, CORS settings, and build options, or undefined if no server has been configured.",
28
+ },
29
+ ]}
30
+ />
31
+
32
+ ## Related
33
+
34
+ - [Server deployment](../../docs/deployment/server-deployment.mdx)
35
+ - [Server configuration](../../docs/server-db/custom-api-routes.mdx)
@@ -0,0 +1,35 @@
1
+ ---
2
+ title: "Reference: Mastra.getStorage() | Core | Mastra Docs"
3
+ description: "Documentation for the `Mastra.getStorage()` method in Mastra, which retrieves the configured storage instance."
4
+ ---
5
+
6
+ # Mastra.getStorage()
7
+
8
+ The `.getStorage()` method is used to retrieve the storage instance that has been configured in the Mastra instance.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript copy
13
+ mastra.getStorage();
14
+ ```
15
+
16
+ ## Parameters
17
+
18
+ This method does not accept any parameters.
19
+
20
+ ## Returns
21
+
22
+ <PropertiesTable
23
+ content={[
24
+ {
25
+ name: "storage",
26
+ type: "MastraStorage | undefined",
27
+ description: "The configured storage instance, or undefined if no storage has been configured.",
28
+ },
29
+ ]}
30
+ />
31
+
32
+ ## Related
33
+
34
+ - [Storage overview](../../docs/server-db/storage.mdx)
35
+ - [Storage reference](../../reference/storage/libsql.mdx)
@@ -0,0 +1,35 @@
1
+ ---
2
+ title: "Reference: Mastra.getTelemetry() | Core | Mastra Docs"
3
+ description: "Documentation for the `Mastra.getTelemetry()` method in Mastra, which retrieves the configured telemetry instance."
4
+ ---
5
+
6
+ # Mastra.getTelemetry()
7
+
8
+ The `.getTelemetry()` method is used to retrieve the telemetry instance that has been configured in the Mastra instance.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript copy
13
+ mastra.getTelemetry();
14
+ ```
15
+
16
+ ## Parameters
17
+
18
+ This method does not accept any parameters.
19
+
20
+ ## Returns
21
+
22
+ <PropertiesTable
23
+ content={[
24
+ {
25
+ name: "telemetry",
26
+ type: "Telemetry | undefined",
27
+ description: "The configured telemetry instance used for tracing and observability across all components, or undefined if no telemetry has been configured.",
28
+ },
29
+ ]}
30
+ />
31
+
32
+ ## Related
33
+
34
+ - [AI tracing](../../docs/observability/ai-tracing.mdx)
35
+ - [Telemetry reference](../../reference/observability/otel-config.mdx)
@@ -0,0 +1,43 @@
1
+ ---
2
+ title: "Reference: Mastra.getVector() | Core | Mastra Docs"
3
+ description: "Documentation for the `Mastra.getVector()` method in Mastra, which retrieves a vector store by name."
4
+ ---
5
+
6
+ # Mastra.getVector()
7
+
8
+ The `.getVector()` method is used to retrieve a vector store by its name. The method accepts a single `string` parameter for the vector store's name.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript copy
13
+ mastra.getVector("testVectorStore");
14
+ ```
15
+
16
+ ## Parameters
17
+
18
+ <PropertiesTable
19
+ content={[
20
+ {
21
+ name: "name",
22
+ type: "TVectorName extends keyof TVectors",
23
+ description: "The name of the vector store to retrieve. Must be a valid vector store name that exists in the Mastra configuration.",
24
+ },
25
+ ]}
26
+ />
27
+
28
+ ## Returns
29
+
30
+ <PropertiesTable
31
+ content={[
32
+ {
33
+ name: "vector",
34
+ type: "TVectors[TVectorName]",
35
+ description: "The vector store instance with the specified name. Throws an error if the vector store is not found.",
36
+ },
37
+ ]}
38
+ />
39
+
40
+ ## Related
41
+
42
+ - [Vector stores overview](../../docs/rag/vector-databases.mdx)
43
+ - [RAG overview](../../docs/rag/overview.mdx)
@@ -0,0 +1,35 @@
1
+ ---
2
+ title: "Reference: Mastra.getVectors() | Core | Mastra Docs"
3
+ description: "Documentation for the `Mastra.getVectors()` method in Mastra, which retrieves all configured vector stores."
4
+ ---
5
+
6
+ # Mastra.getVectors()
7
+
8
+ The `.getVectors()` method is used to retrieve all vector stores that have been configured in the Mastra instance.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript copy
13
+ mastra.getVectors();
14
+ ```
15
+
16
+ ## Parameters
17
+
18
+ This method does not accept any parameters.
19
+
20
+ ## Returns
21
+
22
+ <PropertiesTable
23
+ content={[
24
+ {
25
+ name: "vectors",
26
+ type: "TVectors",
27
+ description: "A record of all configured vector stores, where keys are vector store names and values are vector store instances.",
28
+ },
29
+ ]}
30
+ />
31
+
32
+ ## Related
33
+
34
+ - [Vector stores overview](../../docs/rag/vector-databases.mdx)
35
+ - [RAG overview](../../docs/rag/overview.mdx)
@@ -0,0 +1,49 @@
1
+ ---
2
+ title: "Reference: Mastra.getWorkflow() | Core | Mastra Docs"
3
+ description: "Documentation for the `Mastra.getWorkflow()` method in Mastra, which retrieves a workflow by ID."
4
+ ---
5
+
6
+ # Mastra.getWorkflow()
7
+
8
+ The `.getWorkflow()` method is used to retrieve a workflow by its ID. The method accepts a workflow ID and an optional options object.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript copy
13
+ mastra.getWorkflow("testWorkflow");
14
+ ```
15
+
16
+ ## Parameters
17
+
18
+ <PropertiesTable
19
+ content={[
20
+ {
21
+ name: "id",
22
+ type: "TWorkflowId extends keyof TWorkflows",
23
+ description: "The ID of the workflow to retrieve. Must be a valid workflow ID that exists in the Mastra configuration.",
24
+ },
25
+ {
26
+ name: "options",
27
+ type: "{ serialized?: boolean }",
28
+ description: "Optional configuration object. When `serialized` is true, returns only the workflow name instead of the full workflow instance.",
29
+ optional: true,
30
+ },
31
+ ]}
32
+ />
33
+
34
+ ## Returns
35
+
36
+ <PropertiesTable
37
+ content={[
38
+ {
39
+ name: "workflow",
40
+ type: "TWorkflows[TWorkflowId]",
41
+ description: "The workflow instance with the specified ID. Throws an error if the workflow is not found.",
42
+ },
43
+ ]}
44
+ />
45
+
46
+ ## Related
47
+
48
+ - [Workflows overview](../../docs/workflows/overview.mdx)
49
+ - [Dynamic workflows](../../docs/workflows/dynamic-workflows.mdx)
@@ -0,0 +1,44 @@
1
+ ---
2
+ title: "Reference: Mastra.getWorkflows() | Core | Mastra Docs"
3
+ description: "Documentation for the `Mastra.getWorkflows()` method in Mastra, which retrieves all configured workflows."
4
+ ---
5
+
6
+ # Mastra.getWorkflows()
7
+
8
+ The `.getWorkflows()` method is used to retrieve all workflows that have been configured in the Mastra instance. The method accepts an optional options object.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript copy
13
+ mastra.getWorkflows();
14
+ ```
15
+
16
+ ## Parameters
17
+
18
+ <PropertiesTable
19
+ content={[
20
+ {
21
+ name: "options",
22
+ type: "{ serialized?: boolean }",
23
+ description: "Optional configuration object. When `serialized` is true, returns simplified workflow objects with only the name property instead of full workflow instances.",
24
+ optional: true,
25
+ },
26
+ ]}
27
+ />
28
+
29
+ ## Returns
30
+
31
+ <PropertiesTable
32
+ content={[
33
+ {
34
+ name: "workflows",
35
+ type: "Record<string, Workflow>",
36
+ description: "A record of all configured workflows, where keys are workflow IDs and values are workflow instances (or simplified objects if serialized is true).",
37
+ },
38
+ ]}
39
+ />
40
+
41
+ ## Related
42
+
43
+ - [Workflows overview](../../docs/workflows/overview.mdx)
44
+ - [Dynamic workflows](../../docs/workflows/dynamic-workflows.mdx)
@@ -3,7 +3,7 @@ title: "Mastra Core"
3
3
  description: Documentation for the Mastra Class, the core entry point for managing agents, workflows, MCP servers, and server endpoints.
4
4
  ---
5
5
 
6
- # The Mastra Class
6
+ # Mastra Class
7
7
 
8
8
  The `Mastra` class is the central orchestrator in any Mastra application, managing agents, workflows, storage, logging, telemetry, and more. Typically, you create a single instance of `Mastra` to coordinate your application.
9
9
 
@@ -13,42 +13,29 @@ Think of `Mastra` as a top-level registry:
13
13
  - **tools** aren’t registered on `Mastra` directly but are associated with agents and discovered automatically.
14
14
 
15
15
 
16
- ## Importing
16
+ ## Usage example
17
17
 
18
- ```typescript
19
- import { Mastra } from "@mastra/core/mastra";
20
- ```
21
-
22
- ## Constructor
23
-
24
- Creates a new `Mastra` instance with the specified configuration.
25
-
26
- ```typescript
27
- constructor(config?: Config);
28
- ```
29
-
30
- ## Initialization
31
-
32
- The Mastra class is typically initialized in your `src/mastra/index.ts` file:
33
-
34
- ```typescript filename="src/mastra/index.ts" showLineNumbers copy
35
- import { Mastra } from "@mastra/core/mastra";
36
- import { LibSQLStore } from "@mastra/libsql";
37
- import { weatherAgent } from "./agents/weather-agent";
18
+ ```typescript filename="src/mastra/index.ts"
19
+ import { Mastra } from '@mastra/core/mastra';
20
+ import { PinoLogger } from '@mastra/loggers';
21
+ import { LibSQLStore } from '@mastra/libsql';
22
+ import { weatherWorkflow } from './workflows/weather-workflow';
23
+ import { weatherAgent } from './agents/weather-agent';
38
24
 
39
25
  export const mastra = new Mastra({
26
+ workflows: { weatherWorkflow },
40
27
  agents: { weatherAgent },
41
28
  storage: new LibSQLStore({
42
29
  url: ":memory:",
43
30
  }),
31
+ logger: new PinoLogger({
32
+ name: 'Mastra',
33
+ level: 'info',
34
+ }),
44
35
  });
45
36
  ```
46
37
 
47
- ## Configuration Object
48
-
49
- The constructor accepts an optional `Config` object to customize its behavior and integrate various Mastra components. All properties on the `Config` object are optional.
50
-
51
- ### Properties
38
+ ## Constructor parameters
52
39
 
53
40
  <PropertiesTable
54
41
  content={[
@@ -145,156 +132,5 @@ The constructor accepts an optional `Config` object to customize its behavior an
145
132
  ]}
146
133
  />
147
134
 
148
- ## Usage
149
-
150
- Any of the below methods can be used with the Mastra class, for example:
151
-
152
- ```typescript {3} filename="example.ts" showLineNumbers
153
- import { mastra } from "./mastra";
154
-
155
- const agent = mastra.getAgent("weatherAgent");
156
- const result = await agent.generate("What's the weather like in London?");
157
- ```
158
-
159
- ### Methods
160
-
161
- <PropertiesTable
162
- content={[
163
- {
164
- name: "getAgent(name)",
165
- type: "Agent",
166
- description:
167
- "Returns an agent instance by id. Throws if agent not found.",
168
- example: 'const agent = mastra.getAgent("agentOne");',
169
- },
170
- {
171
- name: "getAgents()",
172
- type: "Record<string, Agent>",
173
- description: "Returns all registered agents as a key-value object.",
174
- example: "const agents = mastra.getAgents();",
175
- },
176
- {
177
- name: "getWorkflow(id, { serialized })",
178
- type: "Workflow",
179
- description:
180
- "Returns a workflow instance by id. The serialized option (default: false) returns a simplified representation with just the name.",
181
- example: 'const workflow = mastra.getWorkflow("myWorkflow");',
182
- },
183
- {
184
- name: "getWorkflows({ serialized })",
185
- type: "Record<string, Workflow>",
186
- description:
187
- "Returns all registered workflows. The serialized option (default: false) returns simplified representations.",
188
- example: "const workflows = mastra.getWorkflows();",
189
- },
190
- {
191
- name: "getVector(name)",
192
- type: "MastraVector",
193
- description:
194
- "Returns a vector store instance by name. Throws if not found.",
195
- example: 'const vectorStore = mastra.getVector("myVectorStore");',
196
- },
197
- {
198
- name: "getVectors()",
199
- type: "Record<string, MastraVector>",
200
- description:
201
- "Returns all registered vector stores as a key-value object.",
202
- example: "const vectorStores = mastra.getVectors();",
203
- },
204
- {
205
- name: "getDeployer()",
206
- type: "MastraDeployer | undefined",
207
- description: "Returns the configured deployer instance, if any.",
208
- example: "const deployer = mastra.getDeployer();",
209
- },
210
- {
211
- name: "getStorage()",
212
- type: "MastraStorage | undefined",
213
- description: "Returns the configured storage instance.",
214
- example: "const storage = mastra.getStorage();",
215
- },
216
- {
217
- name: "getMemory()",
218
- type: "MastraMemory | undefined",
219
- description:
220
- "Returns the configured memory instance. Note: This is deprecated, memory should be added to agents directly.",
221
- example: "const memory = mastra.getMemory();",
222
- },
223
- {
224
- name: "getServer()",
225
- type: "ServerConfig | undefined",
226
- description:
227
- "Returns the server configuration including port, timeout, API routes, middleware, CORS settings, and build options.",
228
- example: "const serverConfig = mastra.getServer();",
229
- },
230
- {
231
- name: "setStorage(storage)",
232
- type: "void",
233
- description: "Sets the storage instance for the Mastra instance.",
234
- example: "mastra.setStorage(new DefaultStorage());",
235
- },
236
- {
237
- name: "setLogger({ logger })",
238
- type: "void",
239
- description:
240
- "Sets the logger for all components (agents, workflows, etc.).",
241
- example:
242
- 'mastra.setLogger({ logger: new PinoLogger({ name: "MyLogger" }) });',
243
- },
244
- {
245
- name: "setTelemetry(telemetry)",
246
- type: "void",
247
- description: "Sets the telemetry configuration for all components.",
248
- example: 'mastra.setTelemetry({ export: { type: "console" } });',
249
- },
250
- {
251
- name: "getLogger()",
252
- type: "Logger",
253
- description: "Gets the configured logger instance.",
254
- example: "const logger = mastra.getLogger();",
255
- },
256
- {
257
- name: "getTelemetry()",
258
- type: "Telemetry | undefined",
259
- description: "Gets the configured telemetry instance.",
260
- example: "const telemetry = mastra.getTelemetry();",
261
- },
262
- {
263
- name: "getLogsByRunId({ runId, transportId })",
264
- type: "Promise<any>",
265
- description: "Retrieves logs for a specific run ID and transport ID.",
266
- example:
267
- 'const logs = await mastra.getLogsByRunId({ runId: "123", transportId: "456" });',
268
- },
269
- {
270
- name: "getLogs(transportId)",
271
- type: "Promise<any>",
272
- description: "Retrieves all logs for a specific transport ID.",
273
- example: 'const logs = await mastra.getLogs("transportId");',
274
- },
275
- {
276
- name: "getMCPServers()",
277
- type: "Record<string, MCPServerBase> | undefined",
278
- description: "Retrieves all registered MCP server instances.",
279
- example: "const mcpServers = mastra.getMCPServers();",
280
- },
281
- ]}
282
- />
283
-
284
- ## Error Handling
285
-
286
- The Mastra class methods throw typed errors that can be caught:
287
135
 
288
- ```typescript {8} filename="example.ts" showLineNumbers
289
- import { mastra } from "./mastra";
290
136
 
291
- try {
292
- const agent = mastra.getAgent("weatherAgent");
293
- const result = await agent.generate("What's the weather like in London?");
294
-
295
- } catch (error) {
296
- if (error instanceof Error) {
297
- console.log(error.message);
298
- }
299
- }
300
- ```
@@ -0,0 +1,47 @@
1
+ ---
2
+ title: "Reference: Mastra.setLogger() | Core | Mastra Docs"
3
+ description: "Documentation for the `Mastra.setLogger()` method in Mastra, which sets the logger for all components (agents, workflows, etc.)."
4
+ ---
5
+
6
+ # Mastra.setLogger()
7
+
8
+ The `.setLogger()` method is used to set the logger for all components (agents, workflows, etc.) in the Mastra instance. This method accepts a single object parameter with a logger property.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript copy
13
+ mastra.setLogger({ logger: new PinoLogger({ name: "testLogger" }) });
14
+ ```
15
+
16
+ ## Parameters
17
+
18
+ <PropertiesTable
19
+ content={[
20
+ {
21
+ name: "options",
22
+ type: "{ logger: TLogger }",
23
+ description: "An object containing the logger instance to set for all components.",
24
+ },
25
+ ]}
26
+ />
27
+
28
+ ### Options
29
+
30
+ <PropertiesTable
31
+ content={[
32
+ {
33
+ name: "logger",
34
+ type: "TLogger",
35
+ description: "The logger instance to set for all components (agents, workflows, etc.).",
36
+ },
37
+ ]}
38
+ />
39
+
40
+ ## Returns
41
+
42
+ This method does not return a value.
43
+
44
+ ## Related
45
+
46
+ - [Logging overview](../../docs/observability/logging.mdx)
47
+ - [Logger reference](../../reference/observability/logger.mdx)