@mastra/mcp-docs-server 1.2.1-alpha.2 → 1.2.1-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/agent-builder/overview.md +2 -0
- package/.docs/docs/agents/background-tasks.md +89 -14
- package/.docs/docs/agents/durable-agents.md +231 -0
- package/.docs/docs/agents/skills.md +186 -0
- package/.docs/docs/agents/using-tools.md +52 -0
- package/.docs/docs/evals/datasets/running-experiments.md +76 -0
- package/.docs/docs/getting-started/build-with-ai.md +273 -8
- package/.docs/docs/server/pubsub.md +2 -2
- package/.docs/docs/workflows/overview.md +71 -0
- package/.docs/docs/workspace/skills.md +9 -1
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +3 -3
- package/.docs/guides/concepts/streaming.md +317 -0
- package/.docs/guides/getting-started/quickstart.md +1 -1
- package/.docs/models/gateways/openrouter.md +2 -2
- package/.docs/models/gateways/vercel.md +10 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/baseten.md +1 -1
- package/.docs/models/providers/friendli.md +3 -2
- package/.docs/models/providers/lilac.md +7 -7
- package/.docs/models/providers/opencode.md +2 -1
- package/.docs/models/providers/siliconflow-cn.md +2 -1
- package/.docs/models/providers/wafer.ai.md +2 -1
- package/.docs/reference/agents/createSkill.md +78 -0
- package/.docs/reference/agents/durable-agent.md +30 -1
- package/.docs/reference/agents/getDefaultOptions.md +1 -1
- package/.docs/reference/agents/getDefaultStreamOptions.md +1 -1
- package/.docs/reference/agents/getSkill.md +58 -0
- package/.docs/reference/agents/inngest-agent.md +339 -0
- package/.docs/reference/agents/listSkills.md +53 -0
- package/.docs/reference/ai-sdk/handle-workflow-stream.md +1 -1
- package/.docs/reference/ai-sdk/workflow-route.md +1 -1
- package/.docs/reference/index.md +4 -0
- package/.docs/reference/processors/stream-error-retry-processor.md +32 -0
- package/.docs/reference/streaming/workflows/timeTravelStream.md +1 -1
- package/.docs/reference/tools/create-tool.md +1 -1
- package/.docs/reference/workflows/run.md +1 -1
- package/CHANGELOG.md +14 -0
- package/package.json +4 -4
- package/.docs/docs/build-with-ai/mcp-docs-server.md +0 -238
- package/.docs/docs/build-with-ai/skills.md +0 -63
- package/.docs/docs/streaming/background-task-streaming.md +0 -80
- package/.docs/docs/streaming/events.md +0 -148
- package/.docs/docs/streaming/overview.md +0 -136
- package/.docs/docs/streaming/tool-streaming.md +0 -189
- package/.docs/docs/streaming/workflow-streaming.md +0 -109
|
@@ -127,6 +127,82 @@ for (const item of summary.results) {
|
|
|
127
127
|
|
|
128
128
|
> **Info:** Visit the [Scorers overview](https://mastra.ai/docs/evals/overview) for details on available and custom scorers.
|
|
129
129
|
|
|
130
|
+
## Tool mocks
|
|
131
|
+
|
|
132
|
+
When an experiment runs an agent that calls side-effecting tools, you can make the run deterministic by attaching static tool mocks to individual dataset items. During the experiment, a mocked tool returns its declared output instead of executing. Tools that have no mock on the item run live.
|
|
133
|
+
|
|
134
|
+
Mocks live on the dataset item, so they version with the row and travel with the test case. Each mock declares a tool name, the arguments it expects, and the output to return:
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
await dataset.addItem({
|
|
138
|
+
input: 'What is the weather in Seattle?',
|
|
139
|
+
toolMocks: [
|
|
140
|
+
{
|
|
141
|
+
toolName: 'getWeather',
|
|
142
|
+
args: { city: 'Seattle' },
|
|
143
|
+
output: { temperature: 60, conditions: 'rainy' },
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
})
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Tool mocks are supported for `agent` targets only.
|
|
150
|
+
|
|
151
|
+
### Matching and consumption
|
|
152
|
+
|
|
153
|
+
Arguments are matched strictly: object key order is ignored, array order is significant, and there is no type coercion. A mock is served only when the agent calls the tool with arguments that deep-equal the mock's `args`.
|
|
154
|
+
|
|
155
|
+
When an item declares several mocks for the same tool and arguments, they are consumed in order — the first call gets the first mock, the next call gets the second, and so on. Ordering is tracked per `(toolName, args)` group and is independent across different arguments.
|
|
156
|
+
|
|
157
|
+
### Matching mode
|
|
158
|
+
|
|
159
|
+
By default each mock matches strictly on its `args`. Set `matchArgs: 'ignore'` to match on the tool name only — the mock's `args` are not compared and the next unconsumed mock for that tool is served regardless of how the agent called it:
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
const subAgentMock = {
|
|
163
|
+
toolName: 'agent-balanceAgent',
|
|
164
|
+
args: { prompt: 'look up the balance for YJ' },
|
|
165
|
+
output: { text: "YJ's balance is $100." },
|
|
166
|
+
matchArgs: 'ignore',
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
This is useful when a tool's arguments are noisy or generated by the model. The most common case is mocking a **sub-agent's response**: a delegated sub-agent is exposed to the parent as a tool named `agent-<name>`, and its arguments include an LLM-authored `prompt` plus runtime-injected fields. Mocking `agent-<name>` returns the canned response in place of running the sub-agent and its inner tools. When you create a mock from a trace, sub-agent delegation calls are derived with `matchArgs: 'ignore'` automatically; you can change it to `'strict'` to pin the exact arguments.
|
|
171
|
+
|
|
172
|
+
### Failures
|
|
173
|
+
|
|
174
|
+
A mocked tool call fails the item when the arguments do not match or all matching mocks have been consumed:
|
|
175
|
+
|
|
176
|
+
- `TOOL_MOCK_MISMATCH` — the tool was called with arguments that no mock matches.
|
|
177
|
+
- `TOOL_MOCK_EXHAUSTED` — every matching mock has already been consumed.
|
|
178
|
+
|
|
179
|
+
When a mocked tool is mis-called, the agent run is aborted immediately, so the model cannot go on to call any further tools — including unmocked, side-effecting tools that would otherwise run live. These failures are deterministic, so they are not retried. Mocks that are declared but never used do not fail the item — they are reported as unconsumed.
|
|
180
|
+
|
|
181
|
+
While an item has mocks, the agent's tools execute sequentially so repeated `(toolName, args)` mocks are consumed in the provider's call order. This serialization applies only to items that declare mocks.
|
|
182
|
+
|
|
183
|
+
### Diagnostics
|
|
184
|
+
|
|
185
|
+
Each item result carries a `toolMockReport` describing what the run did with the item's mocks:
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
for (const item of summary.results) {
|
|
189
|
+
const report = item.toolMockReport
|
|
190
|
+
if (!report) continue
|
|
191
|
+
|
|
192
|
+
console.log(report.served) // mocks matched and returned
|
|
193
|
+
console.log(report.unconsumed) // mocks declared but never used
|
|
194
|
+
console.log(report.liveCalls) // unmocked tools that ran live
|
|
195
|
+
console.log(report.failure) // the mismatch/exhausted failure, if any
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
In [Studio](https://mastra.ai/docs/studio/overview), edit a dataset item to author tool mocks as a JSON array, and open an experiment result to see the same report.
|
|
200
|
+
|
|
201
|
+
### Limitations
|
|
202
|
+
|
|
203
|
+
- **No tool span for mocked calls.** A mocked call returns its output before the tool executes, so it does not create a tool span. Trajectory scorers backed by stored traces may therefore not see mocked tool calls. Trajectory extraction that falls back to the agent's message output still sees them, so trajectory scoring can differ depending on your observability configuration.
|
|
204
|
+
- **Storage support.** Tool mocks and tool mock reports are persisted by the LibSQL, PostgreSQL, MongoDB, and Spanner adapters. The MySQL adapter does not support them and rejects writes that carry tool mocks or a tool mock report so the feature never silently runs tools live.
|
|
205
|
+
|
|
130
206
|
## Async experiments
|
|
131
207
|
|
|
132
208
|
`startExperiment()` blocks until every item completes. For long-running datasets, use [`startExperimentAsync()`](https://mastra.ai/reference/datasets/startExperimentAsync) to start the experiment in the background:
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
AI agents may not have up-to-date knowledge about Mastra's APIs, patterns, and best practices. These resources give your AI tools direct access to current Mastra documentation, enabling them to generate accurate code and help you build faster.
|
|
4
4
|
|
|
5
|
+
To give your agent access to Mastra's documentation, we recommend using **skills**. While the MCP docs server also provides this information, skills will perform better. Use the MCP docs server when you need its tools, e.g. the migration tool.
|
|
6
|
+
|
|
5
7
|
## Mastra skills
|
|
6
8
|
|
|
7
|
-
Agent Skills are folders of instructions, scripts, and resources that agents can discover and use to do things more accurately and efficiently.
|
|
9
|
+
Agent Skills are folders of instructions, scripts, and resources that agents can discover and use to do things more accurately and efficiently. Mastra skills contain setup instructions, best practices, CLI commands, and instructions on how to fetch up-to-date information from Mastra's documentation.
|
|
10
|
+
|
|
11
|
+
To install all available Mastra skills, run the following command:
|
|
8
12
|
|
|
9
13
|
**npm**:
|
|
10
14
|
|
|
@@ -30,15 +34,37 @@ yarn dlx skills add mastra-ai/skills
|
|
|
30
34
|
bun x skills add mastra-ai/skills
|
|
31
35
|
```
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
Mastra skills work with any coding agent that supports the [Skills standard](https://agentskills.io/), including Claude Code, Cursor, Codex, OpenCode, and others.
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
They're also available on [GitHub](https://github.com/mastra-ai/skills).
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
### Update skill
|
|
42
|
+
|
|
43
|
+
To update to the latest version of the Mastra skill, run:
|
|
44
|
+
|
|
45
|
+
**npm**:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx skills update mastra
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**pnpm**:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pnpm dlx skills update mastra
|
|
55
|
+
```
|
|
38
56
|
|
|
39
|
-
|
|
57
|
+
**Yarn**:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
yarn dlx skills update mastra
|
|
61
|
+
```
|
|
40
62
|
|
|
41
|
-
|
|
63
|
+
**Bun**:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
bun x skills update mastra
|
|
67
|
+
```
|
|
42
68
|
|
|
43
69
|
## Mastra CLI
|
|
44
70
|
|
|
@@ -75,7 +101,7 @@ mastra api --url http://localhost:4111 agent run weather-agent '{"messages":"Wha
|
|
|
75
101
|
mastra api --url http://localhost:4111 trace list
|
|
76
102
|
```
|
|
77
103
|
|
|
78
|
-
See the [CLI commands reference](https://mastra.ai/reference/cli/mastra) for the full list of available commands.
|
|
104
|
+
Install the [Mastra skills](#mastra-skills) to teach your agent how to use the CLI. See the [CLI commands reference](https://mastra.ai/reference/cli/mastra) for the full list of available commands.
|
|
79
105
|
|
|
80
106
|
## Embedded package docs
|
|
81
107
|
|
|
@@ -102,4 +128,243 @@ Examples for the [introduction page](https://mastra.ai/docs):
|
|
|
102
128
|
|
|
103
129
|
## Mastra's documentation
|
|
104
130
|
|
|
105
|
-
In addition to the [context files](#context-files) each documentation page also features a "Copy markdown" button at the top of the page. It'll copy the streamlined markdown version to your clipboard. Beside it, you'll find a dropdown menu to open the page on GitHub, in ChatGPT, Claude, and others.
|
|
131
|
+
In addition to the [context files](#context-files) each documentation page also features a "Copy markdown" button at the top of the page. It'll copy the streamlined markdown version to your clipboard. Beside it, you'll find a dropdown menu to open the page on GitHub, in ChatGPT, Claude, and others.
|
|
132
|
+
|
|
133
|
+
## MCP docs server
|
|
134
|
+
|
|
135
|
+
The `@mastra/mcp-docs-server` package provides direct access to Mastra’s full documentation via the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/docs/getting-started/intro). It works with Cursor, Windsurf, Cline, Claude Code, VS Code, Codex or any tool that supports MCP.
|
|
136
|
+
|
|
137
|
+
These tools are designed to help agents retrieve precise, task-specific information — whether you're adding a feature to an agent, scaffolding a new project, or exploring how something works.
|
|
138
|
+
|
|
139
|
+
In this guide you'll learn how to add Mastra's MCP server to your AI tooling.
|
|
140
|
+
|
|
141
|
+
[YouTube video player](https://www.youtube-nocookie.com/embed/vciV57lF0og)
|
|
142
|
+
|
|
143
|
+
### Installation
|
|
144
|
+
|
|
145
|
+
#### create-mastra
|
|
146
|
+
|
|
147
|
+
During the interactive [create-mastra](https://mastra.ai/reference/cli/create-mastra) wizard, choose one of your tools in the MCP step.
|
|
148
|
+
|
|
149
|
+
#### Manual setup
|
|
150
|
+
|
|
151
|
+
If there are no specific instructions for your tool below, you may be able to add the MCP server with this common JSON configuration anyways.
|
|
152
|
+
|
|
153
|
+
```json
|
|
154
|
+
{
|
|
155
|
+
"mcpServers": {
|
|
156
|
+
"mastra": {
|
|
157
|
+
"type": "stdio",
|
|
158
|
+
"command": "npx",
|
|
159
|
+
"args": ["-y", "@mastra/mcp-docs-server@latest"]
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
#### Claude Code CLI
|
|
166
|
+
|
|
167
|
+
Install using the terminal command:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
claude mcp add --scope project mastra -- npx -y @mastra/mcp-docs-server@latest
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
This creates a project-scoped `.mcp.json` file if one doesn't already exist. You can use the same command when using Claude Code as a [Visual Studio Code extension](https://code.claude.com/docs/en/vs-code#connect-to-external-tools-with-mcp).
|
|
174
|
+
|
|
175
|
+
[More info on using MCP servers with Claude Code](https://docs.claude.com/en/docs/claude-code/mcp)
|
|
176
|
+
|
|
177
|
+
#### OpenAI Codex CLI
|
|
178
|
+
|
|
179
|
+
1. Register it from the terminal:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
codex mcp add mastra-docs -- npx -y @mastra/mcp-docs-server@latest
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
2. Run `codex mcp list` to confirm the server shows as `enabled`.
|
|
186
|
+
|
|
187
|
+
[More info on using MCP servers with OpenAI Codex](https://developers.openai.com/codex/mcp)
|
|
188
|
+
|
|
189
|
+
#### Cursor
|
|
190
|
+
|
|
191
|
+
Install by selecting the button below:
|
|
192
|
+
|
|
193
|
+
[](cursor://anysphere.cursor-deeplink/mcp/install?name=mastra\&config=eyJjb21tYW5kIjoibnB4IC15IEBtYXN0cmEvbWNwLWRvY3Mtc2VydmVyIn0%3D)
|
|
194
|
+
|
|
195
|
+
If you followed the automatic installation, you'll see a popup when you open cursor in the bottom left corner to prompt you to enable the Mastra Docs MCP Server.
|
|
196
|
+
|
|
197
|
+

|
|
198
|
+
|
|
199
|
+
[More info on using MCP servers with Cursor](https://cursor.com/de/docs/context/mcp)
|
|
200
|
+
|
|
201
|
+
#### Antigravity
|
|
202
|
+
|
|
203
|
+
Google Antigravity is an agent-first development platform that supports MCP servers for accessing external documentation, APIs, and project context.
|
|
204
|
+
|
|
205
|
+
1. Open your Antigravity MCP configuration file:
|
|
206
|
+
|
|
207
|
+
- Click on **Agent session** and select the **“…” dropdown** at the top of the editor’s side panel, then select **MCP Servers** to access the **MCP Store**.
|
|
208
|
+
- You can access it through the MCP Store interface in Antigravity
|
|
209
|
+
|
|
210
|
+

|
|
211
|
+
|
|
212
|
+
2. To add a custom MCP server, select **Manage MCP Servers** at the top of the MCP Store and select **View raw config** in the main tab.
|
|
213
|
+
|
|
214
|
+

|
|
215
|
+
|
|
216
|
+
3. Add the Mastra MCP server configuration:
|
|
217
|
+
|
|
218
|
+
```json
|
|
219
|
+
{
|
|
220
|
+
"mcpServers": {
|
|
221
|
+
"mastra-docs": {
|
|
222
|
+
"command": "npx",
|
|
223
|
+
"args": ["-y", "@mastra/mcp-docs-server"]
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
4. Save the configuration and restart Antigravity
|
|
230
|
+
|
|
231
|
+

|
|
232
|
+
|
|
233
|
+
Once configured, the Mastra MCP server exposes the following to Antigravity agents:
|
|
234
|
+
|
|
235
|
+
- Indexed documentation and API schemas for Mastra, enabling programmatic retrieval of relevant context during code generation
|
|
236
|
+
- Access to example code snippets and usage patterns stored in Mastra Docs
|
|
237
|
+
- Structured data for error handling and debugging references in the editor
|
|
238
|
+
- Metadata about current Mastra project patterns for code suggestion and completion
|
|
239
|
+
|
|
240
|
+
The MCP server will appear in Antigravity's MCP Store, where you can manage its connection status and authentication if needed.
|
|
241
|
+
|
|
242
|
+
[More info on using MCP servers with Antigravity](https://antigravity.google)
|
|
243
|
+
|
|
244
|
+
#### Visual Studio Code
|
|
245
|
+
|
|
246
|
+
1. Create a `.vscode/mcp.json` file in your workspace
|
|
247
|
+
|
|
248
|
+
2. Insert the following configuration:
|
|
249
|
+
|
|
250
|
+
```json
|
|
251
|
+
{
|
|
252
|
+
"servers": {
|
|
253
|
+
"mastra": {
|
|
254
|
+
"type": "stdio",
|
|
255
|
+
"command": "npx",
|
|
256
|
+
"args": ["-y", "@mastra/mcp-docs-server@latest"]
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Once you installed the MCP server, you can use it like so:
|
|
263
|
+
|
|
264
|
+
1. Open VSCode settings.
|
|
265
|
+
|
|
266
|
+
2. Navigate to MCP settings.
|
|
267
|
+
|
|
268
|
+
3. Click "enable" on the Chat > MCP option.
|
|
269
|
+
|
|
270
|
+

|
|
271
|
+
|
|
272
|
+
MCP only works in Agent mode in VSCode. Once you are in agent mode, open the `mcp.json` file and select the "start" button. Note that the "start" button will only appear if the `.vscode` folder containing `mcp.json` is in your workspace root, or the highest level of the in-editor file explorer.
|
|
273
|
+
|
|
274
|
+

|
|
275
|
+
|
|
276
|
+
After starting the MCP server, select the tools button in the Copilot pane to see available tools.
|
|
277
|
+
|
|
278
|
+

|
|
279
|
+
|
|
280
|
+
[More info on using MCP servers with Visual Studio Code](https://code.visualstudio.com/docs/copilot/customization/mcp-servers)
|
|
281
|
+
|
|
282
|
+
#### Windsurf
|
|
283
|
+
|
|
284
|
+
1. Open `~/.codeium/windsurf/mcp_config.json` in your editor
|
|
285
|
+
|
|
286
|
+
2. Insert the following configuration:
|
|
287
|
+
|
|
288
|
+
```json
|
|
289
|
+
{
|
|
290
|
+
"mcpServers": {
|
|
291
|
+
"mastra": {
|
|
292
|
+
"command": "npx",
|
|
293
|
+
"args": ["-y", "@mastra/mcp-docs-server@latest"]
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
3. Save the configuration and restart Windsurf
|
|
300
|
+
|
|
301
|
+
[More info on using MCP servers with Windsurf](https://docs.windsurf.com/windsurf/cascade/mcp#mcp-config-json)
|
|
302
|
+
|
|
303
|
+
#### OpenCode
|
|
304
|
+
|
|
305
|
+
You can define MCP servers in your [OpenCode configuration](https://opencode.ai/docs/config/) under `mcp`. Create an `opencode.jsonc` file in your project root with the following content:
|
|
306
|
+
|
|
307
|
+
```json
|
|
308
|
+
{
|
|
309
|
+
"$schema": "https://opencode.ai/config.json",
|
|
310
|
+
"mcp": {
|
|
311
|
+
"mastra": {
|
|
312
|
+
"type": "local",
|
|
313
|
+
"command": ["npx", "-y", "@mastra/mcp-docs-server@latest"],
|
|
314
|
+
"enabled": true
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
[More info on using MCP servers with OpenCode](https://opencode.ai/docs/mcp-servers)
|
|
321
|
+
|
|
322
|
+
#### Zed
|
|
323
|
+
|
|
324
|
+
1. Open `~/.config/zed/settings.json` in your editor
|
|
325
|
+
2. Insert the following configuration:
|
|
326
|
+
|
|
327
|
+
```json
|
|
328
|
+
{
|
|
329
|
+
"context_servers": {
|
|
330
|
+
"Mastra": {
|
|
331
|
+
"command": "npx",
|
|
332
|
+
"args": ["-y", "@mastra/mcp-docs-server@latest"]
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Usage
|
|
339
|
+
|
|
340
|
+
Once configured, you can ask your AI tool questions about Mastra or instruct it to take actions. For these steps, it'll take the up-to-date information from Mastra's MCP server.
|
|
341
|
+
|
|
342
|
+
**Add features:**
|
|
343
|
+
|
|
344
|
+
- "Add evals to my agent and write tests"
|
|
345
|
+
- "Write me a workflow that does the following `[task]`"
|
|
346
|
+
- "Make a new tool that allows my agent to access `[3rd party API]`"
|
|
347
|
+
|
|
348
|
+
**Ask about integrations:**
|
|
349
|
+
|
|
350
|
+
- "Does Mastra work with the AI SDK? How can I use it in my `[React/Svelte/etc]` project?"
|
|
351
|
+
- "Does Mastra support `[provider]` speech and voice APIs? Show me an example in my code of how I can use it."
|
|
352
|
+
|
|
353
|
+
**Debug or update existing code:**
|
|
354
|
+
|
|
355
|
+
- "I'm running into a bug with agent memory, have there been any related changes or bug fixes recently?"
|
|
356
|
+
- "How does working memory behave in Mastra and how can I use it to do `[task]`? It doesn't seem to work the way I expect."
|
|
357
|
+
- "I saw there are new workflow features, explain them to me and then update `[workflow]` to use them."
|
|
358
|
+
|
|
359
|
+
#### Troubleshooting
|
|
360
|
+
|
|
361
|
+
1. **Server Not Starting**
|
|
362
|
+
|
|
363
|
+
- Ensure [npx](https://docs.npmjs.com/cli/v11/commands/npx) is installed and working.
|
|
364
|
+
- Check for conflicting MCP servers.
|
|
365
|
+
- Verify your configuration file syntax.
|
|
366
|
+
|
|
367
|
+
2. **Tool Calls Failing**
|
|
368
|
+
|
|
369
|
+
- Restart the MCP server and/or your IDE.
|
|
370
|
+
- Update to the latest version of your IDE.
|
|
@@ -10,7 +10,7 @@ Several built-in systems publish and subscribe to events through the same pub/su
|
|
|
10
10
|
|
|
11
11
|
- **Workflow execution**: The scheduler publishes a `workflow.start` event, and a long-lived worker consumes it to run the workflow. Step and lifecycle events flow over pub/sub during execution.
|
|
12
12
|
- **Scheduled workflows**: The scheduler dispatches due runs by publishing to the workflow topic. See [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows).
|
|
13
|
-
- **Background tasks**: A task manager dispatches work to a worker group and fans task lifecycle updates out to subscribers, which is how background task streams stay live. See [Background task streaming](https://mastra.ai/docs/
|
|
13
|
+
- **Background tasks**: A task manager dispatches work to a worker group and fans task lifecycle updates out to subscribers, which is how background task streams stay live. See [Background task streaming](https://mastra.ai/docs/agents/background-tasks).
|
|
14
14
|
- **Agent signals**: Sending a signal to an active agent run publishes an event on a thread topic, so a run executing in another process receives the signal.
|
|
15
15
|
- **Resumable streams**: Stream chunks are published per run, so a client that reconnects can replay what it missed.
|
|
16
16
|
|
|
@@ -120,5 +120,5 @@ export const mastra = new Mastra({
|
|
|
120
120
|
|
|
121
121
|
- [PubSub reference](https://mastra.ai/reference/pubsub/base)
|
|
122
122
|
- [Mastra class](https://mastra.ai/reference/core/mastra-class)
|
|
123
|
-
- [Background task streaming](https://mastra.ai/docs/
|
|
123
|
+
- [Background task streaming](https://mastra.ai/docs/agents/background-tasks)
|
|
124
124
|
- [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows)
|
|
@@ -405,6 +405,77 @@ Here's an example of a successful workflow result, showing the `input`, `steps`,
|
|
|
405
405
|
}
|
|
406
406
|
```
|
|
407
407
|
|
|
408
|
+
## Streaming
|
|
409
|
+
|
|
410
|
+
For generic `writer` API usage, see [Streaming](https://mastra.ai/guides/concepts/streaming).
|
|
411
|
+
|
|
412
|
+
### Inspecting workflow stream payloads
|
|
413
|
+
|
|
414
|
+
Events written to the stream are included in the emitted chunks. These chunks can be inspected to access any custom fields, such as event types, intermediate values, or step-specific data.
|
|
415
|
+
|
|
416
|
+
```typescript
|
|
417
|
+
const testWorkflow = mastra.getWorkflow('testWorkflow')
|
|
418
|
+
|
|
419
|
+
const run = await testWorkflow.createRun()
|
|
420
|
+
|
|
421
|
+
const stream = await run.stream({
|
|
422
|
+
inputData: {
|
|
423
|
+
value: 'initial data',
|
|
424
|
+
},
|
|
425
|
+
})
|
|
426
|
+
|
|
427
|
+
for await (const chunk of stream) {
|
|
428
|
+
console.log(chunk)
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
if (result!.status === 'suspended') {
|
|
432
|
+
// if the workflow is suspended, we can resume it with the resumeStream method
|
|
433
|
+
const resumedStream = await run.resumeStream({
|
|
434
|
+
resumeData: { value: 'resume data' },
|
|
435
|
+
})
|
|
436
|
+
|
|
437
|
+
for await (const chunk of resumedStream) {
|
|
438
|
+
console.log(chunk)
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
### Resuming an interrupted workflow stream
|
|
444
|
+
|
|
445
|
+
If a workflow stream is closed or interrupted for any reason, you can resume it with the `resumeStream` method. This will return a new `ReadableStream` that you can use to observe the workflow events.
|
|
446
|
+
|
|
447
|
+
```typescript
|
|
448
|
+
const newStream = await run.resumeStream()
|
|
449
|
+
|
|
450
|
+
for await (const chunk of newStream) {
|
|
451
|
+
console.log(chunk)
|
|
452
|
+
}
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
### Workflow using an agent
|
|
456
|
+
|
|
457
|
+
Pipe an agent's `textStream` to the workflow step's `writer`. This streams partial output, and Mastra automatically aggregates the agent's usage into the workflow run.
|
|
458
|
+
|
|
459
|
+
```typescript
|
|
460
|
+
import { createStep } from '@mastra/core/workflows'
|
|
461
|
+
import { z } from 'zod'
|
|
462
|
+
|
|
463
|
+
export const testStep = createStep({
|
|
464
|
+
execute: async ({ inputData, mastra, writer }) => {
|
|
465
|
+
const { city } = inputData
|
|
466
|
+
|
|
467
|
+
const testAgent = mastra?.getAgent('testAgent')
|
|
468
|
+
const stream = await testAgent?.stream(`What is the weather in ${city}?`)
|
|
469
|
+
|
|
470
|
+
await stream!.textStream.pipeTo(writer!)
|
|
471
|
+
|
|
472
|
+
return {
|
|
473
|
+
value: await stream!.text,
|
|
474
|
+
}
|
|
475
|
+
},
|
|
476
|
+
})
|
|
477
|
+
```
|
|
478
|
+
|
|
408
479
|
## Restarting active workflow runs
|
|
409
480
|
|
|
410
481
|
When a workflow run loses connection to the server, it can be restarted from the last active step. This is useful for long-running workflows that might still be running when the server loses connection. Restarting a workflow run will resume execution from the last active step, and the workflow will continue from there.
|
|
@@ -187,8 +187,16 @@ const workspace = new Workspace({
|
|
|
187
187
|
|
|
188
188
|
When `skillSource` is provided, it's used instead of the workspace filesystem for skill discovery.
|
|
189
189
|
|
|
190
|
+
## Agent-level skills
|
|
191
|
+
|
|
192
|
+
You can also attach skills directly to an agent without a workspace using `createSkill()` and the agent's `skills` config. When both agent-level and workspace-level skills exist, they merge — agent-level skills take precedence on name conflicts.
|
|
193
|
+
|
|
194
|
+
See [Agent skills](https://mastra.ai/docs/agents/skills) for details.
|
|
195
|
+
|
|
190
196
|
## Related
|
|
191
197
|
|
|
198
|
+
- [Agent skills](https://mastra.ai/docs/agents/skills)
|
|
192
199
|
- [Agent skills specification](https://agentskills.io)
|
|
193
200
|
- [Workspace overview](https://mastra.ai/docs/workspace/overview)
|
|
194
|
-
- [Search and indexing](https://mastra.ai/docs/workspace/search)
|
|
201
|
+
- [Search and indexing](https://mastra.ai/docs/workspace/search)
|
|
202
|
+
- [`createSkill()` reference](https://mastra.ai/reference/agents/createSkill)
|
|
@@ -103,7 +103,7 @@ You can also use dynamic workflow routing, see the [`workflowRoute()` reference
|
|
|
103
103
|
|
|
104
104
|
> **Agent streaming in workflows:** When a workflow step pipes an agent's stream to the workflow writer (e.g., `await response.fullStream.pipeTo(writer)`), the agent's text chunks and tool calls are forwarded to the UI stream in real time, even when the agent runs inside workflow steps.
|
|
105
105
|
>
|
|
106
|
-
> See [Workflow Streaming](https://mastra.ai/docs/
|
|
106
|
+
> See [Workflow Streaming](https://mastra.ai/docs/workflows/overview) for more details.
|
|
107
107
|
|
|
108
108
|
**networkRoute()**:
|
|
109
109
|
|
|
@@ -676,7 +676,7 @@ export function WorkflowChat() {
|
|
|
676
676
|
}
|
|
677
677
|
```
|
|
678
678
|
|
|
679
|
-
For more details on workflow streaming, see [Workflow Streaming](https://mastra.ai/docs/
|
|
679
|
+
For more details on workflow streaming, see [Workflow Streaming](https://mastra.ai/docs/workflows/overview).
|
|
680
680
|
|
|
681
681
|
### Rendering network data
|
|
682
682
|
|
|
@@ -906,7 +906,7 @@ export function TaskChat() {
|
|
|
906
906
|
|
|
907
907
|
### Tool streaming
|
|
908
908
|
|
|
909
|
-
Tools can also stream data using `context.writer.write()` for lower-level control, or pipe an agent's stream directly to the tool's writer. For more details, see [Tool Streaming](https://mastra.ai/docs/
|
|
909
|
+
Tools can also stream data using `context.writer.write()` for lower-level control, or pipe an agent's stream directly to the tool's writer. For more details, see [Tool Streaming](https://mastra.ai/docs/agents/using-tools).
|
|
910
910
|
|
|
911
911
|
### Examples
|
|
912
912
|
|