@mastra/mcp-docs-server 1.1.33-alpha.6 → 1.1.33-alpha.8
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/mastra-platform/configuration.md +23 -1
- package/.docs/docs/mcp/mcp-apps.md +304 -0
- package/.docs/docs/mcp/overview.md +7 -0
- package/.docs/docs/memory/observational-memory.md +3 -3
- package/.docs/docs/studio/deployment.md +23 -1
- package/.docs/guides/migrations/mastra-cloud.md +26 -0
- package/.docs/guides/migrations/upgrade-to-v1/overview.md +4 -0
- package/.docs/guides/migrations/upgrade-to-v1/tracing.md +4 -0
- package/.docs/models/gateways/openrouter.md +2 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/clarifai.md +2 -1
- package/.docs/models/providers/deepinfra.md +3 -1
- package/.docs/models/providers/dinference.md +4 -2
- package/.docs/models/providers/frogbot.md +96 -0
- package/.docs/models/providers.md +1 -1
- package/.docs/reference/cli/mastra.md +39 -3
- package/.docs/reference/tools/mcp-client.md +32 -0
- package/.docs/reference/tools/mcp-server.md +64 -0
- package/CHANGELOG.md +15 -0
- package/package.json +4 -4
|
@@ -33,4 +33,26 @@ The CLI reads from `.env` and `.env.local` files in your project directory durin
|
|
|
33
33
|
You can set environment variables like so:
|
|
34
34
|
|
|
35
35
|
- **Studio**: Environment variables are read from your local `.env` files and bundled into the deploy artifact. To update them, redeploy.
|
|
36
|
-
- **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.
|
|
36
|
+
- **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.
|
|
37
|
+
|
|
38
|
+
To pin the deploy to a specific env file (instead of relying on the default selection), pass `--env-file`:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
mastra studio deploy --env-file .env.production --yes
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Multiple environments
|
|
45
|
+
|
|
46
|
+
A platform project maps to a single deployed instance with one set of env vars. There is no built-in concept of `staging` vs `production` slots within a project. To run the same codebase across multiple environments, create one project per environment and override `.mastra-project.json` per deploy.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Create-and-deploy each environment (first time only)
|
|
50
|
+
mastra studio deploy --project "my-app-staging" --env-file .env.staging --yes
|
|
51
|
+
mastra studio deploy --project "my-app-production" --env-file .env.production --yes
|
|
52
|
+
|
|
53
|
+
# Subsequent deploys — set MASTRA_PROJECT_ID per environment
|
|
54
|
+
MASTRA_PROJECT_ID="<staging-id>" mastra studio deploy --env-file .env.staging --yes
|
|
55
|
+
MASTRA_PROJECT_ID="<production-id>" mastra studio deploy --env-file .env.production --yes
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Each project has its own Studio URL and its own observability data. When using [`CloudExporter`](https://mastra.ai/docs/observability/tracing/exporters/cloud), set `MASTRA_PROJECT_ID` and `MASTRA_CLOUD_ACCESS_TOKEN` per environment so traces route to the matching Studio project.
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
# MCP Apps
|
|
2
|
+
|
|
3
|
+
The [MCP Apps extension](https://github.com/modelcontextprotocol/ext-apps) allows MCP tools to serve interactive HTML UIs via `ui://` resources. When a tool has an associated app resource, Mastra Studio renders it in a sandboxed iframe alongside the tool form or inline in agent chat.
|
|
4
|
+
|
|
5
|
+
## When to use MCP Apps
|
|
6
|
+
|
|
7
|
+
Use MCP Apps when a tool result is better presented as an interactive UI rather than plain text. For example:
|
|
8
|
+
|
|
9
|
+
- A calculator that renders input fields and buttons for computation
|
|
10
|
+
- A color picker that displays swatches and hex values
|
|
11
|
+
- A form builder that captures structured user input
|
|
12
|
+
- A data visualizer that renders charts
|
|
13
|
+
|
|
14
|
+
## Quickstart
|
|
15
|
+
|
|
16
|
+
Define app resources on your `MCPServer` by providing a `ui://` URI mapped to inline HTML or an HTML file path.
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { MCPServer } from '@mastra/mcp'
|
|
20
|
+
import { createTool } from '@mastra/core/tools'
|
|
21
|
+
import { z } from 'zod'
|
|
22
|
+
|
|
23
|
+
const calculatorTool = createTool({
|
|
24
|
+
id: 'calculatorWithUI',
|
|
25
|
+
description: 'An interactive calculator',
|
|
26
|
+
inputSchema: z.object({
|
|
27
|
+
num1: z.number(),
|
|
28
|
+
num2: z.number(),
|
|
29
|
+
operation: z.enum(['add', 'subtract']),
|
|
30
|
+
}),
|
|
31
|
+
execute: async ({ num1, num2, operation }) => {
|
|
32
|
+
const result = operation === 'add' ? num1 + num2 : num1 - num2
|
|
33
|
+
return {
|
|
34
|
+
content: [{ type: 'text', text: 'An interactive calculator is displayed.' }],
|
|
35
|
+
structuredContent: { result },
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const server = new MCPServer({
|
|
41
|
+
id: 'my-app-server',
|
|
42
|
+
name: 'My App Server',
|
|
43
|
+
version: '1.0.0',
|
|
44
|
+
tools: { calculatorTool },
|
|
45
|
+
appResources: {
|
|
46
|
+
'ui://calculator/main': {
|
|
47
|
+
name: 'Interactive Calculator',
|
|
48
|
+
html: `<html>
|
|
49
|
+
<body>
|
|
50
|
+
<h2>Calculator</h2>
|
|
51
|
+
<button id="btn">Compute</button>
|
|
52
|
+
<script type="module">
|
|
53
|
+
import { App } from 'https://cdn.jsdelivr.net/npm/@modelcontextprotocol/ext-apps/+esm';
|
|
54
|
+
const app = new App({ name: 'Calculator', version: '1.0.0' });
|
|
55
|
+
app.ontoolinput = (params) => {
|
|
56
|
+
console.log('Tool input:', params.arguments);
|
|
57
|
+
};
|
|
58
|
+
document.getElementById('btn').addEventListener('click', async () => {
|
|
59
|
+
const result = await app.callServerTool({
|
|
60
|
+
name: 'calculatorWithUI',
|
|
61
|
+
arguments: { num1: 10, num2: 5, operation: 'add' }
|
|
62
|
+
});
|
|
63
|
+
document.body.innerHTML += '<p>Result: ' + JSON.stringify(result) + '</p>';
|
|
64
|
+
});
|
|
65
|
+
await app.connect();
|
|
66
|
+
</script>
|
|
67
|
+
</body>
|
|
68
|
+
</html>`,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Link the tool to its app resource by adding `_meta.ui.resourceUri` to the tool definition:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
calculatorTool._meta = {
|
|
78
|
+
ui: { resourceUri: 'ui://calculator/main' },
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
> **Note:** Visit [MCPServer reference](https://mastra.ai/reference/tools/mcp-server) for the full `appResources` configuration.
|
|
83
|
+
|
|
84
|
+
## Connecting MCP Apps to agents
|
|
85
|
+
|
|
86
|
+
Agents consume tools — they do not need to know about MCP servers. Pass tools to the agent's `tools` config, and register the MCP server at the Mastra level so Studio can resolve app resources.
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { Agent } from '@mastra/core/agent'
|
|
90
|
+
import { calculatorTool } from '../mcp/tools'
|
|
91
|
+
|
|
92
|
+
export const myAgent = new Agent({
|
|
93
|
+
id: 'my-agent',
|
|
94
|
+
name: 'My Agent',
|
|
95
|
+
instructions: 'You have access to interactive UI tools.',
|
|
96
|
+
model: 'openai/gpt-5-mini',
|
|
97
|
+
tools: { calculatorTool },
|
|
98
|
+
})
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Register the MCP server at the Mastra level. Studio scans registered MCP servers to map tools to their app resources.
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { Mastra } from '@mastra/core/mastra'
|
|
105
|
+
import { myAgent } from './agents'
|
|
106
|
+
import { myAppServer } from './mcp/server'
|
|
107
|
+
|
|
108
|
+
export const mastra = new Mastra({
|
|
109
|
+
agents: { myAgent },
|
|
110
|
+
mcpServers: { myAppServer },
|
|
111
|
+
})
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
For remote MCP servers, use `MCPClient.listTools()` to get tools and `toMCPServerProxies()` to register the server:
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import { MCPClient } from '@mastra/mcp'
|
|
118
|
+
|
|
119
|
+
const mcpClient = new MCPClient({
|
|
120
|
+
servers: {
|
|
121
|
+
remoteApp: { url: new URL('https://remote-mcp-server.example.com/mcp') },
|
|
122
|
+
},
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
const myAgent = new Agent({
|
|
126
|
+
id: 'my-agent',
|
|
127
|
+
name: 'My Agent',
|
|
128
|
+
model: 'openai/gpt-5-mini',
|
|
129
|
+
tools: await mcpClient.listTools(),
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
export const mastra = new Mastra({
|
|
133
|
+
agents: { myAgent },
|
|
134
|
+
mcpServers: { ...mcpClient.toMCPServerProxies() },
|
|
135
|
+
})
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
When tools come from `MCPClient.listTools()`, each tool's `_meta.ui` is automatically stamped with a `serverId` so Studio can resolve its app resources without scanning all servers.
|
|
139
|
+
|
|
140
|
+
## How MCP Apps work
|
|
141
|
+
|
|
142
|
+
MCP Apps follow a specific communication pattern between the host (Mastra Studio) and the iframe:
|
|
143
|
+
|
|
144
|
+
1. The tool executes and returns a brief summary in `content` (visible to the model) and detailed data in `structuredContent` (visible to the UI only).
|
|
145
|
+
2. The host renders the app HTML in a sandboxed iframe.
|
|
146
|
+
3. The iframe communicates with the host via a JSON-RPC postMessage protocol.
|
|
147
|
+
4. The app can call server tools using `callServerTool()` and inject messages into the chat using `sendMessage()`.
|
|
148
|
+
|
|
149
|
+
```text
|
|
150
|
+
Agent calls tool → Tool returns brief content + structuredContent
|
|
151
|
+
→ Host renders iframe with app HTML
|
|
152
|
+
→ User interacts with UI
|
|
153
|
+
→ UI calls callServerTool() for computation
|
|
154
|
+
→ UI calls sendMessage() to inject result into chat
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Tool result format
|
|
158
|
+
|
|
159
|
+
Tools with app resources should return two fields:
|
|
160
|
+
|
|
161
|
+
- `content`: A brief text summary for the model. Keep this short so the agent does not parrot the full result.
|
|
162
|
+
- `structuredContent`: The data payload that hydrates the UI. The model does not see this field.
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
execute: async ({ num1, num2, operation }) => {
|
|
166
|
+
const result = operation === 'add' ? num1 + num2 : num1 - num2
|
|
167
|
+
return {
|
|
168
|
+
content: [{ type: 'text', text: 'An interactive calculator is displayed.' }],
|
|
169
|
+
structuredContent: { result },
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## App API (guest-side)
|
|
175
|
+
|
|
176
|
+
MCP App HTML uses the standard [`App` class from `@modelcontextprotocol/ext-apps`](https://github.com/modelcontextprotocol/ext-apps) to communicate with the host. Import it via ESM CDN or bundle it.
|
|
177
|
+
|
|
178
|
+
```javascript
|
|
179
|
+
import { App } from 'https://cdn.jsdelivr.net/npm/@modelcontextprotocol/ext-apps/+esm'
|
|
180
|
+
const app = new App({ name: 'MyApp', version: '1.0.0' })
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### `app.callServerTool(params)`
|
|
184
|
+
|
|
185
|
+
Calls an MCP server tool from within the iframe. This is useful for interactive computation without leaving the UI.
|
|
186
|
+
|
|
187
|
+
```javascript
|
|
188
|
+
const result = await app.callServerTool({
|
|
189
|
+
name: 'calculatorWithUI',
|
|
190
|
+
arguments: { num1: 42, num2: 8, operation: 'add' },
|
|
191
|
+
})
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### `app.sendMessage(params)`
|
|
195
|
+
|
|
196
|
+
Injects a user message into the agent chat, triggering a new model turn. Use this for sharing results or requesting follow-up actions.
|
|
197
|
+
|
|
198
|
+
```javascript
|
|
199
|
+
await app.sendMessage({
|
|
200
|
+
role: 'user',
|
|
201
|
+
content: [{ type: 'text', text: 'The result of 42 + 8 is 50' }],
|
|
202
|
+
})
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### `app.ontoolinput`
|
|
206
|
+
|
|
207
|
+
A callback that fires when the host delivers tool input data to the iframe, allowing pre-population of form fields. The `params.arguments` object contains the tool call arguments.
|
|
208
|
+
|
|
209
|
+
```javascript
|
|
210
|
+
app.ontoolinput = params => {
|
|
211
|
+
document.getElementById('num1').value = params.arguments.num1
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
> **Preventing UI flicker:** If your app has default form values, the user may briefly see them before `ontoolinput` hydrates the correct values. To prevent this, start the body hidden and reveal it after hydration:
|
|
216
|
+
>
|
|
217
|
+
> ```html
|
|
218
|
+
> <style>
|
|
219
|
+
> body {
|
|
220
|
+
> opacity: 0;
|
|
221
|
+
> transition: opacity 0.15s;
|
|
222
|
+
> }
|
|
223
|
+
> body.ready {
|
|
224
|
+
> opacity: 1;
|
|
225
|
+
> }
|
|
226
|
+
> </style>
|
|
227
|
+
> <script type="module">
|
|
228
|
+
> import { App } from 'https://cdn.jsdelivr.net/npm/@modelcontextprotocol/ext-apps/+esm'
|
|
229
|
+
> const app = new App({ name: 'MyApp', version: '1.0.0' })
|
|
230
|
+
>
|
|
231
|
+
> app.ontoolinput = params => {
|
|
232
|
+
> // Hydrate form fields from params.arguments
|
|
233
|
+
> document.body.classList.add('ready')
|
|
234
|
+
> }
|
|
235
|
+
>
|
|
236
|
+
> await app.connect()
|
|
237
|
+
> // Fallback: reveal after connection if no tool input arrives
|
|
238
|
+
> setTimeout(() => document.body.classList.add('ready'), 150)
|
|
239
|
+
> </script>
|
|
240
|
+
> ```
|
|
241
|
+
|
|
242
|
+
### `app.connect()`
|
|
243
|
+
|
|
244
|
+
Establishes the connection to the host. Call this after registering all event handlers.
|
|
245
|
+
|
|
246
|
+
```javascript
|
|
247
|
+
await app.connect()
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
> **Note:** See the [`App` class API reference](https://apps.extensions.modelcontextprotocol.io/api/classes/app.App.html) for the full list of methods, callbacks, and lifecycle hooks.
|
|
251
|
+
|
|
252
|
+
## Using external MCP servers with apps
|
|
253
|
+
|
|
254
|
+
External (non-Mastra) MCP servers that implement the MCP Apps extension work with Mastra via `MCPClient`. Use `listTools()` for agent tools and `toMCPServerProxies()` to register them in Studio.
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
import { Mastra } from '@mastra/core/mastra'
|
|
258
|
+
import { MCPClient } from '@mastra/mcp'
|
|
259
|
+
import { Agent } from '@mastra/core/agent'
|
|
260
|
+
|
|
261
|
+
const mcpClient = new MCPClient({
|
|
262
|
+
servers: {
|
|
263
|
+
'external-server': {
|
|
264
|
+
command: 'node',
|
|
265
|
+
args: ['path/to/external-server.js'],
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
const myAgent = new Agent({
|
|
271
|
+
id: 'my-agent',
|
|
272
|
+
name: 'My Agent',
|
|
273
|
+
model: 'openai/gpt-5-mini',
|
|
274
|
+
tools: await mcpClient.listTools(),
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
export const mastra = new Mastra({
|
|
278
|
+
agents: { myAgent },
|
|
279
|
+
mcpServers: {
|
|
280
|
+
...mcpClient.toMCPServerProxies(),
|
|
281
|
+
},
|
|
282
|
+
})
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
> **Note:** Visit [MCPClient reference](https://mastra.ai/reference/tools/mcp-client) for more details on proxying external servers.
|
|
286
|
+
|
|
287
|
+
## Sandbox security
|
|
288
|
+
|
|
289
|
+
Mastra Studio uses [`@mcp-ui/client`](https://www.npmjs.com/package/@mcp-ui/client) to render MCP App iframes through a sandbox proxy. The proxy loads app HTML via `postMessage` rather than `srcDoc`, providing additional isolation.
|
|
290
|
+
|
|
291
|
+
App iframes are sandboxed with the following permissions:
|
|
292
|
+
|
|
293
|
+
- `allow-scripts`: Enables JavaScript execution
|
|
294
|
+
- `allow-forms`: Allows form submission
|
|
295
|
+
- `allow-popups`: Permits `window.open()` and link targets
|
|
296
|
+
|
|
297
|
+
The iframe does not have access to the parent page's DOM, cookies, or storage. All communication happens through the JSON-RPC postMessage protocol managed by `@mcp-ui/client`'s `AppRenderer` on the host side and `@modelcontextprotocol/ext-apps`'s `App` class on the guest side.
|
|
298
|
+
|
|
299
|
+
## Related
|
|
300
|
+
|
|
301
|
+
- [MCP overview](https://mastra.ai/docs/mcp/overview)
|
|
302
|
+
- [MCPServer reference](https://mastra.ai/reference/tools/mcp-server)
|
|
303
|
+
- [MCPClient reference](https://mastra.ai/reference/tools/mcp-client)
|
|
304
|
+
- [MCP Apps extension spec](https://github.com/modelcontextprotocol/ext-apps)
|
|
@@ -408,8 +408,15 @@ export const mcp = new MCPClient({
|
|
|
408
408
|
|
|
409
409
|
As an alternative to MCP, Ampersand's AI SDK also has an adapter for Mastra, so you can [directly import Ampersand tools](https://docs.withampersand.com/ai-sdk#use-with-mastra) for your agent to access.
|
|
410
410
|
|
|
411
|
+
## MCP Apps
|
|
412
|
+
|
|
413
|
+
MCP servers can serve interactive HTML UIs via the MCP Apps extension. Tools with associated `ui://` resources render sandboxed iframes in Studio — both on tool detail pages and inline in agent chat. The app iframe can call server tools and inject messages into the conversation.
|
|
414
|
+
|
|
415
|
+
> **Note:** Visit [MCP Apps](https://mastra.ai/docs/mcp/mcp-apps) for setup instructions and the app bridge API.
|
|
416
|
+
|
|
411
417
|
## Related
|
|
412
418
|
|
|
419
|
+
- [MCP Apps](https://mastra.ai/docs/mcp/mcp-apps)
|
|
413
420
|
- [Using Tools](https://mastra.ai/docs/agents/using-tools)
|
|
414
421
|
- [MCPClient](https://mastra.ai/reference/tools/mcp-client)
|
|
415
422
|
- [MCPServer](https://mastra.ai/reference/tools/mcp-server)
|
|
@@ -24,7 +24,7 @@ export const agent = new Agent({
|
|
|
24
24
|
})
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
That's it. The agent now has humanlike long-term memory that persists across conversations. Setting `observationalMemory: true` uses `google/gemini-2.5-flash` by default.
|
|
27
|
+
That's it. The agent now has humanlike long-term memory that persists across conversations. Setting `observationalMemory: true` uses `google/gemini-2.5-flash` by default. Config objects also use this model unless you set a different one. To use a different model, pass it in the config object:
|
|
28
28
|
|
|
29
29
|
```typescript
|
|
30
30
|
const memory = new Memory({
|
|
@@ -44,7 +44,7 @@ See [configuration options](https://mastra.ai/reference/memory/observational-mem
|
|
|
44
44
|
>
|
|
45
45
|
> For an AI SDK example, see [Using Mastra Memory](https://mastra.ai/guides/build-your-ui/ai-sdk-ui).
|
|
46
46
|
|
|
47
|
-
> **Note:** OM currently only supports `@mastra/pg`, `@mastra/libsql`, and `@mastra/mongodb` storage adapters. It uses background agents for managing memory. When
|
|
47
|
+
> **Note:** OM currently only supports `@mastra/pg`, `@mastra/libsql`, and `@mastra/mongodb` storage adapters. It uses background agents for managing memory. When no model is set, the default model is `google/gemini-2.5-flash`.
|
|
48
48
|
|
|
49
49
|
## Temporal gap markers
|
|
50
50
|
|
|
@@ -212,7 +212,7 @@ The progress bars update live while the agent is observing or reflecting, showin
|
|
|
212
212
|
|
|
213
213
|
## Models
|
|
214
214
|
|
|
215
|
-
The Observer and Reflector run in the background. Any model that works with Mastra's [model routing](https://mastra.ai/models) (`provider/model`) can be used. When
|
|
215
|
+
The Observer and Reflector run in the background. Any model that works with Mastra's [model routing](https://mastra.ai/models) (`provider/model`) can be used. When no model is set, the default model is `google/gemini-2.5-flash`.
|
|
216
216
|
|
|
217
217
|
Generally speaking, we recommend using a model that has a large context window (128K+ tokens) and is fast enough to run in the background without slowing down your actions.
|
|
218
218
|
|
|
@@ -75,7 +75,29 @@ This builds your project (compiling `src/mastra/` into `.mastra/output`), packag
|
|
|
75
75
|
|
|
76
76
|
If this is your first deploy, the CLI will prompt you to create a new project or select an existing one. The `.mastra-project.json` file is written automatically.
|
|
77
77
|
|
|
78
|
-
A deploy transitions through **queued → uploading → starting → running** (or **failed** if something goes wrong). If a sandbox is already running for your project, the platform hot-updates it in place with no downtime. Otherwise it creates a fresh sandbox. Your instance URL is assigned per project slug and remains stable across deploys.
|
|
78
|
+
A deploy transitions through **queued → uploading → starting → running** (or **failed** if something goes wrong). If a sandbox is already running for your project, the platform hot-updates it in place with no downtime. Otherwise it creates a fresh sandbox. Your instance URL is assigned per project slug and remains stable across deploys.
|
|
79
|
+
|
|
80
|
+
### Env file requirement
|
|
81
|
+
|
|
82
|
+
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.
|
|
83
|
+
|
|
84
|
+
When multiple env files are present, the CLI prompts you to pick one. To select non-interactively, pass `--env-file`:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
mastra studio deploy --env-file .env.production --yes
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
This is also how you target multiple environments from a single codebase: maintain one env file per environment (for example `.env.staging`, `.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.
|
|
91
|
+
|
|
92
|
+
### Create a new project non-interactively
|
|
93
|
+
|
|
94
|
+
`mastra studio deploy` can create a project on first run. If `--project <name>` does not match an existing project, the CLI uses the value as the new project name and creates it after confirmation. Combined with `--yes`, this is fully scriptable:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
mastra studio deploy --project "my-new-project" --yes
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Use this from CI or AI coding agents instead of `mastra studio projects create`, which is interactive only.
|
|
79
101
|
|
|
80
102
|
## Running a server
|
|
81
103
|
|
|
@@ -269,8 +269,34 @@ mastra studio deploy
|
|
|
269
269
|
|
|
270
270
|
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.
|
|
271
271
|
|
|
272
|
+
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.
|
|
273
|
+
|
|
274
|
+
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`:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
mastra studio deploy --project "my-new-project" --yes
|
|
278
|
+
```
|
|
279
|
+
|
|
272
280
|
See [Studio deployment](https://mastra.ai/docs/studio/deployment) for details.
|
|
273
281
|
|
|
282
|
+
### Multiple environments
|
|
283
|
+
|
|
284
|
+
Mastra platform projects do not 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`.
|
|
285
|
+
|
|
286
|
+
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`:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
# First deploy of each environment — creates the project
|
|
290
|
+
mastra studio deploy --project "my-app-staging" --env-file .env.staging --yes
|
|
291
|
+
mastra studio deploy --project "my-app-production" --env-file .env.production --yes
|
|
292
|
+
|
|
293
|
+
# Subsequent deploys (CI/CD) — target the existing project
|
|
294
|
+
MASTRA_PROJECT_ID="<staging-id>" mastra studio deploy --env-file .env.staging --yes
|
|
295
|
+
MASTRA_PROJECT_ID="<production-id>" mastra studio deploy --env-file .env.production --yes
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Each environment ends up with its own Studio URL and its own observability data. Send `MASTRA_CLOUD_ACCESS_TOKEN` and `MASTRA_PROJECT_ID` per environment so `CloudExporter` routes traces to the correct project.
|
|
299
|
+
|
|
274
300
|
## Deploy Server (optional)
|
|
275
301
|
|
|
276
302
|
If you need a production API endpoint, deploy a Server:
|
|
@@ -8,6 +8,10 @@ This guide provides a comprehensive overview of breaking changes when upgrading
|
|
|
8
8
|
|
|
9
9
|
> **Need help?:** Need help with the migration? Join our [Discord community](https://discord.gg/BTYqqHKUrf) to ask questions.
|
|
10
10
|
|
|
11
|
+
> **Coming from Mastra Cloud?:** The legacy Mastra Cloud product has been replaced by the [Mastra platform](https://mastra.ai/docs/mastra-platform/overview), which splits hosting into two separate products: **Studio** (visual environment, observability) and **Server** (production API). Old Mastra Cloud access tokens do not work with Mastra platform — you must create new ones with `mastra auth tokens create`.
|
|
12
|
+
>
|
|
13
|
+
> If you upgrade to v1 packages without also migrating your `telemetry:` config to `observability:` and creating a Studio project, observability data will stop flowing. Follow the [Mastra Cloud migration guide](https://mastra.ai/guides/migrations/mastra-cloud) end to end.
|
|
14
|
+
|
|
11
15
|
## Migration strategy
|
|
12
16
|
|
|
13
17
|
### Update all Mastra packages to `latest` tag
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
The observability system has been restructured in v1 with a dedicated `@mastra/observability` package. This guide covers two migration paths depending on which version you're upgrading from.
|
|
4
4
|
|
|
5
|
+
> **Observability data stops flowing on upgrade:** If you upgrade Mastra packages to v1 without migrating your `telemetry:` config to `observability:`, the old config is ignored at runtime. Your service will start cleanly with no error, but **no traces, logs, or metrics will be sent anywhere**. If you were sending data to Mastra Cloud, the dashboard will go empty.
|
|
6
|
+
>
|
|
7
|
+
> Complete this migration in the same change that bumps your Mastra packages, and verify traces appear in [Mastra Studio](https://mastra.ai/docs/studio/observability) before considering the upgrade complete. If you previously hosted on Mastra Cloud, also follow the [Mastra Cloud migration guide](https://mastra.ai/guides/migrations/mastra-cloud) — the new platform requires a new access token and a Studio project before `CloudExporter` can route data to it.
|
|
8
|
+
|
|
5
9
|
## Migration paths
|
|
6
10
|
|
|
7
11
|
### From OTEL-based Telemetry (0.x)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenRouter
|
|
2
2
|
|
|
3
|
-
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
3
|
+
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 185 models through Mastra's model router.
|
|
4
4
|
|
|
5
5
|
Learn more in the [OpenRouter documentation](https://openrouter.ai/models).
|
|
6
6
|
|
|
@@ -201,6 +201,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
201
201
|
| `x-ai/grok-4.1-fast` |
|
|
202
202
|
| `x-ai/grok-4.20-beta` |
|
|
203
203
|
| `x-ai/grok-4.20-multi-agent-beta` |
|
|
204
|
+
| `x-ai/grok-4.3` |
|
|
204
205
|
| `x-ai/grok-code-fast-1` |
|
|
205
206
|
| `xiaomi/mimo-v2-flash` |
|
|
206
207
|
| `xiaomi/mimo-v2-omni` |
|
package/.docs/models/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Model Providers
|
|
2
2
|
|
|
3
|
-
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to
|
|
3
|
+
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to 3875 models from 107 providers through a single API.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Clarifai
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 12 Clarifai models through Mastra's model router. Authentication is handled automatically using the `CLARIFAI_PAT` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Clarifai documentation](https://docs.clarifai.com).
|
|
6
6
|
|
|
@@ -40,6 +40,7 @@ for await (const chunk of stream) {
|
|
|
40
40
|
| `clarifai/minimaxai/chat-completion/models/MiniMax-M2_5-high-throughput` | 205K | | | | | | $0.30 | $1 |
|
|
41
41
|
| `clarifai/mistralai/completion/models/Ministral-3-14B-Reasoning-2512` | 262K | | | | | | $3 | $2 |
|
|
42
42
|
| `clarifai/mistralai/completion/models/Ministral-3-3B-Reasoning-2512` | 262K | | | | | | $1 | $0.55 |
|
|
43
|
+
| `clarifai/moonshotai/chat-completion/models/Kimi-K2_6` | 262K | | | | | | $0.95 | $4 |
|
|
43
44
|
| `clarifai/openai/chat-completion/models/gpt-oss-120b-high-throughput` | 131K | | | | | | $0.09 | $0.36 |
|
|
44
45
|
| `clarifai/openai/chat-completion/models/gpt-oss-20b` | 131K | | | | | | $0.04 | $0.18 |
|
|
45
46
|
| `clarifai/qwen/qwenCoder/models/Qwen3-Coder-30B-A3B-Instruct` | 262K | | | | | | $0.11 | $0.75 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Deep Infra
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 35 Deep Infra models through Mastra's model router. Authentication is handled automatically using the `DEEPINFRA_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Deep Infra documentation](https://deepinfra.com/models).
|
|
6
6
|
|
|
@@ -37,6 +37,8 @@ for await (const chunk of stream) {
|
|
|
37
37
|
| `deepinfra/deepseek-ai/DeepSeek-R1-0528` | 164K | | | | | | $0.50 | $2 |
|
|
38
38
|
| `deepinfra/deepseek-ai/DeepSeek-V3.2` | 164K | | | | | | $0.26 | $0.38 |
|
|
39
39
|
| `deepinfra/deepseek-ai/DeepSeek-V4-Pro` | 66K | | | | | | $2 | $3 |
|
|
40
|
+
| `deepinfra/google/gemma-4-26B-A4B-it` | 256K | | | | | | $0.07 | $0.34 |
|
|
41
|
+
| `deepinfra/google/gemma-4-31B-it` | 256K | | | | | | $0.13 | $0.38 |
|
|
40
42
|
| `deepinfra/meta-llama/Llama-3.1-70B-Instruct` | 131K | | | | | | $0.40 | $0.40 |
|
|
41
43
|
| `deepinfra/meta-llama/Llama-3.1-70B-Instruct-Turbo` | 131K | | | | | | $0.40 | $0.40 |
|
|
42
44
|
| `deepinfra/meta-llama/Llama-3.1-8B-Instruct` | 131K | | | | | | $0.02 | $0.05 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# DInference
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 5 DInference models through Mastra's model router. Authentication is handled automatically using the `DINFERENCE_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [DInference documentation](https://dinference.com).
|
|
6
6
|
|
|
@@ -36,7 +36,9 @@ for await (const chunk of stream) {
|
|
|
36
36
|
| ------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
37
37
|
| `dinference/glm-4.7` | 200K | | | | | | $0.45 | $2 |
|
|
38
38
|
| `dinference/glm-5` | 200K | | | | | | $0.75 | $2 |
|
|
39
|
+
| `dinference/glm-5.1` | 200K | | | | | | $1 | $4 |
|
|
39
40
|
| `dinference/gpt-oss-120b` | 131K | | | | | | $0.07 | $0.27 |
|
|
41
|
+
| `dinference/minimax-m2.5` | 200K | | | | | | $0.22 | $0.88 |
|
|
40
42
|
|
|
41
43
|
## Advanced configuration
|
|
42
44
|
|
|
@@ -66,7 +68,7 @@ const agent = new Agent({
|
|
|
66
68
|
model: ({ requestContext }) => {
|
|
67
69
|
const useAdvanced = requestContext.task === "complex";
|
|
68
70
|
return useAdvanced
|
|
69
|
-
? "dinference/
|
|
71
|
+
? "dinference/minimax-m2.5"
|
|
70
72
|
: "dinference/glm-4.7";
|
|
71
73
|
}
|
|
72
74
|
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# FrogBot
|
|
2
|
+
|
|
3
|
+
Access 26 FrogBot models through Mastra's model router. Authentication is handled automatically using the `FROGBOT_API_KEY` environment variable.
|
|
4
|
+
|
|
5
|
+
Learn more in the [FrogBot documentation](https://docs.frogbot.ai).
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
FROGBOT_API_KEY=your-api-key
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { Agent } from "@mastra/core/agent";
|
|
13
|
+
|
|
14
|
+
const agent = new Agent({
|
|
15
|
+
id: "my-agent",
|
|
16
|
+
name: "My Agent",
|
|
17
|
+
instructions: "You are a helpful assistant",
|
|
18
|
+
model: "frogbot/claude-haiku-4-5"
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Generate a response
|
|
22
|
+
const response = await agent.generate("Hello!");
|
|
23
|
+
|
|
24
|
+
// Stream a response
|
|
25
|
+
const stream = await agent.stream("Tell me a story");
|
|
26
|
+
for await (const chunk of stream) {
|
|
27
|
+
console.log(chunk);
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
> **Info:** Mastra uses the OpenAI-compatible `/chat/completions` endpoint. Some provider-specific features may not be available. Check the [FrogBot documentation](https://docs.frogbot.ai) for details.
|
|
32
|
+
|
|
33
|
+
## Models
|
|
34
|
+
|
|
35
|
+
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
36
|
+
| ------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
37
|
+
| `frogbot/claude-haiku-4-5` | 200K | | | | | | $1 | $5 |
|
|
38
|
+
| `frogbot/claude-opus-4-6` | 200K | | | | | | $5 | $25 |
|
|
39
|
+
| `frogbot/claude-opus-4-7` | 200K | | | | | | $5 | $25 |
|
|
40
|
+
| `frogbot/claude-sonnet-4-6` | 200K | | | | | | $3 | $15 |
|
|
41
|
+
| `frogbot/deepseek-v4-pro` | 128K | | | | | | $2 | $3 |
|
|
42
|
+
| `frogbot/gemini-2.5-flash` | 1.0M | | | | | | $0.30 | $3 |
|
|
43
|
+
| `frogbot/gemini-2.5-pro` | 1.0M | | | | | | $1 | $10 |
|
|
44
|
+
| `frogbot/gemini-3-1-pro-preview` | 1.0M | | | | | | $2 | $12 |
|
|
45
|
+
| `frogbot/gemini-3-flash-preview` | 1.0M | | | | | | $0.50 | $3 |
|
|
46
|
+
| `frogbot/gpt-4o` | 128K | | | | | | $3 | $10 |
|
|
47
|
+
| `frogbot/gpt-5-3-codex` | 400K | | | | | | $2 | $14 |
|
|
48
|
+
| `frogbot/gpt-5-4-mini` | 400K | | | | | | $0.75 | $5 |
|
|
49
|
+
| `frogbot/gpt-5-4-nano` | 400K | | | | | | $0.20 | $1 |
|
|
50
|
+
| `frogbot/gpt-5-5` | 272K | | | | | | $3 | $15 |
|
|
51
|
+
| `frogbot/gpt-oss-120b` | 131K | | | | | | $0.15 | $0.60 |
|
|
52
|
+
| `frogbot/gpt-oss-20b` | 131K | | | | | | $0.07 | $0.20 |
|
|
53
|
+
| `frogbot/grok-4-1-fast-non-reasoning` | 2.0M | | | | | | $0.20 | $0.50 |
|
|
54
|
+
| `frogbot/grok-4-1-fast-reasoning` | 2.0M | | | | | | $0.20 | $0.50 |
|
|
55
|
+
| `frogbot/grok-4-3` | 1.0M | | | | | | $1 | $3 |
|
|
56
|
+
| `frogbot/grok-code-fast-1` | 256K | | | | | | $0.20 | $2 |
|
|
57
|
+
| `frogbot/kimi-k2-6` | 256K | | | | | | $0.95 | $4 |
|
|
58
|
+
| `frogbot/kimi-k2.5` | 256K | | | | | | $0.60 | $3 |
|
|
59
|
+
| `frogbot/minimax-m2-5` | 192K | | | | | | $0.30 | $1 |
|
|
60
|
+
| `frogbot/minimax-m2-7` | 192K | | | | | | $0.30 | $1 |
|
|
61
|
+
| `frogbot/qwen-3-6-plus` | 1.0M | | | | | | $0.50 | $3 |
|
|
62
|
+
| `frogbot/zai-glm-5-1` | 198K | | | | | | $1 | $4 |
|
|
63
|
+
|
|
64
|
+
## Advanced configuration
|
|
65
|
+
|
|
66
|
+
### Custom headers
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
const agent = new Agent({
|
|
70
|
+
id: "custom-agent",
|
|
71
|
+
name: "custom-agent",
|
|
72
|
+
model: {
|
|
73
|
+
url: "https://app.frogbot.ai/api/v1",
|
|
74
|
+
id: "frogbot/claude-haiku-4-5",
|
|
75
|
+
apiKey: process.env.FROGBOT_API_KEY,
|
|
76
|
+
headers: {
|
|
77
|
+
"X-Custom-Header": "value"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Dynamic model selection
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
const agent = new Agent({
|
|
87
|
+
id: "dynamic-agent",
|
|
88
|
+
name: "Dynamic Agent",
|
|
89
|
+
model: ({ requestContext }) => {
|
|
90
|
+
const useAdvanced = requestContext.task === "complex";
|
|
91
|
+
return useAdvanced
|
|
92
|
+
? "frogbot/zai-glm-5-1"
|
|
93
|
+
: "frogbot/claude-haiku-4-5";
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
```
|
|
@@ -32,8 +32,8 @@ Direct access to individual AI model providers. Each provider offers unique mode
|
|
|
32
32
|
- [evroc](https://mastra.ai/models/providers/evroc)
|
|
33
33
|
- [FastRouter](https://mastra.ai/models/providers/fastrouter)
|
|
34
34
|
- [Fireworks AI](https://mastra.ai/models/providers/fireworks-ai)
|
|
35
|
-
- [Firmware](https://mastra.ai/models/providers/firmware)
|
|
36
35
|
- [Friendli](https://mastra.ai/models/providers/friendli)
|
|
36
|
+
- [FrogBot](https://mastra.ai/models/providers/frogbot)
|
|
37
37
|
- [GitHub Models](https://mastra.ai/models/providers/github-models)
|
|
38
38
|
- [Helicone](https://mastra.ai/models/providers/helicone)
|
|
39
39
|
- [HPC-AI](https://mastra.ai/models/providers/hpc-ai)
|
|
@@ -199,10 +199,18 @@ Builds and deploys your project to Mastra platform. Requires authentication via
|
|
|
199
199
|
mastra studio deploy
|
|
200
200
|
```
|
|
201
201
|
|
|
202
|
-
The command runs `mastra build`, zips the output, reads
|
|
202
|
+
The command runs `mastra build`, zips the output, reads an env file from the project directory, and uploads everything to the platform. After uploading, it polls the deploy status and streams build logs until the deploy reaches a terminal state.
|
|
203
|
+
|
|
204
|
+
The CLI requires at least one `.env` or `.env.*` file (excluding `.env.example`) in the project directory and fails with `Error: No env file found for deploy.` if none exists. When multiple env files are present, the CLI prompts you to pick one (defaulting to `.env.production`); pass `--env-file` to choose explicitly. With `--yes` and multiple env files, you must pass `--env-file` or the deploy errors.
|
|
203
205
|
|
|
204
206
|
Organization and project are resolved in order from: Environment variable flag, `.mastra-project.json` config file, current org from credentials, and lastly interactive prompt. On first deploy, the CLI saves the resolved IDs to `.mastra-project.json` so subsequent deploys skip the prompts.
|
|
205
207
|
|
|
208
|
+
If `--project <value>` does not match an existing project (by ID or slug), the CLI treats `<value>` as a new project name and creates it after confirmation. Combined with `--yes`, this creates and deploys a new project in one non-interactive command:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
mastra studio deploy --project "my-new-project" --yes
|
|
212
|
+
```
|
|
213
|
+
|
|
206
214
|
### Arguments
|
|
207
215
|
|
|
208
216
|
#### `[dir]`
|
|
@@ -217,7 +225,7 @@ Organization ID. Can also be set via the `MASTRA_ORG_ID` environment variable.
|
|
|
217
225
|
|
|
218
226
|
#### `--project`
|
|
219
227
|
|
|
220
|
-
Project ID or slug. Can also be set via the `MASTRA_PROJECT_ID` environment variable.
|
|
228
|
+
Project ID or slug. Can also be set via the `MASTRA_PROJECT_ID` environment variable. If no project matches, the value is used as the name of a new project to create on deploy.
|
|
221
229
|
|
|
222
230
|
#### `-y, --yes`
|
|
223
231
|
|
|
@@ -227,6 +235,14 @@ Auto-accept defaults without confirmation prompts.
|
|
|
227
235
|
|
|
228
236
|
Path to the project config file. Defaults to `.mastra-project.json`.
|
|
229
237
|
|
|
238
|
+
#### `--env-file`
|
|
239
|
+
|
|
240
|
+
Path to the env file to bundle with the deploy (relative to the project directory). Use this to deploy the same project to multiple environments by pointing at different env files (for example `.env.staging`, `.env.production`).
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
mastra studio deploy --env-file .env.staging --yes
|
|
244
|
+
```
|
|
245
|
+
|
|
230
246
|
#### `--skip-build`
|
|
231
247
|
|
|
232
248
|
Skip the build step and deploy the existing `.mastra/output` directory.
|
|
@@ -271,13 +287,23 @@ Stream logs in real time.
|
|
|
271
287
|
|
|
272
288
|
Number of recent log lines to show.
|
|
273
289
|
|
|
290
|
+
### `mastra studio deploy suggestions`
|
|
291
|
+
|
|
292
|
+
Shows diagnosis results and suggested fixes for a failed Studio deploy.
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
mastra studio deploy suggestions [deploy-id]
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
If you omit `deploy-id`, the command uses the latest deploy for the linked project. If a diagnosis does not exist yet, the command starts one and polls until results are ready. If the deploy is healthy, no suggestions are shown.
|
|
299
|
+
|
|
274
300
|
### `mastra studio projects`
|
|
275
301
|
|
|
276
302
|
Lists all projects in the current organization.
|
|
277
303
|
|
|
278
304
|
### `mastra studio projects create`
|
|
279
305
|
|
|
280
|
-
Creates a new project through an interactive prompt.
|
|
306
|
+
Creates a new project through an interactive prompt. This command does not accept a `--name` flag; for non-interactive project creation, use [`mastra studio deploy --project <name> --yes`](#mastra-studio-deploy) instead, which creates the project and deploys to it in one step.
|
|
281
307
|
|
|
282
308
|
## `mastra server deploy`
|
|
283
309
|
|
|
@@ -287,6 +313,16 @@ Builds and deploys your project to Server on Mastra platform. Works the same as
|
|
|
287
313
|
mastra server deploy [dir]
|
|
288
314
|
```
|
|
289
315
|
|
|
316
|
+
### `mastra server deploy suggestions`
|
|
317
|
+
|
|
318
|
+
Shows diagnosis results and suggested fixes for a failed Server deploy.
|
|
319
|
+
|
|
320
|
+
```bash
|
|
321
|
+
mastra server deploy suggestions [deploy-id]
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
If you omit `deploy-id`, the command uses the latest deploy for the linked project. If a diagnosis does not exist yet, the command starts one and polls until results are ready. If the deploy is healthy, no suggestions are shown.
|
|
325
|
+
|
|
290
326
|
## `mastra server pause`
|
|
291
327
|
|
|
292
328
|
Pauses the running server instance for the linked project. Organization and project resolution work the same as [`mastra server deploy`](#mastra-server-deploy).
|
|
@@ -126,6 +126,38 @@ Disconnects from all MCP servers and cleans up resources.
|
|
|
126
126
|
async disconnect(): Promise<void>
|
|
127
127
|
```
|
|
128
128
|
|
|
129
|
+
### `toMCPServerProxies()`
|
|
130
|
+
|
|
131
|
+
Returns a map of `MCPClientServerProxy` instances, one per configured server. Each proxy wraps the underlying client connection as an `MCPServerBase` instance, allowing external (non-Mastra) MCP servers to be registered in `mcpServers` and appear in Studio.
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
async toMCPServerProxies(): Promise<Record<string, MCPClientServerProxy>>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Spread the result into the `mcpServers` config on `Mastra`:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
import { Mastra } from '@mastra/core/mastra'
|
|
141
|
+
import { MCPClient } from '@mastra/mcp'
|
|
142
|
+
|
|
143
|
+
const mcpClient = new MCPClient({
|
|
144
|
+
servers: {
|
|
145
|
+
'color-mixer': {
|
|
146
|
+
command: 'node',
|
|
147
|
+
args: ['path/to/color-mixer-server.js'],
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
export const mastra = new Mastra({
|
|
153
|
+
mcpServers: {
|
|
154
|
+
...(await mcpClient.toMCPServerProxies()),
|
|
155
|
+
},
|
|
156
|
+
})
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
This is useful for connecting external MCP servers that implement the MCP Apps extension or other features to Studio without wrapping them in a Mastra `MCPServer`.
|
|
160
|
+
|
|
129
161
|
### `resources` Property
|
|
130
162
|
|
|
131
163
|
The `MCPClient` instance has a `resources` property that provides access to resource-related operations.
|
|
@@ -83,6 +83,8 @@ The constructor accepts an `MCPServerConfig` object with the following propertie
|
|
|
83
83
|
|
|
84
84
|
**prompts** (`MCPServerPrompts`): An object defining how the server should handle MCP prompts. See Prompt Handling section for details.
|
|
85
85
|
|
|
86
|
+
**appResources** (`AppResources`): A map of \`ui://\` URIs to app resource configurations. Each entry defines an interactive HTML UI served via the MCP Apps extension (SEP-1865). See the MCP Apps section for details.
|
|
87
|
+
|
|
86
88
|
## Exposing agents as tools
|
|
87
89
|
|
|
88
90
|
A powerful feature of `MCPServer` is its ability to automatically expose your Mastra Agents as callable tools. When you provide agents in the `agents` property of the configuration:
|
|
@@ -1263,6 +1265,68 @@ app.all('/mcp', async (req, res) => {
|
|
|
1263
1265
|
app.listen(3000)
|
|
1264
1266
|
```
|
|
1265
1267
|
|
|
1268
|
+
## MCP Apps (`appResources`)
|
|
1269
|
+
|
|
1270
|
+
The `appResources` option lets you serve interactive HTML UIs from your MCP server via the [MCP Apps extension](https://github.com/modelcontextprotocol/ext-apps). Each entry maps a `ui://` URI to an HTML app that renders in a sandboxed iframe in Mastra Studio.
|
|
1271
|
+
|
|
1272
|
+
### `AppResources` type
|
|
1273
|
+
|
|
1274
|
+
**Key (URI)** (`string`): A \`ui://\` URI that identifies the app resource (e.g., \`ui://calculator/main\`).
|
|
1275
|
+
|
|
1276
|
+
Each value is an `AppResource` object:
|
|
1277
|
+
|
|
1278
|
+
**name** (`string`): Display name for the UI resource.
|
|
1279
|
+
|
|
1280
|
+
**description** (`string`): Optional description of the UI resource.
|
|
1281
|
+
|
|
1282
|
+
**html** (`string`): Inline HTML content for the UI. Provide either \`html\` or \`htmlPath\`.
|
|
1283
|
+
|
|
1284
|
+
**htmlPath** (`string`): Path to an HTML file. Resolved at server startup. Provide either \`html\` or \`htmlPath\`.
|
|
1285
|
+
|
|
1286
|
+
**meta** (`McpUiResourceMeta`): UI resource metadata (CSP, permissions, rendering preferences) from the official ext-apps SDK.
|
|
1287
|
+
|
|
1288
|
+
### Example
|
|
1289
|
+
|
|
1290
|
+
```typescript
|
|
1291
|
+
import { MCPServer } from '@mastra/mcp'
|
|
1292
|
+
import { createTool } from '@mastra/core/tools'
|
|
1293
|
+
import { z } from 'zod'
|
|
1294
|
+
|
|
1295
|
+
const calculatorTool = createTool({
|
|
1296
|
+
id: 'calculatorWithUI',
|
|
1297
|
+
description: 'An interactive calculator',
|
|
1298
|
+
inputSchema: z.object({
|
|
1299
|
+
num1: z.number(),
|
|
1300
|
+
num2: z.number(),
|
|
1301
|
+
operation: z.enum(['add', 'subtract']),
|
|
1302
|
+
}),
|
|
1303
|
+
execute: async ({ num1, num2, operation }) => {
|
|
1304
|
+
const result = operation === 'add' ? num1 + num2 : num1 - num2
|
|
1305
|
+
return {
|
|
1306
|
+
content: [{ type: 'text', text: 'An interactive calculator is displayed.' }],
|
|
1307
|
+
structuredContent: { result },
|
|
1308
|
+
}
|
|
1309
|
+
},
|
|
1310
|
+
})
|
|
1311
|
+
|
|
1312
|
+
const server = new MCPServer({
|
|
1313
|
+
id: 'app-server',
|
|
1314
|
+
name: 'App Server',
|
|
1315
|
+
version: '1.0.0',
|
|
1316
|
+
tools: { calculatorTool },
|
|
1317
|
+
appResources: {
|
|
1318
|
+
'ui://calculator/main': {
|
|
1319
|
+
name: 'Interactive Calculator',
|
|
1320
|
+
html: '<html><body><h2>Calculator</h2>...</body></html>',
|
|
1321
|
+
},
|
|
1322
|
+
},
|
|
1323
|
+
})
|
|
1324
|
+
```
|
|
1325
|
+
|
|
1326
|
+
Link a tool to its app resource by setting `_meta.ui.resourceUri` on the tool to the matching `ui://` URI. The server auto-normalizes this metadata when registering tools.
|
|
1327
|
+
|
|
1328
|
+
> **Note:** Visit [MCP Apps](https://mastra.ai/docs/mcp/mcp-apps) for the full app bridge API and usage patterns.
|
|
1329
|
+
|
|
1266
1330
|
## Related information
|
|
1267
1331
|
|
|
1268
1332
|
- For connecting to MCP servers in Mastra, see the [MCPClient documentation](https://mastra.ai/reference/tools/mcp-client).
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.1.33-alpha.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`7679a63`](https://github.com/mastra-ai/mastra/commit/7679a634eae8e8ca459fd87538fdf72b4389b07f), [`7679a63`](https://github.com/mastra-ai/mastra/commit/7679a634eae8e8ca459fd87538fdf72b4389b07f), [`1d64a76`](https://github.com/mastra-ai/mastra/commit/1d64a765861a0772ea187bab76e5ed37bf82d042), [`7679a63`](https://github.com/mastra-ai/mastra/commit/7679a634eae8e8ca459fd87538fdf72b4389b07f), [`a0d9b6d`](https://github.com/mastra-ai/mastra/commit/a0d9b6d6b810aeaa9e177a0dcc99a4402e609634)]:
|
|
8
|
+
- @mastra/core@1.32.0-alpha.4
|
|
9
|
+
- @mastra/mcp@1.7.0-alpha.2
|
|
10
|
+
|
|
11
|
+
## 1.1.33-alpha.7
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`ca28c23`](https://github.com/mastra-ai/mastra/commit/ca28c232a2f18801a6cf20fe053479237b4d4fb0)]:
|
|
16
|
+
- @mastra/core@1.32.0-alpha.3
|
|
17
|
+
|
|
3
18
|
## 1.1.33-alpha.5
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.1.33-alpha.
|
|
3
|
+
"version": "1.1.33-alpha.8",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"jsdom": "^26.1.0",
|
|
30
30
|
"local-pkg": "^1.1.2",
|
|
31
31
|
"zod": "^4.3.6",
|
|
32
|
-
"@mastra/core": "1.32.0-alpha.
|
|
33
|
-
"@mastra/mcp": "^1.
|
|
32
|
+
"@mastra/core": "1.32.0-alpha.4",
|
|
33
|
+
"@mastra/mcp": "^1.7.0-alpha.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@hono/node-server": "^1.19.11",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"vitest": "4.1.5",
|
|
49
49
|
"@internal/lint": "0.0.90",
|
|
50
50
|
"@internal/types-builder": "0.0.65",
|
|
51
|
-
"@mastra/core": "1.32.0-alpha.
|
|
51
|
+
"@mastra/core": "1.32.0-alpha.4"
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://mastra.ai",
|
|
54
54
|
"repository": {
|