@mastra/mcp-docs-server 1.2.1-alpha.2 → 1.2.1-alpha.4

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.
Files changed (30) hide show
  1. package/.docs/docs/agents/background-tasks.md +89 -14
  2. package/.docs/docs/agents/durable-agents.md +231 -0
  3. package/.docs/docs/agents/using-tools.md +52 -0
  4. package/.docs/docs/getting-started/build-with-ai.md +273 -8
  5. package/.docs/docs/server/pubsub.md +2 -2
  6. package/.docs/docs/workflows/overview.md +71 -0
  7. package/.docs/guides/build-your-ui/ai-sdk-ui.md +3 -3
  8. package/.docs/guides/concepts/streaming.md +317 -0
  9. package/.docs/guides/getting-started/quickstart.md +1 -1
  10. package/.docs/models/index.md +1 -1
  11. package/.docs/models/providers/opencode.md +2 -1
  12. package/.docs/reference/agents/durable-agent.md +30 -1
  13. package/.docs/reference/agents/getDefaultOptions.md +1 -1
  14. package/.docs/reference/agents/getDefaultStreamOptions.md +1 -1
  15. package/.docs/reference/agents/inngest-agent.md +339 -0
  16. package/.docs/reference/ai-sdk/handle-workflow-stream.md +1 -1
  17. package/.docs/reference/ai-sdk/workflow-route.md +1 -1
  18. package/.docs/reference/index.md +1 -0
  19. package/.docs/reference/streaming/workflows/timeTravelStream.md +1 -1
  20. package/.docs/reference/tools/create-tool.md +1 -1
  21. package/.docs/reference/workflows/run.md +1 -1
  22. package/CHANGELOG.md +7 -0
  23. package/package.json +5 -5
  24. package/.docs/docs/build-with-ai/mcp-docs-server.md +0 -238
  25. package/.docs/docs/build-with-ai/skills.md +0 -63
  26. package/.docs/docs/streaming/background-task-streaming.md +0 -80
  27. package/.docs/docs/streaming/events.md +0 -148
  28. package/.docs/docs/streaming/overview.md +0 -136
  29. package/.docs/docs/streaming/tool-streaming.md +0 -189
  30. package/.docs/docs/streaming/workflow-streaming.md +0 -109
@@ -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. [Mastra Skills](https://mastra.ai/docs/build-with-ai/skills) contain setup instructions, best practices, and instructions on how to fetch up-to-date information from Mastra's documentation.
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
- Read the dedicated [Mastra Skills](https://mastra.ai/docs/build-with-ai/skills) guide to learn more about installation options and available skills.
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
- > **Tip:** If you're interested in giving 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.
39
+ They're also available on [GitHub](https://github.com/mastra-ai/skills).
36
40
 
37
- ## MCP docs server
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
- In addition to documentation access, the [MCP Docs Server](https://mastra.ai/docs/build-with-ai/mcp-docs-server) also provides tools to help you migrate to newer versions of Mastra or follow the [Mastra 101 course](https://mastra.ai/course).
57
+ **Yarn**:
58
+
59
+ ```bash
60
+ yarn dlx skills update mastra
61
+ ```
40
62
 
41
- Learn how to use the [MCP Docs Server](https://mastra.ai/docs/build-with-ai/mcp-docs-server).
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
+ [![Install MCP Server](https://cursor.com/deeplink/mcp-install-light.svg)](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
+ ![Popup inside Cursor showing: \"New MCP server detected: mastra\". The user can \"Skip\" or \"Enable\" it as an action.](/assets/images/enable-mastra-docs-cursor-cd5872abdc36c0e10951a59a47f25e12.png)
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
+ ![The Antigravity MCP store. At the top is a search bar and below a list of available MCP servers. On the very top right is a dropdown menu.](/assets/images/antigravity_mcp_server-689ea495d9c7139cc431f1f1b9827f9b.png)
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
+ ![The Antigravity MCP store showing the Manage MCP Servers option and the View raw config button.](/assets/images/antigravity_managed_mcp-b661e8c04b3219000f8d842e5eb26a1a.png)
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
+ ![The UI shows that the MCP server is enabled. You can also toggle individual tools.](/assets/images/antigravity_final_interface_mcp-7fa132dbe76cdee9f61136a26d6e6615.png)
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
+ ![Entry in VSCode\'s settings page. The option is called \"Chat \> MCP: Enabled (Preview)\". The description says: \"Enables integration with Model Context Protocol servers to provide additional tools and functionality.\"](/assets/images/vscode-mcp-setting-8d1eb4f3df1e33606503f8c5e937e9e3.png)
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
+ ![A screenshot of the mcp.json file showing the start button in the editor](/assets/images/vscode-start-mcp-26480d86080c4907cb497a325de106a4.png)
275
+
276
+ After starting the MCP server, select the tools button in the Copilot pane to see available tools.
277
+
278
+ ![Tools page of VSCode to see available tools](/assets/images/vscode-mcp-running-d92d6ed234d1148093dc804b0ead3515.png)
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/streaming/background-task-streaming).
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/streaming/background-task-streaming)
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.
@@ -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/streaming/workflow-streaming) for more details.
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/streaming/workflow-streaming).
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/streaming/tool-streaming).
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