@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.
Files changed (45) hide show
  1. package/.docs/docs/agent-builder/overview.md +2 -0
  2. package/.docs/docs/agents/background-tasks.md +89 -14
  3. package/.docs/docs/agents/durable-agents.md +231 -0
  4. package/.docs/docs/agents/skills.md +186 -0
  5. package/.docs/docs/agents/using-tools.md +52 -0
  6. package/.docs/docs/evals/datasets/running-experiments.md +76 -0
  7. package/.docs/docs/getting-started/build-with-ai.md +273 -8
  8. package/.docs/docs/server/pubsub.md +2 -2
  9. package/.docs/docs/workflows/overview.md +71 -0
  10. package/.docs/docs/workspace/skills.md +9 -1
  11. package/.docs/guides/build-your-ui/ai-sdk-ui.md +3 -3
  12. package/.docs/guides/concepts/streaming.md +317 -0
  13. package/.docs/guides/getting-started/quickstart.md +1 -1
  14. package/.docs/models/gateways/openrouter.md +2 -2
  15. package/.docs/models/gateways/vercel.md +10 -1
  16. package/.docs/models/index.md +1 -1
  17. package/.docs/models/providers/baseten.md +1 -1
  18. package/.docs/models/providers/friendli.md +3 -2
  19. package/.docs/models/providers/lilac.md +7 -7
  20. package/.docs/models/providers/opencode.md +2 -1
  21. package/.docs/models/providers/siliconflow-cn.md +2 -1
  22. package/.docs/models/providers/wafer.ai.md +2 -1
  23. package/.docs/reference/agents/createSkill.md +78 -0
  24. package/.docs/reference/agents/durable-agent.md +30 -1
  25. package/.docs/reference/agents/getDefaultOptions.md +1 -1
  26. package/.docs/reference/agents/getDefaultStreamOptions.md +1 -1
  27. package/.docs/reference/agents/getSkill.md +58 -0
  28. package/.docs/reference/agents/inngest-agent.md +339 -0
  29. package/.docs/reference/agents/listSkills.md +53 -0
  30. package/.docs/reference/ai-sdk/handle-workflow-stream.md +1 -1
  31. package/.docs/reference/ai-sdk/workflow-route.md +1 -1
  32. package/.docs/reference/index.md +4 -0
  33. package/.docs/reference/processors/stream-error-retry-processor.md +32 -0
  34. package/.docs/reference/streaming/workflows/timeTravelStream.md +1 -1
  35. package/.docs/reference/tools/create-tool.md +1 -1
  36. package/.docs/reference/workflows/run.md +1 -1
  37. package/CHANGELOG.md +14 -0
  38. package/package.json +4 -4
  39. package/.docs/docs/build-with-ai/mcp-docs-server.md +0 -238
  40. package/.docs/docs/build-with-ai/skills.md +0 -63
  41. package/.docs/docs/streaming/background-task-streaming.md +0 -80
  42. package/.docs/docs/streaming/events.md +0 -148
  43. package/.docs/docs/streaming/overview.md +0 -136
  44. package/.docs/docs/streaming/tool-streaming.md +0 -189
  45. package/.docs/docs/streaming/workflow-streaming.md +0 -109
@@ -1,189 +0,0 @@
1
- # Tool streaming
2
-
3
- Tool streaming in Mastra enables tools to send incremental results while they run, rather than waiting until execution finishes. This allows you to surface partial progress, intermediate states, or progressive data directly to users or upstream agents and workflows.
4
-
5
- Streams can be written to in two main ways:
6
-
7
- - **From within a tool**: every tool receives a `context.writer` object, which is a writable stream you can use to push updates as execution progresses.
8
- - **From an agent stream**: you can also pipe an agent's `stream` output directly into a tool's writer, making it convenient to chain agent responses into tool results without extra glue code.
9
-
10
- By combining writable tool streams with agent streaming, you gain fine grained control over how intermediate results flow through your system and into the user experience.
11
-
12
- ## Agent using tool
13
-
14
- Agent streaming can be combined with tool calls, allowing tool outputs to be written directly into the agent’s streaming response. This makes it possible to surface tool activity as part of the overall interaction.
15
-
16
- ```typescript
17
- import { Agent } from '@mastra/core/agent'
18
- import { testTool } from '../tools/test-tool'
19
-
20
- export const testAgent = new Agent({
21
- id: 'test-agent',
22
- name: 'Test Agent',
23
- instructions: 'You are a weather agent.',
24
- model: 'openai/gpt-5.5',
25
- tools: { testTool },
26
- })
27
- ```
28
-
29
- ### Using `context.writer`
30
-
31
- The `context.writer` object is available in a tool's `execute()` function and can be used to emit custom events, data, or values into the active stream. This enables tools to provide intermediate results or status updates while execution is still in progress.
32
-
33
- > **Warning:** You must `await` the call to `writer.write()` or else you will lock the stream and get a `WritableStream is locked` error.
34
-
35
- ```typescript
36
- import { createTool } from '@mastra/core/tools'
37
-
38
- export const testTool = createTool({
39
- execute: async (inputData, context) => {
40
- const { value } = inputData
41
-
42
- await context?.writer?.write({
43
- type: 'custom-event',
44
- status: 'pending',
45
- })
46
-
47
- const response = await fetch()
48
-
49
- await context?.writer?.write({
50
- type: 'custom-event',
51
- status: 'success',
52
- })
53
-
54
- return {
55
- value: '',
56
- }
57
- },
58
- })
59
- ```
60
-
61
- You can also use `writer.custom()` to emit top-level stream chunks. This is useful when integrating with UI frameworks.
62
-
63
- ```typescript
64
- import { createTool } from '@mastra/core/tools'
65
-
66
- export const testTool = createTool({
67
- execute: async (inputData, context) => {
68
- const { value } = inputData
69
-
70
- await context?.writer?.custom({
71
- type: 'data-tool-progress',
72
- status: 'pending',
73
- })
74
-
75
- const response = await fetch()
76
-
77
- await context?.writer?.custom({
78
- type: 'data-tool-progress',
79
- status: 'success',
80
- })
81
-
82
- return {
83
- value: '',
84
- }
85
- },
86
- })
87
- ```
88
-
89
- ### Transient data chunks
90
-
91
- By default, `data-*` chunks emitted with `writer.custom()` are persisted to storage as part of the message history. For chunks that are only needed during live streaming — such as progress updates or verbose log output — set `transient: true` to skip storage persistence. Transient chunks are still streamed to the client in real time but aren't saved to the database.
92
-
93
- ```typescript
94
- await context?.writer?.custom({
95
- type: 'data-build-log',
96
- data: { line: 'Compiling module 3 of 12...' },
97
- transient: true,
98
- })
99
- ```
100
-
101
- Use transient chunks when the data is large or high-frequency and only relevant during the live session. After a page refresh, transient chunks are no longer available — only the tool's return value and any non-transient chunks are loaded from storage.
102
-
103
- ### Inspecting stream payloads
104
-
105
- 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 tool-specific data.
106
-
107
- ```typescript
108
- const stream = await testAgent.stream(['What is the weather in London?', 'Use the testTool'])
109
-
110
- for await (const chunk of stream) {
111
- if (chunk.payload.output?.type === 'custom-event') {
112
- console.log(JSON.stringify(chunk, null, 2))
113
- }
114
- }
115
- ```
116
-
117
- ## Tool lifecycle hooks
118
-
119
- Tools support lifecycle hooks that allow you to monitor different stages of tool execution during streaming. These hooks are particularly useful for logging or analytics.
120
-
121
- ### Example: Using `onInputAvailable` and `onOutput`
122
-
123
- ```typescript
124
- import { createTool } from '@mastra/core/tools'
125
- import { z } from 'zod'
126
-
127
- export const weatherTool = createTool({
128
- id: 'weather-tool',
129
- description: 'Get weather information',
130
- inputSchema: z.object({
131
- city: z.string(),
132
- }),
133
- outputSchema: z.object({
134
- temperature: z.number(),
135
- conditions: z.string(),
136
- }),
137
- // Called when the complete input is available
138
- onInputAvailable: ({ input, toolCallId }) => {
139
- console.log(`Weather requested for: ${input.city}`)
140
- },
141
- execute: async input => {
142
- const weather = await fetchWeather(input.city)
143
- return weather
144
- },
145
- // Called after successful execution
146
- onOutput: ({ output, toolName }) => {
147
- console.log(`${toolName} result: ${output.temperature}°F, ${output.conditions}`)
148
- },
149
- })
150
- ```
151
-
152
- ### Available Hooks
153
-
154
- - **onInputStart**: Called when tool call input streaming begins
155
- - **onInputDelta**: Called for each chunk of input as it streams in
156
- - **onInputAvailable**: Called when complete input is parsed and validated
157
- - **onOutput**: Called after the tool successfully executes with the output
158
-
159
- For detailed documentation on all lifecycle hooks, see the [createTool() reference](https://mastra.ai/reference/tools/create-tool).
160
-
161
- ### Streaming tool input in UIs
162
-
163
- When a model generates a tool call, the arguments arrive incrementally as `tool-call-delta` stream chunks before the final `tool-call` chunk. UIs can listen for the corresponding `tool_input_start`, `tool_input_delta`, and `tool_input_end` events to render tool arguments as they stream in — for example, showing a file path or command immediately rather than waiting for the complete tool call.
164
-
165
- Using a partial JSON parser on the accumulated `argsTextDelta` fragments lets you extract usable argument values before the JSON is complete. This enables features like live diff previews for edit tools, streaming file content for write tools, and instant display of search patterns or file paths.
166
-
167
- ## Tool using an agent
168
-
169
- Pipe an agent's `fullStream` to the tool's `writer`. This streams partial output, and Mastra automatically aggregates the agent's usage into the tool run.
170
-
171
- ```typescript
172
- import { createTool } from '@mastra/core/tools'
173
- import { z } from 'zod'
174
-
175
- export const testTool = createTool({
176
- execute: async (inputData, context) => {
177
- const { city } = inputData
178
-
179
- const agent = context?.mastra?.getAgent('testAgent')
180
- const stream = await agent?.stream(`What is the weather in ${city}?`)
181
-
182
- await stream!.fullStream.pipeTo(context?.writer!)
183
-
184
- return {
185
- value: await stream!.text,
186
- }
187
- },
188
- })
189
- ```
@@ -1,109 +0,0 @@
1
- # Workflow streaming
2
-
3
- Workflow streaming in Mastra enables workflows to send incremental results while they execute, rather than waiting until completion. This allows you to surface partial progress, intermediate states, or progressive data directly to users or upstream agents and workflows.
4
-
5
- Streams can be written to in two main ways:
6
-
7
- - **From within a workflow step**: every workflow step receives a `writer` argument, which is a writable stream you can use to push updates as execution progresses.
8
- - **From an agent stream**: you can also pipe an agent's `stream` output directly into a workflow step's writer, making it convenient to chain agent responses into workflow results without extra glue code.
9
-
10
- By combining writable workflow streams with agent streaming, you gain fine-grained control over how intermediate results flow through your system and into the user experience.
11
-
12
- ## Using the `writer` argument
13
-
14
- The `writer` argument is passed to a workflow step's `execute` function and can be used to emit custom events, data, or values into the active stream. This enables workflow steps to provide intermediate results or status updates while execution is still in progress.
15
-
16
- > **Warning:** You must `await` the call to `writer.write(...)` or else you will lock the stream and get a `WritableStream is locked` error.
17
-
18
- ```typescript
19
- import { createStep } from "@mastra/core/workflows";
20
-
21
- export const testStep = createStep({
22
- execute: async ({ inputData, writer }) => {
23
- const { value } = inputData;
24
-
25
- await writer?.write({
26
- type: "custom-event",
27
- status: "pending"
28
- });
29
-
30
- const response = await fetch(...);
31
-
32
- await writer?.write({
33
- type: "custom-event",
34
- status: "success"
35
- });
36
-
37
- return {
38
- value: ""
39
- };
40
- },
41
- });
42
- ```
43
-
44
- ## Inspecting workflow stream payloads
45
-
46
- 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.
47
-
48
- ```typescript
49
- const testWorkflow = mastra.getWorkflow('testWorkflow')
50
-
51
- const run = await testWorkflow.createRun()
52
-
53
- const stream = await run.stream({
54
- inputData: {
55
- value: 'initial data',
56
- },
57
- })
58
-
59
- for await (const chunk of stream) {
60
- console.log(chunk)
61
- }
62
-
63
- if (result!.status === 'suspended') {
64
- // if the workflow is suspended, we can resume it with the resumeStream method
65
- const resumedStream = await run.resumeStream({
66
- resumeData: { value: 'resume data' },
67
- })
68
-
69
- for await (const chunk of resumedStream) {
70
- console.log(chunk)
71
- }
72
- }
73
- ```
74
-
75
- ## Resuming an interrupted workflow stream
76
-
77
- 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.
78
-
79
- ```typescript
80
- const newStream = await run.resumeStream()
81
-
82
- for await (const chunk of newStream) {
83
- console.log(chunk)
84
- }
85
- ```
86
-
87
- ## Workflow using an agent
88
-
89
- 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.
90
-
91
- ```typescript
92
- import { createStep } from '@mastra/core/workflows'
93
- import { z } from 'zod'
94
-
95
- export const testStep = createStep({
96
- execute: async ({ inputData, mastra, writer }) => {
97
- const { city } = inputData
98
-
99
- const testAgent = mastra?.getAgent('testAgent')
100
- const stream = await testAgent?.stream(`What is the weather in ${city}$?`)
101
-
102
- await stream!.textStream.pipeTo(writer!)
103
-
104
- return {
105
- value: await stream!.text,
106
- }
107
- },
108
- })
109
- ```