@mastra/mcp-docs-server 1.2.7-alpha.18 → 1.2.7-alpha.20

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.
@@ -126,6 +126,22 @@ const agent = new Agent({
126
126
 
127
127
  The generated code for `sales_code` can't call an inventory tool, and the reverse holds too. Use this for least-privilege scoping and to keep each tool's prompt surface small.
128
128
 
129
+ ## Remote sandboxes
130
+
131
+ By default, code mode uses a transport that writes the program to the host filesystem and runs `node` against it. That works for `LocalSandbox`, which shares the host, but not for remote sandboxes that run in their own micro-VM (such as [E2B](https://mastra.ai/reference/workspace/e2b-sandbox)), where the host paths don't exist.
132
+
133
+ Remote sandboxes need a transport that writes the program into the sandbox filesystem. For E2B, pass the shipped `E2BCodeModeTransport` as the second argument to `createCodeMode`:
134
+
135
+ ```typescript
136
+ import { createCodeMode } from '@mastra/core/tools'
137
+ import { E2BSandbox, E2BCodeModeTransport } from '@mastra/e2b'
138
+
139
+ const { tool, instructions } = createCodeMode(
140
+ { tools, sandbox: new E2BSandbox() },
141
+ new E2BCodeModeTransport(),
142
+ )
143
+ ```
144
+
129
145
  ## Related
130
146
 
131
147
  - [createCodeMode() reference](https://mastra.ai/reference/tools/create-code-mode)
@@ -2,13 +2,13 @@
2
2
 
3
3
  # Configuration
4
4
 
5
- When you deploy to the Mastra platform, the CLI generates a `.mastra-project.json` config file and reads environment variables from your local `.env` files.
5
+ When you deploy to the Mastra platform, the CLI generates a `.mastra-project.json` config file and resolves environment variables from the platform and, optionally, your local `.env` files.
6
6
 
7
- This page explains both mechanisms and how they differ between Studio and Server deployments.
7
+ This page explains both mechanisms.
8
8
 
9
9
  ## Project config
10
10
 
11
- The `.mastra-project.json` file is auto-generated on your first Studio or Server deploy. It links your local project to a platform project. The [GitHub integration](https://mastra.ai/docs/mastra-platform/github) writes the same file into linked repositories.
11
+ The `.mastra-project.json` file is auto-generated on your first [`mastra deploy`](https://mastra.ai/docs/mastra-platform/deploy). It links your local project to a platform project. The [GitHub integration](https://mastra.ai/docs/mastra-platform/github) writes the same file into linked repositories.
12
12
 
13
13
  Commit it to your version control so that subsequent deploys (including from CI) target the correct project.
14
14
 
@@ -30,19 +30,20 @@ Your file will look something like this:
30
30
 
31
31
  ## Environment variables
32
32
 
33
- The CLI reads from `.env` and `.env.local` files in your project directory during deploy. Variables from `.env.local` override those in `.env`.
33
+ A local env file is optional. [`mastra deploy`](https://mastra.ai/docs/mastra-platform/deploy) resolves variables from three sources:
34
34
 
35
- You can set environment variables like so:
35
+ - **Managed variables**: Injected by platform resources like [hosted databases](https://mastra.ai/docs/mastra-platform/database). The platform defines these, and you can't edit them.
36
+ - **Stored variables**: Saved on the project or environment through the dashboard. Used as-is on every deploy with no local file needed.
37
+ - **Local env files**: An explicit `--env-file`, or ambient `.env` and `.env.local` files, layered on top at deploy time. Variables from `.env.local` override those in `.env`.
36
38
 
37
- - **Studio**: Environment variables are read from your local `.env` files and bundled into the deploy artifact. To update them, redeploy.
38
- - **Server**: On the first deploy, the CLI automatically seeds environment variables from your local `.env` files. After that, manage them per-project through the dashboard or API.
39
-
40
- To pin the deploy to a specific env file (instead of relying on the default selection), pass `--env-file`:
39
+ To pin the deploy to a specific env file instead of relying on the default selection, pass `--env-file`:
41
40
 
42
41
  ```bash
43
- mastra studio deploy --env-file .env.production --yes
42
+ mastra deploy --env-file .env.production --yes
44
43
  ```
45
44
 
45
+ Review and sanitize local env files before deploying to avoid uploading development-only or personal secrets.
46
+
46
47
  ### Observability
47
48
 
48
49
  The following environment variables configure the Observability product on the Mastra platform.
@@ -58,19 +59,11 @@ The following environment variables configure the Observability product on the M
58
59
 
59
60
  ## Multiple environments
60
61
 
61
- A platform project maps to a single deployed instance with one set of env vars. Platform projects don't have built-in `staging` vs `production` slots. To run the same codebase across multiple environments, create one project per environment and use the matching `.mastra-project.json` file for each deploy.
62
+ A single project runs the same codebase across multiple [environments](https://mastra.ai/docs/mastra-platform/environments), such as `production` and `staging`. Each environment has its own URL, its own stored variables, and its own deploy history. One `.mastra-project.json` file covers all of them:
62
63
 
63
64
  ```bash
64
- # Create and deploy each environment for the first time.
65
- mastra studio deploy --project "my-app-staging" --env-file .env.staging --yes
66
- mastra studio deploy --project "my-app-production" --env-file .env.production --yes
67
-
68
- # For subsequent deploys, restore the matching .mastra-project.json file before deploying.
69
- cp .mastra-project.staging.json .mastra-project.json
70
- mastra studio deploy --env-file .env.staging --yes
71
-
72
- cp .mastra-project.production.json .mastra-project.json
73
- mastra studio deploy --env-file .env.production --yes
65
+ mastra deploy --env production --yes
66
+ mastra deploy --env staging --env-file .env.staging --yes
74
67
  ```
75
68
 
76
- Each project has its own Studio URL and can send observability data to the Mastra platform. When using [`MastraPlatformExporter`](https://mastra.ai/docs/observability/integrations/exporters/mastra-platform), set `MASTRA_PROJECT_ID` and `MASTRA_PLATFORM_ACCESS_TOKEN` per environment so traces route to the matching platform project.
69
+ > **Note:** Earlier platform versions required one project per environment. Environments replace that pattern, so keep one project and deploy to named environments instead.
@@ -2,7 +2,11 @@
2
2
 
3
3
  # Hosted databases
4
4
 
5
- From your [platform](https://mastra.ai/docs/mastra-platform/overview) project settings, provision a fully managed database and attach it to your project. Mastra creates it with your provider, stores credentials securely, and injects connection details as runtime environment variables when the database is ready, so there are no connection strings to copy or configure.
5
+ Provision a fully managed database from the CLI or your [platform](https://mastra.ai/docs/mastra-platform/overview) project settings and attach it to your project. Mastra creates it with your provider, stores credentials securely, and injects connection details as runtime environment variables when the database is ready, so there are no connection strings to copy or configure.
6
+
7
+ ```bash
8
+ mastra env db create --kind turso
9
+ ```
6
10
 
7
11
  ## When to use hosted databases
8
12
 
@@ -14,9 +18,9 @@ Use a hosted database when your project needs durable storage that's managed by
14
18
 
15
19
  ## Providers
16
20
 
17
- Hosted databases are available through three providers. Pick one when you attach a database from project settings. Mastra provisions it with the provider, stores credentials securely, and injects connection details as runtime environment variables when the database is ready. Wire those variables into the matching Mastra storage adapter in your code.
21
+ Hosted databases are available through two providers today Turso and Postgres with MongoDB coming soon. Pick one when you attach a database, then wire its injected variables into the matching Mastra storage adapter in your code.
18
22
 
19
- You can attach one database per provider to a project. This keeps environment variable names unambiguous — for example, a project has a single `DATABASE_URL` for Postgres and separate `TURSO_*` variables for Turso. Attach Turso and Postgres to the same project when you need separate stores for different workloads.
23
+ Each provider injects a fixed set of variable names — for example, a single `DATABASE_URL` for Postgres and separate `TURSO_*` variables for Turso. Those names must be unique within each environment, which means an environment can use at most one database per provider. Attach Turso and Postgres to the same project when you need separate stores for different workloads.
20
24
 
21
25
  For most agent-focused projects, **Turso** is the simplest starting point. It provides a lightweight, SQLite-compatible engine well suited to agent memory, conversation history, and per-tenant isolation. Choose **Postgres** when your workload needs full SQL, relational schemas, or structured application data beyond Mastra runtime state. **MongoDB** (_coming soon_) will add document storage and built-in vector search for workloads that don't map cleanly to SQL.
22
26
 
@@ -26,7 +30,47 @@ For most agent-focused projects, **Turso** is the simplest starting point. It pr
26
30
  | **PostgreSQL** | Serverless Postgres | Relational workloads, structured data |
27
31
  | **MongoDB** | Document and vector search | Document storage, vector search (_coming soon_) |
28
32
 
29
- ## Attach a database
33
+ ## Database scope
34
+
35
+ A database is attached at one of two scopes:
36
+
37
+ - **Project scope**: The default. One database shared by all of the project's [environments](https://mastra.ai/docs/mastra-platform/environments). Its variables are injected into every deploy.
38
+ - **Environment scope**: Attached to a single environment. Use this to isolate data between environments, for example separate production and staging databases.
39
+
40
+ The scope is set when you attach the database and shown in `mastra env db list`.
41
+
42
+ The two scopes can't overlap for the same provider. Because a project-scoped database already injects its variables into every environment, attaching an environment-scoped database of the same provider is rejected with a variable name conflict. To move from a shared database to per-environment databases, delete the project-scoped database first, then attach one database per environment. Deleting a database destroys it with the provider along with all of its data — export anything you need to keep before switching scopes. Environment-scoped databases on different environments never conflict — each deploy only receives the variables for its own environment.
43
+
44
+ ## Attach with the CLI
45
+
46
+ Create and attach a database in one command. The CLI polls until it's ready, which takes a few seconds:
47
+
48
+ ```bash
49
+ # Shared by all environments
50
+ mastra env db create --kind turso
51
+
52
+ # Scoped to the staging environment
53
+ mastra env db create staging --kind turso
54
+ ```
55
+
56
+ Supported kinds are `turso` and `neon` (Postgres). Useful flags:
57
+
58
+ - `--name <name>`: Database name. Defaults to a name derived from the project slug.
59
+ - `--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
+ - `--no-wait`: Return immediately instead of polling. Check progress later with `mastra env db show`.
61
+ - `--json`: Machine-readable output.
62
+
63
+ Inspect and manage attached databases:
64
+
65
+ ```bash
66
+ mastra env db list
67
+ mastra env db show <database>
68
+ mastra env db delete <database>
69
+ ```
70
+
71
+ `mastra env db list` shows each database's kind, status, scope, and injected variable names. `mastra env db show` prints connection instructions with secret values masked; pass `--show-secrets` to reveal them. `mastra env db delete` permanently deletes the database and all of its data with the provider. Creating and deleting databases requires the admin role in your organization.
72
+
73
+ ## Attach from project settings
30
74
 
31
75
  1. Open your project in the [platform](https://mastra.ai/docs/mastra-platform/overview) and go to **Project Settings**.
32
76
 
@@ -41,7 +85,7 @@ For most agent-focused projects, **Turso** is the simplest starting point. It pr
41
85
 
42
86
  5. Select **Attach database**. Provisioning runs in the background. The database starts in a `provisioning` state and moves to `ready` once the provider finishes setup. Connection details are injected into your project as server runtime environment variables automatically.
43
87
 
44
- > **Note:** Hosted databases are created from your platform project settings. No CLI or public API currently provisions them.
88
+ Databases attached from project settings are project-scoped. Use the [CLI](#attach-with-the-cli) to attach an environment-scoped database.
45
89
 
46
90
  ## Connect from your code
47
91
 
@@ -149,4 +193,4 @@ Each provider injects a fixed set of managed environment variables. These are av
149
193
  ## Manage a database
150
194
 
151
195
  - **View connection details**: Open a `ready` database in your project settings to see its environment variables and a copy-pasteable code snippet.
152
- - **Detach**: Removing a database from a project deletes it with the provider and clears its injected environment variables. This is irreversible, so ensure you no longer need the data.
196
+ - **Delete**: Removing a database from a project deletes it with the provider and clears its injected environment variables. This is irreversible, so ensure you no longer need the data.
@@ -0,0 +1,142 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Deploy to Mastra platform
4
+
5
+ [`mastra deploy`](https://mastra.ai/reference/cli/mastra) is the single command for shipping a Mastra application to the [Mastra platform](https://mastra.ai/docs/mastra-platform/overview). One command builds your project, validates it before anything ships, creates the platform project and environment on your first run, deploys, streams build logs, and prints your public URL once the deploy is serving traffic.
6
+
7
+ ```bash
8
+ mastra deploy
9
+ ```
10
+
11
+ > **Note:** This page covers the unified deploy flow. The earlier split commands, [`mastra server deploy`](https://mastra.ai/docs/mastra-platform/server) and [`mastra studio deploy`](https://mastra.ai/docs/mastra-platform/studio), still work but `mastra deploy` is the recommended path.
12
+
13
+ ## Before you begin
14
+
15
+ You'll need a [Mastra application](https://mastra.ai/guides/getting-started/quickstart) and a [Mastra platform](https://projects.mastra.ai) account. If you're not authenticated, the CLI prompts you to log in on first use.
16
+
17
+ A local `.env` file is optional. Environment variables stored on the platform are used as-is at deploy time, and managed resources like [hosted databases](https://mastra.ai/docs/mastra-platform/database) inject their own variables. Pass `--env-file` only when you want to layer local values on top.
18
+
19
+ ## Your first deploy
20
+
21
+ 1. From your project directory, run:
22
+
23
+ ```bash
24
+ mastra deploy
25
+ ```
26
+
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
+
29
+ 2. The CLI runs a preflight check before anything ships. Storage that would fall back to a local file path blocks the deploy, because local files don't survive on the platform's ephemeral filesystem:
30
+
31
+ ```text
32
+ [LOCAL_STORAGE_PATH] file:./mastra.db will be used at runtime because TURSO_DATABASE_URL is not set
33
+ ```
34
+
35
+ Attach a [hosted database](https://mastra.ai/docs/mastra-platform/database) that provides the missing variables:
36
+
37
+ ```bash
38
+ mastra env db create --kind turso
39
+ ```
40
+
41
+ Provisioning takes a few seconds. The database's connection variables are injected into your deploys automatically, with nothing to copy into an `.env` file.
42
+
43
+ > **Note:** If preflight reports a hard-coded local path instead (`Build contains a host-local storage URL`), guard it with an environment variable first so the file is only used during local development:
44
+ >
45
+ > ```ts
46
+ > new LibSQLStore({
47
+ > // Uses the hosted database when deployed, a local file during development
48
+ > url: process.env.TURSO_DATABASE_URL ?? 'file:./mastra.db',
49
+ > authToken: process.env.TURSO_AUTH_TOKEN,
50
+ > })
51
+ > ```
52
+
53
+ 3. Run `mastra deploy` again. Preflight passes, the build uploads, and the CLI streams build logs until the deploy is live. Expect the full build and deploy to take between 30 seconds and a few minutes. The success message prints only when the new version is serving traffic.
54
+
55
+ 4. Verify your deployment at the URL printed by the CLI. Append `/api/agents` to confirm it returns a JSON list of your agents.
56
+
57
+ > **Warning:** Set up [authentication](https://mastra.ai/docs/server/auth) before exposing your endpoints publicly.
58
+
59
+ The first deploy writes a `.mastra-project.json` file linking your directory to the platform project. Commit it so later deploys, CI runs, and [`mastra env`](https://mastra.ai/docs/mastra-platform/environments) commands target the same project without extra flags.
60
+
61
+ ## Deploy to another environment
62
+
63
+ `mastra deploy` targets the `production` environment by default. Pass `--env` to target a different one. If the environment doesn't exist yet, the CLI offers to create it:
64
+
65
+ ```bash
66
+ mastra deploy --env staging
67
+ ```
68
+
69
+ Each environment gets its own URL, its own environment variables, and optionally its own [hosted database](https://mastra.ai/docs/mastra-platform/database). See [Environments](https://mastra.ai/docs/mastra-platform/environments) for the full model.
70
+
71
+ ## Choose a region
72
+
73
+ Pass `--region` when a deploy creates a new environment to control where it runs. Use the `us` or `eu` shorthand:
74
+
75
+ ```bash
76
+ mastra deploy --env production --region eu
77
+ ```
78
+
79
+ The region is fixed when the environment is created. Databases attached to an environment are placed near that environment's region automatically.
80
+
81
+ ## Preflight checks
82
+
83
+ Preflight validates the built output before anything ships, and only flags issues in your own code:
84
+
85
+ - **Local storage paths**: A hard block. File-backed storage (for example `file:./mastra.db`) is lost on every deploy. Preflight passes when the path is guarded by an environment variable that is set locally, stored on the platform, or provided by a managed database:
86
+
87
+ ```ts
88
+ import { LibSQLStore } from '@mastra/libsql'
89
+
90
+ export const storage = new LibSQLStore({
91
+ // Uses the hosted database when deployed, a local file during development
92
+ url: process.env.TURSO_DATABASE_URL ?? 'file:./mastra.db',
93
+ authToken: process.env.TURSO_AUTH_TOKEN,
94
+ })
95
+ ```
96
+
97
+ - **Missing environment variables**: A warning for variables your code reads but no source provides. Variables referenced only by library code are excluded.
98
+
99
+ The recommended response to a preflight block is to fix the cause, usually by attaching a hosted database or storing the variable on the platform. `--skip-preflight` exists as an escape hatch but skips the checks that prevent broken deploys.
100
+
101
+ Run the checks without deploying:
102
+
103
+ ```bash
104
+ mastra lint --preflight
105
+ ```
106
+
107
+ `mastra lint` only sees your local env files. Variables stored on the platform or injected by managed databases aren't visible to it, so a deploy can pass preflight where lint still reports an error.
108
+
109
+ ## Environment variables
110
+
111
+ Deploys resolve environment variables from three sources:
112
+
113
+ - **Managed variables**: Injected by platform resources like hosted databases (for example `TURSO_DATABASE_URL`). The platform defines these, and you can't edit them.
114
+ - **Stored variables**: Saved on the project or environment through the dashboard. Used as-is on every deploy with no local file needed.
115
+ - **Local env files**: An explicit `--env-file`, or ambient `.env` and `.env.local` files, layered on top at deploy time.
116
+
117
+ ```bash
118
+ mastra deploy --env staging --env-file .env.staging
119
+ ```
120
+
121
+ To change variables on a running service without a redeploy, update them in the dashboard and run [`mastra env restart`](https://mastra.ai/reference/cli/mastra).
122
+
123
+ ## Project resolution
124
+
125
+ Every deploy resolves its target project in this order:
126
+
127
+ 1. The `MASTRA_PROJECT_ID` environment variable
128
+ 2. The `--project <name|slug|id>` flag
129
+ 3. The `.mastra-project.json` file in the current directory
130
+
131
+ In CI, set `MASTRA_PROJECT_ID` and `MASTRA_API_TOKEN` and pass `--yes`:
132
+
133
+ ```bash
134
+ mastra deploy --env production --yes
135
+ ```
136
+
137
+ ## Related
138
+
139
+ - [Environments](https://mastra.ai/docs/mastra-platform/environments)
140
+ - [Hosted databases](https://mastra.ai/docs/mastra-platform/database)
141
+ - [`mastra deploy` CLI reference](https://mastra.ai/reference/cli/mastra)
142
+ - [Configuration](https://mastra.ai/docs/mastra-platform/configuration)
@@ -0,0 +1,103 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Environments
4
+
5
+ Every platform project contains one or more environments. An environment is an isolated deployment target with its own URL, its own environment variables, its own deploy history, and optionally its own [hosted database](https://mastra.ai/docs/mastra-platform/database). Use environments to run `production`, `staging`, and preview versions of the same codebase inside a single project.
6
+
7
+ Your first [`mastra deploy`](https://mastra.ai/docs/mastra-platform/deploy) creates the `production` environment. Create more with the CLI or by deploying to a name that doesn't exist yet.
8
+
9
+ ## Create an environment
10
+
11
+ Create an environment explicitly:
12
+
13
+ ```bash
14
+ mastra env create staging
15
+ ```
16
+
17
+ Or let a deploy create it, which prompts for confirmation:
18
+
19
+ ```bash
20
+ mastra deploy --env staging
21
+ ```
22
+
23
+ `mastra env create` defaults to the `staging` type. Pass `--type` to set `staging` or `preview` explicitly, and `--region` to choose where the environment runs:
24
+
25
+ ```bash
26
+ mastra env create eu-preview --type preview --region eu
27
+ ```
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.
30
+
31
+ ## List environments
32
+
33
+ ```bash
34
+ mastra env list
35
+ ```
36
+
37
+ The output shows each environment's name, region, active deploy status, and the managed environment variables injected by attached databases. Pass `--json` for machine-readable output in CI.
38
+
39
+ All `mastra env` commands resolve their project from `MASTRA_PROJECT_ID`, the `--project` flag, or the `.mastra-project.json` file written by your first deploy, in that order. Run them from your project directory and you never need to name the project.
40
+
41
+ ## Environment variables
42
+
43
+ An environment resolves its variables from three scopes:
44
+
45
+ - **Managed variables**: Injected by attached [hosted databases](https://mastra.ai/docs/mastra-platform/database) (for example `TURSO_DATABASE_URL`). The platform defines these, and you can't edit them.
46
+ - **Environment-scoped variables**: Stored on one environment through the dashboard. Use these for values that differ between environments, like API keys for staging and production services.
47
+ - **Project-scoped variables**: Stored on the project and shared by all environments.
48
+
49
+ Environment-scoped and project-scoped variables together are the stored variables described on the [Deploy](https://mastra.ai/docs/mastra-platform/deploy) page.
50
+
51
+ Variables are applied when a deploy starts. To apply changed variables to a running service without a full redeploy:
52
+
53
+ ```bash
54
+ mastra env restart staging
55
+ ```
56
+
57
+ To see the full set an environment's deploys actually run with — environment-scoped and project-scoped values merged, with managed variables listed by name — pull them into a local env file:
58
+
59
+ ```bash
60
+ mastra env vars pull staging --output .env.staging
61
+ ```
62
+
63
+ Managed variable values are injected at deploy time and never written to the file; they appear as name-only comments.
64
+
65
+ > **Note:** Environment variables don't override managed database variables. To point an environment at a different database, attach an [environment-scoped database](https://mastra.ai/docs/mastra-platform/database) instead.
66
+
67
+ ## Deploy history
68
+
69
+ List deploys across all environments, or filter to one:
70
+
71
+ ```bash
72
+ mastra env deploys
73
+ mastra env deploys staging
74
+ ```
75
+
76
+ Each row shows the deploy status, environment, timestamp, and which deploy is currently active. A deploy transitions through **queued → uploading → building → deploying → running**, and the platform reports **running** only when the new version is serving traffic.
77
+
78
+ ## Isolate an environment's data
79
+
80
+ By default a hosted database attached to the project is shared by all environments. To isolate production data from staging data, attach a separate database to each environment instead:
81
+
82
+ ```bash
83
+ mastra env db create production --kind turso --name my-project-production-db
84
+ mastra env db create staging --kind turso --name my-project-staging-db
85
+ ```
86
+
87
+ Each environment then reads and writes only its own database.
88
+
89
+ An environment can only use one database per provider. If the project already has a shared project-scoped 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
+
91
+ ## Delete an environment
92
+
93
+ ```bash
94
+ mastra env delete staging
95
+ ```
96
+
97
+ The CLI asks for confirmation before deleting. Deleting an environment removes its deploys and stored variables.
98
+
99
+ ## Related
100
+
101
+ - [Deploy](https://mastra.ai/docs/mastra-platform/deploy)
102
+ - [Hosted databases](https://mastra.ai/docs/mastra-platform/database)
103
+ - [`mastra env` CLI reference](https://mastra.ai/reference/cli/mastra)
@@ -8,9 +8,9 @@ The [Mastra platform](https://projects.mastra.ai) provides three products for de
8
8
  - [**Studio**](https://mastra.ai/docs/mastra-platform/studio): A hosted visual environment for testing agents, running workflows, and inspecting traces. Starting with Studio also gives you Observability.
9
9
  - [**Server**](https://mastra.ai/docs/mastra-platform/server): A production deployment target that runs your Mastra application as an API server. Starting with Server also gives you Observability.
10
10
 
11
- You can deploy Studio and Server from the CLI or connect a GitHub repository for push-to-deploy. See the [GitHub integration](https://mastra.ai/docs/mastra-platform/github) for the repository-linked flow.
11
+ Deploy with a single command, [`mastra deploy`](https://mastra.ai/docs/mastra-platform/deploy), or connect a GitHub repository for push-to-deploy. See the [GitHub integration](https://mastra.ai/docs/mastra-platform/github) for the repository-linked flow.
12
12
 
13
- You can also provision [**Hosted databases**](https://mastra.ai/docs/mastra-platform/database) from your project settings to persist your application data with no manual configuration.
13
+ Each project can run multiple [**Environments**](https://mastra.ai/docs/mastra-platform/environments) (for example `production` and `staging`) and provision [**Hosted databases**](https://mastra.ai/docs/mastra-platform/database) from the CLI or project settings to persist application data with no manual configuration.
14
14
 
15
15
  ## Get started
16
16
 
@@ -20,7 +20,7 @@ Choose the path that matches what you want to do:
20
20
  - **Deploy Studio**: Use [Studio](https://mastra.ai/docs/mastra-platform/studio) to host the visual development environment for your team. Start here if you want a shared UI for testing agents, running workflows, and inspecting traces.
21
21
  - **Deploy Server**: Use [Server](https://mastra.ai/docs/mastra-platform/server) to run your Mastra application as a production API server. Start here when you’re ready to serve agents, tools, and workflows from the cloud.
22
22
 
23
- ## Key Concepts
23
+ ## Key concepts
24
24
 
25
25
  **Projects** are the shared parent entity across all products. A single project can have Observability, a Studio deployment, and a Server deployment. Projects belong to an **Organization**, which is the multi-tenant container for your team.
26
26
 
@@ -34,8 +34,8 @@ Your Mastra application is built from three building blocks:
34
34
 
35
35
  Develop your project locally with [`mastra dev`](https://mastra.ai/reference/cli/mastra) and open [Studio](https://mastra.ai/docs/studio/overview) to test your agents, workflows, and tools in a visual environment.
36
36
 
37
- Once you're ready to deploy your application to production, use [`mastra studio deploy`](https://mastra.ai/reference/cli/mastra) and [`mastra server deploy`](https://mastra.ai/reference/cli/mastra) to push your application to the cloud.
37
+ Once you're ready to deploy your application to production, run [`mastra deploy`](https://mastra.ai/reference/cli/mastra) to push your application to the cloud.
38
38
 
39
- Follow the [Studio on Mastra platform](https://mastra.ai/docs/mastra-platform/studio) and [Server on Mastra platform](https://mastra.ai/docs/mastra-platform/server) docs for step-by-step instructions.
39
+ Follow the [Deploy](https://mastra.ai/docs/mastra-platform/deploy) docs for step-by-step instructions.
40
40
 
41
41
  If you host your Mastra application on your own infrastructure, you can still send observability data to Mastra platform using the [MastraPlatformExporter](https://mastra.ai/docs/observability/integrations/exporters/mastra-platform).
@@ -6,6 +6,8 @@ Server on Mastra platform is a production deployment target that runs your Mastr
6
6
 
7
7
  You get a stable API endpoint, environment variable management, custom domain support, and deploy history out of the box.
8
8
 
9
+ > **Note:** `mastra server deploy` is the earlier split deploy path. New projects should use the unified [`mastra deploy`](https://mastra.ai/docs/mastra-platform/deploy) command, which adds preflight validation, environments, and CLI-managed databases.
10
+
9
11
  > **Note:** Server deploy provisions hosted storage automatically. If you override storage with [LibSQLStore](https://mastra.ai/reference/storage/libsql) and a file URL, switch to a remotely hosted database because Mastra platform uses an ephemeral filesystem.
10
12
 
11
13
  ## Quickstart
@@ -2,10 +2,12 @@
2
2
 
3
3
  # Studio on Mastra platform
4
4
 
5
- Studio on Mastra platform is a hosted visual environment for testing agents, running workflows, and inspecting traces. Use it when you want to share Studio with your team without hosting the Studio UI yourself.
5
+ Studio on Mastra platform is a hosted visual workspace for testing agents, running workflows, and inspecting traces. Use it when you want to share Studio with your team without hosting the Studio UI yourself.
6
6
 
7
7
  You can deploy Studio from the CLI as shown below, or link a GitHub repository for push-to-deploy. See the [GitHub integration](https://mastra.ai/docs/mastra-platform/github) for the repository-linked flow.
8
8
 
9
+ > **Note:** `mastra studio deploy` is the earlier split deploy path. New projects should use the unified [`mastra deploy`](https://mastra.ai/docs/mastra-platform/deploy) command, which adds preflight validation, environments, and CLI-managed databases.
10
+
9
11
  ## Quickstart
10
12
 
11
13
  1. Follow the [get started guide](https://mastra.ai/docs) to create your first Mastra project.
@@ -56,7 +58,7 @@ See the [`mastra studio deploy` CLI reference](https://mastra.ai/reference/cli/m
56
58
 
57
59
  ## Environment files
58
60
 
59
- The deploy bundles environment variables from a `.env` or `.env.*` file in the project directory. If no env file is present, the deploy errors with `No env file found for deploy.` after the build step. Add at least an empty `.env` file before running the command.
61
+ A local env file is optional. When a `.env` or `.env.*` file is present in the project directory, the deploy bundles its environment variables.
60
62
 
61
63
  When multiple env files are present, the CLI prompts you to pick one. To select non-interactively, pass `--env-file`:
62
64
 
@@ -64,7 +66,7 @@ When multiple env files are present, the CLI prompts you to pick one. To select
64
66
  mastra studio deploy --env-file .env.production --yes
65
67
  ```
66
68
 
67
- This is also how you target multiple environments from a single codebase: maintain one env file per environment, such as `.env.staging` and `.env.production`, and pass the right one to each deploy. Each environment still requires its own Mastra platform project. See [Configuration](https://mastra.ai/docs/mastra-platform/configuration) for the multi-environment pattern.
69
+ To run the same codebase across `production` and `staging`, use the unified [`mastra deploy --env`](https://mastra.ai/docs/mastra-platform/deploy) command instead. [Environments](https://mastra.ai/docs/mastra-platform/environments) replace the earlier pattern of one project per environment.
68
70
 
69
71
  ## Create a new project non-interactively
70
72
 
@@ -1,6 +1,6 @@
1
1
  > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
2
 
3
- # How to build an AI chef assistant
3
+ # Building an AI chef assistant
4
4
 
5
5
  In this guide, you'll create a "Chef Assistant" agent that helps users cook meals with available ingredients.
6
6
 
@@ -0,0 +1,392 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Building a coding agent
4
+
5
+ In this guide, you'll build a small coding-agent application in the same category as Mastra Code, Claude Code, or Codex. You'll create the coding agent with `buildBasePrompt()` and `createCodingAgent()`, wrap it in an `AgentController` for interactive sessions and tool approvals, and run the controller in a terminal UI built with pi-tui.
6
+
7
+ The video below shows the coding agent you'll build in action.
8
+
9
+ ## Prerequisites
10
+
11
+ - Node.js `v22.19.0` or later installed
12
+ - An API key from a supported [Model Provider](https://mastra.ai/models)
13
+ - An existing Mastra project. Follow the [installation guide](https://mastra.ai/guides/getting-started/quickstart) if needed.
14
+
15
+ ## Install the terminal dependencies
16
+
17
+ Install [pi-tui](https://github.com/earendil-works/pi/tree/main/packages/tui) and `tsx`:
18
+
19
+ **npm**:
20
+
21
+ ```bash
22
+ npm install @earendil-works/pi-tui
23
+ npm install --save-dev tsx
24
+ ```
25
+
26
+ **pnpm**:
27
+
28
+ ```bash
29
+ pnpm add @earendil-works/pi-tui
30
+ pnpm add --save-dev tsx
31
+ ```
32
+
33
+ **Yarn**:
34
+
35
+ ```bash
36
+ yarn add @earendil-works/pi-tui
37
+ yarn add --dev tsx
38
+ ```
39
+
40
+ **Bun**:
41
+
42
+ ```bash
43
+ bun add @earendil-works/pi-tui
44
+ bun add --dev tsx
45
+ ```
46
+
47
+ pi-tui provides the terminal renderer and input editor. `tsx` runs the TypeScript entry point directly.
48
+
49
+ ## Create the coding agent
50
+
51
+ Create `src/mastra/agents/coding-agent.ts`. The prompt describes the current project and maps the prompt's generic tool names to the tools supplied by the default workspace.
52
+
53
+ ```typescript
54
+ import { basename } from 'node:path'
55
+ import { buildBasePrompt, createCodingAgent } from '@mastra/core/coding-agent'
56
+
57
+ export const projectPath = process.cwd()
58
+ const model = 'openai/gpt-5.5'
59
+
60
+ const instructions = buildBasePrompt({
61
+ projectPath,
62
+ projectName: basename(projectPath),
63
+ platform: process.platform,
64
+ date: new Date().toISOString().slice(0, 10),
65
+ mode: 'build',
66
+ modelId: model,
67
+ productName: 'My Coding Agent',
68
+ coAuthorName: 'My Coding Agent',
69
+ coAuthorEmail: 'coding-agent@example.com',
70
+ toolGuidance: `# Workspace tools
71
+ - Use mastra_workspace_read_file for view.
72
+ - Use mastra_workspace_list_files for find_files.
73
+ - Use mastra_workspace_grep for search_content.
74
+ - Use mastra_workspace_execute_command for execute_command.
75
+ - Use mastra_workspace_write_file, mastra_workspace_edit_file, and mastra_workspace_file_stat for writing, editing, and inspecting file metadata.
76
+ - Use only the workspace tools provided to you. Do not attempt unavailable capabilities.`,
77
+ })
78
+
79
+ export const codingAgent = createCodingAgent({
80
+ id: 'coding-agent',
81
+ name: 'Coding Agent',
82
+ model,
83
+ instructions,
84
+ basePath: projectPath,
85
+ })
86
+ ```
87
+
88
+ Replace the branding values with the name and co-author details for your agent. `createCodingAgent()` supplies a local filesystem and sandbox workspace, along with defaults for recovering from transient provider errors. The `basePath` scopes the filesystem tools and sets the initial working directory for commands. Any configuration you pass to the factory takes precedence over its defaults.
89
+
90
+ The default local sandbox runs commands directly on the host without isolation, so `basePath` isn't an operating-system security boundary. This example adds per-tool-call approval in the terminal, but you should still run it only against a trusted local project.
91
+
92
+ ## Register the coding agent
93
+
94
+ Register the returned agent like any other Mastra agent in `src/mastra/index.ts`. Registration also makes the underlying agent available in Studio and through the Mastra server.
95
+
96
+ ```typescript
97
+ import { Mastra } from '@mastra/core/mastra'
98
+ import { codingAgent } from './agents/coding-agent'
99
+
100
+ export const mastra = new Mastra({
101
+ agents: { codingAgent },
102
+ })
103
+ ```
104
+
105
+ ## Test the coding agent
106
+
107
+ Before adding the terminal interface, verify the underlying agent in Studio. When the development server starts, its working directory is `src/mastra/public`, so add a non-sensitive file there for the agent to inspect:
108
+
109
+ ```md
110
+ # Project notes
111
+
112
+ Name: Acme support portal
113
+ Status: In development
114
+ Owner: Platform team
115
+ ```
116
+
117
+ Start the development server:
118
+
119
+ **npm**:
120
+
121
+ ```bash
122
+ npm run dev
123
+ ```
124
+
125
+ **pnpm**:
126
+
127
+ ```bash
128
+ pnpm run dev
129
+ ```
130
+
131
+ **Yarn**:
132
+
133
+ ```bash
134
+ yarn dev
135
+ ```
136
+
137
+ **Bun**:
138
+
139
+ ```bash
140
+ bun run dev
141
+ ```
142
+
143
+ Open [Studio](https://mastra.ai/docs/studio/overview), select **Coding Agent**, and enter:
144
+
145
+ ```text
146
+ Inspect project-notes.md and report the project name, status, and owner. Do not modify files.
147
+ ```
148
+
149
+ The response should identify the Acme support portal, its development status, and the Platform team without changing the file. Model wording may vary.
150
+
151
+ ## Create the agent controller
152
+
153
+ Create `src/mastra/coding-agent-controller.ts`. The controller owns the interactive session, exposes UI events, and pauses workspace tools for approval.
154
+
155
+ ```typescript
156
+ import { AgentController } from '@mastra/core/agent-controller'
157
+ import { codingAgent, projectPath } from './agents/coding-agent'
158
+
159
+ export async function createCodingAgentSession() {
160
+ const workspace = await codingAgent.getWorkspace()
161
+
162
+ if (!workspace) {
163
+ throw new Error('The coding agent requires a workspace.')
164
+ }
165
+
166
+ const controller = new AgentController({
167
+ id: 'coding-agent-controller',
168
+ agent: codingAgent,
169
+ workspace,
170
+ modes: [{ id: 'build', name: 'Build', metadata: { default: true } }],
171
+ disableBuiltinTools: [
172
+ 'ask_user',
173
+ 'submit_plan',
174
+ 'task_write',
175
+ 'task_update',
176
+ 'task_complete',
177
+ 'task_check',
178
+ 'subagent',
179
+ ],
180
+ })
181
+
182
+ await controller.init()
183
+
184
+ const session = await controller.createSession({
185
+ id: 'local-session',
186
+ ownerId: 'local-user',
187
+ resourceId: projectPath,
188
+ })
189
+
190
+ return { controller, session }
191
+ }
192
+ ```
193
+
194
+ This example uses one mode and disables the controller's additional built-in tools so the introductory UI can focus on workspace execution. This is a tutorial simplification, not a production recommendation. In a production application, enable the built-in tools your product needs and implement their UI flows: interactive tools such as `ask_user` and `submit_plan` suspend until your interface resumes them, while task and subagent tools have their own lifecycle events. See [tool approvals and suspensions](https://mastra.ai/docs/agent-controller/tool-approvals).
195
+
196
+ The example also omits storage, so the conversation lasts only for the current process. You can add storage later when you want to resume sessions.
197
+
198
+ ## Build the terminal UI
199
+
200
+ Create `src/coding-agent-tui.ts`. The UI renders assistant message updates, shows tool activity, and asks the user to approve or decline each workspace tool call.
201
+
202
+ ```typescript
203
+ import { pathToFileURL } from 'node:url'
204
+ import {
205
+ Editor,
206
+ matchesKey,
207
+ ProcessTerminal,
208
+ Text,
209
+ TUI,
210
+ type EditorTheme,
211
+ type Terminal,
212
+ } from '@earendil-works/pi-tui'
213
+ import { createCodingAgentSession } from './mastra/coding-agent-controller'
214
+
215
+ const plain = (text: string) => text
216
+ const editorTheme: EditorTheme = {
217
+ borderColor: plain,
218
+ selectList: {
219
+ selectedPrefix: plain,
220
+ selectedText: plain,
221
+ description: plain,
222
+ scrollInfo: plain,
223
+ noMatch: plain,
224
+ },
225
+ }
226
+
227
+ function getText(message: { content: Array<{ type: string; text?: string }> }) {
228
+ return message.content
229
+ .filter(part => part.type === 'text')
230
+ .map(part => part.text ?? '')
231
+ .join('')
232
+ }
233
+
234
+ export async function startCodingAgentTui(terminal: Terminal = new ProcessTerminal()) {
235
+ const { controller, session } = await createCodingAgentSession()
236
+ const tui = new TUI(terminal)
237
+ const output = new Text('Ask me to inspect or change this project.', 1, 0)
238
+ const editor = new Editor(tui, editorTheme)
239
+
240
+ let busy = false
241
+ let pendingApproval: { toolCallId: string; toolName: string } | undefined
242
+
243
+ const showError = (error: unknown) => {
244
+ output.setText(`Error: ${error instanceof Error ? error.message : String(error)}`)
245
+ busy = false
246
+ pendingApproval = undefined
247
+ tui.requestRender()
248
+ }
249
+
250
+ const unsubscribe = session.subscribe(event => {
251
+ if (event.type === 'message_update' && event.message.role === 'assistant') {
252
+ output.setText(getText(event.message))
253
+ } else if (event.type === 'tool_start') {
254
+ output.setText(`Running ${event.toolName}...`)
255
+ } else if (event.type === 'tool_approval_required') {
256
+ pendingApproval = { toolCallId: event.toolCallId, toolName: event.toolName }
257
+ output.setText(`Allow ${event.toolName}? Enter y or n.`)
258
+ } else if (event.type === 'agent_end') {
259
+ busy = false
260
+ } else if (event.type === 'error') {
261
+ showError(event.error)
262
+ return
263
+ }
264
+
265
+ tui.requestRender()
266
+ })
267
+
268
+ editor.onSubmit = value => {
269
+ if (pendingApproval) {
270
+ const answer = value.trim().toLowerCase()
271
+ if (answer !== 'y' && answer !== 'n') {
272
+ output.setText(`Allow ${pendingApproval.toolName}? Enter y or n.`)
273
+ tui.requestRender()
274
+ return
275
+ }
276
+
277
+ const approval = pendingApproval
278
+ pendingApproval = undefined
279
+ session.respondToToolApproval({
280
+ toolCallId: approval.toolCallId,
281
+ decision: answer === 'y' ? 'approve' : 'decline',
282
+ })
283
+ return
284
+ }
285
+
286
+ if (busy || !value.trim()) return
287
+
288
+ busy = true
289
+ output.setText('Thinking...')
290
+ tui.requestRender()
291
+ void session.sendMessage({ content: value.trim() }).catch(showError)
292
+ }
293
+
294
+ tui.addChild(new Text('My Coding Agent', 1, 0))
295
+ tui.addChild(output)
296
+ tui.addChild(editor)
297
+ tui.setFocus(editor)
298
+
299
+ let stopPromise: Promise<void> | undefined
300
+ let removeInputListener = () => {}
301
+
302
+ const stop = () => {
303
+ stopPromise ??= (async () => {
304
+ process.off('SIGINT', handleExit)
305
+ removeInputListener()
306
+ session.abort()
307
+ unsubscribe()
308
+ tui.stop()
309
+ await controller.destroy()
310
+ })()
311
+ return stopPromise
312
+ }
313
+
314
+ const handleExit = () => {
315
+ void stop().catch(error => {
316
+ console.error(error)
317
+ process.exitCode = 1
318
+ })
319
+ }
320
+
321
+ removeInputListener = tui.addInputListener(data => {
322
+ if (!matchesKey(data, 'ctrl+c')) return
323
+ handleExit()
324
+ return { consume: true }
325
+ })
326
+ process.once('SIGINT', handleExit)
327
+ tui.start()
328
+
329
+ return { stop }
330
+ }
331
+
332
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
333
+ await startCodingAgentTui()
334
+ }
335
+ ```
336
+
337
+ The optional `Terminal` parameter supports automated tests while using `ProcessTerminal` during normal execution. The UI intentionally renders only the latest response; the `Session` still maintains the conversation context for follow-up prompts.
338
+
339
+ ## Run the coding agent
340
+
341
+ Start the terminal application from the project root so `process.cwd()` points to the project you want the agent to use:
342
+
343
+ **npm**:
344
+
345
+ ```bash
346
+ npx tsx src/coding-agent-tui.ts
347
+ ```
348
+
349
+ **pnpm**:
350
+
351
+ ```bash
352
+ pnpm dlx tsx src/coding-agent-tui.ts
353
+ ```
354
+
355
+ **Yarn**:
356
+
357
+ ```bash
358
+ yarn dlx tsx src/coding-agent-tui.ts
359
+ ```
360
+
361
+ **Bun**:
362
+
363
+ ```bash
364
+ bun x tsx src/coding-agent-tui.ts
365
+ ```
366
+
367
+ Enter this prompt:
368
+
369
+ ```text
370
+ Inspect package.json and report the package name and available scripts. Do not modify files.
371
+ ```
372
+
373
+ When the controller asks whether to allow `mastra_workspace_read_file`, enter `y`. The agent reads `package.json` and reports what it finds. Model wording varies, but the response should include the package name and its scripts without changing the file.
374
+
375
+ Press **Ctrl+C** to close the application and destroy the controller.
376
+
377
+ ## Next steps
378
+
379
+ You can extend this foundation to:
380
+
381
+ - Add storage to persist and resume controller sessions
382
+ - Add more modes with different instructions and workspace-tool allowlists
383
+ - Replace the latest-response component with a transcript that renders tool calls and results
384
+ - Add sandbox isolation before accepting untrusted prompts or distributing the application
385
+
386
+ Learn more:
387
+
388
+ - [`createCodingAgent()` reference](https://mastra.ai/reference/coding-agent/create-coding-agent)
389
+ - [`buildBasePrompt()` reference](https://mastra.ai/reference/coding-agent/build-base-prompt)
390
+ - [AgentController overview](https://mastra.ai/docs/agent-controller/overview)
391
+ - [`AgentController` reference](https://mastra.ai/reference/agent-controller/agent-controller-class)
392
+ - [Workspace overview](https://mastra.ai/docs/workspace/overview)
@@ -271,7 +271,7 @@ mastra studio deploy
271
271
 
272
272
  The CLI builds your project, uploads the artifact, and deploys it. On first deploy, a `.mastra-project.json` file is created to link your local project to the platform. Commit this file to your repository.
273
273
 
274
- The deploy requires a `.env` or `.env.*` file in the project directory. If none exists the CLI errors with `No env file found for deploy.` after the build completes — add at least an empty `.env` before running the command.
274
+ A local env file is optional. When a `.env` or `.env.*` file is present in the project directory, the deploy bundles its environment variables.
275
275
 
276
276
  To create a new platform project in one non-interactive step (instead of running `mastra studio projects create` separately), pass a name with `--project` and accept defaults with `--yes`:
277
277
 
@@ -283,21 +283,14 @@ See [Studio deployment](https://mastra.ai/docs/studio/deployment) for details.
283
283
 
284
284
  ### Multiple environments
285
285
 
286
- Mastra platform projects don't have a built-in concept of named environments (for example `staging` vs `production`). To deploy the same codebase to multiple environments, create one project per environment and pair each deploy with the matching env file using `--env-file`.
287
-
288
- The pattern below uses one `.env.<env>` file per environment, deploys to a project named `my-app-<env>`, and overrides `.mastra-project.json` per deploy with `MASTRA_ORG_ID` and `MASTRA_PROJECT_ID`:
286
+ A single Mastra platform project runs the same codebase across multiple named [environments](https://mastra.ai/docs/mastra-platform/environments), such as `production` and `staging`. Deploy to each with the unified [`mastra deploy`](https://mastra.ai/docs/mastra-platform/deploy) command:
289
287
 
290
288
  ```bash
291
- # First deploy of each environment — creates the project
292
- mastra studio deploy --project "my-app-staging" --env-file .env.staging --yes
293
- mastra studio deploy --project "my-app-production" --env-file .env.production --yes
294
-
295
- # Subsequent deploys (CI/CD) — target the existing project
296
- MASTRA_PROJECT_ID="<staging-id>" mastra studio deploy --env-file .env.staging --yes
297
- MASTRA_PROJECT_ID="<production-id>" mastra studio deploy --env-file .env.production --yes
289
+ mastra deploy --env production --yes
290
+ mastra deploy --env staging --env-file .env.staging --yes
298
291
  ```
299
292
 
300
- Each environment ends up with its own Studio URL and its own observability data. Send `MASTRA_PLATFORM_ACCESS_TOKEN` and `MASTRA_PROJECT_ID` per environment so `MastraPlatformExporter` routes traces to the correct project.
293
+ Each environment gets its own URL, its own environment variables, and its own deploy history.
301
294
 
302
295
  ## Deploy Server (optional)
303
296
 
@@ -342,13 +342,28 @@ mastra env restart <env>
342
342
 
343
343
  `<env>` can be an environment name, slug, or ID. Fails with a conflict error if the environment has never been deployed.
344
344
 
345
+ ### `mastra env vars pull`
346
+
347
+ Pulls an environment's env vars into a local env file (default: `.env`). The file contains the merged set a deploy actually runs with: vars stored on the environment (for example, added in the dashboard's environment editor) plus project-level vars, with project values winning on conflict. Managed vars injected by attached databases are listed as comments (names only) since their values are platform-managed secrets.
348
+
349
+ ```bash
350
+ mastra env vars pull
351
+ mastra env vars pull <env> --output .env.staging
352
+ ```
353
+
354
+ `<env>` can be an environment name, slug, or ID, and can be omitted when the project has exactly one environment. The file is written with `0600` permissions.
355
+
356
+ #### `-o, --output`
357
+
358
+ File to write. Defaults to `.env`.
359
+
345
360
  ### `mastra env db`
346
361
 
347
362
  Manages databases attached to a project on Mastra platform. Databases are provisioned from a managed provider (for example Turso or Neon) and inject their connection env vars into deploys automatically.
348
363
 
349
364
  A database is either **environment-scoped** (its env vars only go to one environment) or **shared** (project-scoped: its env vars go to all environments). Pass the environment argument to work with environment-scoped databases; omit it for shared databases.
350
365
 
351
- Creating and detaching databases requires the `admin` role in the organization.
366
+ Creating and deleting databases requires the `admin` role in the organization.
352
367
 
353
368
  ### `mastra env db list`
354
369
 
@@ -412,12 +427,12 @@ Print secret connection values instead of masking them.
412
427
 
413
428
  Emit machine-readable JSON. Secret values are masked unless `--show-secrets` is passed.
414
429
 
415
- ### `mastra env db detach`
430
+ ### `mastra env db delete`
416
431
 
417
- Detaches a database from the project. The CLI prompts for confirmation unless `--yes` is passed. After detaching, deploys no longer receive the database's env vars.
432
+ Permanently deletes a database with the provider, including all of its data. This cannot be undone. The CLI prompts for confirmation unless `--yes` is passed. After deletion, deploys no longer receive the database's env vars.
418
433
 
419
434
  ```bash
420
- mastra env db detach <database>
435
+ mastra env db delete <database>
421
436
  ```
422
437
 
423
438
  #### `-y, --yes`
@@ -63,6 +63,8 @@ export const mastra = new Mastra({
63
63
 
64
64
  **maxStreamLength** (`number`): Approximate maximum number of entries kept per stream. Set to 0 to disable trimming. (Default: `10000`)
65
65
 
66
+ **streamIdleTtlMs** (`number`): Idle expiry in milliseconds: a sliding TTL refreshed on every write (publish, nack retry, group re-creation). Each write resets it, so an actively-written stream never expires mid-flight; a stream left idle for the full duration is deleted by Redis automatically. Note that only writes refresh the TTL — a consumer slowly draining a backlog does not — so set it well above the longest expected gap between writes on a live topic. This is a backstop, not the primary cleanup — clearTopic handles normal end-of-lifecycle deletion; this only bounds memory for streams that never reach a clearTopic call (e.g. a crashed run). Must be a non-negative integer. Defaults to 0 (disabled). (Default: `0`)
67
+
66
68
  **reclaimIntervalMs** (`number`): How often, in milliseconds, a subscription reclaims events that an earlier consumer read but never acknowledged. Set to 0 to disable. (Default: `30000`)
67
69
 
68
70
  **reclaimIdleMs** (`number`): Minimum idle time, in milliseconds, before a pending event is eligible for reclaim. Keep this well above typical processing time to avoid double delivery. (Default: `60000`)
@@ -97,6 +99,16 @@ Waits for in-flight publishes to complete.
97
99
  await pubsub.flush()
98
100
  ```
99
101
 
102
+ ### `clearTopic(topic)`
103
+
104
+ Deletes a topic's stream and every consumer group on it, freeing the memory a finished topic would otherwise hold. The durable-agent runtime calls this automatically when a run's cleanup fires; call it yourself only once nothing will read the topic again. It's best-effort and never throws — failures are logged at warn level. A subscriber still attached when the stream is deleted recovers on its own but misses the deleted entries.
105
+
106
+ Automatic cleanup requires `@mastra/core` and `@mastra/redis-streams` versions that both support `clearTopic`: the runtime routes the call through its caching layer, so upgrade the two packages together to get end-of-run stream deletion.
107
+
108
+ ```typescript
109
+ await pubsub.clearTopic('workflow.events.run-123')
110
+ ```
111
+
100
112
  ### `close()`
101
113
 
102
114
  Closes the Redis connections and stops all subscriptions. Call this during graceful shutdown.
@@ -15,15 +15,15 @@ const voice = new SpeechifyVoice()
15
15
  // Initialize with custom configuration
16
16
  const voice = new SpeechifyVoice({
17
17
  speechModel: {
18
- name: 'simba-english',
18
+ name: 'simba-3.2',
19
19
  apiKey: 'your-api-key',
20
20
  },
21
- speaker: 'george', // Default voice
21
+ speaker: 'harper_32', // Default voice (simba-3.2 serves the curated Simba 3 voices only)
22
22
  })
23
23
 
24
24
  // Convert text to speech
25
25
  const audioStream = await voice.speak('Hello, world!', {
26
- speaker: 'henry', // Override default voice
26
+ speaker: 'imogen_32', // Override default voice
27
27
  })
28
28
  ```
29
29
 
@@ -31,11 +31,11 @@ const audioStream = await voice.speak('Hello, world!', {
31
31
 
32
32
  **speechModel** (`SpeechifyConfig`): Configuration for text-to-speech functionality (Default: `{ name: 'simba-english' }`)
33
33
 
34
- **speechModel.name** (`VoiceModelName`): The Speechify model to use
34
+ **speechModel.name** (`SpeechifyModel`): The Speechify model to use ('simba-3.2', 'simba-3.0', 'simba-english', or 'simba-multilingual')
35
35
 
36
36
  **speechModel.apiKey** (`string`): Speechify API key. Falls back to SPEECHIFY\_API\_KEY environment variable
37
37
 
38
- **speaker** (`SpeechifyVoiceId`): Default voice ID to use for speech synthesis (Default: `'george'`)
38
+ **speaker** (`SpeechifyVoiceId`): Default voice ID to use for speech synthesis. The Simba 3 models serve a curated voice set only (harper\_32, imogen\_32, ...); the classic catalog voices (george, henry, ...) work with simba-english and simba-multilingual (Default: `'harper_32' for Simba 3 models, otherwise 'george'`)
39
39
 
40
40
  ## Methods
41
41
 
@@ -49,7 +49,7 @@ Converts text to speech using the configured speech model and voice.
49
49
 
50
50
  **options.speaker** (`string`): Override the default speaker for this request
51
51
 
52
- **options.model** (`VoiceModelName`): Override the default model for this request
52
+ **options.model** (`SpeechifyModel`): Override the default model for this request
53
53
 
54
54
  Returns: `Promise<NodeJS.ReadableStream>`
55
55
 
@@ -73,5 +73,9 @@ This method isn't supported by Speechify and will throw an error. Speechify does
73
73
 
74
74
  - Speechify requires an API key for authentication
75
75
  - The default model is 'simba-english'
76
+ - 'simba-3.2' is Speechify's latest streaming model with the lowest latency and richest expressivity, and the recommended model for English
77
+ - 'simba-3.2' and 'simba-3.0' are currently English only; use 'simba-multilingual' for non-English or mixed-language input
78
+ - 'simba-3.2' and 'simba-3.0' serve a curated voice set only: 'beatrice\_32', 'dominic\_32', 'edmund\_32', 'geffen\_32', 'harper\_32', 'hugh\_32', 'imogen\_32', 'wyatt\_32'. Classic catalog voices such as 'george' return an error on these models
79
+ - The default speaker follows the configured model: 'harper\_32' for the Simba 3 models, otherwise 'george'
76
80
  - Speech-to-text functionality isn't supported
77
81
  - Additional audio stream options can be passed through the speak() method's options parameter
@@ -247,6 +247,25 @@ const workspace = new Workspace({
247
247
 
248
248
  This is optional—`gcsfuse` is installed automatically at mount time if not present.
249
249
 
250
+ ## Using with Code Mode
251
+
252
+ [Code Mode](https://mastra.ai/docs/agents/code-mode) lets an agent write a single TypeScript program that orchestrates its tools. Because E2B runs that program in a remote micro-VM, it needs a transport that writes the program into the sandbox filesystem rather than the host. `@mastra/e2b` ships `E2BCodeModeTransport` for this—pass it as the second argument to `createCodeMode`:
253
+
254
+ ```typescript
255
+ import { createCodeMode } from '@mastra/core/tools'
256
+ import { E2BSandbox, E2BCodeModeTransport } from '@mastra/e2b'
257
+
258
+ const { tool, instructions } = createCodeMode(
259
+ {
260
+ tools: { getWeather, getForecast },
261
+ sandbox: new E2BSandbox({ timeout: 60_000 }),
262
+ },
263
+ new E2BCodeModeTransport(),
264
+ )
265
+ ```
266
+
267
+ `E2BCodeModeTransport` auto-starts the sandbox if it isn't running, strips TypeScript on the host with esbuild (so it works regardless of the sandbox's Node version), runs `node` inside the VM, and cleans up the program files afterwards. The default `StdioCodeModeTransport` from `@mastra/core` only works with sandboxes that share the host filesystem, such as `LocalSandbox`.
268
+
250
269
  ## Related
251
270
 
252
271
  - [SandboxProcessManager reference](https://mastra.ai/reference/workspace/process-manager)
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @mastra/mcp-docs-server
2
2
 
3
+ ## 1.2.7-alpha.20
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`4adc391`](https://github.com/mastra-ai/mastra/commit/4adc3911075249c352bb4832d2471922826344de), [`b486abf`](https://github.com/mastra-ai/mastra/commit/b486abfa2a7528c6f527e4015c819ea9fa54aaad)]:
8
+ - @mastra/core@1.51.0-alpha.10
9
+
10
+ ## 1.2.7-alpha.19
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [[`edce8d2`](https://github.com/mastra-ai/mastra/commit/edce8d2769f19e27a05737c627af2d765472a4f8)]:
15
+ - @mastra/core@1.51.0-alpha.9
16
+
3
17
  ## 1.2.7-alpha.17
4
18
 
5
19
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mcp-docs-server",
3
- "version": "1.2.7-alpha.18",
3
+ "version": "1.2.7-alpha.20",
4
4
  "description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -28,8 +28,8 @@
28
28
  "jsdom": "^26.1.0",
29
29
  "local-pkg": "^1.1.2",
30
30
  "zod": "^4.4.3",
31
- "@mastra/core": "1.51.0-alpha.8",
32
- "@mastra/mcp": "^1.14.0-alpha.0"
31
+ "@mastra/mcp": "^1.14.0-alpha.0",
32
+ "@mastra/core": "1.51.0-alpha.10"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@hono/node-server": "^1.19.11",
@@ -45,9 +45,9 @@
45
45
  "tsx": "^4.22.4",
46
46
  "typescript": "^6.0.3",
47
47
  "vitest": "4.1.10",
48
+ "@internal/lint": "0.0.113",
48
49
  "@internal/types-builder": "0.0.88",
49
- "@mastra/core": "1.51.0-alpha.8",
50
- "@internal/lint": "0.0.113"
50
+ "@mastra/core": "1.51.0-alpha.10"
51
51
  },
52
52
  "homepage": "https://mastra.ai",
53
53
  "repository": {