@mastra/mcp-docs-server 1.1.35 → 1.1.36-alpha.3
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/agents/a2a.md +235 -0
- package/.docs/docs/agents/response-caching.md +11 -11
- package/.docs/docs/agents/signals.md +1 -1
- package/.docs/docs/deployment/cloud-providers.md +1 -1
- package/.docs/docs/deployment/overview.md +6 -5
- package/.docs/docs/mastra-platform/configuration.md +22 -6
- package/.docs/docs/mastra-platform/observability.md +99 -0
- package/.docs/docs/mastra-platform/overview.md +12 -55
- package/.docs/{guides/deployment/mastra-platform.md → docs/mastra-platform/server.md} +30 -37
- package/.docs/docs/mastra-platform/studio.md +81 -0
- package/.docs/docs/observability/overview.md +10 -5
- package/.docs/docs/observability/tracing/exporters/mastra-platform.md +13 -13
- package/.docs/docs/observability/tracing/exporters/mastra-storage.md +1 -1
- package/.docs/docs/observability/tracing/overview.md +4 -4
- package/.docs/docs/server/mastra-client.md +1 -0
- package/.docs/docs/server/mastra-server.md +2 -1
- package/.docs/docs/studio/deployment.md +1 -37
- package/.docs/docs/studio/observability.md +28 -23
- package/.docs/docs/studio/overview.md +3 -3
- package/.docs/guides/getting-started/quickstart.md +4 -4
- package/.docs/guides/migrations/mastra-cloud.md +8 -8
- package/.docs/guides/migrations/upgrade-to-v1/tracing.md +2 -2
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/alibaba-cn.md +1 -1
- package/.docs/models/providers/alibaba.md +1 -1
- package/.docs/models/providers/auriko.md +85 -0
- package/.docs/models/providers/claudinio.md +71 -0
- package/.docs/models/providers/deepinfra.md +3 -1
- package/.docs/models/providers/google.md +1 -1
- package/.docs/models/providers/kilo.md +1 -1
- package/.docs/models/providers/llmgateway.md +1 -1
- package/.docs/models/providers/wafer.ai.md +4 -6
- package/.docs/models/providers.md +2 -0
- package/.docs/reference/cli/create-mastra.md +6 -0
- package/.docs/reference/cli/mastra.md +30 -14
- package/.docs/reference/harness/harness-class.md +1 -1
- package/.docs/reference/observability/metrics/automatic-metrics.md +1 -1
- package/.docs/reference/observability/tracing/configuration.md +1 -1
- package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +2 -2
- package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +3 -3
- package/.docs/reference/observability/tracing/interfaces.md +1 -1
- package/CHANGELOG.md +14 -0
- package/package.json +4 -4
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# A2A (Agent-to-Agent)
|
|
2
|
+
|
|
3
|
+
Mastra supports the Agent-to-Agent (A2A) protocol for exposing agents as remote agents that other agents and services can discover, call, and track over time. A2A is useful when an agent needs to cross a network boundary without exposing the remote agent's internal tools, memory, prompts, or implementation.
|
|
4
|
+
|
|
5
|
+
## When to use A2A
|
|
6
|
+
|
|
7
|
+
- A parent agent should delegate work to a specialized agent owned by another service or team.
|
|
8
|
+
- A remote agent should keep its tools, prompts, memory, workflows, and infrastructure private.
|
|
9
|
+
- A backend, browser app, or another A2A-compatible system needs programmatic access to a Mastra agent.
|
|
10
|
+
- Long-running remote work needs task IDs, status updates, artifacts, cancellation, resubscription, or push notifications.
|
|
11
|
+
|
|
12
|
+
## How A2A works
|
|
13
|
+
|
|
14
|
+
A2A maps to the roles described in the [A2A core concepts](https://a2a-protocol.org/latest/topics/key-concepts/):
|
|
15
|
+
|
|
16
|
+
- **User**: The human, service, or process that asks for work.
|
|
17
|
+
- **Client agent**: The caller that discovers a remote agent, sends messages, and listens for task updates.
|
|
18
|
+
- **Remote agent**: The Mastra agent running behind an A2A endpoint.
|
|
19
|
+
|
|
20
|
+
Any registered Mastra agent can be called as an A2A remote agent. It keeps using its own instructions, tools, memory, workflows, and server configuration; A2A changes how the agent is reached, not how it's authored.
|
|
21
|
+
|
|
22
|
+
The flow is:
|
|
23
|
+
|
|
24
|
+
1. Register a standard Mastra agent in your `Mastra` instance.
|
|
25
|
+
2. Start Mastra Server or mount Mastra routes into your own server.
|
|
26
|
+
3. Mastra exposes the agent through an agent card at `/.well-known/:agentId/agent-card.json` and an execution endpoint at `/a2a/:agentId`.
|
|
27
|
+
4. A client reads the card, sends A2A JSON-RPC methods such as `message/send`, `message/stream`, `tasks/get`, `tasks/cancel`, or `tasks/resubscribe`, then receives task, artifact, and status events.
|
|
28
|
+
|
|
29
|
+
Agent cards describe the remote agent's name, description, provider, endpoint URL, capabilities, security metadata, and skills. Capabilities advertise features such as streaming and push notifications. Skills describe what the remote agent can do so callers can decide whether it fits the task.
|
|
30
|
+
|
|
31
|
+
A2A represents work as messages and tasks. Messages carry text, file, or structured data parts. Tasks are stateful units of work with IDs and lifecycle states, so clients can follow long-running work, send follow-up turns, cancel work, or resubscribe after a disconnect. Remote agents can also return artifacts, such as text, files, or structured data, during or after a task.
|
|
32
|
+
|
|
33
|
+
## Quickstart
|
|
34
|
+
|
|
35
|
+
Start with any agent registered in your `Mastra` instance. When Mastra Server runs, the agent is available as a remote A2A agent through its registered ID.
|
|
36
|
+
|
|
37
|
+
For an agent registered as `research-agent`, Mastra exposes:
|
|
38
|
+
|
|
39
|
+
- Agent card: `/.well-known/research-agent/agent-card.json`
|
|
40
|
+
- Execution endpoint: `/a2a/research-agent`
|
|
41
|
+
|
|
42
|
+
Use `MastraClient.getA2A()` to fetch the agent card and call the remote agent:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { MastraClient } from '@mastra/client-js'
|
|
46
|
+
|
|
47
|
+
const client = new MastraClient({
|
|
48
|
+
baseUrl: 'https://agent.example.com',
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
const a2a = client.getA2A('research-agent')
|
|
52
|
+
const card = await a2a.getAgentCard()
|
|
53
|
+
|
|
54
|
+
console.log(card.name, card.capabilities)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Discover and call remote agents
|
|
58
|
+
|
|
59
|
+
A2A discovery starts with the agent card. The [A2A discovery guide](https://a2a-protocol.org/latest/topics/agent-discovery/) describes well-known URI discovery, registries, and direct configuration. Mastra supports the well-known route for registered agents at `/.well-known/:agentId/agent-card.json`.
|
|
60
|
+
|
|
61
|
+
Use `sendMessageStream()` to receive task status and artifact updates over Server-Sent Events (SSE):
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
const stream = a2a.sendMessageStream({
|
|
65
|
+
message: {
|
|
66
|
+
kind: 'message',
|
|
67
|
+
role: 'user',
|
|
68
|
+
messageId: crypto.randomUUID(),
|
|
69
|
+
parts: [{ kind: 'text', text: 'Summarize this incident report.' }],
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
for await (const event of stream) {
|
|
74
|
+
if (event.kind === 'artifact-update') {
|
|
75
|
+
console.log(event.artifact.parts)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
If a stream disconnects while a task is still running, use `resubscribeTask()` to receive live updates for the in-progress task:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
const updates = a2a.resubscribeTask({
|
|
84
|
+
id: 'task-123',
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
for await (const event of updates) {
|
|
88
|
+
console.log(event)
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Agent cards can contain sensitive information, such as internal URLs or private skill descriptions. Protect restricted cards with access controls, and use agent card verification when a client needs to validate that a card came from a trusted source.
|
|
93
|
+
|
|
94
|
+
## Push notifications
|
|
95
|
+
|
|
96
|
+
Mastra supports A2A push notifications for remote agents that advertise `capabilities.pushNotifications`. Use push notifications when a client can't keep a stream open, or when a long-running task should update a callback URL after the original request ends.
|
|
97
|
+
|
|
98
|
+
After a client has a task ID, it can register a callback URL for that task:
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
await a2a.setTaskPushNotificationConfig({
|
|
102
|
+
taskId: 'task-123',
|
|
103
|
+
pushNotificationConfig: {
|
|
104
|
+
url: 'https://app.example.com/a2a/tasks',
|
|
105
|
+
token: process.env.A2A_WEBHOOK_TOKEN,
|
|
106
|
+
},
|
|
107
|
+
})
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Mastra Server sends the current task snapshot to registered callbacks when the task reaches `completed`, `failed`, `canceled`, or `input-required`. Push notification delivery is best-effort. Protect callback URLs, validate notification tokens, and avoid exposing internal network targets as push notification destinations.
|
|
111
|
+
|
|
112
|
+
## Sign and verify agent cards
|
|
113
|
+
|
|
114
|
+
Mastra supports signed A2A agent cards so clients can verify that a discovered card came from a trusted publisher and wasn't changed in transit. Configure signing on the Mastra server that exposes the remote agent:
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import { Mastra } from '@mastra/core/mastra'
|
|
118
|
+
|
|
119
|
+
export const mastra = new Mastra({
|
|
120
|
+
server: {
|
|
121
|
+
a2a: {
|
|
122
|
+
agentCardSigning: {
|
|
123
|
+
privateKey: process.env.A2A_AGENT_CARD_PRIVATE_KEY!,
|
|
124
|
+
protectedHeader: {
|
|
125
|
+
alg: 'ES256',
|
|
126
|
+
kid: 'agent-card-key',
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
})
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
When signing is configured, Mastra includes a `signatures` array on the agent card. Client verification is opt-in, and unsigned cards still return unchanged.
|
|
135
|
+
|
|
136
|
+
Verify a signed card with `MastraClient.getA2A()`:
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
const card = await a2a.getAgentCard({
|
|
140
|
+
verifySignature: {
|
|
141
|
+
algorithms: ['ES256'],
|
|
142
|
+
keyProvider: async ({ kid, jku }) => {
|
|
143
|
+
return fetchTrustedPublicJwk({ kid, jku })
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
})
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Use client-side signature verification to enforce trusted keys before calling the remote agent.
|
|
150
|
+
|
|
151
|
+
## Use remote agents as subagents
|
|
152
|
+
|
|
153
|
+
Use `A2AAgent` when a Mastra parent agent should call a remote A2A agent as a subagent. Create an `A2AAgent` with a remote agent card URL or single-agent domain, then register it in the parent agent's `agents` map.
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
import { Agent } from '@mastra/core/agent'
|
|
157
|
+
import { A2AAgent } from '@mastra/core/a2a'
|
|
158
|
+
|
|
159
|
+
const remoteWeatherAgent = new A2AAgent({
|
|
160
|
+
url: 'https://weather.example.com',
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
export const supportAgent = new Agent({
|
|
164
|
+
id: 'support-agent',
|
|
165
|
+
name: 'Support Agent',
|
|
166
|
+
instructions: 'Answer user questions and delegate weather questions when needed.',
|
|
167
|
+
model: 'openai/gpt-5.4',
|
|
168
|
+
agents: {
|
|
169
|
+
remoteWeatherAgent,
|
|
170
|
+
},
|
|
171
|
+
})
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
> **Tip:** If `url` points to a domain, `A2AAgent` fetches the agent card from `/.well-known/agent-card.json`. Use this for single-agent servers. For multi-agent servers, pass the explicit card URL, such as `https://agent.example.com/.well-known/:agentId/agent-card.json`. If `url` already ends with `/agent-card.json`, Mastra uses that URL directly. `A2AAgent` doesn't discover agent IDs beyond the URL you provide.
|
|
175
|
+
|
|
176
|
+
`A2AAgent` implements Mastra's subagent interface. The parent agent can call it like any other subagent, while `A2AAgent` handles the protocol details.
|
|
177
|
+
|
|
178
|
+
During execution, `A2AAgent`:
|
|
179
|
+
|
|
180
|
+
- Fetches and caches the remote agent card.
|
|
181
|
+
- Reads the execution URL and capabilities from the card.
|
|
182
|
+
- Calls `message/send` for non-streaming runs or `message/stream` when streaming is supported.
|
|
183
|
+
- Converts remote messages, tasks, artifacts, and status updates into Mastra subagent results.
|
|
184
|
+
- Supports `resumeGenerate()` and `resumeStream()` when the remote task requires follow-up input or resubscription.
|
|
185
|
+
|
|
186
|
+
If the remote card doesn't advertise streaming support, `A2AAgent.stream()` falls back to the non-streaming generate path and returns a buffered stream result.
|
|
187
|
+
|
|
188
|
+
## Configure subagent calls
|
|
189
|
+
|
|
190
|
+
`A2AAgent` accepts request options for authenticated or constrained environments:
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
import { A2AAgent } from '@mastra/core/a2a'
|
|
194
|
+
|
|
195
|
+
const remoteWeatherAgent = new A2AAgent({
|
|
196
|
+
url: 'https://weather.example.com',
|
|
197
|
+
headers: {
|
|
198
|
+
Authorization: `Bearer ${process.env.WEATHER_AGENT_TOKEN}`,
|
|
199
|
+
},
|
|
200
|
+
retries: 2,
|
|
201
|
+
backoffMs: 250,
|
|
202
|
+
maxBackoffMs: 1000,
|
|
203
|
+
timeoutMs: 30_000,
|
|
204
|
+
})
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
You can also pass `credentials`, `fetch`, and `abortSignal` when the runtime needs custom fetch behavior or request cancellation.
|
|
208
|
+
|
|
209
|
+
## Verify subagent cards
|
|
210
|
+
|
|
211
|
+
Use `verifyAgentCard` when a parent agent should validate a remote agent before delegating work to it. The verification hook receives the fetched agent card and context about where and when it was fetched.
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
import { A2AAgent } from '@mastra/core/a2a'
|
|
215
|
+
|
|
216
|
+
const remoteWeatherAgent = new A2AAgent({
|
|
217
|
+
url: 'https://weather.example.com/.well-known/agent-card.json',
|
|
218
|
+
verifyAgentCard: {
|
|
219
|
+
verify: async (card, context) => {
|
|
220
|
+
if (card.provider?.organization !== 'Weather Inc') {
|
|
221
|
+
throw new Error(`Unexpected provider for ${context.cardUrl}`)
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
})
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Use this hook to enforce expected providers, expected endpoints, certificate-bound identities, signed cards, or other trust requirements before a parent agent delegates to the remote agent.
|
|
229
|
+
|
|
230
|
+
## Related
|
|
231
|
+
|
|
232
|
+
- [Agent reference](https://mastra.ai/reference/agents/agent)
|
|
233
|
+
- [JavaScript client agents reference](https://mastra.ai/reference/client-js/agents)
|
|
234
|
+
- [A2A core concepts](https://a2a-protocol.org/latest/topics/key-concepts/)
|
|
235
|
+
- [A2A discovery guide](https://a2a-protocol.org/latest/topics/agent-discovery/)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Response
|
|
1
|
+
# Response Caching
|
|
2
2
|
|
|
3
|
-
Response caching skips the LLM call and replays a previously cached response when an agent receives an identical request. Use it to
|
|
3
|
+
Response caching skips the LLM call and replays a previously cached response when an agent receives an identical request. Use it to reduce latency and avoid paying for repeated calls.
|
|
4
4
|
|
|
5
|
-
Caching is implemented as the [`ResponseCache`](https://mastra.ai/reference/processors/response-cache) input processor.
|
|
5
|
+
Caching is implemented as the [`ResponseCache`](https://mastra.ai/reference/processors/response-cache) input processor. Mastra doesn't provide an agent-level option. To enable caching, register the processor explicitly. This keeps the API surface small while Mastra collects feedback; per-call overrides flow through `RequestContext`.
|
|
6
6
|
|
|
7
7
|
## When to use response caching
|
|
8
8
|
|
|
@@ -51,15 +51,15 @@ await agent.stream('hello', { requestContext: ctx })
|
|
|
51
51
|
|
|
52
52
|
Three fields are overridable per call:
|
|
53
53
|
|
|
54
|
-
- `key
|
|
55
|
-
- `scope
|
|
56
|
-
- `bust
|
|
54
|
+
- `key`: String or function. Overrides the auto-derived cache key for this request only.
|
|
55
|
+
- `scope`: String or `null`. Overrides the tenant/user scope for this request only. `null` opts out of scoping.
|
|
56
|
+
- `bust`: Boolean. Skips the cache read but still writes on completion (useful for "force refresh" buttons).
|
|
57
57
|
|
|
58
|
-
`cache`, `ttl`, and `agentId` stay on the constructor
|
|
58
|
+
`cache`, `ttl`, and `agentId` stay on the constructor. They're instance-level concerns and not safe to vary per call.
|
|
59
59
|
|
|
60
60
|
## Tenant scoping
|
|
61
61
|
|
|
62
|
-
By default, `ResponseCache` looks up `MASTRA_RESOURCE_ID_KEY` on the request context and uses it as the cache scope. This means an agent that already populates the resource id (e.g. via memory) gets per-user isolation automatically
|
|
62
|
+
By default, `ResponseCache` looks up `MASTRA_RESOURCE_ID_KEY` on the request context and uses it as the cache scope. This means an agent that already populates the resource id (e.g. via memory) gets per-user isolation automatically. Two users never see each other's cached responses.
|
|
63
63
|
|
|
64
64
|
Override explicitly when you need a different scope:
|
|
65
65
|
|
|
@@ -75,7 +75,7 @@ new Agent({
|
|
|
75
75
|
})
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
Pass `scope: null` to deliberately share entries across all callers
|
|
78
|
+
Pass `scope: null` to deliberately share entries across all callers. Only use this for known-public, non-personalized content.
|
|
79
79
|
|
|
80
80
|
## Custom cache backend
|
|
81
81
|
|
|
@@ -102,7 +102,7 @@ For a custom backend, extend `MastraServerCache` and implement its abstract meth
|
|
|
102
102
|
|
|
103
103
|
`ResponseCache` hooks into `processLLMRequest` (cache lookup, short-circuits on hit) and `processLLMResponse` (cache write on completion). Both run inside the agentic loop _after_ memory has loaded and earlier input processors have transformed the prompt.
|
|
104
104
|
|
|
105
|
-
This means the cache key is derived from the resolved `LanguageModelV2Prompt` Mastra is about to send to the model
|
|
105
|
+
This means the cache key is derived from the resolved `LanguageModelV2Prompt` Mastra is about to send to the model. The key is created _after_ memory has loaded and earlier input processors have run, and each step in an agentic tool loop is independently cached.
|
|
106
106
|
|
|
107
107
|
## What's in the cache key
|
|
108
108
|
|
|
@@ -137,7 +137,7 @@ If the function throws, the processor falls back to the default key derivation s
|
|
|
137
137
|
|
|
138
138
|
When the processor finds a cache hit, it short-circuits the LLM call by returning the cached chunks from `processLLMRequest`. The agentic loop synthesizes a stream from those chunks instead of calling the model. `agent.generate()` collects them into a `FullOutput`; `agent.stream()` returns a `MastraModelOutput` whose chunks come from the cached buffer, so consumers iterating `fullStream` or awaiting `text`, `usage`, and `finishReason` see the cached values.
|
|
139
139
|
|
|
140
|
-
Cache writes happen after the response completes. Failed runs (errors, tripwire activations)
|
|
140
|
+
Cache writes happen after the response completes. Failed runs (errors, tripwire activations) aren't cached, so the next call retries cleanly.
|
|
141
141
|
|
|
142
142
|
## Related
|
|
143
143
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Signals
|
|
2
2
|
|
|
3
|
-
> **Experimental:** Agent signals are experimental.
|
|
3
|
+
> **Experimental:** Agent signals are experimental. Breaking changes may occur without a major version bump until the API is stable.
|
|
4
4
|
|
|
5
5
|
Signals are a way to interact with an agent through a thread. Instead of starting every interaction with `agent.stream()`, subscribe to a thread and send signals. Mastra either wakes the agent when the thread is idle or drops the signal into the running agent loop.
|
|
6
6
|
|
|
@@ -4,7 +4,7 @@ Mastra applications can be deployed to cloud providers and serverless platforms.
|
|
|
4
4
|
|
|
5
5
|
## Mastra platform
|
|
6
6
|
|
|
7
|
-
Mastra provides a platform to deploy your server to the cloud. Read the [Mastra platform deployment guide](https://mastra.ai/
|
|
7
|
+
Mastra provides a platform to deploy your server to the cloud. Read the [Mastra platform deployment guide](https://mastra.ai/docs/mastra-platform/overview) to learn more.
|
|
8
8
|
|
|
9
9
|
## Cloud providers
|
|
10
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Deployment overview
|
|
2
2
|
|
|
3
|
-
Mastra applications can be deployed to any Node.js-compatible environment. You can deploy a Mastra server, integrate with an existing web framework, deploy to cloud providers, or use [Mastra platform](https://mastra.ai/docs/mastra-platform/overview) for Studio and server deployment.
|
|
3
|
+
Mastra applications can be deployed to any Node.js-compatible environment. You can deploy a Mastra server, integrate with an existing web framework, deploy to cloud providers, or use [Mastra platform](https://mastra.ai/docs/mastra-platform/overview) for observability, Studio, and server deployment.
|
|
4
4
|
|
|
5
5
|
## Runtime support
|
|
6
6
|
|
|
@@ -27,12 +27,13 @@ Read about [monorepo deployment](https://mastra.ai/docs/deployment/monorepo).
|
|
|
27
27
|
|
|
28
28
|
### Mastra platform
|
|
29
29
|
|
|
30
|
-
The [Mastra platform](https://mastra.ai/docs/mastra-platform/overview) provides
|
|
30
|
+
The [Mastra platform](https://mastra.ai/docs/mastra-platform/overview) provides three products for deploying, monitoring, and managing AI applications built with the Mastra framework:
|
|
31
31
|
|
|
32
|
-
- **
|
|
33
|
-
- **
|
|
32
|
+
- [**Observability**](https://mastra.ai/docs/mastra-platform/observability): A standalone hosted product for searchable traces, logs, and metrics across Mastra projects and deploys
|
|
33
|
+
- [**Studio**](https://mastra.ai/docs/mastra-platform/studio): A hosted visual environment for testing agents, running workflows, and inspecting traces
|
|
34
|
+
- [**Server**](https://mastra.ai/docs/mastra-platform/server): A production deployment target that runs your Mastra application as an API server
|
|
34
35
|
|
|
35
|
-
Learn more in the [
|
|
36
|
+
Learn more in the [Mastra platform overview](https://mastra.ai/docs/mastra-platform/overview).
|
|
36
37
|
|
|
37
38
|
### Cloud Providers
|
|
38
39
|
|
|
@@ -41,18 +41,34 @@ To pin the deploy to a specific env file (instead of relying on the default sele
|
|
|
41
41
|
mastra studio deploy --env-file .env.production --yes
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
+
### Observability
|
|
45
|
+
|
|
46
|
+
The following environment variables configure the Observability product on the Mastra platform.
|
|
47
|
+
|
|
48
|
+
| Variable | Description |
|
|
49
|
+
| ---------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
50
|
+
| `MASTRA_PLATFORM_ACCESS_TOKEN` | Org-scoped access token. The CLI writes this during observability provisioning and uses it for platform authentication. |
|
|
51
|
+
| `MASTRA_PROJECT_ID` | UUID of the platform project. `MastraPlatformExporter` uses it to link observability data to the platform project. Studio and Server deploys read the project ID from `.mastra-project.json`. |
|
|
52
|
+
| `MASTRA_PLATFORM_OBSERVABILITY_ENDPOINT` | Optional observability endpoint override. This is only set automatically for local platform development. Defaults to `https://observability.mastra.ai`. |
|
|
53
|
+
| `MASTRA_ORG_ID` | Overrides the active organization for CLI commands. You can also set it with the `--org` flag on supported commands. |
|
|
54
|
+
|
|
55
|
+
`MastraPlatformExporter` reads `MASTRA_PLATFORM_ACCESS_TOKEN` to authenticate platform export.
|
|
56
|
+
|
|
44
57
|
## Multiple environments
|
|
45
58
|
|
|
46
|
-
A platform project maps to a single deployed instance with one set of env vars.
|
|
59
|
+
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.
|
|
47
60
|
|
|
48
61
|
```bash
|
|
49
|
-
# Create
|
|
62
|
+
# Create and deploy each environment for the first time.
|
|
50
63
|
mastra studio deploy --project "my-app-staging" --env-file .env.staging --yes
|
|
51
64
|
mastra studio deploy --project "my-app-production" --env-file .env.production --yes
|
|
52
65
|
|
|
53
|
-
#
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
# For subsequent deploys, restore the matching .mastra-project.json file before deploying.
|
|
67
|
+
cp .mastra-project.staging.json .mastra-project.json
|
|
68
|
+
mastra studio deploy --env-file .env.staging --yes
|
|
69
|
+
|
|
70
|
+
cp .mastra-project.production.json .mastra-project.json
|
|
71
|
+
mastra studio deploy --env-file .env.production --yes
|
|
56
72
|
```
|
|
57
73
|
|
|
58
|
-
Each project has its own Studio URL and
|
|
74
|
+
Each project has its own Studio URL and can send observability data to the Mastra platform. When using [`MastraPlatformExporter`](https://mastra.ai/docs/observability/tracing/exporters/mastra-platform), set `MASTRA_PROJECT_ID` and `MASTRA_PLATFORM_ACCESS_TOKEN` per environment so traces route to the matching platform project.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Observability on Mastra platform
|
|
2
|
+
|
|
3
|
+
Observability on Mastra platform is a standalone hosted product for searchable traces, logs, and metrics across Mastra projects and deploys. Use it when you want observability without deploying Studio first or setting up local storage.
|
|
4
|
+
|
|
5
|
+
Mastra can configure platform observability during project setup. The CLI provisions a platform project, writes the required environment variables, and registers observability exporters in your Mastra config.
|
|
6
|
+
|
|
7
|
+
## Quickstart
|
|
8
|
+
|
|
9
|
+
Choose the setup path that matches your project. New and existing projects can use the CLI to provision Observability automatically, while manual setup is available when you already manage platform projects and environment variables yourself.
|
|
10
|
+
|
|
11
|
+
### New project
|
|
12
|
+
|
|
13
|
+
Create a new Mastra project:
|
|
14
|
+
|
|
15
|
+
**npm**:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm create mastra@latest
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**pnpm**:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pnpm create mastra
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Yarn**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
yarn create mastra
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Bun**:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
bunx create-mastra
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
When prompted, enable Mastra Observability:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
Enable Mastra Observability? (will open auth flow)
|
|
43
|
+
|
|
44
|
+
> Yes
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The CLI authenticates with Mastra platform, creates a platform project, writes the required environment variables, and configures the observability exporters.
|
|
48
|
+
|
|
49
|
+
### Existing non-Mastra projects
|
|
50
|
+
|
|
51
|
+
If you already have an application, such as a Next.js app, but have not added Mastra yet, run `mastra init` and enable Mastra Observability when prompted:
|
|
52
|
+
|
|
53
|
+
**npm**:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npx mastra init
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**pnpm**:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pnpm dlx mastra init
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Yarn**:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
yarn dlx mastra init
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Bun**:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
bun x mastra init
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The CLI can select an existing platform project or create a new one.
|
|
78
|
+
|
|
79
|
+
### Manual setup
|
|
80
|
+
|
|
81
|
+
Create a project in [Mastra Platform](https://projects.mastra.ai), add `MASTRA_PLATFORM_ACCESS_TOKEN` and `MASTRA_PROJECT_ID` to `.env`, then register `MastraPlatformExporter` in your Mastra config. Add `MastraStorageExporter` if you also want to persist observability events to your configured Mastra Storage:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { Mastra } from '@mastra/core/mastra'
|
|
85
|
+
import { Observability, MastraPlatformExporter } from '@mastra/observability'
|
|
86
|
+
|
|
87
|
+
export const mastra = new Mastra({
|
|
88
|
+
observability: new Observability({
|
|
89
|
+
configs: {
|
|
90
|
+
default: {
|
|
91
|
+
serviceName: 'mastra',
|
|
92
|
+
exporters: [new MastraPlatformExporter()],
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
})
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
See [Mastra platform configuration](https://mastra.ai/docs/mastra-platform/configuration) for the environment variables used by platform observability.
|
|
@@ -1,65 +1,22 @@
|
|
|
1
1
|
# Mastra platform
|
|
2
2
|
|
|
3
|
-
The [Mastra platform](https://projects.mastra.ai) provides
|
|
3
|
+
The [Mastra platform](https://projects.mastra.ai) provides three products for deploying, monitoring, and managing AI applications built with the Mastra framework:
|
|
4
4
|
|
|
5
|
-
- **
|
|
6
|
-
- **
|
|
5
|
+
- [**Observability**](https://mastra.ai/docs/mastra-platform/observability): The baseline product for every platform project, with searchable traces, logs, and metrics across Mastra projects and deploys
|
|
6
|
+
- [**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.
|
|
7
|
+
- [**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.
|
|
7
8
|
|
|
8
|
-
##
|
|
9
|
+
## Get started
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
Choose the path that matches what you want to do:
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
**npm**:
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
npm install -g mastra
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
**pnpm**:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
pnpm add -g mastra
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
**Yarn**:
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
yarn global add mastra
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
**Bun**:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
bun add --global mastra
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
3. Deploy Studio with a single command:
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
mastra studio deploy
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
On a successful deploy, the CLI will output the URL of your deployed Studio instance.
|
|
47
|
-
|
|
48
|
-
4. Deploy Server with a single command:
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
mastra server deploy
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
On a successful deploy, the CLI will output the URL of your deployed Server instance.
|
|
55
|
-
|
|
56
|
-
You have now successfully deployed both Studio and Server instances of your Mastra application. The CLI created a `.mastra-project.json` file in your project directory.
|
|
57
|
-
|
|
58
|
-
This file links your local project to a platform project. It's auto-generated on your first deploy and contains the `projectId`, `projectName`, and `organizationId`. Commit this file to your repository so CI/CD knows which project to deploy to.
|
|
13
|
+
- **Add hosted observability**: Use [Observability](https://mastra.ai/docs/mastra-platform/observability) to collect searchable traces, logs, and metrics across projects and deploys. Start here if you want monitoring without deploying Studio or Server first.
|
|
14
|
+
- **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.
|
|
15
|
+
- **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.
|
|
59
16
|
|
|
60
17
|
## Key Concepts
|
|
61
18
|
|
|
62
|
-
**Projects** are the shared parent entity across all products. A single project can have a Studio deployment and a Server deployment. Projects belong to an **Organization**, which is the multi-tenant container for your team.
|
|
19
|
+
**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.
|
|
63
20
|
|
|
64
21
|
Your Mastra application is built from three building blocks:
|
|
65
22
|
|
|
@@ -73,6 +30,6 @@ Develop your project locally with [`mastra dev`](https://mastra.ai/reference/cli
|
|
|
73
30
|
|
|
74
31
|
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.
|
|
75
32
|
|
|
76
|
-
Follow the [Studio
|
|
33
|
+
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.
|
|
77
34
|
|
|
78
|
-
If you host your Mastra application on your own infrastructure, you can still send observability data to
|
|
35
|
+
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/tracing/exporters/mastra-platform).
|