@mastra/mcp-docs-server 0.13.6 → 0.13.7-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 (115) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +9 -9
  2. package/.docs/organized/changelogs/%40mastra%2Fastra.md +8 -8
  3. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +8 -8
  4. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +8 -8
  5. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +35 -35
  6. package/.docs/organized/changelogs/%40mastra%2Fcloud.md +8 -8
  7. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +25 -25
  8. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +8 -8
  9. package/.docs/organized/changelogs/%40mastra%2Fcore.md +30 -30
  10. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +8 -8
  11. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +30 -30
  12. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +28 -28
  13. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +28 -28
  14. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +45 -45
  15. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +26 -26
  16. package/.docs/organized/changelogs/%40mastra%2Fevals.md +35 -35
  17. package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +29 -29
  18. package/.docs/organized/changelogs/%40mastra%2Fgithub.md +8 -8
  19. package/.docs/organized/changelogs/%40mastra%2Flance.md +7 -0
  20. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +28 -28
  21. package/.docs/organized/changelogs/%40mastra%2Floggers.md +8 -8
  22. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +35 -35
  23. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +8 -8
  24. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +9 -9
  25. package/.docs/organized/changelogs/%40mastra%2Fmem0.md +26 -26
  26. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +37 -37
  27. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +26 -26
  28. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +7 -0
  29. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +8 -8
  30. package/.docs/organized/changelogs/%40mastra%2Fpg.md +8 -8
  31. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +8 -8
  32. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +43 -43
  33. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +8 -8
  34. package/.docs/organized/changelogs/%40mastra%2Frag.md +27 -27
  35. package/.docs/organized/changelogs/%40mastra%2Fragie.md +8 -8
  36. package/.docs/organized/changelogs/%40mastra%2Fserver.md +34 -34
  37. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +8 -8
  38. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +26 -26
  39. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +8 -8
  40. package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +26 -26
  41. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +8 -8
  42. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +8 -8
  43. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +8 -8
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +8 -8
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +8 -8
  46. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +28 -28
  47. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +26 -26
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +8 -8
  49. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +8 -8
  50. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +8 -8
  51. package/.docs/organized/changelogs/create-mastra.md +15 -15
  52. package/.docs/organized/changelogs/mastra.md +43 -43
  53. package/.docs/organized/code-examples/a2a.md +1 -1
  54. package/.docs/organized/code-examples/agui.md +2 -2
  55. package/.docs/organized/code-examples/ai-sdk-useChat.md +1 -1
  56. package/.docs/organized/code-examples/ai-sdk-v5.md +1 -1
  57. package/.docs/organized/code-examples/assistant-ui.md +1 -1
  58. package/.docs/organized/code-examples/bird-checker-with-express.md +1 -1
  59. package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +1 -1
  60. package/.docs/organized/code-examples/bird-checker-with-nextjs.md +1 -1
  61. package/.docs/organized/code-examples/client-side-tools.md +2 -2
  62. package/.docs/organized/code-examples/crypto-chatbot.md +1 -1
  63. package/.docs/organized/code-examples/fireworks-r1.md +1 -1
  64. package/.docs/organized/code-examples/memory-with-mem0.md +1 -1
  65. package/.docs/organized/code-examples/memory-with-pg.md +1 -0
  66. package/.docs/organized/code-examples/openapi-spec-writer.md +1 -1
  67. package/.docs/organized/code-examples/quick-start.md +1 -1
  68. package/.docs/organized/code-examples/workflow-ai-recruiter.md +1 -1
  69. package/.docs/organized/code-examples/workflow-with-inline-steps.md +1 -1
  70. package/.docs/organized/code-examples/workflow-with-memory.md +1 -1
  71. package/.docs/organized/code-examples/workflow-with-separate-steps.md +1 -1
  72. package/.docs/organized/code-examples/workflow-with-suspend-resume.md +1 -1
  73. package/.docs/raw/agents/runtime-variables.mdx +1 -1
  74. package/.docs/raw/auth/index.mdx +24 -0
  75. package/.docs/raw/auth/jwt.mdx +99 -0
  76. package/.docs/raw/community/contributing-templates.mdx +192 -0
  77. package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +6 -5
  78. package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +84 -14
  79. package/.docs/raw/evals/custom-eval.mdx +12 -12
  80. package/.docs/raw/getting-started/installation.mdx +16 -0
  81. package/.docs/raw/getting-started/templates.mdx +95 -0
  82. package/.docs/raw/index.mdx +2 -2
  83. package/.docs/raw/reference/agents/generate.mdx +18 -1
  84. package/.docs/raw/reference/agents/stream.mdx +18 -1
  85. package/.docs/raw/reference/auth/jwt.mdx +42 -0
  86. package/.docs/raw/reference/client-js/agents.mdx +3 -11
  87. package/.docs/raw/reference/client-js/error-handling.mdx +1 -21
  88. package/.docs/raw/reference/client-js/logs.mdx +2 -10
  89. package/.docs/raw/reference/client-js/mastra-client.mdx +141 -0
  90. package/.docs/raw/reference/client-js/memory.mdx +6 -18
  91. package/.docs/raw/reference/client-js/telemetry.mdx +1 -9
  92. package/.docs/raw/reference/client-js/tools.mdx +2 -10
  93. package/.docs/raw/reference/client-js/vectors.mdx +1 -9
  94. package/.docs/raw/reference/client-js/workflows-legacy.mdx +3 -11
  95. package/.docs/raw/reference/client-js/workflows.mdx +5 -13
  96. package/.docs/raw/reference/core/mastra-class.mdx +7 -1
  97. package/.docs/raw/reference/observability/providers/dash0.mdx +2 -2
  98. package/.docs/raw/reference/scorers/answer-relevancy.mdx +115 -0
  99. package/.docs/raw/reference/scorers/bias.mdx +127 -0
  100. package/.docs/raw/reference/scorers/completeness.mdx +89 -0
  101. package/.docs/raw/reference/scorers/content-similarity.mdx +96 -0
  102. package/.docs/raw/reference/scorers/custom-code-scorer.mdx +155 -0
  103. package/.docs/raw/reference/scorers/faithfulness.mdx +123 -0
  104. package/.docs/raw/reference/scorers/hallucination.mdx +135 -0
  105. package/.docs/raw/reference/scorers/keyword-coverage.mdx +92 -0
  106. package/.docs/raw/reference/scorers/llm-scorer.mdx +166 -0
  107. package/.docs/raw/reference/scorers/mastra-scorer.mdx +218 -0
  108. package/.docs/raw/reference/scorers/textual-difference.mdx +76 -0
  109. package/.docs/raw/reference/scorers/tone-consistency.mdx +75 -0
  110. package/.docs/raw/reference/scorers/toxicity.mdx +109 -0
  111. package/.docs/raw/reference/templates.mdx +222 -0
  112. package/.docs/raw/reference/tools/vector-query-tool.mdx +29 -0
  113. package/.docs/raw/tools-mcp/overview.mdx +1 -1
  114. package/package.json +6 -6
  115. package/.docs/organized/changelogs/%40mastra%2Fagui.md +0 -302
@@ -0,0 +1,95 @@
1
+ ---
2
+ title: "Templates | Getting Started | Mastra Docs"
3
+ description: Pre-built project structures that demonstrate common Mastra use cases and patterns
4
+ ---
5
+
6
+ import { Callout } from "nextra/components";
7
+ import { Tabs, Tab } from "@/components/tabs";
8
+
9
+ # Templates
10
+
11
+ Templates are pre-built Mastra projects that demonstrate specific use cases and patterns. They provide working examples you can run immediately and customize for your needs.
12
+
13
+ ## What Templates Offer
14
+
15
+ Templates include:
16
+
17
+ - **Complete working examples** - Functional code demonstrating specific patterns
18
+ - **Best practices** - Proper project structure and Mastra conventions
19
+ - **Educational value** - Learn different Mastra features through examples
20
+ - **Quick start** - Bootstrap projects faster than starting from scratch
21
+
22
+ ## Using Templates
23
+
24
+ Install a template using the `create-mastra` command:
25
+
26
+ <Tabs items={["npx", "npm", "yarn", "pnpm", "bun"]}>
27
+ <Tab>
28
+ ```bash copy
29
+ npx create-mastra@latest --template template-name
30
+ ```
31
+ </Tab>
32
+ <Tab>
33
+ ```bash copy
34
+ npm create mastra@latest --template template-name
35
+ ```
36
+ </Tab>
37
+ <Tab>
38
+ ```bash copy
39
+ yarn create mastra@latest --template template-name
40
+ ```
41
+ </Tab>
42
+ <Tab>
43
+ ```bash copy
44
+ pnpm create mastra@latest --template template-name
45
+ ```
46
+ </Tab>
47
+ <Tab>
48
+ ```bash copy
49
+ bun create mastra@latest --template template-name
50
+ ```
51
+ </Tab>
52
+ </Tabs>
53
+
54
+ For example, to create a text-to-SQL application:
55
+
56
+ ```bash copy
57
+ npx create-mastra@latest --template text-to-sql
58
+ ```
59
+
60
+ ## Setting Up a Template
61
+
62
+ After installation:
63
+
64
+ 1. **Navigate to your project**:
65
+ ```bash copy
66
+ cd your-project-name
67
+ ```
68
+
69
+ 2. **Configure environment variables**:
70
+ ```bash copy
71
+ cp .env.example .env
72
+ ```
73
+ Edit `.env` with your API keys as specified in the template's README.
74
+
75
+ 3. **Start development**:
76
+ ```bash copy
77
+ npm run dev
78
+ ```
79
+
80
+ <Callout type="info">
81
+ Each template includes a comprehensive README with specific setup instructions and usage examples.
82
+ </Callout>
83
+
84
+ ## Available Templates
85
+
86
+ Browse available templates in the [templates directory](https://github.com/mastra-ai/mastra/tree/main/templates) on GitHub.
87
+
88
+ ## Next Steps
89
+
90
+ - **Explore code** - Understand how templates implement functionality
91
+ - **Customize** - Modify agents, tools, and workflows for your use case
92
+ - **Learn patterns** - Study templates to understand Mastra best practices
93
+ - **Contribute** - Create your own templates for the community
94
+
95
+ For detailed information on creating templates, see the [Templates Reference](/reference/templates).
@@ -9,14 +9,14 @@ Mastra is an open-source TypeScript agent framework.
9
9
 
10
10
  It's designed to give you the primitives you need to build AI applications and features.
11
11
 
12
- You can use Mastra to build [AI agents](/docs/agents/overview.mdx) that have memory and can execute functions, or chain LLM calls in deterministic [workflows](/docs/workflows/overview.mdx). You can chat with your agents in Mastra's [local dev environment](/docs/local-dev/mastra-dev.mdx), feed them application-specific knowledge with [RAG](/docs/rag/overview.mdx), and score their outputs with Mastra's [evals](/docs/evals/overview.mdx).
12
+ You can use Mastra to build [AI agents](/docs/agents/overview.mdx) that have memory and can execute functions, or chain LLM calls in deterministic [workflows](/docs/workflows/overview.mdx). You can chat with your agents in Mastra's [local dev playground](/docs/server-db/local-dev-playground.mdx), feed them application-specific knowledge with [RAG](/docs/rag/overview.mdx), and score their outputs with Mastra's [evals](/docs/evals/overview.mdx).
13
13
 
14
14
  The main features include:
15
15
 
16
16
  - **[Model routing](https://sdk.vercel.ai/docs/introduction)**: Mastra uses the [Vercel AI SDK](https://sdk.vercel.ai/docs/introduction) for model routing, providing a unified interface to interact with any LLM provider including OpenAI, Anthropic, and Google Gemini.
17
17
  - **[Agent memory and tool calling](/docs/agents/agent-memory.mdx)**: With Mastra, you can give your agent tools (functions) that it can call. You can persist agent memory and retrieve it based on recency, semantic similarity, or conversation thread.
18
18
  - **[Workflow graphs](/docs/workflows/overview.mdx)**: When you want to execute LLM calls in a deterministic way, Mastra gives you a graph-based workflow engine. You can define discrete steps, log inputs and outputs at each step of each run, and pipe them into an observability tool. Mastra workflows have a simple syntax for control flow (`.then()`, `.branch()`, `.parallel()`) that allows branching and chaining.
19
- - **[Agent development environment](/docs/local-dev/mastra-dev.mdx)**: When you're developing an agent locally, you can chat with it and see its state and memory in Mastra's agent development environment.
19
+ - **[Agent development playground](/docs/server-db/local-dev-playground.mdx)**: When you're developing an agent locally, you can chat with it and see its state and memory in Mastra's agent development environment.
20
20
  - **[Retrieval-augmented generation (RAG)](/docs/rag/overview.mdx)**: Mastra gives you APIs to process documents (text, HTML, Markdown, JSON) into chunks, create embeddings, and store them in a vector database. At query time, it retrieves relevant chunks to ground LLM responses in your data, with a unified API on top of multiple vector stores (Pinecone, pgvector, etc) and embedding providers (OpenAI, Cohere, etc).
21
21
  - **[Deployment](/docs/deployment/deployment.mdx)**: Mastra supports bundling your agents and workflows within an existing React, Next.js, or Node.js application, or into standalone endpoints. The Mastra deploy helper lets you easily bundle agents and workflows into a Node.js server using Hono, or deploy it onto a serverless platform like Vercel, Cloudflare Workers, or Netlify.
22
22
  - **[Evals](/docs/evals/overview.mdx)**: Mastra provides automated evaluation metrics that use model-graded, rule-based, and statistical methods to assess LLM outputs, with built-in metrics for toxicity, bias, relevance, and factual accuracy. You can also define your own evals.
@@ -16,16 +16,27 @@ The `messages` parameter can be:
16
16
  - A single string
17
17
  - An array of strings
18
18
  - An array of message objects with `role` and `content` properties
19
+ - An array of `UIMessageWithMetadata` objects (for messages with metadata)
19
20
 
20
- The message object structure:
21
+ The message object structures:
21
22
 
22
23
  ```typescript
23
24
  interface Message {
24
25
  role: "system" | "user" | "assistant";
25
26
  content: string;
26
27
  }
28
+
29
+ // For messages with metadata
30
+ interface UIMessageWithMetadata {
31
+ role: "user" | "assistant";
32
+ content: string;
33
+ parts: Array<{ type: string; text?: string; [key: string]: any }>;
34
+ metadata?: Record<string, unknown>; // Optional metadata field
35
+ }
27
36
  ```
28
37
 
38
+ When using `UIMessageWithMetadata`, the metadata will be preserved throughout the conversation and stored with the messages in memory.
39
+
29
40
  ### `options` (Optional)
30
41
 
31
42
  An optional object that can include configuration for output structure, memory management, tool usage, telemetry, and more.
@@ -175,6 +186,12 @@ An optional object that can include configuration for output structure, memory m
175
186
  description:
176
187
  "Tools that are executed on the 'client' side of the request. These tools do not have execute functions in the definition.",
177
188
  },
189
+ {
190
+ name: "savePerStep",
191
+ type: "boolean",
192
+ isOptional: true,
193
+ description: "Save messages incrementally after each stream step completes (default: false).",
194
+ }
178
195
  ]}
179
196
  />
180
197
 
@@ -16,16 +16,27 @@ The `messages` parameter can be:
16
16
  - A single string
17
17
  - An array of strings
18
18
  - An array of message objects with `role` and `content` properties
19
+ - An array of `UIMessageWithMetadata` objects (for messages with metadata)
19
20
 
20
- The message object structure:
21
+ The message object structures:
21
22
 
22
23
  ```typescript
23
24
  interface Message {
24
25
  role: "system" | "user" | "assistant";
25
26
  content: string;
26
27
  }
28
+
29
+ // For messages with metadata
30
+ interface UIMessageWithMetadata {
31
+ role: "user" | "assistant";
32
+ content: string;
33
+ parts: Array<{ type: string; text?: string; [key: string]: any }>;
34
+ metadata?: Record<string, unknown>; // Optional metadata field
35
+ }
27
36
  ```
28
37
 
38
+ When using `UIMessageWithMetadata`, the metadata will be preserved throughout the conversation and stored with the messages in memory.
39
+
29
40
  ### `options` (Optional)
30
41
 
31
42
  An optional object that can include configuration for output structure, memory management, tool usage, telemetry, and more.
@@ -181,6 +192,12 @@ An optional object that can include configuration for output structure, memory m
181
192
  description:
182
193
  "Tools that are executed on the 'client' side of the request. These tools do not have execute functions in the definition.",
183
194
  },
195
+ {
196
+ name: "savePerStep",
197
+ type: "boolean",
198
+ isOptional: true,
199
+ description: "Save messages incrementally after each generation step completes (default: false)",
200
+ }
184
201
  ]}
185
202
  />
186
203
 
@@ -0,0 +1,42 @@
1
+ ---
2
+ title: "MastraJwtAuth"
3
+ description: "API reference for the MastraJwtAuth class, which authenticates Mastra applications using JSON Web Tokens."
4
+ ---
5
+
6
+ # MastraJwtAuth
7
+
8
+ The `MastraJwtAuth` class provides a lightweight authentication mechanism for Mastra using JSON Web Tokens (JWTs). It verifies incoming requests based on a shared secret and integrates with the Mastra server using the `experimental_auth` option.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript filename="src/mastra/index.ts" showLineNumbers copy
13
+ import { Mastra } from "@mastra/core/mastra";
14
+ import { MastraJwtAuth } from '@mastra/auth';
15
+
16
+ export const mastra = new Mastra({
17
+ // ..
18
+ server: {
19
+ experimental_auth: new MastraJwtAuth({
20
+ secret: "<your-secret>"
21
+ }),
22
+ },
23
+ });
24
+ ```
25
+
26
+ ## Constructor parameters
27
+
28
+ <PropertiesTable
29
+ content={[
30
+ {
31
+ name: "secret",
32
+ type: "string",
33
+ description: "A unique string used to sign and verify JSON Web Tokens (JWTs) for authenticating incoming requests.",
34
+ isOptional: false,
35
+ },
36
+ ]}
37
+ />
38
+
39
+
40
+ ## Related
41
+
42
+ [MastraJwtAuth](/docs/auth/jwt.mdx)
@@ -7,20 +7,12 @@ description: Learn how to interact with Mastra AI agents, including generating r
7
7
 
8
8
  The Agents API provides methods to interact with Mastra AI agents, including generating responses, streaming interactions, and managing agent tools.
9
9
 
10
- ## Initialize Mastra Client
11
-
12
- ```typescript
13
- import { MastraClient } from "@mastra/client-js";
14
-
15
- const client = new MastraClient();
16
- ```
17
-
18
10
  ## Getting All Agents
19
11
 
20
12
  Retrieve a list of all available agents:
21
13
 
22
14
  ```typescript
23
- const agents = await client.getAgents();
15
+ const agents = await mastraClient.getAgents();
24
16
  ```
25
17
 
26
18
  ## Working with a Specific Agent
@@ -28,7 +20,7 @@ const agents = await client.getAgents();
28
20
  Get an instance of a specific agent:
29
21
 
30
22
  ```typescript
31
- const agent = client.getAgent("agent-id");
23
+ const agent = mastraClient.getAgent("agent-id");
32
24
  ```
33
25
 
34
26
  ## Agent Methods
@@ -89,7 +81,7 @@ response.processDataStream({
89
81
  },
90
82
  });
91
83
 
92
- // Process text stream with the processTextStream util
84
+ // Process text stream with the processTextStream util
93
85
  // (used with structured output)
94
86
  response.processTextStream({
95
87
  onTextPart: text => {
@@ -13,7 +13,7 @@ All API methods can throw errors that you can catch and handle:
13
13
 
14
14
  ```typescript
15
15
  try {
16
- const agent = client.getAgent("agent-id");
16
+ const agent = mastraClient.getAgent("agent-id");
17
17
  const response = await agent.generate({
18
18
  messages: [{ role: "user", content: "Hello" }],
19
19
  });
@@ -21,23 +21,3 @@ try {
21
21
  console.error("An error occurred:", error.message);
22
22
  }
23
23
  ```
24
-
25
- ## Retry Mechanism
26
-
27
- The client automatically retries failed requests with exponential backoff:
28
-
29
- ```typescript
30
- const client = new MastraClient({
31
- baseUrl: "http://localhost:4111",
32
- retries: 3, // Number of retry attempts
33
- backoffMs: 300, // Initial backoff time
34
- maxBackoffMs: 5000, // Maximum backoff time
35
- });
36
- ```
37
-
38
- ### How Retries Work
39
-
40
- 1. First attempt fails → Wait 300ms
41
- 2. Second attempt fails → Wait 600ms
42
- 3. Third attempt fails → Wait 1200ms
43
- 4. Final attempt fails → Throw error
@@ -7,20 +7,12 @@ description: Learn how to access and query system logs and debugging information
7
7
 
8
8
  The Logs API provides methods to access and query system logs and debugging information in Mastra.
9
9
 
10
- ## Initialize Mastra Client
11
-
12
- ```typescript
13
- import { MastraClient } from "@mastra/client-js";
14
-
15
- const client = new MastraClient();
16
- ```
17
-
18
10
  ## Getting Logs
19
11
 
20
12
  Retrieve system logs with optional filtering:
21
13
 
22
14
  ```typescript
23
- const logs = await client.getLogs({
15
+ const logs = await mastraClient.getLogs({
24
16
  transportId: "transport-1",
25
17
  });
26
18
  ```
@@ -30,7 +22,7 @@ const logs = await client.getLogs({
30
22
  Retrieve logs for a specific execution run:
31
23
 
32
24
  ```typescript
33
- const runLogs = await client.getLogForRun({
25
+ const runLogs = await mastraClient.getLogForRun({
34
26
  runId: "run-1",
35
27
  transportId: "transport-1",
36
28
  });
@@ -0,0 +1,141 @@
1
+ ---
2
+ title: MastraClient
3
+ description: Learn how to interact with Mastra using the client-js SDK.
4
+ ---
5
+
6
+ # Mastra Client SDK
7
+
8
+ The Mastra Client SDK provides a simple and type-safe interface for interacting with your [Mastra Server](/docs/deployment/server-deployment.mdx) from your client environment.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript filename="lib/mastra/mastra-client.ts" showLineNumbers copy
13
+ import { MastraClient } from "@mastra/client-js";
14
+
15
+ export const mastraClient = new MastraClient({
16
+ baseUrl: "http://localhost:4111/",
17
+ });
18
+ ```
19
+
20
+ ## Parameters
21
+
22
+ <PropertiesTable
23
+ content={[
24
+ {
25
+ name: "baseUrl",
26
+ type: "string",
27
+ description: "The base URL for the Mastra API. All requests will be sent relative to this URL.",
28
+ isOptional: false,
29
+ },
30
+ {
31
+ name: "retries",
32
+ type: "number",
33
+ description: "The number of times a request will be retried on failure before throwing an error.",
34
+ isOptional: true,
35
+ defaultValue: "3",
36
+ },
37
+ {
38
+ name: "backoffMs",
39
+ type: "number",
40
+ description: "The initial delay in milliseconds before retrying a failed request. This value is doubled with each retry (exponential backoff).",
41
+ isOptional: true,
42
+ defaultValue: "300",
43
+ },
44
+ {
45
+ name: "maxBackoffMs",
46
+ type: "number",
47
+ description: "The maximum backoff time in milliseconds. Prevents retries from waiting too long between attempts.",
48
+ isOptional: true,
49
+ defaultValue: "5000",
50
+ },
51
+ {
52
+ name: "headers",
53
+ type: "Record<string, string>",
54
+ description: "An object containing custom HTTP headers to include with every request.",
55
+ isOptional: true,
56
+ },
57
+ ]}
58
+ />
59
+
60
+ ## Methods
61
+
62
+ <PropertiesTable
63
+ content={[
64
+ {
65
+ name: "getAgents()",
66
+ type: "Promise<Record<string, GetAgentResponse>>",
67
+ description: "Returns all available agent instances.",
68
+ },
69
+ {
70
+ name: "getAgent(agentId)",
71
+ type: "Agent",
72
+ description: "Retrieves a specific agent instance by ID.",
73
+ },
74
+ {
75
+ name: "getMemoryThreads(params)",
76
+ type: "Promise<StorageThreadType[]>",
77
+ description: "Retrieves memory threads for the specified resource and agent. Requires a `resourceId` and an `agentId`.",
78
+ },
79
+ {
80
+ name: "createMemoryThread(params)",
81
+ type: "Promise<MemoryThread>",
82
+ description: "Creates a new memory thread with the given parameters.",
83
+ },
84
+ {
85
+ name: "getMemoryThread(threadId)",
86
+ type: "Promise<MemoryThread>",
87
+ description: "Fetches a specific memory thread by ID.",
88
+ },
89
+ {
90
+ name: "saveMessageToMemory(params)",
91
+ type: "Promise<void>",
92
+ description: "Saves one or more messages to the memory system.",
93
+ },
94
+ {
95
+ name: "getMemoryStatus()",
96
+ type: "Promise<MemoryStatus>",
97
+ description: "Returns the current status of the memory system.",
98
+ },
99
+ {
100
+ name: "getTools()",
101
+ type: "Record<string, Tool>",
102
+ description: "Returns all available tools.",
103
+ },
104
+ {
105
+ name: "getTool(toolId)",
106
+ type: "Tool",
107
+ description: "Retrieves a specific tool instance by ID.",
108
+ },
109
+ {
110
+ name: "getWorkflows()",
111
+ type: "Record<string, Workflow>",
112
+ description: "Returns all available workflow instances.",
113
+ },
114
+ {
115
+ name: "getWorkflow(workflowId)",
116
+ type: "Workflow",
117
+ description: "Retrieves a specific workflow instance by ID.",
118
+ },
119
+ {
120
+ name: "getVector(vectorName)",
121
+ type: "MastraVector",
122
+ description: "Returns a vector store instance by name.",
123
+ },
124
+ {
125
+ name: "getLogs(params)",
126
+ type: "Promise<LogEntry[]>",
127
+ description: "Fetches system logs matching the provided filters.",
128
+ },
129
+ {
130
+ name: "getLog(params)",
131
+ type: "Promise<LogEntry>",
132
+ description: "Retrieves a specific log entry by ID or filter.",
133
+ },
134
+ {
135
+ name: "getLogTransports()",
136
+ type: "string[]",
137
+ description: "Returns the list of configured log transport types.",
138
+ },
139
+ ]}
140
+ />
141
+
@@ -7,22 +7,12 @@ description: Learn how to manage conversation threads and message history in Mas
7
7
 
8
8
  The Memory API provides methods to manage conversation threads and message history in Mastra.
9
9
 
10
- ## Initialize Mastra Client
11
-
12
- ```typescript
13
- import { MastraClient } from "@mastra/client-js";
14
-
15
- const client = new MastraClient();
16
- ```
17
-
18
- ## Memory Thread Operations
19
-
20
10
  ### Get All Threads
21
11
 
22
12
  Retrieve all memory threads for a specific resource:
23
13
 
24
14
  ```typescript
25
- const threads = await client.getMemoryThreads({
15
+ const threads = await mastraClient.getMemoryThreads({
26
16
  resourceId: "resource-1",
27
17
  agentId: "agent-1",
28
18
  });
@@ -33,10 +23,10 @@ const threads = await client.getMemoryThreads({
33
23
  Create a new memory thread:
34
24
 
35
25
  ```typescript
36
- const thread = await client.createMemoryThread({
26
+ const thread = await mastraClient.createMemoryThread({
37
27
  title: "New Conversation",
38
28
  metadata: { category: "support" },
39
- resourceid: "resource-1",
29
+ resourceId: "resource-1",
40
30
  agentId: "agent-1",
41
31
  });
42
32
  ```
@@ -46,7 +36,7 @@ const thread = await client.createMemoryThread({
46
36
  Get an instance of a specific memory thread:
47
37
 
48
38
  ```typescript
49
- const thread = client.getMemoryThread("thread-id", "agent-id");
39
+ const thread = mastraClient.getMemoryThread("thread-id", "agent-id");
50
40
  ```
51
41
 
52
42
  ## Thread Methods
@@ -79,8 +69,6 @@ Delete a thread and its messages:
79
69
  await thread.delete();
80
70
  ```
81
71
 
82
-
83
-
84
72
  ## Message Operations
85
73
 
86
74
  ### Save Messages
@@ -88,7 +76,7 @@ await thread.delete();
88
76
  Save messages to memory:
89
77
 
90
78
  ```typescript
91
- const savedMessages = await client.saveMessageToMemory({
79
+ const savedMessages = await mastraClient.saveMessageToMemory({
92
80
  messages: [
93
81
  {
94
82
  role: "user",
@@ -120,5 +108,5 @@ const { messages } = await thread.getMessages({ limit: 10 });
120
108
  Check the status of the memory system:
121
109
 
122
110
  ```typescript
123
- const status = await client.getMemoryStatus("agent-id");
111
+ const status = await mastraClient.getMemoryStatus("agent-id");
124
112
  ```
@@ -7,20 +7,12 @@ description: Learn how to retrieve and analyze traces from your Mastra applicati
7
7
 
8
8
  The Telemetry API provides methods to retrieve and analyze traces from your Mastra application. This helps you monitor and debug your application's behavior and performance.
9
9
 
10
- ## Initialize Mastra Client
11
-
12
- ```typescript
13
- import { MastraClient } from "@mastra/client-js";
14
-
15
- const client = new MastraClient();
16
- ```
17
-
18
10
  ## Getting Traces
19
11
 
20
12
  Retrieve traces with optional filtering and pagination:
21
13
 
22
14
  ```typescript
23
- const telemetry = await client.getTelemetry({
15
+ const telemetry = await mastraClient.getTelemetry({
24
16
  name: "trace-name", // Optional: Filter by trace name
25
17
  scope: "scope-name", // Optional: Filter by scope
26
18
  page: 1, // Optional: Page number for pagination
@@ -7,20 +7,12 @@ description: Learn how to interact with and execute tools available in the Mastr
7
7
 
8
8
  The Tools API provides methods to interact with and execute tools available in the Mastra platform.
9
9
 
10
- ## Initialize Mastra Client
11
-
12
- ```typescript
13
- import { MastraClient } from "@mastra/client-js";
14
-
15
- const client = new MastraClient();
16
- ```
17
-
18
10
  ## Getting All Tools
19
11
 
20
12
  Retrieve a list of all available tools:
21
13
 
22
14
  ```typescript
23
- const tools = await client.getTools();
15
+ const tools = await mastraClient.getTools();
24
16
  ```
25
17
 
26
18
  ## Working with a Specific Tool
@@ -28,7 +20,7 @@ const tools = await client.getTools();
28
20
  Get an instance of a specific tool:
29
21
 
30
22
  ```typescript
31
- const tool = client.getTool("tool-id");
23
+ const tool = mastraClient.getTool("tool-id");
32
24
  ```
33
25
 
34
26
  ## Tool Methods
@@ -7,20 +7,12 @@ description: Learn how to work with vector embeddings for semantic search and si
7
7
 
8
8
  The Vectors API provides methods to work with vector embeddings for semantic search and similarity matching in Mastra.
9
9
 
10
- ## Initialize Mastra Client
11
-
12
- ```typescript
13
- import { MastraClient } from "@mastra/client-js";
14
-
15
- const client = new MastraClient();
16
- ```
17
-
18
10
  ## Working with Vectors
19
11
 
20
12
  Get an instance of a vector store:
21
13
 
22
14
  ```typescript
23
- const vector = client.getVector("vector-name");
15
+ const vector = mastraClient.getVector("vector-name");
24
16
  ```
25
17
 
26
18
  ## Vector Methods
@@ -7,20 +7,12 @@ description: Learn how to interact with and execute automated legacy workflows i
7
7
 
8
8
  The Workflows (Legacy) API provides methods to interact with and execute automated legacy workflows in Mastra.
9
9
 
10
- ## Initialize Mastra Client
11
-
12
- ```typescript
13
- import { MastraClient } from "@mastra/client-js";
14
-
15
- const client = new MastraClient();
16
- ```
17
-
18
10
  ## Getting All Legacy Workflows
19
11
 
20
12
  Retrieve a list of all available legacy workflows:
21
13
 
22
14
  ```typescript
23
- const workflows = await client.getLegacyWorkflows();
15
+ const workflows = await mastraClient.getLegacyWorkflows();
24
16
  ```
25
17
 
26
18
  ## Working with a Specific Legacy Workflow
@@ -28,7 +20,7 @@ const workflows = await client.getLegacyWorkflows();
28
20
  Get an instance of a specific legacy workflow:
29
21
 
30
22
  ```typescript
31
- const workflow = client.getLegacyWorkflow("workflow-id");
23
+ const workflow = mastraClient.getLegacyWorkflow("workflow-id");
32
24
  ```
33
25
 
34
26
  ## Legacy Workflow Methods
@@ -78,7 +70,7 @@ Watch legacy workflow transitions
78
70
  ```typescript
79
71
  try {
80
72
  // Get workflow instance
81
- const workflow = client.getLegacyWorkflow("workflow-id");
73
+ const workflow = mastraClient.getLegacyWorkflow("workflow-id");
82
74
 
83
75
  // Create a workflow run
84
76
  const { runId } = workflow.createRun();