@mastra/mcp-docs-server 0.13.5 → 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 (135) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +84 -84
  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 +61 -61
  5. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +210 -210
  6. package/.docs/organized/changelogs/%40mastra%2Fcloud.md +8 -8
  7. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +99 -99
  8. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +98 -98
  9. package/.docs/organized/changelogs/%40mastra%2Fcore.md +189 -189
  10. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +8 -8
  11. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +241 -241
  12. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +170 -170
  13. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +170 -170
  14. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +236 -236
  15. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +109 -109
  16. package/.docs/organized/changelogs/%40mastra%2Fevals.md +80 -80
  17. package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +7 -0
  18. package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +90 -90
  19. package/.docs/organized/changelogs/%40mastra%2Fgithub.md +8 -8
  20. package/.docs/organized/changelogs/%40mastra%2Flance.md +62 -0
  21. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +83 -83
  22. package/.docs/organized/changelogs/%40mastra%2Floggers.md +8 -8
  23. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +50 -50
  24. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +8 -8
  25. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +32 -32
  26. package/.docs/organized/changelogs/%40mastra%2Fmem0.md +26 -26
  27. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +145 -145
  28. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +83 -83
  29. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +76 -0
  30. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +8 -8
  31. package/.docs/organized/changelogs/%40mastra%2Fpg.md +126 -126
  32. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +8 -8
  33. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +245 -245
  34. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +8 -8
  35. package/.docs/organized/changelogs/%40mastra%2Frag.md +87 -87
  36. package/.docs/organized/changelogs/%40mastra%2Fragie.md +8 -8
  37. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +18 -0
  38. package/.docs/organized/changelogs/%40mastra%2Fserver.md +208 -208
  39. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +8 -8
  40. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +101 -101
  41. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +8 -8
  42. package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +26 -26
  43. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +8 -8
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +8 -8
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +8 -8
  46. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +8 -8
  47. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +8 -8
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +71 -71
  49. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +26 -26
  50. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +8 -8
  51. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +8 -8
  52. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +8 -8
  53. package/.docs/organized/changelogs/create-mastra.md +127 -127
  54. package/.docs/organized/changelogs/mastra.md +250 -250
  55. package/.docs/organized/code-examples/a2a.md +1 -1
  56. package/.docs/organized/code-examples/agent.md +6 -0
  57. package/.docs/organized/code-examples/agui.md +5 -5
  58. package/.docs/organized/code-examples/ai-sdk-useChat.md +3 -3
  59. package/.docs/organized/code-examples/ai-sdk-v5.md +201 -0
  60. package/.docs/organized/code-examples/assistant-ui.md +3 -3
  61. package/.docs/organized/code-examples/bird-checker-with-express.md +1 -1
  62. package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +3 -3
  63. package/.docs/organized/code-examples/bird-checker-with-nextjs.md +3 -3
  64. package/.docs/organized/code-examples/client-side-tools.md +3 -3
  65. package/.docs/organized/code-examples/crypto-chatbot.md +6 -6
  66. package/.docs/organized/code-examples/fireworks-r1.md +1 -1
  67. package/.docs/organized/code-examples/memory-with-mem0.md +1 -1
  68. package/.docs/organized/code-examples/memory-with-pg.md +1 -0
  69. package/.docs/organized/code-examples/openapi-spec-writer.md +3 -3
  70. package/.docs/organized/code-examples/quick-start.md +1 -1
  71. package/.docs/organized/code-examples/workflow-ai-recruiter.md +1 -1
  72. package/.docs/organized/code-examples/workflow-with-inline-steps.md +1 -1
  73. package/.docs/organized/code-examples/workflow-with-memory.md +1 -1
  74. package/.docs/organized/code-examples/workflow-with-separate-steps.md +1 -1
  75. package/.docs/organized/code-examples/workflow-with-suspend-resume.md +181 -0
  76. package/.docs/raw/agents/agent-memory.mdx +126 -0
  77. package/.docs/raw/agents/dynamic-agents.mdx +34 -2
  78. package/.docs/raw/agents/overview.mdx +5 -0
  79. package/.docs/raw/agents/runtime-variables.mdx +1 -1
  80. package/.docs/raw/auth/index.mdx +24 -0
  81. package/.docs/raw/auth/jwt.mdx +99 -0
  82. package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +60 -26
  83. package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +6 -5
  84. package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +84 -14
  85. package/.docs/raw/deployment/cloud-providers/index.mdx +44 -9
  86. package/.docs/raw/deployment/serverless-platforms/cloudflare-deployer.mdx +9 -30
  87. package/.docs/raw/deployment/serverless-platforms/index.mdx +13 -13
  88. package/.docs/raw/evals/custom-eval.mdx +12 -12
  89. package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +291 -216
  90. package/.docs/raw/frameworks/agentic-uis/assistant-ui.mdx +0 -34
  91. package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +162 -181
  92. package/.docs/raw/frameworks/servers/express.mdx +1 -1
  93. package/.docs/raw/frameworks/web-frameworks/astro.mdx +2 -2
  94. package/.docs/raw/frameworks/web-frameworks/next-js.mdx +1 -1
  95. package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +4 -4
  96. package/.docs/raw/frameworks/web-frameworks/vite-react.mdx +1 -1
  97. package/.docs/raw/getting-started/installation.mdx +10 -7
  98. package/.docs/raw/getting-started/model-capability.mdx +1 -1
  99. package/.docs/raw/index.mdx +2 -2
  100. package/.docs/raw/memory/overview.mdx +8 -0
  101. package/.docs/raw/memory/semantic-recall.mdx +6 -0
  102. package/.docs/raw/observability/tracing.mdx +30 -0
  103. package/.docs/raw/reference/agents/agent.mdx +2 -2
  104. package/.docs/raw/reference/auth/jwt.mdx +42 -0
  105. package/.docs/raw/reference/cli/create-mastra.mdx +7 -0
  106. package/.docs/raw/reference/cli/dev.mdx +4 -3
  107. package/.docs/raw/reference/client-js/agents.mdx +10 -10
  108. package/.docs/raw/reference/client-js/error-handling.mdx +1 -21
  109. package/.docs/raw/reference/client-js/logs.mdx +2 -10
  110. package/.docs/raw/reference/client-js/mastra-client.mdx +141 -0
  111. package/.docs/raw/reference/client-js/memory.mdx +6 -18
  112. package/.docs/raw/reference/client-js/telemetry.mdx +1 -9
  113. package/.docs/raw/reference/client-js/tools.mdx +2 -10
  114. package/.docs/raw/reference/client-js/vectors.mdx +1 -9
  115. package/.docs/raw/reference/client-js/workflows-legacy.mdx +3 -11
  116. package/.docs/raw/reference/client-js/workflows.mdx +5 -13
  117. package/.docs/raw/reference/core/mastra-class.mdx +6 -0
  118. package/.docs/raw/reference/memory/query.mdx +35 -14
  119. package/.docs/raw/reference/observability/providers/dash0.mdx +2 -2
  120. package/.docs/raw/reference/observability/providers/keywordsai.mdx +73 -0
  121. package/.docs/raw/reference/storage/mssql.mdx +108 -0
  122. package/.docs/raw/reference/tools/vector-query-tool.mdx +29 -0
  123. package/.docs/raw/server-db/custom-api-routes.mdx +38 -26
  124. package/.docs/raw/tools-mcp/mcp-overview.mdx +24 -1
  125. package/.docs/raw/tools-mcp/overview.mdx +1 -1
  126. package/.docs/raw/workflows/control-flow.mdx +85 -87
  127. package/.docs/raw/workflows/input-data-mapping.mdx +31 -43
  128. package/.docs/raw/workflows/overview.mdx +22 -12
  129. package/.docs/raw/workflows/pausing-execution.mdx +49 -4
  130. package/.docs/raw/workflows/suspend-and-resume.mdx +17 -16
  131. package/.docs/raw/workflows/using-with-agents-and-tools.mdx +16 -13
  132. package/.docs/raw/workflows-legacy/overview.mdx +11 -0
  133. package/package.json +7 -9
  134. package/.docs/organized/changelogs/%40mastra%2Fagui.md +0 -302
  135. package/.docs/raw/frameworks/ai-sdk-v5.mdx +0 -91
@@ -37,6 +37,132 @@ const agent = new Agent({
37
37
 
38
38
  This basic setup uses the default settings. Visit the [Memory documentation](/docs/memory/overview) for more configuration info.
39
39
 
40
+ ## Dynamic Memory Configuration
41
+
42
+ Similar to how you can configure dynamic [instructions, models, and tools](./dynamic-agents.mdx), you can also configure memory dynamically using runtime context. This allows you to:
43
+
44
+ - Use different memory systems based on user tiers or preferences
45
+ - Switch between memory configurations for different environments
46
+ - Enable or disable memory features based on feature flags
47
+ - Customize memory behavior based on user context
48
+
49
+ ### Example: User Tier-Based Memory
50
+
51
+ ```typescript
52
+ import { Agent } from "@mastra/core/agent";
53
+ import { Memory } from "@mastra/memory";
54
+ import { LibSQLStore } from "@mastra/libsql";
55
+ import { PostgresStore } from "@mastra/pg";
56
+ import { openai } from "@ai-sdk/openai";
57
+
58
+ // Create different memory instances for different user tiers
59
+ const premiumMemory = new Memory({
60
+ storage: new LibSQLStore({ url: "file:premium.db" }),
61
+ options: {
62
+ semanticRecall: { topK: 10, messageRange: 5 }, // More context for premium users
63
+ workingMemory: { enabled: true },
64
+ },
65
+ });
66
+
67
+ const standardMemory = new Memory({
68
+ storage: new LibSQLStore({ url: "file:standard.db" }),
69
+ options: {
70
+ semanticRecall: { topK: 3, messageRange: 2 }, // Basic recall for standard users
71
+ workingMemory: { enabled: false },
72
+ },
73
+ });
74
+
75
+ const agent = new Agent({
76
+ name: "TieredMemoryAgent",
77
+ instructions: "You are a helpful assistant with tiered memory capabilities.",
78
+ model: openai("gpt-4o"),
79
+ memory: ({ runtimeContext }) => {
80
+ const userTier = runtimeContext.get("userTier");
81
+ return userTier === "premium" ? premiumMemory : standardMemory;
82
+ },
83
+ });
84
+ ```
85
+
86
+ ### Example: Environment-Based Memory
87
+
88
+ ```typescript
89
+ const agent = new Agent({
90
+ name: "EnvironmentAwareAgent",
91
+ instructions: "You are a helpful assistant.",
92
+ model: openai("gpt-4o"),
93
+ memory: ({ runtimeContext }) => {
94
+ const environment = runtimeContext.get("environment");
95
+
96
+ if (environment === "test") {
97
+ // Use local storage for testing
98
+ return new Memory({
99
+ storage: new LibSQLStore({ url: ":memory:" }),
100
+ options: {
101
+ workingMemory: { enabled: true },
102
+ },
103
+ });
104
+ } else if (environment === "production") {
105
+ // Use production database
106
+ return new Memory({
107
+ storage: new PostgresStore({ connectionString: process.env.PRODUCTION_DB_URL }),
108
+ options: {
109
+ workingMemory: { enabled: true },
110
+ },
111
+ });
112
+ }
113
+
114
+ // Development environment
115
+ return new Memory({
116
+ storage: new LibSQLStore({ url: "file:dev.db" }),
117
+ });
118
+ },
119
+ });
120
+ ```
121
+
122
+ ### Example: Async Memory Configuration
123
+
124
+ ```typescript
125
+ const agent = new Agent({
126
+ name: "AsyncMemoryAgent",
127
+ instructions: "You are a helpful assistant.",
128
+ model: openai("gpt-4o"),
129
+ memory: async ({ runtimeContext }) => {
130
+ const userId = runtimeContext.get("userId");
131
+
132
+ // Simulate async memory setup (e.g., database lookup)
133
+ await new Promise(resolve => setTimeout(resolve, 10));
134
+
135
+ return new Memory({
136
+ storage: new LibSQLStore({
137
+ url: `file:user_${userId}.db`
138
+ }),
139
+ });
140
+ },
141
+ });
142
+ ```
143
+
144
+ ### Using Dynamic Memory
145
+
146
+ When using dynamic memory, pass the runtime context to your agent calls:
147
+
148
+ ```typescript
149
+ import { RuntimeContext } from "@mastra/core/runtime-context";
150
+
151
+ // Create runtime context with user information
152
+ const runtimeContext = new RuntimeContext();
153
+ runtimeContext.set("userTier", "premium");
154
+ runtimeContext.set("environment", "production");
155
+
156
+ // Use the agent with runtime context
157
+ const response = await agent.generate("Remember my favorite color is blue.", {
158
+ memory: {
159
+ resource: "user_alice",
160
+ thread: { id: "preferences_thread" },
161
+ },
162
+ runtimeContext, // Pass the runtime context
163
+ });
164
+ ```
165
+
40
166
  ## Using Memory in Agent Calls
41
167
 
42
168
  To utilize memory during interactions, you **must** provide `resourceId` and `threadId` when calling the agent's `stream()` or `generate()` methods.
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  title: "Dynamic Agents"
3
- description: Dynamically configure your agent's instruction, model and tools using runtime context.
3
+ description: Dynamically configure your agent's instruction, model, tools, and memory using runtime context.
4
4
  ---
5
5
 
6
6
  # Dynamic Agents
7
7
 
8
8
  Dynamic agents use [runtime context](./runtime-variables), like user IDs and other important parameters, to adjust their settings in real-time.
9
9
 
10
- This means they can change the model they use, update their instructions, and select different tools as needed.
10
+ This means they can change the model they use, update their instructions, select different tools, and configure memory as needed.
11
11
 
12
12
  By using this context, agents can better respond to each user's needs. They can also call any API to gather more information, which helps improve what the agents can do.
13
13
 
@@ -55,6 +55,37 @@ const supportAgent = new Agent({
55
55
 
56
56
  return baseTools;
57
57
  },
58
+
59
+ memory: ({ runtimeContext }) => {
60
+ const userTier = runtimeContext.get("user-tier");
61
+
62
+ if (userTier === "enterprise") {
63
+ return new Memory({
64
+ storage: new LibSQLStore({ url: "file:enterprise.db" }),
65
+ options: {
66
+ semanticRecall: { topK: 15, messageRange: 8 },
67
+ workingMemory: { enabled: true },
68
+ },
69
+ });
70
+ } else if (userTier === "pro") {
71
+ return new Memory({
72
+ storage: new LibSQLStore({ url: "file:pro.db" }),
73
+ options: {
74
+ semanticRecall: { topK: 8, messageRange: 4 },
75
+ workingMemory: { enabled: true },
76
+ },
77
+ });
78
+ }
79
+
80
+ // Basic memory for free tier
81
+ return new Memory({
82
+ storage: new LibSQLStore({ url: "file:free.db" }),
83
+ options: {
84
+ semanticRecall: { topK: 3, messageRange: 2 },
85
+ workingMemory: { enabled: false },
86
+ },
87
+ });
88
+ },
58
89
  });
59
90
  ```
60
91
 
@@ -63,6 +94,7 @@ In this example, the agent:
63
94
  - Adjusts its instructions based on the user's subscription tier (free, pro, or enterprise)
64
95
  - Uses a more powerful model (GPT-4) for enterprise users
65
96
  - Provides different sets of tools based on the user's tier
97
+ - Configures memory with different capabilities based on the user's tier
66
98
  - Responds in the user's preferred language
67
99
 
68
100
  This demonstrates how a single agent can handle different types of users and scenarios by leveraging runtime context, making it more flexible and maintainable than creating separate agents for each use case.
@@ -9,6 +9,8 @@ description: Overview of agents in Mastra, detailing their capabilities and how
9
9
 
10
10
  Agents can run autonomously in a loop, run once, or take turns with a user. You can give short-term, long-term, and working memory of their user interactions. They can stream text or return structured output (ie, JSON). They can access third-party APIs, query knowledge bases, and so on.
11
11
 
12
+ Additionally, agents support dynamic configuration, allowing you to change their instructions, model, tools, and memory based on runtime context like user preferences, subscription tiers, or environment settings.
13
+
12
14
  ## 1. Creating an Agent
13
15
 
14
16
  To create an agent in Mastra, you use the `Agent` class and define its properties:
@@ -36,6 +38,8 @@ Also, make sure you have the `@mastra/core` package installed:
36
38
  npm install @mastra/core@latest
37
39
  ```
38
40
 
41
+ All agent properties (instructions, model, tools, memory) can be configured dynamically using runtime context. See the [Dynamic Agents guide](./dynamic-agents.mdx) for examples of how to adapt agent behavior based on user context, subscription tiers, or other runtime variables.
42
+
39
43
  ### Registering the Agent
40
44
 
41
45
  Register your agent with Mastra to enable logging and access to configured tools and integrations:
@@ -282,5 +286,6 @@ For more details, see the [Local Dev Playground](/docs/server-db/local-dev-playg
282
286
  ## Next Steps
283
287
 
284
288
  - Learn about Agent Memory in the [Agent Memory](./agent-memory.mdx) guide.
289
+ - Learn about Dynamic Agent configuration in the [Dynamic Agents](./dynamic-agents.mdx) guide.
285
290
  - Learn about Agent Tools in the [Agent Tools and MCP](./using-tools-and-mcp.mdx) guide.
286
291
  - See an example agent in the [Chef Michel](../../guides/guide/chef-michel.mdx) example.
@@ -23,7 +23,7 @@ const agent = mastra.getAgent("weatherAgent");
23
23
 
24
24
  // Define your runtimeContext's type structure
25
25
  type WeatherRuntimeContext = {
26
- "temperature-scale": "celsius" | "fahrenheit"; // Fixed typo in "fahrenheit"
26
+ "temperature-scale": "celsius" | "fahrenheit";
27
27
  };
28
28
 
29
29
  const runtimeContext = new RuntimeContext<WeatherRuntimeContext>();
@@ -0,0 +1,24 @@
1
+ ---
2
+ title: Auth Overview
3
+ description: Learn about different Auth options for your Mastra applications
4
+ ---
5
+
6
+ # Auth Overview
7
+
8
+ Mastra lets you choose how you handle authentication, so you can secure access to your application's endpoints using the identity system that fits your stack.
9
+
10
+ You can start with simple shared secret JWT authentication and switch to providers like Supabase, Firebase Auth, Auth0, Clerk, or WorkOS when you need more advanced identity features.
11
+
12
+ ## Available providers
13
+
14
+ - [JSON Web Token (JWT)](/docs/auth/jwt)
15
+
16
+ ### Coming soon
17
+
18
+ The following providers will be available soon:
19
+
20
+ - Supabase Auth
21
+ - Firebase Auth
22
+ - Auth0
23
+ - Clerk
24
+ - WorkOS
@@ -0,0 +1,99 @@
1
+ ---
2
+ title: "MastraJwtAuth"
3
+ description: "Documentation for the MastraJwtAuth class, which authenticates Mastra applications using JSON Web Tokens."
4
+ ---
5
+
6
+ import { Tabs, Tab } from "@/components/tabs";
7
+
8
+ # MastraJwtAuth
9
+
10
+ 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.
11
+
12
+ ## Installation
13
+
14
+ ```bash copy
15
+ npm install @mastra/auth
16
+ ```
17
+
18
+ ## Usage example
19
+
20
+ ```typescript {2,7-9} filename="src/mastra/index.ts" showLineNumbers copy
21
+ import { Mastra } from "@mastra/core/mastra";
22
+ import { MastraJwtAuth } from '@mastra/auth';
23
+
24
+ export const mastra = new Mastra({
25
+ // ..
26
+ server: {
27
+ experimental_auth: new MastraJwtAuth({
28
+ secret: process.env.MASTRA_JWT_SECRET
29
+ }),
30
+ },
31
+ });
32
+ ```
33
+
34
+ > See the [MastraJwtAuth](/reference/auth/jwt.mdx) API reference for all available configuration options.
35
+
36
+ ## Configuring `MastraClient`
37
+
38
+ When `experimental_auth` is enabled, all requests made with `MastraClient` must include a valid JWT in the `Authorization` header:
39
+
40
+ ```typescript {6} filename="lib/mastra/mastra-client.ts" showLineNumbers copy
41
+ import { MastraClient } from "@mastra/client-js";
42
+
43
+ export const mastraClient = new MastraClient({
44
+ baseUrl: "https://<mastra-api-url>",
45
+ headers: {
46
+ Authorization: `Bearer ${process.env.MASTRA_JWT_TOKEN}`
47
+ }
48
+ });
49
+ ```
50
+
51
+ > See [Mastra Client SDK](/docs/server-db/mastra-client.mdx) for more configuration options.
52
+
53
+ ### Making authenticated requests
54
+
55
+ Once `MastraClient` is configured, you can send authenticated requests from your frontend application, or use `curl` for quick local testing:
56
+
57
+ <Tabs items={["MastraClient", "curl"]}>
58
+ <Tab>
59
+ ```tsx filename="src/components/test-agent.tsx" showLineNumbers copy
60
+ import { mastraClient } from "../../lib/mastra-client";
61
+
62
+ export const TestAgent = () => {
63
+ async function handleClick() {
64
+ const agent = mastraClient.getAgent("weatherAgent");
65
+
66
+ const response = await agent.generate({
67
+ messages: "Weather in London"
68
+ });
69
+
70
+ console.log(response);
71
+ }
72
+
73
+ return <button onClick={handleClick}>Test Agent</button>;
74
+ };
75
+ ```
76
+ </Tab>
77
+ <Tab>
78
+ ```bash copy
79
+ curl -X POST http://localhost:4111/api/agents/weatherAgent/generate \
80
+ -H "Content-Type: application/json" \
81
+ -H "Authorization: Bearer <your-jwt>" \
82
+ -d '{
83
+ "messages": "Weather in London"
84
+ }'
85
+ ```
86
+ </Tab>
87
+ </Tabs>
88
+
89
+ ## Creating a JWT
90
+
91
+ To authenticate requests to your Mastra server, you'll need a valid JSON Web Token (JWT) signed with your `MASTRA_JWT_SECRET`.
92
+
93
+ The easiest way to generate one is using [jwt.io](https://www.jwt.io/):
94
+
95
+ 1. Select **JWT Encoder**.
96
+ 2. Scroll down to the **Sign JWT: Secret** section.
97
+ 3. Enter your secret (for example: `supersecretdevkeythatishs256safe!`).
98
+ 4. Click **Generate example** to create a valid JWT.
99
+ 5. Copy the generated token and set it as `MASTRA_JWT_TOKEN` in your `.env` file.
@@ -3,8 +3,7 @@ title: "Amazon EC2"
3
3
  description: "Deploy your Mastra applications to Amazon EC2."
4
4
  ---
5
5
 
6
- import { Callout, Steps } from "nextra/components";
7
- import ServerConfig from "@/components/content-blocks/server-config.mdx";
6
+ import { Callout, Steps, Tabs } from "nextra/components";
8
7
 
9
8
  ## Amazon EC2
10
9
 
@@ -17,50 +16,85 @@ Deploy your Mastra applications to Amazon EC2 (Elastic Cloud Compute).
17
16
  refer to our [getting started guide](/docs/getting-started/installation)
18
17
  </Callout>
19
18
 
20
- ### Setting up EC2
19
+ ### Prerequisites
20
+
21
+ - An AWS account with [EC2](https://aws.amazon.com/ec2/) access
22
+ - An EC2 instance running Ubuntu 24+ or Amazon Linux
23
+ - A domain name with an A record pointing to your instance
24
+ - A reverse proxy configured (e.g., using [nginx](https://nginx.org/))
25
+ - SSL certificate configured (e.g., using [Let's Encrypt](https://letsencrypt.org/))
26
+ - Node.js 18+ installed on your instance
27
+
28
+ ### Deployment Steps
21
29
 
22
30
  <Steps>
23
31
 
24
- #### Log into your AWS console
32
+ #### Clone your Mastra application
25
33
 
26
- Navigate to the [AWS Management Console](https://aws.amazon.com/console/) and sign in to your account.
34
+ Connect to your EC2 instance and clone your repository:
27
35
 
28
- #### Navigate to EC2
36
+ <Tabs items={["Public Repository", "Private Repository"]}>
37
+ <Tabs.Tab>
29
38
 
30
- Head over to **All services** in the left side navigation. Under **Compute**, click on **EC2**.
39
+ ```bash copy
40
+ git clone https://github.com/<your-username>/<your-repository>.git
41
+ ```
31
42
 
32
- #### Launch a virtual server instance
43
+ </Tabs.Tab>
33
44
 
34
- Click on **Launch instance** to create a new EC2 instance.
45
+ <Tabs.Tab>
46
+
47
+ ```bash copy
48
+ git clone https://<your-username>:<your-personal-access-token>@github.com/<your-username>/<your-repository>.git
49
+ ```
35
50
 
36
- #### Configure your instance details
51
+ </Tabs.Tab>
52
+ </Tabs>
37
53
 
38
- Add the following details for your instance:
54
+ Navigate to the repository directory:
39
55
 
40
- - **Name**: Give your instance a descriptive name
41
- - **Application and OS Images**: For this example, we'll use the **Amazon Linux** environment
42
- - **Instance type**: Select **t3.micro** (eligible for free tier)
43
- - **Key pair**: Select an existing key pair or create a new one for secure login
44
- - **Network settings**: Ensure to **allow HTTPS and HTTP traffic from the internet** by checking the appropriate boxes
56
+ ```bash copy
57
+ cd "<your-repository>"
58
+ ```
45
59
 
46
- #### Launch your instance
60
+ #### Install dependencies
47
61
 
48
- Review your configuration and click **Launch instance**.
62
+ ```bash copy
63
+ npm install
64
+ ```
49
65
 
50
- #### Connect to your instance
66
+ #### Set up environment variables
51
67
 
52
- You'll be redirected to a next steps page. You can connect to your instance either:
68
+ Create a `.env` file and add your environment variables:
53
69
 
54
- - **Through the browser**: Click the **Connect** button for browser-based access
55
- - **Via SSH**: Use your key pair to SSH into the instance (instructions available when you click **Connect**)
70
+ ```bash copy
71
+ touch .env
72
+ ```
56
73
 
57
- </Steps>
74
+ Edit the `.env` file and add your environment variables:
58
75
 
59
- ### Server Configuration
76
+ ```bash copy
77
+ OPENAI_API_KEY=<your-openai-api-key>
78
+ # Add other required environment variables
79
+ ```
60
80
 
61
- Once you have access to your EC2 instance (either via SSH or browser), follow these steps to set up your server environment:
81
+ #### Build the application
62
82
 
63
- <ServerConfig />
83
+ ```bash copy
84
+ npm run build
85
+ ```
86
+
87
+ #### Run the application
88
+
89
+ ```bash copy
90
+ node --import=./.mastra/output/instrumentation.mjs --env-file=".env" .mastra/output/index.mjs
91
+ ```
92
+
93
+ <Callout>
94
+ Your Mastra application will run on port 4111 by default. Ensure your reverse proxy is configured to forward requests to this port.
95
+ </Callout>
96
+
97
+ </Steps>
64
98
 
65
99
  ### Connect to your Mastra server
66
100
 
@@ -18,8 +18,8 @@ Deploy your Mastra applications to Azure App Services.
18
18
 
19
19
  ### Prerequisites
20
20
 
21
- - An Azure account with an active subscription
22
- - A GitHub repository containing your Mastra application
21
+ - An [Azure account](https://azure.microsoft.com/) with an active subscription
22
+ - A [GitHub repository](https://github.com/) containing your Mastra application
23
23
  - Your Mastra application should be created using `npx create-mastra@latest`
24
24
 
25
25
  ### Deployment Steps
@@ -29,7 +29,7 @@ Deploy your Mastra applications to Azure App Services.
29
29
  #### Create a new App Service
30
30
 
31
31
  - Log in to the [Azure Portal](https://portal.azure.com)
32
- - Navigate to **App Services** or search for it in the top search bar
32
+ - Navigate to **[App Services](https://docs.microsoft.com/en-us/azure/app-service/)** or search for it in the top search bar
33
33
  - Click **Create** to create a new App Service
34
34
  - In the drop-down, select **Web App**
35
35
 
@@ -67,7 +67,7 @@ Before setting up deployment, configure your environment variables:
67
67
  - Navigate to **Deployment Center** in the left sidebar
68
68
  - Select **GitHub** as your source
69
69
  - Sign in to GitHub if you're not already authenticated with Azure
70
- - In this example, we will keep GitHub Actions as our provider.
70
+ - In this example, we will keep [GitHub Actions](https://docs.github.com/en/actions) as our provider
71
71
  - Select your organization, repository, and branch
72
72
  - Azure will generate a GitHub workflow file and you can preview it before proceeding
73
73
  - Click **Save** (the save button is located at the top of the page)
@@ -84,7 +84,7 @@ Pull the latest changes to your local repository and modify the generated workfl
84
84
 
85
85
  1. **Update the build step**: Find the step named "npm install, build, and test" and:
86
86
  - Change the step name to "npm install and build"
87
- - Remove the `npm test` command from the run section
87
+ - If you haven't set up proper tests in your Mastra application, remove the `npm test` command from the run section as the default test script will fail and disrupt deployment. If you have working tests, you can keep the test command.
88
88
 
89
89
  2. **Update the zip artifact step**: Find the "Zip artifact for deployment" step and replace the zip command with:
90
90
 
@@ -133,4 +133,5 @@ such as `LibSQLStore` with a file URL. Consider using cloud-based storage soluti
133
133
  - [Mastra Client SDK](/docs/client-js/overview)
134
134
  - [Configure custom domains](https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-custom-domain)
135
135
  - [Enable HTTPS](https://docs.microsoft.com/en-us/azure/app-service/configure-ssl-bindings)
136
+ - [Azure App Service documentation](https://docs.microsoft.com/en-us/azure/app-service/)
136
137
 
@@ -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/)