@mastra/mcp-docs-server 0.13.6 → 0.13.7-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 (96) 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 +25 -25
  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 +22 -22
  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 +34 -34
  15. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +26 -26
  16. package/.docs/organized/changelogs/%40mastra%2Fevals.md +25 -25
  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 +26 -26
  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 +28 -28
  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 +32 -32
  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 +25 -25
  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 +9 -9
  52. package/.docs/organized/changelogs/mastra.md +33 -33
  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/deployment/cloud-providers/azure-app-services.mdx +6 -5
  77. package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +84 -14
  78. package/.docs/raw/evals/custom-eval.mdx +12 -12
  79. package/.docs/raw/index.mdx +2 -2
  80. package/.docs/raw/reference/auth/jwt.mdx +42 -0
  81. package/.docs/raw/reference/client-js/agents.mdx +3 -11
  82. package/.docs/raw/reference/client-js/error-handling.mdx +1 -21
  83. package/.docs/raw/reference/client-js/logs.mdx +2 -10
  84. package/.docs/raw/reference/client-js/mastra-client.mdx +141 -0
  85. package/.docs/raw/reference/client-js/memory.mdx +6 -18
  86. package/.docs/raw/reference/client-js/telemetry.mdx +1 -9
  87. package/.docs/raw/reference/client-js/tools.mdx +2 -10
  88. package/.docs/raw/reference/client-js/vectors.mdx +1 -9
  89. package/.docs/raw/reference/client-js/workflows-legacy.mdx +3 -11
  90. package/.docs/raw/reference/client-js/workflows.mdx +5 -13
  91. package/.docs/raw/reference/core/mastra-class.mdx +6 -0
  92. package/.docs/raw/reference/observability/providers/dash0.mdx +2 -2
  93. package/.docs/raw/reference/tools/vector-query-tool.mdx +29 -0
  94. package/.docs/raw/tools-mcp/overview.mdx +1 -1
  95. package/package.json +5 -5
  96. package/.docs/organized/changelogs/%40mastra%2Fagui.md +0 -302
@@ -4,7 +4,6 @@ description: "Deploy your Mastra applications to Digital Ocean."
4
4
  ---
5
5
 
6
6
  import { Callout, Steps, Tabs } from "nextra/components";
7
- import ServerConfig from "@/components/content-blocks/server-config.mdx";
8
7
 
9
8
  ## Digital Ocean
10
9
 
@@ -25,8 +24,8 @@ Deploy your Mastra applications to Digital Ocean's App Platform and Droplets.
25
24
 
26
25
  #### Prerequisites [#app-platform-prerequisites]
27
26
 
28
- - A Git repository containing your Mastra application. This can be a GitHub repository, GitLab repository, or any other compatible source provider.
29
- - A Digital Ocean account
27
+ - A Git repository containing your Mastra application. This can be a [GitHub](https://github.com/) repository, [GitLab](https://gitlab.com/) repository, or any other compatible source provider.
28
+ - A [Digital Ocean account](https://www.digitalocean.com/)
30
29
 
31
30
  #### Deployment Steps
32
31
 
@@ -34,8 +33,8 @@ Deploy your Mastra applications to Digital Ocean's App Platform and Droplets.
34
33
 
35
34
  #### Create a new App
36
35
 
37
- - Log in to your Digital Ocean dashboard.
38
- - Navigate to the App Platform service.
36
+ - Log in to your [Digital Ocean dashboard](https://cloud.digitalocean.com/).
37
+ - Navigate to the [App Platform](https://docs.digitalocean.com/products/app-platform/) service.
39
38
  - Select your source provider and create a new app.
40
39
 
41
40
  #### Configure Deployment Source
@@ -76,21 +75,86 @@ such as `LibSQLStore` with a file URL.
76
75
  ### Droplets
77
76
 
78
77
  Deploy your Mastra application to Digital Ocean's Droplets.
79
- This guide will cover setting up a droplet, a reverse proxy using Nginx, and running your Mastra application.
80
-
81
- <Callout>
82
- The guide assumes your droplet runs Ubuntu 24+.
83
- </Callout>
84
78
 
85
79
  #### Prerequisites [#droplets-prerequisites]
86
80
 
87
- - A Digital Ocean account
88
- - A droplet running Ubuntu 24+
81
+ - A [Digital Ocean account](https://www.digitalocean.com/)
82
+ - A [Droplet](https://docs.digitalocean.com/products/droplets/) running Ubuntu 24+
89
83
  - A domain name with an A record pointing to your droplet
84
+ - A reverse proxy configured (e.g., using [nginx](https://nginx.org/))
85
+ - SSL certificate configured (e.g., using [Let's Encrypt](https://letsencrypt.org/))
86
+ - Node.js 18+ installed on your droplet
87
+
88
+ #### Deployment Steps
89
+
90
+ <Steps>
91
+
92
+ #### Clone your Mastra application
93
+
94
+ Connect to your Droplet and clone your repository:
95
+
96
+ <Tabs items={["Public Repository", "Private Repository"]}>
97
+ <Tabs.Tab>
98
+
99
+ ```bash copy
100
+ git clone https://github.com/<your-username>/<your-repository>.git
101
+ ```
102
+
103
+ </Tabs.Tab>
104
+
105
+ <Tabs.Tab>
106
+
107
+ ```bash copy
108
+ git clone https://<your-username>:<your-personal-access-token>@github.com/<your-username>/<your-repository>.git
109
+ ```
110
+
111
+ </Tabs.Tab>
112
+ </Tabs>
113
+
114
+ Navigate to the repository directory:
90
115
 
91
- #### Setting up the droplet
116
+ ```bash copy
117
+ cd "<your-repository>"
118
+ ```
119
+
120
+ #### Install dependencies
121
+
122
+ ```bash copy
123
+ npm install
124
+ ```
125
+
126
+ #### Set up environment variables
127
+
128
+ Create a `.env` file and add your environment variables:
92
129
 
93
- <ServerConfig />
130
+ ```bash copy
131
+ touch .env
132
+ ```
133
+
134
+ Edit the `.env` file and add your environment variables:
135
+
136
+ ```bash copy
137
+ OPENAI_API_KEY=<your-openai-api-key>
138
+ # Add other required environment variables
139
+ ```
140
+
141
+ #### Build the application
142
+
143
+ ```bash copy
144
+ npm run build
145
+ ```
146
+
147
+ #### Run the application
148
+
149
+ ```bash copy
150
+ node --import=./.mastra/output/instrumentation.mjs --env-file=".env" .mastra/output/index.mjs
151
+ ```
152
+
153
+ <Callout>
154
+ Your Mastra application will run on port 4111 by default. Ensure your reverse proxy is configured to forward requests to this port.
155
+ </Callout>
156
+
157
+ </Steps>
94
158
 
95
159
  </Tabs.Tab>
96
160
 
@@ -109,3 +173,9 @@ const mastraClient = new MastraClient({
109
173
  baseUrl: "https://<your-domain-name>",
110
174
  });
111
175
  ```
176
+
177
+ ## Next steps
178
+
179
+ - [Mastra Client SDK](/docs/client-js/overview)
180
+ - [Digital Ocean App Platform documentation](https://docs.digitalocean.com/products/app-platform/)
181
+ - [Digital Ocean Droplets documentation](https://docs.digitalocean.com/products/droplets/)
@@ -1,22 +1,22 @@
1
1
  ---
2
- title: "Create your own Eval"
3
- description: "Mastra allows so create your own evals, here is how."
2
+ title: "Create a custom eval"
3
+ description: "Mastra allows you to create your own evals, here is how."
4
4
  ---
5
5
 
6
- # Create your own Eval
6
+ # Create a Custom Eval
7
7
 
8
- Creating your own eval is as easy as creating a new function. You simply create a class that extends the `Metric` class and implement the `measure` method.
8
+ Create a custom eval by extending the `Metric` class and implementing the `measure` method. This gives you full control over how scores are calculated and what information is returned. For LLM-based evaluations, extend the `MastraAgentJudge` class to define how the model reasons and scores output.
9
9
 
10
- ## Basic example
10
+ ## Native JavaScript evaluation
11
11
 
12
- For a simple example of creating a custom metric that checks if the output contains certain words, see our [Word Inclusion example](/examples/evals/word-inclusion).
12
+ You can write lightweight custom metrics using plain JavaScript/TypeScript. These are ideal for simple string comparisons, pattern checks, or other rule-based logic.
13
13
 
14
- ## Creating a custom LLM-Judge
14
+ See our [Word Inclusion example](/examples/evals/custom-native-javascript-eval.mdx), which scores responses based on the number of reference words found in the output.
15
15
 
16
- A custom LLM judge helps evaluate specific aspects of your AI's responses. Think of it like having an expert reviewer for your particular use case:
16
+ ## LLM as a judge evaluation
17
+
18
+ For more complex evaluations, you can build a judge powered by an LLM. This lets you capture more nuanced criteria, like factual accuracy, tone, or reasoning.
19
+
20
+ See the [Real World Countries example](/examples/evals/custom-llm-judge-eval.mdx) for a complete walkthrough of building a custom judge and metric that evaluates real-world factual accuracy.
17
21
 
18
- - Medical Q&A → Judge checks for medical accuracy and safety
19
- - Customer Service → Judge evaluates tone and helpfulness
20
- - Code Generation → Judge verifies code correctness and style
21
22
 
22
- For a practical example, see how we evaluate [Chef Michel's](/docs/guides/chef-michel) recipes for gluten content in our [Gluten Checker example](/examples/evals/custom-eval).
@@ -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.
@@ -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();