@mastra/mcp-docs-server 1.2.8-alpha.9 → 1.2.9-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.
- package/.docs/docs/agent-builder/integrations.md +1 -3
- package/.docs/docs/agent-builder/overview.md +2 -0
- package/.docs/docs/agents/overview.md +17 -13
- package/.docs/docs/agents/skills.md +1 -3
- package/.docs/docs/agents/structured-output.md +2 -0
- package/.docs/docs/agents/using-tools.md +66 -49
- package/.docs/docs/browser/agent-browser.md +1 -0
- package/.docs/docs/browser/firecrawl.md +129 -0
- package/.docs/docs/browser/overview.md +16 -2
- package/.docs/docs/capabilities/channels/slack.md +111 -1
- package/.docs/docs/deployment/mastra-server.md +35 -0
- package/.docs/docs/deployment/monorepo.md +2 -0
- package/.docs/docs/deployment/overview.md +6 -0
- package/.docs/docs/deployment/sandbox.md +277 -0
- package/.docs/docs/editor/overview.md +2 -6
- package/.docs/docs/editor/tools.md +2 -6
- package/.docs/docs/evals/running-in-ci.md +3 -9
- package/.docs/docs/getting-started/build-with-ai.md +2 -6
- package/.docs/docs/getting-started/manual-install.md +1 -1
- package/.docs/docs/index.md +17 -13
- package/.docs/docs/long-running-agents/background-tasks.md +2 -2
- package/.docs/docs/long-running-agents/goals.md +3 -1
- package/.docs/docs/mastra-platform/database.md +12 -6
- package/.docs/docs/mastra-platform/deploy.md +14 -7
- package/.docs/docs/mastra-platform/environments.md +5 -4
- package/.docs/docs/mastra-platform/observability.md +4 -12
- package/.docs/docs/mastra-platform/overview.md +1 -1
- package/.docs/docs/mastra-platform/regions.md +73 -0
- package/.docs/docs/mastra-platform/workspace.md +111 -0
- package/.docs/docs/memory/observational-memory.md +77 -2
- package/.docs/docs/memory/overview.md +4 -0
- package/.docs/docs/observability/feedback.md +4 -0
- package/.docs/docs/observability/integrations/bridges/otel.md +1 -3
- package/.docs/docs/observability/integrations/exporters/otel.md +1 -3
- package/.docs/docs/server/auth/fga.md +40 -0
- package/.docs/docs/server/auth/simple-auth.md +1 -3
- package/.docs/docs/studio/overview.md +2 -0
- package/.docs/docs/workflows/control-flow.md +1 -3
- package/.docs/docs/workspace/filesystem.md +1 -0
- package/.docs/docs/workspace/sandbox.md +1 -0
- package/.docs/guides/getting-started/quickstart.md +40 -25
- package/.docs/guides/index.md +1 -1
- package/.docs/guides/migrations/vnext-to-standard-apis.md +1 -3
- package/.docs/models/environment-variables.md +2 -0
- package/.docs/models/gateways/netlify.md +3 -6
- package/.docs/models/gateways/openrouter.md +343 -346
- package/.docs/models/gateways/vercel.md +6 -5
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/aki-io.md +78 -0
- package/.docs/models/providers/alibaba-token-plan-cn.md +22 -21
- package/.docs/models/providers/alibaba-token-plan.md +22 -21
- package/.docs/models/providers/ambient.md +12 -10
- package/.docs/models/providers/baseten.md +2 -1
- package/.docs/models/providers/cline-pass.md +82 -0
- package/.docs/models/providers/cortecs.md +2 -1
- package/.docs/models/providers/crossmodel.md +2 -1
- package/.docs/models/providers/deepinfra.md +4 -7
- package/.docs/models/providers/deepseek.md +3 -1
- package/.docs/models/providers/empiriolabs.md +2 -1
- package/.docs/models/providers/google.md +4 -2
- package/.docs/models/providers/huggingface.md +2 -1
- package/.docs/models/providers/inferx.md +3 -3
- package/.docs/models/providers/kenari.md +44 -29
- package/.docs/models/providers/kimi-for-coding.md +6 -9
- package/.docs/models/providers/llmgateway.md +4 -1
- package/.docs/models/providers/moonshotai-cn.md +1 -1
- package/.docs/models/providers/moonshotai.md +1 -1
- package/.docs/models/providers/nebius.md +3 -1
- package/.docs/models/providers/novita-ai.md +3 -1
- package/.docs/models/providers/opencode-go.md +4 -3
- package/.docs/models/providers/opencode.md +4 -2
- package/.docs/models/providers/poolside.md +2 -2
- package/.docs/models/providers/togetherai.md +2 -6
- package/.docs/models/providers/wandb.md +2 -1
- package/.docs/models/providers/zenmux.md +3 -1
- package/.docs/models/providers.md +2 -0
- package/.docs/reference/agent-controller/session.md +13 -0
- package/.docs/reference/agents/agent.md +13 -1
- package/.docs/reference/agents/generate.md +18 -0
- package/.docs/reference/browser/firecrawl-browser.md +71 -0
- package/.docs/reference/cli/create-mastra.md +118 -43
- package/.docs/reference/cli/mastra.md +59 -5
- package/.docs/reference/code-sdk/mount-agent-controller.md +4 -4
- package/.docs/reference/core/getMCPServer.md +1 -3
- package/.docs/reference/core/getMCPServerById.md +1 -3
- package/.docs/reference/core/getWorkflow.md +1 -3
- package/.docs/reference/core/listMCPServers.md +2 -6
- package/.docs/reference/datasets/addItem.md +1 -3
- package/.docs/reference/datasets/addItems.md +1 -3
- package/.docs/reference/datasets/compareExperiments.md +1 -3
- package/.docs/reference/datasets/create.md +1 -3
- package/.docs/reference/datasets/dataset.md +2 -6
- package/.docs/reference/datasets/datasets-manager.md +5 -15
- package/.docs/reference/datasets/delete.md +1 -3
- package/.docs/reference/datasets/deleteExperiment.md +1 -3
- package/.docs/reference/datasets/deleteItem.md +1 -3
- package/.docs/reference/datasets/deleteItems.md +1 -3
- package/.docs/reference/datasets/get.md +1 -3
- package/.docs/reference/datasets/getDetails.md +1 -3
- package/.docs/reference/datasets/getExperiment.md +1 -3
- package/.docs/reference/datasets/getItem.md +1 -3
- package/.docs/reference/datasets/getItemHistory.md +1 -3
- package/.docs/reference/datasets/list.md +1 -3
- package/.docs/reference/datasets/listExperimentResults.md +1 -3
- package/.docs/reference/datasets/listExperiments.md +1 -3
- package/.docs/reference/datasets/listItems.md +1 -3
- package/.docs/reference/datasets/listVersions.md +1 -3
- package/.docs/reference/datasets/startExperiment.md +1 -3
- package/.docs/reference/datasets/startExperimentAsync.md +1 -3
- package/.docs/reference/datasets/update.md +1 -3
- package/.docs/reference/datasets/updateItem.md +1 -3
- package/.docs/reference/editor/mastra-editor.md +1 -3
- package/.docs/reference/evals/context-recall.md +205 -0
- package/.docs/reference/evals/create-scorer.md +3 -9
- package/.docs/reference/evals/mastra-scorer.md +1 -3
- package/.docs/reference/file-based-agents/tools.md +7 -6
- package/.docs/reference/index.md +5 -0
- package/.docs/reference/memory/observational-memory.md +21 -0
- package/.docs/reference/observability/tracing/exporters/posthog.md +39 -1
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +1 -3
- package/.docs/reference/processors/token-limiter-processor.md +1 -3
- package/.docs/reference/rag/database-config.md +12 -0
- package/.docs/reference/streaming/agents/stream.md +2 -0
- package/.docs/reference/templates/overview.md +6 -32
- package/.docs/reference/tools/create-tool.md +78 -52
- package/.docs/reference/tools/mcp-client.md +8 -24
- package/.docs/reference/tools/mcp-server.md +143 -44
- package/.docs/reference/tools/tavily.md +1 -1
- package/.docs/reference/tools/vector-query-tool.md +22 -0
- package/.docs/reference/vectors/mongodb.md +2 -0
- package/.docs/reference/vectors/turbopuffer.md +4 -0
- package/.docs/reference/voice/mistral.md +127 -0
- package/.docs/reference/workspace/daytona-sandbox.md +2 -6
- package/.docs/reference/workspace/platform-filesystem.md +182 -0
- package/.docs/reference/workspace/platform-sandbox.md +200 -0
- package/.docs/reference/workspace/railway-sandbox.md +37 -1
- package/CHANGELOG.md +71 -0
- package/dist/{chunk-GLPCVXXO.js → chunk-HGADBLKG.js} +2 -2
- package/dist/{chunk-GLPCVXXO.js.map → chunk-HGADBLKG.js.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/stdio.js +1 -1
- package/dist/tools/docs.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -97,6 +97,8 @@ export const mastra = new Mastra({
|
|
|
97
97
|
})
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
+
Keep `bundler` as a direct property in the object passed to `new Mastra()`. See [build-time configuration](https://mastra.ai/docs/deployment/mastra-server) for the supported entry-file shape.
|
|
101
|
+
|
|
100
102
|
## Environment variables
|
|
101
103
|
|
|
102
104
|
Store `.env` files in the Mastra application directory (e.g., `apps/api/.env`), not the monorepo root.
|
|
@@ -51,6 +51,12 @@ Use this option for auto-scaling, minimal infrastructure management, or when you
|
|
|
51
51
|
- [Netlify](https://mastra.ai/guides/deployment/netlify)
|
|
52
52
|
- [Vercel](https://mastra.ai/guides/deployment/vercel)
|
|
53
53
|
|
|
54
|
+
### Sandbox
|
|
55
|
+
|
|
56
|
+
Deploy a Mastra server into an ephemeral workspace sandbox (such as Vercel Sandbox or E2B) and get a live public URL in seconds.
|
|
57
|
+
|
|
58
|
+
Use this option for instant previews, deploys from your CI pipeline, verifying agent-built apps, or running untrusted per-user instances. Read the [sandbox deployment guide](https://mastra.ai/docs/deployment/sandbox).
|
|
59
|
+
|
|
54
60
|
### Web Framework
|
|
55
61
|
|
|
56
62
|
When Mastra is integrated with a web framework, it deploys alongside your application using the framework's standard deployment process. The guides below cover framework-specific configuration requirements for deployment.
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Deploy to a sandbox
|
|
4
|
+
|
|
5
|
+
`@mastra/deployer-sandbox` deploys a full Mastra server, including Studio, into an ephemeral workspace sandbox and returns a live public URL. Repeat deployments can finish faster because the deployer skips dependency installation.
|
|
6
|
+
|
|
7
|
+
Use sandbox deployments for:
|
|
8
|
+
|
|
9
|
+
- Agent-built apps: An agent generates a Mastra project and deploys it to verify the result.
|
|
10
|
+
- Continuous integration (CI): Spin up a real server for checks, then tear it down.
|
|
11
|
+
- Instant previews: Share a working agent with your team before merging.
|
|
12
|
+
- Multi-tenant untrusted code: Run per-user Mastra instances isolated from your infrastructure.
|
|
13
|
+
|
|
14
|
+
Sandboxes have provider-enforced runtime caps and expire. For production hosting, see the [deployment overview](https://mastra.ai/docs/deployment/overview).
|
|
15
|
+
|
|
16
|
+
## Supported sandboxes
|
|
17
|
+
|
|
18
|
+
The deployer works with any workspace sandbox that supports networking (public port URLs):
|
|
19
|
+
|
|
20
|
+
- [Vercel Sandbox](https://mastra.ai/reference/workspace/vercel-sandbox) (`@mastra/vercel`)
|
|
21
|
+
- [E2B](https://mastra.ai/reference/workspace/e2b-sandbox) (`@mastra/e2b`)
|
|
22
|
+
- [Daytona](https://mastra.ai/reference/workspace/daytona-sandbox) (`@mastra/daytona`)
|
|
23
|
+
|
|
24
|
+
Provider authors can add support by implementing the optional `networking` capability on [`WorkspaceSandbox`](https://mastra.ai/reference/workspace/sandbox).
|
|
25
|
+
|
|
26
|
+
## Quickstart
|
|
27
|
+
|
|
28
|
+
Install the deployer and a sandbox provider of your choice. This example uses Vercel Sandbox:
|
|
29
|
+
|
|
30
|
+
**npm**:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install @mastra/deployer-sandbox @mastra/vercel
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**pnpm**:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pnpm add @mastra/deployer-sandbox @mastra/vercel
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Yarn**:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
yarn add @mastra/deployer-sandbox @mastra/vercel
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Bun**:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
bun add @mastra/deployer-sandbox @mastra/vercel
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Configure the deployer in your `src/mastra/index.ts` file. The `sandboxName` identifies the deployment, so subsequent deployments with the same name reuse the existing sandbox.
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { Mastra } from '@mastra/core/mastra'
|
|
58
|
+
import { SandboxDeployer } from '@mastra/deployer-sandbox'
|
|
59
|
+
import { VercelSandbox } from '@mastra/vercel'
|
|
60
|
+
|
|
61
|
+
export const mastra = new Mastra({
|
|
62
|
+
deployer: new SandboxDeployer({
|
|
63
|
+
sandbox: new VercelSandbox({
|
|
64
|
+
sandboxName: 'my-preview',
|
|
65
|
+
timeout: 3_600_000, // 1 hour
|
|
66
|
+
ports: [4111],
|
|
67
|
+
}),
|
|
68
|
+
}),
|
|
69
|
+
})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Build and deploy in one command:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
mastra build
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
When a `SandboxDeployer()` is configured, `mastra build` bundles your project and deploys it into the sandbox. The deploy prints the API and Studio URLs and writes a `sandbox-deployment.json` manifest into `.mastra/output`:
|
|
79
|
+
|
|
80
|
+
```text
|
|
81
|
+
API: https://<sandbox-id>-4111.vercel.run/api
|
|
82
|
+
Studio: https://<sandbox-id>-4111.vercel.run
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The manifest includes `expiresAt` when the sandbox provider reports an expiration time. Redeploys to the same sandbox skip the dependency install when the install inputs (`package.json`, bundled lockfiles, and the install command) are unchanged.
|
|
86
|
+
|
|
87
|
+
### Using E2B
|
|
88
|
+
|
|
89
|
+
For E2B, the `id` identifies the deployment, so subsequent deployments with the same value reconnect to the existing sandbox, whether it's running or paused.
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { SandboxDeployer } from '@mastra/deployer-sandbox'
|
|
93
|
+
import { E2BSandbox } from '@mastra/e2b'
|
|
94
|
+
|
|
95
|
+
const deployer = new SandboxDeployer({
|
|
96
|
+
sandbox: new E2BSandbox({
|
|
97
|
+
id: 'my-preview',
|
|
98
|
+
template: 'base',
|
|
99
|
+
timeout: 3_600_000, // 1 hour
|
|
100
|
+
}),
|
|
101
|
+
})
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Pass `template: 'base'` unless you need filesystem mounts; without it, the provider builds a custom Filesystem in Userspace (FUSE) template on first use. E2B pauses instead of stopping: `stop()` snapshots the whole virtual machine (VM), including memory and running processes. When a paused sandbox wakes, the Mastra server resumes where it left off, and there's no relaunch step like on Vercel.
|
|
105
|
+
|
|
106
|
+
### Using Daytona
|
|
107
|
+
|
|
108
|
+
For Daytona, the `id` identifies the deployment, so subsequent deployments with the same value reconnect to the existing sandbox. Set `public: true` to make the preview URL accessible without a token.
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import { SandboxDeployer } from '@mastra/deployer-sandbox'
|
|
112
|
+
import { DaytonaSandbox } from '@mastra/daytona'
|
|
113
|
+
|
|
114
|
+
const deployer = new SandboxDeployer({
|
|
115
|
+
sandbox: new DaytonaSandbox({
|
|
116
|
+
id: 'my-preview',
|
|
117
|
+
public: true,
|
|
118
|
+
autoStopInterval: 30, // minutes
|
|
119
|
+
}),
|
|
120
|
+
})
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Stopping a Daytona sandbox persists its filesystem but not running processes, so waking works like Vercel: the resolver relaunches the server on `wake: true`.
|
|
124
|
+
|
|
125
|
+
## Deploying programmatically
|
|
126
|
+
|
|
127
|
+
`deployToSandbox()` deploys a prebuilt output directory without the bundler. Unlike `SandboxDeployer()`, it doesn't include Studio unless you pass `studio: true`. Use it in CI or from agent code:
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import { deployToSandbox } from '@mastra/deployer-sandbox'
|
|
131
|
+
import { VercelSandbox } from '@mastra/vercel'
|
|
132
|
+
|
|
133
|
+
const deployment = await deployToSandbox({
|
|
134
|
+
sandbox: new VercelSandbox({ sandboxName: 'ci-smoke', ports: [4111] }),
|
|
135
|
+
dir: '.mastra/output',
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
console.info(deployment.url) // https://<sandbox-id>-4111.vercel.run
|
|
139
|
+
await deployment.logs() // tail the server log
|
|
140
|
+
await deployment.stop() // stop the sandbox (resumable)
|
|
141
|
+
await deployment.destroy() // permanently delete the sandbox
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Lifecycle
|
|
145
|
+
|
|
146
|
+
### Managing a deployment
|
|
147
|
+
|
|
148
|
+
Use the server-only `getDeployment()` export from `@mastra/deployer-sandbox/client` to retrieve an existing deployment. It identifies the sandbox through provider-specific configuration, such as a Vercel `sandboxName` or an E2B or Daytona `id`. The lookup isn't tied to the process that created the deployment, so you can use it from another server-side service or in CI.
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import { getDeployment } from '@mastra/deployer-sandbox/client'
|
|
152
|
+
import { VercelSandbox } from '@mastra/vercel'
|
|
153
|
+
|
|
154
|
+
const deployment = await getDeployment({
|
|
155
|
+
sandbox: new VercelSandbox({ sandboxName: 'my-preview', ports: [4111] }),
|
|
156
|
+
port: 4111,
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
console.info(deployment.status, deployment.url)
|
|
160
|
+
await deployment.logs() // tail the server log
|
|
161
|
+
await deployment.stop() // stop the sandbox (resumable)
|
|
162
|
+
await deployment.destroy() // permanently delete the sandbox
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Pass `wake: true` to resume a stopped sandbox before returning. The server is relaunched only if it isn't healthy after the resume. Provider tooling works too, for example `vercel sandbox ls`, `vercel sandbox stop`, and `vercel sandbox rm`.
|
|
166
|
+
|
|
167
|
+
### Expiry and URLs
|
|
168
|
+
|
|
169
|
+
Sandboxes expire according to the provider's runtime limits. When the provider reports an expiration time, the deploy logs it and `deployment.expiresAt` exposes it programmatically.
|
|
170
|
+
|
|
171
|
+
Sandbox URLs can change when a sandbox stops and resumes. Treat the URL as plumbing and the sandbox identity (for example, the `sandboxName`) as the stable handle. The routing tiers below deal with URL rotation.
|
|
172
|
+
|
|
173
|
+
## Routing tiers
|
|
174
|
+
|
|
175
|
+
### Tier 1: Direct URL
|
|
176
|
+
|
|
177
|
+
Use the printed URL directly for development, demos, and CI where a fresh URL per deploy is acceptable.
|
|
178
|
+
|
|
179
|
+
### Tier 2: Resolve at runtime
|
|
180
|
+
|
|
181
|
+
`getDeployment()` resolves the current URL at runtime, so consumers never hold a stale URL. Any server that knows the sandbox name can resolve it, including one in a different codebase than the Mastra project:
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
import { getDeployment } from '@mastra/deployer-sandbox/client'
|
|
185
|
+
import { VercelSandbox } from '@mastra/vercel'
|
|
186
|
+
|
|
187
|
+
const deployment = await getDeployment({
|
|
188
|
+
sandbox: new VercelSandbox({ sandboxName: 'my-preview', ports: [4111] }),
|
|
189
|
+
wake: true,
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
console.info(deployment.url, deployment.status)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
With `wake: false` (the default) the sandbox isn't started and you get `{ url, status }` to act on. Resolving the URL, `stop()`, and `destroy()` attach to the existing sandbox by name without resuming it, so lifecycle operations on a stopped sandbox never wake it or start billing. With `wake: true` the sandbox resumes and the server is relaunched if it isn't answering. Whether a relaunch is needed depends on the provider: Vercel and Daytona restore the filesystem but not running processes, while E2B resumes the whole VM including the server process.
|
|
196
|
+
|
|
197
|
+
> **Warning:** `@mastra/deployer-sandbox/client` is server-only. Resolving a sandbox uses provider credentials that must never reach the browser. The module throws if imported in a browser context.
|
|
198
|
+
|
|
199
|
+
### Tier 3: Stable URL for end users
|
|
200
|
+
|
|
201
|
+
Give end users a stable URL on your own domain and forward to the sandbox server-side, using either a route handler proxy or an Edge Config alias.
|
|
202
|
+
|
|
203
|
+
The example below shows a Vercel & Next.js setup, but the concept applies to any server-side framework or provider that can forward requests.
|
|
204
|
+
|
|
205
|
+
- **Route handler proxy.** `createSandboxHandler()` caches the sandbox URL and re-resolves after a connection-level failure, which covers URL rotation and cold wakes:
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
import { createSandboxHandler, getDeployment } from '@mastra/deployer-sandbox/client'
|
|
209
|
+
import { VercelSandbox } from '@mastra/vercel'
|
|
210
|
+
|
|
211
|
+
const handler = createSandboxHandler({
|
|
212
|
+
resolve: async () => {
|
|
213
|
+
const deployment = await getDeployment({
|
|
214
|
+
sandbox: new VercelSandbox({ sandboxName: 'my-preview', ports: [4111] }),
|
|
215
|
+
wake: true,
|
|
216
|
+
})
|
|
217
|
+
return deployment.url!
|
|
218
|
+
},
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
export { handler as GET, handler as POST }
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
- **Edge Config alias.** Set the `alias` option on the deployer to keep a [Vercel Edge Config](https://vercel.com/docs/edge-config) item pointed at the current URL on every deploy:
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
const deployer = new SandboxDeployer({
|
|
228
|
+
sandbox: new VercelSandbox({ sandboxName: 'my-preview', ports: [4111] }),
|
|
229
|
+
alias: { edgeConfigId: 'ecfg_...', key: 'my-preview', token: process.env.VERCEL_TOKEN! },
|
|
230
|
+
})
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Then rewrite requests in Next.js middleware with `createSandboxProxy()`:
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
import { createSandboxProxy } from '@mastra/deployer-sandbox/client'
|
|
237
|
+
|
|
238
|
+
export const middleware = createSandboxProxy({ key: 'my-preview' })
|
|
239
|
+
export const config = { matcher: '/api/:path*' }
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## CI example
|
|
243
|
+
|
|
244
|
+
Deploy a preview on every pull request:
|
|
245
|
+
|
|
246
|
+
```yaml
|
|
247
|
+
name: Sandbox preview
|
|
248
|
+
on: pull_request
|
|
249
|
+
|
|
250
|
+
jobs:
|
|
251
|
+
preview:
|
|
252
|
+
runs-on: ubuntu-latest
|
|
253
|
+
env:
|
|
254
|
+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
|
|
255
|
+
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
|
|
256
|
+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
|
|
257
|
+
steps:
|
|
258
|
+
- uses: actions/checkout@v4
|
|
259
|
+
- uses: actions/setup-node@v4
|
|
260
|
+
with:
|
|
261
|
+
node-version: 22
|
|
262
|
+
- run: npm ci
|
|
263
|
+
- run: npx mastra build
|
|
264
|
+
- run: curl --fail "$(jq -r .url .mastra/output/sandbox-deployment.json)/api"
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Security
|
|
268
|
+
|
|
269
|
+
- The sandbox URL is public. Anyone with the URL can reach your Mastra server, including Studio. Enable [server auth](https://mastra.ai/docs/server/auth) for anything beyond throwaway previews.
|
|
270
|
+
- Environment variables from your `.env` files are injected into the remote sandbox VM so the server can run. The deploy logs a warning when this happens. Don't deploy secrets you wouldn't put on a shared preview server.
|
|
271
|
+
- To restrict access to Tier 3 traffic, pass a `secret` to `createSandboxHandler()` or `createSandboxProxy()`. The helpers attach it as the `x-mastra-sandbox-secret` header on forwarded requests. Configure [server auth](https://mastra.ai/docs/server/auth) to require that header, and direct hits to the sandbox URL get rejected while traffic through your domain works.
|
|
272
|
+
|
|
273
|
+
## Related
|
|
274
|
+
|
|
275
|
+
- [Deployment overview](https://mastra.ai/docs/deployment/overview)
|
|
276
|
+
- [Server authentication](https://mastra.ai/docs/server/auth)
|
|
277
|
+
- [`WorkspaceSandbox` reference](https://mastra.ai/reference/workspace/sandbox)
|
|
@@ -57,9 +57,7 @@ import { Mastra } from '@mastra/core'
|
|
|
57
57
|
import { MastraEditor } from '@mastra/editor'
|
|
58
58
|
|
|
59
59
|
export const mastra = new Mastra({
|
|
60
|
-
agents: {
|
|
61
|
-
/* your existing agents */
|
|
62
|
-
},
|
|
60
|
+
agents: {/* your existing agents */},
|
|
63
61
|
editor: new MastraEditor(),
|
|
64
62
|
})
|
|
65
63
|
```
|
|
@@ -84,9 +82,7 @@ import { Mastra } from '@mastra/core'
|
|
|
84
82
|
import { MastraEditor } from '@mastra/editor'
|
|
85
83
|
|
|
86
84
|
export const mastra = new Mastra({
|
|
87
|
-
agents: {
|
|
88
|
-
/* your existing agents */
|
|
89
|
-
},
|
|
85
|
+
agents: {/* your existing agents */},
|
|
90
86
|
editor: new MastraEditor({
|
|
91
87
|
source: 'code',
|
|
92
88
|
}),
|
|
@@ -62,9 +62,7 @@ Integration providers connect external tool platforms to the editor. Once regist
|
|
|
62
62
|
import { ComposioToolProvider } from '@mastra/editor/composio'
|
|
63
63
|
|
|
64
64
|
export const mastra = new Mastra({
|
|
65
|
-
agents: {
|
|
66
|
-
/* your agents */
|
|
67
|
-
},
|
|
65
|
+
agents: {/* your agents */},
|
|
68
66
|
editor: new MastraEditor({
|
|
69
67
|
toolProviders: {
|
|
70
68
|
composio: new ComposioToolProvider({
|
|
@@ -91,9 +89,7 @@ Integration providers connect external tool platforms to the editor. Once regist
|
|
|
91
89
|
import { ArcadeToolProvider } from '@mastra/editor/arcade'
|
|
92
90
|
|
|
93
91
|
export const mastra = new Mastra({
|
|
94
|
-
agents: {
|
|
95
|
-
/* your agents */
|
|
96
|
-
},
|
|
92
|
+
agents: {/* your agents */},
|
|
97
93
|
editor: new MastraEditor({
|
|
98
94
|
toolProviders: {
|
|
99
95
|
arcade: new ArcadeToolProvider({
|
|
@@ -71,24 +71,18 @@ Create separate test cases for different evaluation scenarios:
|
|
|
71
71
|
|
|
72
72
|
```typescript
|
|
73
73
|
describe('Weather Agent Tests', () => {
|
|
74
|
-
const locationScorer = createScorer({
|
|
75
|
-
/* ... */
|
|
76
|
-
})
|
|
74
|
+
const locationScorer = createScorer({/* ... */})
|
|
77
75
|
|
|
78
76
|
it('should handle location disambiguation', async () => {
|
|
79
77
|
const result = await runEvals({
|
|
80
78
|
data: [
|
|
81
79
|
{
|
|
82
80
|
input: 'weather in Berlin',
|
|
83
|
-
groundTruth: {
|
|
84
|
-
/* ... */
|
|
85
|
-
},
|
|
81
|
+
groundTruth: {/* ... */},
|
|
86
82
|
},
|
|
87
83
|
{
|
|
88
84
|
input: 'weather in Berlin, Maryland',
|
|
89
|
-
groundTruth: {
|
|
90
|
-
/* ... */
|
|
91
|
-
},
|
|
85
|
+
groundTruth: {/* ... */},
|
|
92
86
|
},
|
|
93
87
|
],
|
|
94
88
|
target: weatherAgent,
|
|
@@ -142,13 +142,9 @@ If you're unable to use a local MCP server and need to connect to a remote serve
|
|
|
142
142
|
|
|
143
143
|
### Installation
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
The [`create-mastra`](https://mastra.ai/reference/cli/create-mastra) command installs Mastra skills automatically. It doesn't configure the MCP docs server. Add the server manually when you need MCP-specific tools such as the migration tool.
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
#### Manual setup
|
|
150
|
-
|
|
151
|
-
If there are no specific instructions for your tool below, you may be able to add the MCP server with this common JSON configuration anyways.
|
|
147
|
+
If there are no specific instructions for your tool below, you may be able to add the MCP server with this common JSON configuration.
|
|
152
148
|
|
|
153
149
|
```json
|
|
154
150
|
{
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
**For AI agents:** Use this guide when tasked to create a runnable Mastra project from scratch without a CLI/boilerplate. It provides code examples for agents, tools, model configuration and how to install dependencies. Do not navigate to the quickstart guide, which is for humans. The model string is Mastra's model router format ('provider/model'; use / and not : to separate provider and model). Do not install any ai-sdk packages.
|
|
6
6
|
|
|
7
|
-
Use this guide to manually build a standalone Mastra server step by step. In most cases, it's quicker to follow the [quickstart guide](https://mastra.ai/guides/getting-started/quickstart), which achieves the same result using the [`mastra
|
|
7
|
+
Use this guide to manually build a standalone Mastra server step by step. In most cases, it's quicker to follow the [quickstart guide](https://mastra.ai/guides/getting-started/quickstart), which achieves the same result using the [`create-mastra`](https://mastra.ai/reference/cli/create-mastra) command. For existing projects, you can also use [`mastra init`](https://mastra.ai/reference/cli/mastra).
|
|
8
8
|
|
|
9
9
|
## Instructions
|
|
10
10
|
|
package/.docs/docs/index.md
CHANGED
|
@@ -44,17 +44,31 @@ export const weatherTool = createTool({
|
|
|
44
44
|
location: z.string().describe('City name'),
|
|
45
45
|
}),
|
|
46
46
|
outputSchema: z.object({
|
|
47
|
-
|
|
47
|
+
location: z.string(),
|
|
48
|
+
temperatureCelsius: z.number(),
|
|
49
|
+
conditions: z.string(),
|
|
48
50
|
}),
|
|
49
51
|
execute: async ({ location }) => {
|
|
50
52
|
return {
|
|
51
|
-
|
|
53
|
+
location,
|
|
54
|
+
temperatureCelsius: 21,
|
|
55
|
+
conditions: 'sunny',
|
|
52
56
|
}
|
|
53
57
|
},
|
|
54
58
|
})
|
|
55
59
|
```
|
|
56
60
|
|
|
57
|
-
If you need to create an agent, create a new file and use `import { Agent } from "@mastra/core/agent"`. The constructor takes `{ id, name, instructions, model }`. The `model` property is a string in Mastra's model router format
|
|
61
|
+
If you need to create an agent, create a new file and use `import { Agent } from "@mastra/core/agent"`. The constructor takes `{ id, name, instructions, model }`. The `model` property is a string in Mastra's model router format. No provider import is needed for this format. Don't install any AI SDK package unless Mastra's documentation says otherwise.
|
|
62
|
+
|
|
63
|
+
By defining the model using `provider/model` format Mastra automatically looks for environment variables for the given provider. The defined model requires an environment variable to be set for the provider. OpenAI: `OPENAI_API_KEY`. Anthropic: `ANTHROPIC_API_KEY`. Google: `GOOGLE_API_KEY`. Example: Any `openai/<model>` requires the `OPENAI_API_KEY` environment variable. Go to <https://mastra.ai/models/environment-variables> for a full list of supported providers and their environment variable names.
|
|
64
|
+
|
|
65
|
+
Short list of known model IDs are:
|
|
66
|
+
|
|
67
|
+
- `openai/gpt-5.5`, `openai/gpt-5-mini`
|
|
68
|
+
- `anthropic/claude-sonnet-4-6`, `anthropic/claude-opus-4-7`, `anthropic/claude-haiku-4-5`
|
|
69
|
+
- `google/gemini-2.5-flash`
|
|
70
|
+
|
|
71
|
+
Go to <https://mastra.ai/models> for a full list of supported models.
|
|
58
72
|
|
|
59
73
|
Add a tool an agent by importing the tool and passing it to the agent constructor as a tools object.
|
|
60
74
|
|
|
@@ -83,16 +97,6 @@ export const weatherAgent = new Agent({
|
|
|
83
97
|
})
|
|
84
98
|
```
|
|
85
99
|
|
|
86
|
-
By defining the model using `provider/model` format Mastra automatically looks for environment variables for the given provider. The defined model requires an environment variable to be set for the provider. OpenAI: `OPENAI_API_KEY`. Anthropic: `ANTHROPIC_API_KEY`. Google: `GOOGLE_API_KEY`. Example: Any `openai/<model>` requires the `OPENAI_API_KEY` environment variable. Go to <https://mastra.ai/models/environment-variables> for a full list of supported providers and their environment variable names.
|
|
87
|
-
|
|
88
|
-
Short list of known model IDs are:
|
|
89
|
-
|
|
90
|
-
- `openai/gpt-5.5`, `openai/gpt-5-mini`
|
|
91
|
-
- `anthropic/claude-sonnet-4-6`, `anthropic/claude-opus-4-7`, `anthropic/claude-haiku-4-5`
|
|
92
|
-
- `google/gemini-2.5-flash`
|
|
93
|
-
|
|
94
|
-
Go to <https://mastra.ai/models> for a full list of supported models.
|
|
95
|
-
|
|
96
100
|
Create a Mastra entry point at `src/mastra/index.ts` and register the agent:
|
|
97
101
|
|
|
98
102
|
```ts
|
|
@@ -59,7 +59,7 @@ A goal step runs inside the agentic execution loop, right after `isTaskComplete`
|
|
|
59
59
|
|
|
60
60
|
- **Not satisfied, budget remaining** → the loop continues; per-evaluation feedback is injected so the agent iterates.
|
|
61
61
|
- **Satisfied** → the loop stops and the objective is marked `done`.
|
|
62
|
-
- **Budget exhausted** (`runsUsed >= maxRuns`) → the loop stops
|
|
62
|
+
- **Budget exhausted** (`runsUsed >= maxRuns`) → the loop stops and the objective is marked `paused`. Raise `maxRuns`, then resume the objective to continue.
|
|
63
63
|
|
|
64
64
|
The step is a no-op for background-task, mid-tool-loop, and working-memory-only iterations — the same gating as `isTaskComplete`.
|
|
65
65
|
|
|
@@ -103,6 +103,8 @@ await worker.updateObjectiveOptions({ threadId, maxRuns: 100 })
|
|
|
103
103
|
await worker.clearObjective({ threadId })
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
+
Objective records include an optional `activeDurationMs` value for user interfaces that display active pursuit time. Mastra advances this value while an agent runs toward an active objective and checkpoints it when the run ends or waits for tool approval. Missing values represent zero, and the duration measures agent execution rather than the goal's wall-clock age.
|
|
107
|
+
|
|
106
108
|
Per-objective values written by `setObjective` / `updateObjectiveOptions` take precedence over the agent's `goal` config, and that precedence is remembered in thread state. See the [`GoalEvaluationPayload` in the ChunkType reference](https://mastra.ai/reference/streaming/ChunkType) for the full goal chunk shape.
|
|
107
109
|
|
|
108
110
|
## Related
|
|
@@ -34,8 +34,8 @@ For most agent-focused projects, **Turso** is the simplest starting point. It pr
|
|
|
34
34
|
|
|
35
35
|
A database is attached at one of two scopes:
|
|
36
36
|
|
|
37
|
-
- **
|
|
38
|
-
- **
|
|
37
|
+
- **Environment scope**: The default. Attached to a single environment so data stays isolated between environments (for example separate production and staging databases). When your project has one environment, `mastra env db create` picks it automatically; with several, the CLI prompts you to select one.
|
|
38
|
+
- **Project scope**: One database shared by all of the project's [environments](https://mastra.ai/docs/mastra-platform/environments). Opt in with `--shared`. Its variables are injected into every deploy.
|
|
39
39
|
|
|
40
40
|
The scope is set when you attach the database and shown in `mastra env db list`.
|
|
41
41
|
|
|
@@ -43,22 +43,28 @@ The two scopes can't overlap for the same provider. Because a project-scoped dat
|
|
|
43
43
|
|
|
44
44
|
## Attach with the CLI
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
You don't have to run this command up front. If your project needs a hosted database but doesn't have one yet, `mastra deploy` offers to attach one for you when the deploy preflight check runs. Say yes and the deploy continues without leaving the CLI.
|
|
47
|
+
|
|
48
|
+
Alternatively, create and attach a database ahead of time. The CLI polls until it's ready, which takes a few seconds:
|
|
47
49
|
|
|
48
50
|
```bash
|
|
49
|
-
#
|
|
51
|
+
# Scoped to a single environment (the CLI picks the only one, or prompts if there are several)
|
|
50
52
|
mastra env db create --kind turso
|
|
51
53
|
|
|
52
|
-
# Scoped to
|
|
54
|
+
# Scoped to a specific environment
|
|
53
55
|
mastra env db create staging --kind turso
|
|
56
|
+
|
|
57
|
+
# Shared by all environments
|
|
58
|
+
mastra env db create --kind turso --shared
|
|
54
59
|
```
|
|
55
60
|
|
|
56
61
|
Supported kinds are `turso` and `neon` (Postgres). Useful flags:
|
|
57
62
|
|
|
63
|
+
- `--shared`: Attach a project-scoped database shared by every environment. Cannot be combined with an environment argument.
|
|
58
64
|
- `--name <name>`: Database name. Defaults to a name derived from the project slug.
|
|
59
65
|
- `--region <region>`: Provider region ID for project-scoped databases (for example `fra`). Environment-scoped databases are placed near the environment's region automatically, and an explicit `--region` is ignored.
|
|
60
66
|
- `--no-wait`: Return immediately instead of polling. Check progress later with `mastra env db show`.
|
|
61
|
-
- `--json`: Machine-readable output.
|
|
67
|
+
- `--json`: Machine-readable output. When the project has multiple environments, `--json` requires an environment argument or `--shared` (no interactive prompt).
|
|
62
68
|
|
|
63
69
|
Inspect and manage attached databases:
|
|
64
70
|
|
|
@@ -26,21 +26,27 @@ A local `.env` file is optional. Environment variables stored on the platform ar
|
|
|
26
26
|
|
|
27
27
|
On the first run the CLI prompts you to create the platform project (named after your `package.json`) and the `production` environment. Accept the prompts, or pass `--yes` to accept defaults without confirmation.
|
|
28
28
|
|
|
29
|
-
2. The CLI runs a preflight check before anything ships. Storage that would fall back to a local file path
|
|
29
|
+
2. The CLI runs a preflight check before anything ships. Storage that would fall back to a local file path (which doesn't survive on the platform's ephemeral filesystem) would normally block the deploy:
|
|
30
30
|
|
|
31
31
|
```text
|
|
32
|
-
|
|
32
|
+
file:./mastra.db will be used at runtime because TURSO_DATABASE_URL is not set
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
Instead of erroring out, the CLI offers to fix it inline for you:
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
Preflight needs TURSO_DATABASE_URL for the production environment. Create a managed turso database now and attach it? (Y/n)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Accept the prompt and provisioning takes a few seconds — the database's connection variables are injected into your deploys automatically, with nothing to copy into an `.env` file. Decline it, or run in a non-interactive shell (CI, `--yes`), and the CLI falls back to the previous behavior: it prints the exact command to run yourself.
|
|
36
42
|
|
|
37
43
|
```bash
|
|
38
|
-
mastra env db create --kind turso
|
|
44
|
+
mastra env db create production --kind turso
|
|
39
45
|
```
|
|
40
46
|
|
|
41
|
-
|
|
47
|
+
The environment slug (`production` above) matches the environment the CLI would have deployed to — this is important because `mastra env db create` requires an environment argument in non-interactive shells when the project has more than one environment.
|
|
42
48
|
|
|
43
|
-
> **Note:** If preflight reports a hard-coded local path instead (`Build contains a host-local storage URL`), guard
|
|
49
|
+
> **Note:** If preflight reports a hard-coded local path instead (`Build contains a host-local storage URL`), it can't offer the inline fix — guard the path with an environment variable first so the file is only used during local development:
|
|
44
50
|
>
|
|
45
51
|
> ```ts
|
|
46
52
|
> new LibSQLStore({
|
|
@@ -77,7 +83,7 @@ Pass `--region` when a deploy creates a new environment to control where it runs
|
|
|
77
83
|
mastra deploy --env production --region eu
|
|
78
84
|
```
|
|
79
85
|
|
|
80
|
-
The region is fixed when the environment is created. Databases attached to an environment are placed near that environment's region automatically.
|
|
86
|
+
The region is fixed when the environment is created. Databases attached to an environment are placed near that environment's region automatically, and observability data is routed to the ingest region that matches the environment's residency zone. See [Regions](https://mastra.ai/docs/mastra-platform/regions) for the full list of supported regions, database placement, and observability co-location.
|
|
81
87
|
|
|
82
88
|
## Preflight checks
|
|
83
89
|
|
|
@@ -139,6 +145,7 @@ mastra deploy --env production --yes
|
|
|
139
145
|
## Related
|
|
140
146
|
|
|
141
147
|
- [Environments](https://mastra.ai/docs/mastra-platform/environments)
|
|
148
|
+
- [Regions](https://mastra.ai/docs/mastra-platform/regions)
|
|
142
149
|
- [Hosted databases](https://mastra.ai/docs/mastra-platform/database)
|
|
143
150
|
- [`mastra deploy` CLI reference](https://mastra.ai/reference/cli/mastra)
|
|
144
151
|
- [Configuration](https://mastra.ai/docs/mastra-platform/configuration)
|
|
@@ -26,7 +26,7 @@ mastra deploy --env staging
|
|
|
26
26
|
mastra env create eu-preview --type preview --region eu
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
Each project has a single `production` environment, created by your first deploy. The region is fixed at creation. Databases attached to an environment are placed near the environment's region automatically. The number of environments per project depends on your plan.
|
|
29
|
+
Each project has a single `production` environment, created by your first deploy. The region is fixed at creation. Databases attached to an environment are placed near the environment's region automatically, and observability data is routed to the ingest region for the matching residency zone. See [Regions](https://mastra.ai/docs/mastra-platform/regions) for the supported regions, database placement, and observability co-location. The number of environments per project depends on your plan.
|
|
30
30
|
|
|
31
31
|
## List environments
|
|
32
32
|
|
|
@@ -77,16 +77,16 @@ Each row shows the deploy status, environment, timestamp, and which deploy is cu
|
|
|
77
77
|
|
|
78
78
|
## Isolate an environment's data
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
Hosted databases are scoped to a single environment by default, so production and staging each read and write their own database:
|
|
81
81
|
|
|
82
82
|
```bash
|
|
83
83
|
mastra env db create production --kind turso --name my-project-production-db
|
|
84
84
|
mastra env db create staging --kind turso --name my-project-staging-db
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
If you'd rather share one database across every environment, attach it with `--shared` instead: `mastra env db create --kind turso --shared`.
|
|
88
88
|
|
|
89
|
-
An environment can only use one database per provider. If the project already has a shared
|
|
89
|
+
An environment can only use one database per provider. If the project already has a shared (`--shared`) database of the same provider, attaching an environment-scoped one is rejected with a variable name conflict — delete the shared database with `mastra env db delete` first. Deleting a database destroys it with the provider along with all of its data, so export anything you need to keep. See [Hosted databases](https://mastra.ai/docs/mastra-platform/database) for the full scoping model.
|
|
90
90
|
|
|
91
91
|
## Delete an environment
|
|
92
92
|
|
|
@@ -99,5 +99,6 @@ The CLI asks for confirmation before deleting. Deleting an environment removes i
|
|
|
99
99
|
## Related
|
|
100
100
|
|
|
101
101
|
- [Deploy](https://mastra.ai/docs/mastra-platform/deploy)
|
|
102
|
+
- [Regions](https://mastra.ai/docs/mastra-platform/regions)
|
|
102
103
|
- [Hosted databases](https://mastra.ai/docs/mastra-platform/database)
|
|
103
104
|
- [`mastra env` CLI reference](https://mastra.ai/reference/cli/mastra)
|