@mastra/mcp-docs-server 1.2.14 → 1.2.15-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 +36 -2
- package/.docs/docs/agents/processors.md +2 -0
- package/.docs/docs/capabilities/subagents.md +23 -5
- package/.docs/docs/connections/overview.md +94 -0
- package/.docs/docs/datasets/running-experiments.md +18 -0
- package/.docs/docs/harness/agent-controller.md +6 -0
- package/.docs/docs/harness/overview.md +26 -0
- package/.docs/docs/mcp/overview.md +10 -0
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +25 -14
- package/.docs/models/gateways/neon.md +17 -14
- package/.docs/models/gateways/openrouter.md +3 -1
- package/.docs/models/gateways/vercel.md +3 -2
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/anthropic.md +2 -2
- package/.docs/models/providers/deepinfra.md +4 -1
- package/.docs/models/providers/digitalocean.md +1 -1
- package/.docs/models/providers/friendli.md +8 -9
- package/.docs/models/providers/huggingface.md +4 -1
- package/.docs/models/providers/hyper.md +7 -7
- package/.docs/models/providers/kilo.md +7 -5
- package/.docs/models/providers/llmgateway.md +1 -1
- package/.docs/models/providers/meta.md +7 -5
- package/.docs/models/providers/minimax.md +25 -23
- package/.docs/models/providers/nano-gpt.md +5 -3
- package/.docs/models/providers/openai.md +28 -26
- package/.docs/models/providers/opencode.md +0 -1
- package/.docs/models/providers/perplexity-agent.md +24 -24
- package/.docs/models/providers/pioneer.md +27 -1
- package/.docs/models/providers/upstage.md +3 -2
- package/.docs/reference/agents/generate.md +1 -1
- package/.docs/reference/ai-sdk/chat-route.md +2 -0
- package/.docs/reference/client-js/observability.md +22 -0
- package/.docs/reference/file-based-agents/schedules.md +232 -0
- package/.docs/reference/index.md +1 -0
- package/.docs/reference/streaming/agents/stream.md +1 -1
- package/.docs/reference/tools/mcp-client.md +54 -0
- package/.docs/reference/workspace/workspace-class.md +2 -0
- package/CHANGELOG.md +15 -0
- package/package.json +6 -6
package/.docs/docs/agents/a2a.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# A2A (Agent-to-Agent)
|
|
4
4
|
|
|
5
|
-
Mastra supports the [Agent-to-Agent (A2A) protocol](https://a2a-protocol.org/latest/) for cross-platform multi-agent systems. Use A2A to expose Mastra agents as remote agents, consume remote A2A agents as Mastra subagents, or call A2A endpoints with the JavaScript client SDK.
|
|
5
|
+
Mastra supports version 0.3.0 of the [Agent-to-Agent (A2A) protocol](https://a2a-protocol.org/latest/) for cross-platform multi-agent systems. Use A2A to expose Mastra agents as remote agents, consume remote A2A agents as Mastra subagents, or call A2A endpoints with the JavaScript client SDK.
|
|
6
6
|
|
|
7
7
|
A2A is an open protocol for delegating work to agents across network, framework, vendor, and language boundaries. A remote agent keeps its own tools, prompts, memory, workflows, and infrastructure private while exposing a protocol endpoint that other systems can discover and call.
|
|
8
8
|
|
|
@@ -176,6 +176,38 @@ const remoteWeatherAgent = new A2AAgent({
|
|
|
176
176
|
|
|
177
177
|
You can also pass `credentials`, `fetch`, and `abortSignal` when the runtime needs custom fetch behavior or request cancellation.
|
|
178
178
|
|
|
179
|
+
## Human-in-the-loop
|
|
180
|
+
|
|
181
|
+
A2A models human-in-the-loop (HITL) work with the `input-required` task state. When a task pauses for input, the client provides the missing input by sending a follow-up message with the same `taskId`, and the server continues the task.
|
|
182
|
+
|
|
183
|
+
Mastra maps its agent suspension model to this state in both directions:
|
|
184
|
+
|
|
185
|
+
- **As a server**: when an exposed agent suspends, the task transitions to `input-required`. This includes suspensions caused by [tool approval](https://mastra.ai/docs/agents/agent-approval) or a tool that calls `suspend()`. The task status message includes a text prompt and a data part with the structured `suspendPayload` and `resumeSchema`. A follow-up `message/send` or `message/stream` request with the same `taskId` resumes the suspended run with the provided input.
|
|
186
|
+
- **As a client**: when a remote task reaches `input-required` or `auth-required`, `A2AAgent` returns a suspended result with `finishReason: 'suspended'` and a `suspendPayload`. Calling `resumeGenerate()` or `resumeStream()` sends the input or credentials back to the remote task with the original `taskId`.
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
import { A2AAgent } from '@mastra/core/a2a'
|
|
190
|
+
|
|
191
|
+
const agent = new A2AAgent({
|
|
192
|
+
url: 'https://agent.example.com/api/.well-known/booking-agent/agent-card.json',
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
const result = await agent.generate('Book a flight to Paris', { runId: 'run-1' })
|
|
196
|
+
|
|
197
|
+
if (result.finishReason === 'suspended') {
|
|
198
|
+
// Inspect result.suspendPayload, collect input from a human,
|
|
199
|
+
// then resume the remote task.
|
|
200
|
+
const resumed = await agent.resumeGenerate({ approved: true }, { runId: 'run-1' })
|
|
201
|
+
console.log(resumed.text)
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Follow-up messages for an `input-required` task can carry the resume data as a structured data part, or as JSON or plain text in a text part.
|
|
206
|
+
|
|
207
|
+
When a resumed run requires additional input, the task returns to `input-required` and the flow repeats. Resuming a suspended run requires storage configured on the Mastra server so the suspended run state can be restored across requests.
|
|
208
|
+
|
|
209
|
+
> **Note:** A2A task records live in an in-memory store, so a paused task can only be resumed by the same server process that suspended it. A server restart or a horizontally scaled deployment without sticky routing loses the task record, and a follow-up message fails with a task-not-found error.
|
|
210
|
+
|
|
179
211
|
## Push notifications
|
|
180
212
|
|
|
181
213
|
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.
|
|
@@ -192,7 +224,9 @@ await a2a.setTaskPushNotificationConfig({
|
|
|
192
224
|
})
|
|
193
225
|
```
|
|
194
226
|
|
|
195
|
-
Mastra Server sends the current task snapshot to registered callbacks when the task reaches `completed`, `failed`, `canceled`,
|
|
227
|
+
Mastra Server sends the current task snapshot to registered callbacks when the task reaches `completed`, `failed`, `canceled`, `rejected`, `input-required`, or `auth-required`. Push notification delivery is best-effort. Protect callback URLs, validate notification tokens, and avoid exposing internal network targets as push notification destinations.
|
|
228
|
+
|
|
229
|
+
Push notification configurations are stored in memory and must be registered again after a server restart.
|
|
196
230
|
|
|
197
231
|
## Sign and verify agent cards
|
|
198
232
|
|
|
@@ -544,6 +544,8 @@ This means the cache key is derived from the resolved `LanguageModelV2Prompt` Ma
|
|
|
544
544
|
|
|
545
545
|
When you don't supply `key`, the processor derives one deterministically from the inputs that change the LLM's response at this step: `agentId`, `stepNumber` (so each step in a tool loop has its own cache entry), `scope`, model identity (`provider`, `modelId`, spec version), and the resolved `prompt` (post-memory + post-processors). Any change to these inputs automatically invalidates the cache.
|
|
546
546
|
|
|
547
|
+
Multimodal prompts are included too. Image and file parts reach the key by value: a URL contributes its full href, and inline binary data (`Uint8Array`, `ArrayBuffer`) contributes a digest of its bytes. Two requests that differ only in which image they reference therefore get different cache entries.
|
|
548
|
+
|
|
547
549
|
#### Customize the cache key
|
|
548
550
|
|
|
549
551
|
Pass `key` as a function on the constructor or per-call to derive your own cache key from any subset of those inputs. The function receives the same inputs the deterministic hash would have consumed and returns a string (or a `Promise<string>`):
|
|
@@ -104,11 +104,29 @@ const stream = await parentAgent.stream('Research AI trends', {
|
|
|
104
104
|
|
|
105
105
|
The `context` object includes:
|
|
106
106
|
|
|
107
|
-
| Property
|
|
108
|
-
|
|
|
109
|
-
| `primitiveId`
|
|
110
|
-
| `prompt`
|
|
111
|
-
| `iteration`
|
|
107
|
+
| Property | Description |
|
|
108
|
+
| ---------------- | ------------------------------------------------- |
|
|
109
|
+
| `primitiveId` | The ID of the subagent being delegated to |
|
|
110
|
+
| `prompt` | The prompt the parent agent is sending |
|
|
111
|
+
| `iteration` | Current iteration number |
|
|
112
|
+
| `requestContext` | The request context the subagent run will receive |
|
|
113
|
+
|
|
114
|
+
### Request context at the delegation boundary
|
|
115
|
+
|
|
116
|
+
Each delegation receives a request context whose entries are shallowly copied from the parent run, excluding run-scoped identity keys. Setting or deleting entries during the subagent run does not affect the parent's context. Set entries on `context.requestContext` in `onDelegationStart` to pass values to the delegated run:
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
const stream = await parentAgent.stream('Research AI trends', {
|
|
120
|
+
maxSteps: 10,
|
|
121
|
+
delegation: {
|
|
122
|
+
onDelegationStart: async context => {
|
|
123
|
+
context.requestContext.set('audience', 'technical')
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
})
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The subagent reads these entries in its tools and dynamic configuration, such as `instructions: ({ requestContext }) => ...`. See [Request Context](https://mastra.ai/docs/server/request-context) for details. Values must be JSON-serializable to work with durable agents.
|
|
112
130
|
|
|
113
131
|
### `onDelegationComplete`
|
|
114
132
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Connections overview
|
|
4
|
+
|
|
5
|
+
Connections let Mastra work with remote agents, coding agents, provider software development kit (SDK) runtimes, and external tools and resources. Choose a connection type based on which system owns the agent runtime and what you need to exchange.
|
|
6
|
+
|
|
7
|
+
- [**Agent-to-Agent (A2A)**](https://mastra.ai/docs/agents/a2a): Expose or consume remote agents across service, framework, vendor, and language boundaries.
|
|
8
|
+
- [**Agent Client Protocol (ACP)**](https://mastra.ai/docs/agents/acp): Run compatible coding-agent processes as Mastra tools or subagents.
|
|
9
|
+
- [**SDK agents**](https://mastra.ai/docs/agents/sdk-agents): Register Claude, Cursor, or OpenAI SDK-backed agents while the provider SDK retains control of the runtime, tools, permissions, and agent loop.
|
|
10
|
+
- [**Model Context Protocol (MCP)**](https://mastra.ai/docs/mcp/overview): Connect agents to external tools and resources, or expose Mastra agents, tools, workflows, prompts, and resources to MCP-compatible systems.
|
|
11
|
+
|
|
12
|
+
## When to use connections
|
|
13
|
+
|
|
14
|
+
Use connections when you need to:
|
|
15
|
+
|
|
16
|
+
- Delegate work to an agent running in another service or runtime.
|
|
17
|
+
- Run a coding agent against a project workspace.
|
|
18
|
+
- Add a provider-native agent without replacing its SDK runtime or agent loop.
|
|
19
|
+
- Connect agents to external tools and resources or publish Mastra capabilities to other systems.
|
|
20
|
+
|
|
21
|
+
## Get started
|
|
22
|
+
|
|
23
|
+
Start with the boundary you need to cross. Use [A2A](https://mastra.ai/docs/agents/a2a) for remote agent endpoints, [ACP](https://mastra.ai/docs/agents/acp) for coding-agent processes, [SDK agents](https://mastra.ai/docs/agents/sdk-agents) for provider-owned runtimes, or [MCP](https://mastra.ai/docs/mcp/overview) for tools and resources.
|
|
24
|
+
|
|
25
|
+
**A2A**:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { A2AAgent } from '@mastra/core/a2a'
|
|
29
|
+
|
|
30
|
+
const agent = new A2AAgent({
|
|
31
|
+
url: 'https://agent.example.com/.well-known/agent-card.json',
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const result = await agent.generate('Summarize the latest report')
|
|
35
|
+
console.log(result.text)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**ACP**:
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { AcpAgent } from '@mastra/acp'
|
|
42
|
+
|
|
43
|
+
const agent = new AcpAgent({
|
|
44
|
+
id: 'coding-agent',
|
|
45
|
+
description: 'Inspects and edits code',
|
|
46
|
+
command: 'claude',
|
|
47
|
+
args: ['--acp'],
|
|
48
|
+
persistSession: false,
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
const result = await agent.generate('Review this project')
|
|
52
|
+
console.log(result.text)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**SDK agents**:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { OpenAISDKAgent } from '@mastra/openai'
|
|
59
|
+
|
|
60
|
+
const agent = new OpenAISDKAgent({
|
|
61
|
+
id: 'openai-agent',
|
|
62
|
+
description: 'Answers project questions',
|
|
63
|
+
sdkOptions: {
|
|
64
|
+
name: 'Project assistant',
|
|
65
|
+
model: 'gpt-5',
|
|
66
|
+
},
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
const result = await agent.generate('Explain agent loops in one sentence')
|
|
70
|
+
console.log(result.text)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**MCP**:
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { MCPClient } from '@mastra/mcp'
|
|
77
|
+
|
|
78
|
+
const client = new MCPClient({
|
|
79
|
+
id: 'wikipedia-client',
|
|
80
|
+
servers: {
|
|
81
|
+
wikipedia: {
|
|
82
|
+
command: 'npx',
|
|
83
|
+
args: ['-y', 'wikipedia-mcp'],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
const tools = await client.listTools()
|
|
90
|
+
console.log(Object.keys(tools))
|
|
91
|
+
} finally {
|
|
92
|
+
await client.disconnect()
|
|
93
|
+
}
|
|
94
|
+
```
|
|
@@ -58,6 +58,24 @@ const summary = await dataset.startExperiment({
|
|
|
58
58
|
|
|
59
59
|
Each item's `input` is passed directly to `agent.generate()`, so it must be a `string`, `string[]`, or `CoreMessage[]`.
|
|
60
60
|
|
|
61
|
+
#### Memory-enabled agents
|
|
62
|
+
|
|
63
|
+
When the target agent has its own memory and the request context carries a resource id (`MASTRA_RESOURCE_ID_KEY`, set by auth middleware, the experiment or item `requestContext`, or the Studio **Run Experiment** form), the experiment runner injects a fresh memory thread for each item. A resource id in the request context means "run as this resource": each item's conversation persists as a thread under that resource, and retried items get a new thread per attempt so earlier failed attempts can't leak into the retry's context.
|
|
64
|
+
|
|
65
|
+
Injected threads are tagged so you can map them back to the run: thread metadata carries the `experimentId` and the dataset item's id as `experimentItemId`. No thread title is generated for them.
|
|
66
|
+
|
|
67
|
+
Because the threads belong to the caller's resource, resource-scoped memory features both read and write that resource's state during the run:
|
|
68
|
+
|
|
69
|
+
- Resource-scoped working memory updates persist to the resource, and later items in the run see updates made by earlier items.
|
|
70
|
+
- Resource-scoped semantic recall can surface the resource's prior conversations to the experiment, and experiment transcripts become recallable in that resource's later conversations.
|
|
71
|
+
|
|
72
|
+
This is useful when you want to evaluate an agent against a real user's accumulated context. If you don't want experiment runs touching real user state, run the experiment with a dedicated evaluation resource id instead.
|
|
73
|
+
|
|
74
|
+
Thread injection is skipped in the following cases:
|
|
75
|
+
|
|
76
|
+
- If the request context also sets `MASTRA_THREAD_ID_KEY`, the runner uses that thread as-is, so every item (and retry) shares the same conversation.
|
|
77
|
+
- If the agent has no memory, or the request context has no resource id, the run is memoryless and nothing is persisted.
|
|
78
|
+
|
|
61
79
|
### Registered workflow
|
|
62
80
|
|
|
63
81
|
Point to a workflow registered on your Mastra instance:
|
|
@@ -322,6 +322,10 @@ const controller = new AgentController({
|
|
|
322
322
|
if (thread.isDM) return message.author.userId
|
|
323
323
|
return defaultResourceId
|
|
324
324
|
},
|
|
325
|
+
onSessionStart: async ({ session, thread }) => {
|
|
326
|
+
const plan = await billing.planFor(thread.resourceId)
|
|
327
|
+
await session.model.switch({ modelId: plan.modelId })
|
|
328
|
+
},
|
|
325
329
|
},
|
|
326
330
|
})
|
|
327
331
|
|
|
@@ -339,6 +343,8 @@ Point each platform webhook at the controller-specific route:
|
|
|
339
343
|
|
|
340
344
|
Each external chat thread maps to one controller Session and Mastra thread. By default, new sessions use a resource ID derived from the adapter's chat-thread ID, prefixed with `channel:`. Use `resolveResourceId` to map direct messages to an existing application user or choose another memory owner. The callback only affects new threads; an existing thread keeps its stored resource ID.
|
|
341
345
|
|
|
346
|
+
Channel sessions are created by the controller rather than by your code, so `onSessionStart` is where you configure them. It runs once per session, after the session is bound to its mapped thread and before the first message is handled. Use it to apply a model, memory settings, or session state that a channel session would otherwise miss. Later messages in the same thread reuse the session and don't call it again. Errors are logged and swallowed so a session that can't be configured still answers the message.
|
|
347
|
+
|
|
342
348
|
Controller channel sessions and auto-approval state are held in memory, so use a long-lived server. Pending approvals and live Session state don't survive process restarts. Adapters that can't render approval controls automatically run tools without an approval prompt so the run doesn't remain suspended.
|
|
343
349
|
|
|
344
350
|
See [Channels](https://mastra.ai/docs/capabilities/channels/overview) for adapter setup and platform-specific webhook configuration.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Harness overview
|
|
4
|
+
|
|
5
|
+
A harness lets an agent pursue long-running, complex goals while keeping its work durable, visible, and steerable. It preserves progress across retries and interruptions, while giving people and other systems a way to inspect progress, add context, approve actions, redirect the agent, or stop it.
|
|
6
|
+
|
|
7
|
+
In Mastra, harness refers to a set of capabilities for managing an agent beyond a single uninterrupted run. You can adopt these capabilities individually or combine them as needed.
|
|
8
|
+
|
|
9
|
+
[`AgentController`](https://mastra.ai/docs/harness/agent-controller) is a harness designed for interactive agent applications. It extends the base [`Agent`](https://mastra.ai/docs/agents/overview) loop with isolated sessions for each user or task, persistent threads and state, switchable modes and models, tool permissions and approvals, subagent orchestration, and streams for events and display state.
|
|
10
|
+
|
|
11
|
+
Agent harnesses are useful wherever work continues over time. Common examples include coding agents that carry changes through CI and review, software factories that coordinate many tasks in parallel, SRE agents that adapt as incidents evolve, and go-to-market agents that respond as accounts, signals, and conversations change.
|
|
12
|
+
|
|
13
|
+
## When to use a harness
|
|
14
|
+
|
|
15
|
+
Choose a starting point based on what the agent needs. You may use one capability or several.
|
|
16
|
+
|
|
17
|
+
| If you want to | Start here | Why |
|
|
18
|
+
| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
|
|
19
|
+
| Keep a run available through client disconnects or server restarts | [Durable Agents](https://mastra.ai/docs/long-running-agents/durable-agents) | Persist run state and let clients reconnect to its stream. |
|
|
20
|
+
| Run slow tools, workflows, or subagents without blocking | [Background Tasks](https://mastra.ai/docs/long-running-agents/background-tasks) | Finish work asynchronously and return its result to the agent. |
|
|
21
|
+
| Keep an agent working until it reaches an objective | [Goals](https://mastra.ai/docs/long-running-agents/goals) | Evaluate a thread-scoped objective until it's complete or reaches its run budget. |
|
|
22
|
+
| Start work automatically at recurring times | [Schedules](https://mastra.ai/docs/long-running-agents/schedules) | Start isolated runs or send prompts into an existing thread on a cron schedule. |
|
|
23
|
+
| Add context, redirect active work, or wake an idle thread | [Signals](https://mastra.ai/docs/long-running-agents/signals) | Deliver input now or hold it for the next turn. |
|
|
24
|
+
| React to changes in GitHub, Slack, continuous integration, or another external system | [Signal Providers](https://mastra.ai/docs/long-running-agents/signal-providers) | Track subscriptions and forward matching events to agent threads. |
|
|
25
|
+
| Build an interactive product with sessions, modes, state, approvals, and events | [AgentController](https://mastra.ai/docs/harness/agent-controller) | Host isolated sessions around a shared agent runtime. |
|
|
26
|
+
| Let users steer, queue follow-up work, or stop an interactive run | [AgentController](https://mastra.ai/docs/harness/agent-controller) | Expose run controls through each session. |
|
|
@@ -142,6 +142,16 @@ requireToolApproval: ({ toolName }) => toolName.startsWith('delete_')
|
|
|
142
142
|
|
|
143
143
|
Treat tool annotations from servers you don't control as untrusted hints. Visit [tool approval](https://mastra.ai/reference/tools/mcp-client) for the callback context and security guidance.
|
|
144
144
|
|
|
145
|
+
### Security
|
|
146
|
+
|
|
147
|
+
MCP servers run code and return content on your agent's behalf, so configure them with the same care as any other external dependency:
|
|
148
|
+
|
|
149
|
+
- **Stdio subprocess environment**: subprocesses inherit only the MCP SDK's curated environment whitelist (for example `PATH` and `HOME` on POSIX), not the full parent environment. Set `inheritDefaultEnv: false` on a server to pass only the variables you list in `env`.
|
|
150
|
+
- **Outbound host restriction**: when HTTP server URLs come from untrusted configuration, set `allowedHosts` to restrict which hosts the client will contact. On the default fetch path this also blocks redirect hops before they're sent; a custom `fetch` gets its final response URL validated after the request runs, so it must enforce redirect policy itself when preventing outbound contact is required.
|
|
151
|
+
- **Tool response trust**: tool results are untrusted model input. Use [input and output processors](https://mastra.ai/docs/agents/processors) to inspect or sanitize content before it reaches the model, and `requireToolApproval` to gate sensitive tools.
|
|
152
|
+
|
|
153
|
+
Visit the [MCPClient security reference](https://mastra.ai/reference/tools/mcp-client) for enforcement details of each option.
|
|
154
|
+
|
|
145
155
|
### MCP registries
|
|
146
156
|
|
|
147
157
|
Registries provide hosted or packaged MCP servers. The client configuration above works with registry endpoints and commands.
|
|
@@ -393,16 +393,17 @@ Use Custom UI when you want to:
|
|
|
393
393
|
|
|
394
394
|
Mastra streams data to the frontend as "parts" within messages. Each part has a `type` that determines how to render it. The `@mastra/ai-sdk` package transforms Mastra streams into AI SDK-compatible [UI Message DataParts](https://ai-sdk.dev/docs/reference/ai-sdk-core/ui-message#datauipart).
|
|
395
395
|
|
|
396
|
-
| Data Part Type
|
|
397
|
-
|
|
|
398
|
-
| `tool-{toolKey}`
|
|
399
|
-
| `data-workflow`
|
|
400
|
-
| `data-workflow-step`
|
|
401
|
-
| `data-network`
|
|
402
|
-
| `data-tool-agent`
|
|
403
|
-
| `data-tool-
|
|
404
|
-
| `data-tool-
|
|
405
|
-
| `data-
|
|
396
|
+
| Data Part Type | Source | Description |
|
|
397
|
+
| ---------------------- | ----------------------- | ---------------------------------------------------------------------------------- |
|
|
398
|
+
| `tool-{toolKey}` | AI SDK built-in | Tool invocation with states: `input-available`, `output-available`, `output-error` |
|
|
399
|
+
| `data-workflow` | `workflowRoute()` | Workflow execution state snapshots with step status and final outputs |
|
|
400
|
+
| `data-workflow-step` | `workflowRoute()` | Workflow step delta with the full payload for the changed step |
|
|
401
|
+
| `data-network` | `networkRoute()` | Agent network execution with ordered steps and outputs |
|
|
402
|
+
| `data-tool-agent` | Nested agent in tool | Compact nested-agent snapshot while the current step is still running |
|
|
403
|
+
| `data-tool-agent-step` | Nested agent in tool | Full nested-agent step payload emitted when a nested step finishes |
|
|
404
|
+
| `data-tool-workflow` | Nested workflow in tool | Workflow output streamed from within a tool's `execute()` |
|
|
405
|
+
| `data-tool-network` | Nested network in tool | Network output streamed from within a tool's `execute()` |
|
|
406
|
+
| `data-{custom}` | `writer.custom()` | Custom events for progress indicators, status updates, etc. |
|
|
406
407
|
|
|
407
408
|
### Rendering tool outputs
|
|
408
409
|
|
|
@@ -1256,7 +1257,7 @@ For a complete implementation, see the [workflow-suspend-resume example](https:/
|
|
|
1256
1257
|
|
|
1257
1258
|
### Nested agent streams in tools
|
|
1258
1259
|
|
|
1259
|
-
Tools can call agents internally and stream the agent's output back to the UI. This creates `data-tool-agent` parts
|
|
1260
|
+
Tools can call agents internally and stream the agent's output back to the UI. This creates compact `data-tool-agent` snapshots while the nested step is still running, `data-tool-agent-step` parts when a nested step finishes, and one full `data-tool-agent` snapshot when the nested run finishes.
|
|
1260
1261
|
|
|
1261
1262
|
The pattern uses:
|
|
1262
1263
|
|
|
@@ -1315,13 +1316,13 @@ export const forecastAgent = new Agent({
|
|
|
1315
1316
|
|
|
1316
1317
|
**Frontend**:
|
|
1317
1318
|
|
|
1318
|
-
Handle `data-tool-agent` parts
|
|
1319
|
+
Handle `data-tool-agent` parts for the live snapshot and `data-tool-agent-step` parts for the completed nested step payload.
|
|
1319
1320
|
|
|
1320
1321
|
```typescript
|
|
1321
1322
|
import { useChat } from '@ai-sdk/react'
|
|
1322
1323
|
import { DefaultChatTransport } from 'ai'
|
|
1323
1324
|
import { useState } from 'react'
|
|
1324
|
-
import type { AgentDataPart } from '@mastra/ai-sdk'
|
|
1325
|
+
import type { AgentDataPart, AgentStepDataPart } from '@mastra/ai-sdk'
|
|
1325
1326
|
|
|
1326
1327
|
export function NestedAgentChat() {
|
|
1327
1328
|
const [input, setInput] = useState('')
|
|
@@ -1361,6 +1362,15 @@ export function NestedAgentChat() {
|
|
|
1361
1362
|
</div>
|
|
1362
1363
|
)
|
|
1363
1364
|
}
|
|
1365
|
+
if (part.type === 'data-tool-agent-step') {
|
|
1366
|
+
const { data } = part as AgentStepDataPart
|
|
1367
|
+
return (
|
|
1368
|
+
<div key={index} className="nested-agent-step">
|
|
1369
|
+
<strong>Completed nested step {data.stepIndex + 1}</strong>
|
|
1370
|
+
{data.step.text && <p>{data.step.text}</p>}
|
|
1371
|
+
</div>
|
|
1372
|
+
)
|
|
1373
|
+
}
|
|
1364
1374
|
return null
|
|
1365
1375
|
})}
|
|
1366
1376
|
</div>
|
|
@@ -1373,7 +1383,8 @@ export function NestedAgentChat() {
|
|
|
1373
1383
|
Key points:
|
|
1374
1384
|
|
|
1375
1385
|
- Piping `fullStream` to `context.writer` creates `data-tool-agent` parts
|
|
1376
|
-
-
|
|
1386
|
+
- Read `data-tool-agent-step` when you need the full payload for the nested step that just finished
|
|
1387
|
+
- The `AgentDataPart` has `id` (on the part) and `data.text` (the current nested-agent text snapshot)
|
|
1377
1388
|
- The tool still returns its own output after the stream completes
|
|
1378
1389
|
|
|
1379
1390
|
For a complete implementation, see the [tool-nested-streams example](https://github.com/mastra-ai/ui-dojo/blob/main/src/pages/ai-sdk/tool-nested-streams.tsx) in UI Dojo.
|
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
# Neon
|
|
4
4
|
|
|
5
|
-
Neon aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
5
|
+
Neon aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 39 models through Mastra's model router.
|
|
6
6
|
|
|
7
7
|
Learn more in the [Neon documentation](https://neon.com/docs).
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
import { Agent } from
|
|
12
|
+
import { Agent } from "@mastra/core/agent";
|
|
13
13
|
|
|
14
14
|
const agent = new Agent({
|
|
15
|
-
id:
|
|
16
|
-
name:
|
|
17
|
-
instructions:
|
|
18
|
-
model:
|
|
19
|
-
})
|
|
15
|
+
id: "my-agent",
|
|
16
|
+
name: "My Agent",
|
|
17
|
+
instructions: "You are a helpful assistant",
|
|
18
|
+
model: "neon/claude-fable-5"
|
|
19
|
+
});
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
> **Info:** Mastra uses the OpenAI-compatible `/chat/completions` endpoint. Some provider-specific features may not be available. Check the [Neon documentation](https://neon.com/docs) for details.
|
|
@@ -33,37 +33,40 @@ NEON_AI_GATEWAY_TOKEN=your-gateway-key
|
|
|
33
33
|
|
|
34
34
|
| Model |
|
|
35
35
|
| ----------------------------- |
|
|
36
|
+
| `claude-fable-5` |
|
|
36
37
|
| `claude-haiku-4-5` |
|
|
37
38
|
| `claude-opus-4-1` |
|
|
38
39
|
| `claude-opus-4-5` |
|
|
39
40
|
| `claude-opus-4-6` |
|
|
40
41
|
| `claude-opus-4-7` |
|
|
41
42
|
| `claude-opus-4-8` |
|
|
42
|
-
| `claude-
|
|
43
|
+
| `claude-opus-5` |
|
|
43
44
|
| `claude-sonnet-4-5` |
|
|
44
45
|
| `claude-sonnet-4-6` |
|
|
45
|
-
| `
|
|
46
|
-
| `gemini-2-5-pro` |
|
|
46
|
+
| `claude-sonnet-5` |
|
|
47
47
|
| `gemini-3-1-flash-lite` |
|
|
48
48
|
| `gemini-3-1-pro` |
|
|
49
49
|
| `gemini-3-5-flash` |
|
|
50
50
|
| `gemini-3-flash` |
|
|
51
|
-
| `gemini-3-pro` |
|
|
52
51
|
| `gemma-3-12b` |
|
|
52
|
+
| `glm-5-2` |
|
|
53
53
|
| `gpt-5` |
|
|
54
54
|
| `gpt-5-1` |
|
|
55
|
-
| `gpt-5-1-codex-max` |
|
|
56
|
-
| `gpt-5-1-codex-mini` |
|
|
57
55
|
| `gpt-5-2` |
|
|
58
|
-
| `gpt-5-2-codex` |
|
|
59
56
|
| `gpt-5-3-codex` |
|
|
60
57
|
| `gpt-5-4` |
|
|
61
58
|
| `gpt-5-4-mini` |
|
|
62
59
|
| `gpt-5-4-nano` |
|
|
60
|
+
| `gpt-5-5` |
|
|
61
|
+
| `gpt-5-5-pro` |
|
|
62
|
+
| `gpt-5-6-luna` |
|
|
63
|
+
| `gpt-5-6-sol` |
|
|
64
|
+
| `gpt-5-6-terra` |
|
|
63
65
|
| `gpt-5-mini` |
|
|
64
66
|
| `gpt-5-nano` |
|
|
65
67
|
| `gpt-oss-120b` |
|
|
66
68
|
| `gpt-oss-20b` |
|
|
69
|
+
| `inkling` |
|
|
67
70
|
| `llama-4-maverick` |
|
|
68
71
|
| `meta-llama-3-1-8b-instruct` |
|
|
69
72
|
| `meta-llama-3-3-70b-instruct` |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# OpenRouter
|
|
4
4
|
|
|
5
|
-
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
5
|
+
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 339 models through Mastra's model router.
|
|
6
6
|
|
|
7
7
|
Learn more in the [OpenRouter documentation](https://openrouter.ai/models).
|
|
8
8
|
|
|
@@ -139,6 +139,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
139
139
|
| `inception/mercury-2` |
|
|
140
140
|
| `inclusionai/ling-2.6-1t` |
|
|
141
141
|
| `inclusionai/ling-2.6-flash` |
|
|
142
|
+
| `inclusionai/ling-3.0-flash` |
|
|
142
143
|
| `inclusionai/ling-3.0-flash:free` |
|
|
143
144
|
| `inclusionai/ring-2.6-1t` |
|
|
144
145
|
| `kwaipilot/kat-coder-air-v2.5` |
|
|
@@ -155,6 +156,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
155
156
|
| `meta-llama/llama-4-scout` |
|
|
156
157
|
| `meta-llama/llama-guard-4-12b` |
|
|
157
158
|
| `meta/muse-spark-1.1` |
|
|
159
|
+
| `meta/muse-spark-1.2` |
|
|
158
160
|
| `microsoft/phi-4` |
|
|
159
161
|
| `microsoft/wizardlm-2-8x22b` |
|
|
160
162
|
| `minimax/minimax-01` |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Vercel
|
|
4
4
|
|
|
5
|
-
Vercel aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
5
|
+
Vercel aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 316 models through Mastra's model router.
|
|
6
6
|
|
|
7
7
|
Learn more in the [Vercel documentation](https://ai-sdk.dev/providers/ai-sdk-providers).
|
|
8
8
|
|
|
@@ -88,7 +88,6 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
88
88
|
| `anthropic/claude-opus-4.8` |
|
|
89
89
|
| `anthropic/claude-opus-4.8-fast` |
|
|
90
90
|
| `anthropic/claude-opus-5` |
|
|
91
|
-
| `anthropic/claude-opus-5-fast` |
|
|
92
91
|
| `anthropic/claude-sonnet-4` |
|
|
93
92
|
| `anthropic/claude-sonnet-4.5` |
|
|
94
93
|
| `anthropic/claude-sonnet-4.6` |
|
|
@@ -182,6 +181,8 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
182
181
|
| `meta/llama-4-maverick` |
|
|
183
182
|
| `meta/llama-4-scout` |
|
|
184
183
|
| `meta/muse-spark-1.1` |
|
|
184
|
+
| `meta/muse-spark-1.2` |
|
|
185
|
+
| `meta/muse-spark-1.2-contributor` |
|
|
185
186
|
| `minimax/minimax-h3` |
|
|
186
187
|
| `minimax/minimax-m2` |
|
|
187
188
|
| `minimax/minimax-m2.1` |
|
package/.docs/models/index.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Model Providers
|
|
4
4
|
|
|
5
|
-
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to
|
|
5
|
+
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to 5378 models from 168 providers through a single API.
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Anthropic
|
|
4
4
|
|
|
5
|
-
Access
|
|
5
|
+
Access 13 Anthropic models through Mastra's model router. Authentication is handled automatically using the `ANTHROPIC_API_KEY` environment variable.
|
|
6
6
|
|
|
7
7
|
Learn more in the [Anthropic documentation](https://docs.anthropic.com/en/docs/about-claude/models).
|
|
8
8
|
|
|
@@ -123,7 +123,7 @@ const response = await agent.generate("Hello!", {
|
|
|
123
123
|
|
|
124
124
|
**inferenceGeo** (`"us" | "global" | undefined`)
|
|
125
125
|
|
|
126
|
-
**fallbacks** (`{ model: string; max_tokens?: number | undefined; thinking?: Record<string, unknown> | undefined; output_config?: Record<string, unknown> | undefined; speed?: "fast" | "standard" | undefined; }[] | undefined`)
|
|
126
|
+
**fallbacks** (`"default" | { model: string; max_tokens?: number | undefined; thinking?: Record<string, unknown> | undefined; output_config?: Record<string, unknown> | undefined; speed?: "fast" | "standard" | undefined; }[] | undefined`)
|
|
127
127
|
|
|
128
128
|
**anthropicBeta** (`string[] | undefined`)
|
|
129
129
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Deep Infra
|
|
4
4
|
|
|
5
|
-
Access
|
|
5
|
+
Access 51 Deep Infra models through Mastra's model router. Authentication is handled automatically using the `DEEPINFRA_API_KEY` environment variable.
|
|
6
6
|
|
|
7
7
|
Learn more in the [Deep Infra documentation](https://deepinfra.com/models).
|
|
8
8
|
|
|
@@ -35,6 +35,8 @@ for await (const chunk of stream) {
|
|
|
35
35
|
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
36
36
|
| ------------------------------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
37
37
|
| `deepinfra/deepseek-ai/DeepSeek-R1-0528` | 164K | | | | | | $0.50 | $2 |
|
|
38
|
+
| `deepinfra/deepseek-ai/DeepSeek-V3` | 164K | | | | | | $0.32 | $0.89 |
|
|
39
|
+
| `deepinfra/deepseek-ai/DeepSeek-V3.1` | 164K | | | | | | $0.25 | $0.95 |
|
|
38
40
|
| `deepinfra/deepseek-ai/DeepSeek-V3.2` | 164K | | | | | | $0.26 | $0.38 |
|
|
39
41
|
| `deepinfra/deepseek-ai/DeepSeek-V4-Flash` | 1.0M | | | | | | $0.09 | $0.18 |
|
|
40
42
|
| `deepinfra/deepseek-ai/DeepSeek-V4-Flash-0731` | 1.0M | | | | | | $0.09 | $0.18 |
|
|
@@ -54,6 +56,7 @@ for await (const chunk of stream) {
|
|
|
54
56
|
| `deepinfra/nvidia/Nemotron-3-Nano-30B-A3B` | 262K | | | | | | $0.05 | $0.20 |
|
|
55
57
|
| `deepinfra/openai/gpt-oss-120b` | 131K | | | | | | $0.04 | $0.17 |
|
|
56
58
|
| `deepinfra/openai/gpt-oss-20b` | 131K | | | | | | $0.03 | $0.14 |
|
|
59
|
+
| `deepinfra/Qwen/Qwen3-235B-A22B-Instruct-2507` | 262K | | | | | | $0.09 | $0.55 |
|
|
57
60
|
| `deepinfra/Qwen/Qwen3-32B` | 41K | | | | | | $0.08 | $0.28 |
|
|
58
61
|
| `deepinfra/Qwen/Qwen3-Coder-480B-A35B-Instruct-Turbo` | 262K | | | | | | $0.30 | $1 |
|
|
59
62
|
| `deepinfra/Qwen/Qwen3-Max` | 256K | | | | | | $1 | $6 |
|
|
@@ -76,7 +76,7 @@ for await (const chunk of stream) {
|
|
|
76
76
|
| `digitalocean/llama-4-maverick` | 128K | | | | | | $0.20 | $0.70 |
|
|
77
77
|
| `digitalocean/llama3-8b-instruct` | 131K | | | | | | $0.20 | $0.20 |
|
|
78
78
|
| `digitalocean/llama3.3-70b-instruct` | 128K | | | | | | $0.65 | $0.65 |
|
|
79
|
-
| `digitalocean/mimo-v2.5-pro` | 262K | | | | | | $0.
|
|
79
|
+
| `digitalocean/mimo-v2.5-pro` | 262K | | | | | | $0.40 | $2 |
|
|
80
80
|
| `digitalocean/minimax-m2.5` | 66K | | | | | | $0.23 | $0.90 |
|
|
81
81
|
| `digitalocean/ministral-3-8b-instruct-2512` | 262K | | | | | | — | — |
|
|
82
82
|
| `digitalocean/mistral-3-14B` | 262K | | | | | | $0.20 | $0.20 |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Friendli
|
|
4
4
|
|
|
5
|
-
Access
|
|
5
|
+
Access 5 Friendli models through Mastra's model router. Authentication is handled automatically using the `FRIENDLI_TOKEN` environment variable.
|
|
6
6
|
|
|
7
7
|
Learn more in the [Friendli documentation](https://friendli.ai/docs/guides/serverless_endpoints/introduction).
|
|
8
8
|
|
|
@@ -34,14 +34,13 @@ for await (const chunk of stream) {
|
|
|
34
34
|
|
|
35
35
|
## Models
|
|
36
36
|
|
|
37
|
-
| Model
|
|
38
|
-
|
|
|
39
|
-
| `friendli/deepseek-ai/DeepSeek-V3.2`
|
|
40
|
-
| `friendli/google/gemma-4-31B-it`
|
|
41
|
-
| `friendli/MiniMaxAI/MiniMax-M2.5`
|
|
42
|
-
| `friendli/
|
|
43
|
-
| `friendli/zai-org/GLM-5.
|
|
44
|
-
| `friendli/zai-org/GLM-5.2` | 1.0M | | | | | | $1 | $4 |
|
|
37
|
+
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
38
|
+
| ------------------------------------ | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
39
|
+
| `friendli/deepseek-ai/DeepSeek-V3.2` | 164K | | | | | | $0.50 | $2 |
|
|
40
|
+
| `friendli/google/gemma-4-31B-it` | 262K | | | | | | $0.14 | $0.40 |
|
|
41
|
+
| `friendli/MiniMaxAI/MiniMax-M2.5` | 197K | | | | | | $0.30 | $1 |
|
|
42
|
+
| `friendli/zai-org/GLM-5.1` | 203K | | | | | | $1 | $4 |
|
|
43
|
+
| `friendli/zai-org/GLM-5.2` | 1.0M | | | | | | $1 | $4 |
|
|
45
44
|
|
|
46
45
|
## Advanced configuration
|
|
47
46
|
|