@mastra/mcp-docs-server 1.2.14-alpha.3 → 1.2.14-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.
- package/.docs/docs/agents/processors.md +25 -1
- package/.docs/docs/workflows/agents-and-tools.md +29 -0
- package/.docs/docs/workflows/stored-workflows.md +146 -0
- package/.docs/models/environment-variables.md +1 -1
- package/.docs/models/gateways/neon.md +71 -0
- package/.docs/models/gateways/netlify.md +6 -6
- package/.docs/models/gateways/openrouter.md +6 -6
- package/.docs/models/gateways/vercel.md +6 -6
- package/.docs/models/gateways.md +1 -0
- package/.docs/models/index.md +95 -96
- package/.docs/models/providers/alibaba-cn.md +23 -25
- package/.docs/models/providers/alibaba-token-plan-cn.md +24 -24
- package/.docs/models/providers/alibaba-token-plan.md +23 -25
- package/.docs/models/providers/alibaba.md +23 -25
- package/.docs/models/providers/ambient.md +23 -25
- package/.docs/models/providers/baseten.md +23 -25
- package/.docs/models/providers/chutes.md +23 -25
- package/.docs/models/providers/cortecs.md +23 -25
- package/.docs/models/providers/crof.md +23 -25
- package/.docs/models/providers/crossmodel.md +23 -25
- package/.docs/models/providers/deepinfra.md +22 -24
- package/.docs/models/providers/digitalocean.md +23 -25
- package/.docs/models/providers/empiriolabs.md +23 -25
- package/.docs/models/providers/fireworks-ai.md +24 -24
- package/.docs/models/providers/greenpt.md +23 -25
- package/.docs/models/providers/groq.md +23 -25
- package/.docs/models/providers/huggingface.md +23 -25
- package/.docs/models/providers/hyper.md +23 -25
- package/.docs/models/providers/impossibl.md +23 -25
- package/.docs/models/providers/infomaniak.md +24 -24
- package/.docs/models/providers/kilo.md +23 -25
- package/.docs/models/providers/llmgateway.md +23 -25
- package/.docs/models/providers/mistral.md +23 -25
- package/.docs/models/providers/modal.md +23 -25
- package/.docs/models/providers/modelis.md +23 -25
- package/.docs/models/providers/nano-gpt.md +23 -25
- package/.docs/models/providers/neuralwatt.md +23 -25
- package/.docs/models/providers/ofox.md +23 -25
- package/.docs/models/providers/ollama-cloud.md +23 -25
- package/.docs/models/providers/opencode-go.md +23 -25
- package/.docs/models/providers/opencode.md +23 -25
- package/.docs/models/providers/pioneer.md +23 -25
- package/.docs/models/providers/requesty.md +23 -25
- package/.docs/models/providers/routing-run.md +23 -25
- package/.docs/models/providers/scx.md +23 -25
- package/.docs/models/providers/tensorx.md +23 -25
- package/.docs/models/providers/togetherai.md +22 -24
- package/.docs/models/providers/umans-ai-coding-plan.md +24 -24
- package/.docs/models/providers/umans-ai.md +23 -25
- package/.docs/models/providers/wandb.md +23 -25
- package/.docs/models/providers/xai.md +26 -28
- package/.docs/models/providers/zai-coding-plan.md +23 -25
- package/.docs/models/providers/zhipuai-coding-plan.md +23 -25
- package/.docs/models/providers.md +0 -1
- package/.docs/reference/client-js/workflows.md +92 -0
- package/.docs/reference/core/addStoredWorkflow.md +62 -0
- package/.docs/reference/core/addStoredWorkflows.md +40 -0
- package/.docs/reference/index.md +5 -0
- package/.docs/reference/processors/processor-interface.md +121 -10
- package/.docs/reference/server/routes.md +13 -0
- package/.docs/reference/storage/overview.md +9 -8
- package/.docs/reference/streaming/workflows/observeStream.md +1 -1
- package/.docs/reference/streaming/workflows/resumeStream.md +1 -1
- package/.docs/reference/streaming/workflows/stream.md +1 -1
- package/.docs/reference/workflows/stored-workflow-definition.md +292 -0
- package/.docs/reference/workflows/workflow-methods/agent.md +62 -0
- package/.docs/reference/workflows/workflow-methods/tool.md +43 -0
- package/CHANGELOG.md +7 -0
- package/package.json +5 -5
- package/.docs/models/providers/neon.md +0 -109
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Stored workflow definition
|
|
4
|
+
|
|
5
|
+
> **Beta:** Stored workflows are in beta. Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
7
|
+
A stored workflow definition is a JSON-compatible `StoredWorkflowGraph` accepted by [`Mastra.addStoredWorkflow()`](https://mastra.ai/reference/core/addStoredWorkflow), the stored-workflow server routes, and the Client SDK workflows API.
|
|
8
|
+
|
|
9
|
+
See [Stored workflows](https://mastra.ai/docs/workflows/stored-workflows) for a complete setup and usage example.
|
|
10
|
+
|
|
11
|
+
## Definition fields
|
|
12
|
+
|
|
13
|
+
| Field | Type | Required | Description |
|
|
14
|
+
| ---------------------- | --------------------------- | -------- | ------------------------------------------------------------------------------ |
|
|
15
|
+
| `id` | `string` | Yes | Unique workflow ID. This is also the ID used to retrieve and run the workflow. |
|
|
16
|
+
| `description` | `string` | No | Human-readable description |
|
|
17
|
+
| `inputSchema` | `JsonSchema` | Yes | JSON Schema for the workflow input |
|
|
18
|
+
| `outputSchema` | `JsonSchema` | Yes | JSON Schema for the workflow output |
|
|
19
|
+
| `stateSchema` | `JsonSchema` | No | JSON Schema for shared workflow state |
|
|
20
|
+
| `requestContextSchema` | `JsonSchema` | No | JSON Schema for values read from the request context |
|
|
21
|
+
| `metadata` | `Record<string, unknown>` | No | Arbitrary JSON metadata preserved through storage |
|
|
22
|
+
| `graph` | `SerializedStepFlowEntry[]` | Yes | Step entries that make up the workflow |
|
|
23
|
+
|
|
24
|
+
Schemas use JSON Schema rather than Zod so the definition can round-trip through JSON. Mastra converts each schema to Zod when it registers the workflow.
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"id": "greeting-workflow",
|
|
29
|
+
"description": "Returns a greeting for the supplied name",
|
|
30
|
+
"inputSchema": {
|
|
31
|
+
"type": "object",
|
|
32
|
+
"properties": { "name": { "type": "string" } },
|
|
33
|
+
"required": ["name"]
|
|
34
|
+
},
|
|
35
|
+
"outputSchema": {
|
|
36
|
+
"type": "object",
|
|
37
|
+
"properties": { "message": { "type": "string" } },
|
|
38
|
+
"required": ["message"]
|
|
39
|
+
},
|
|
40
|
+
"graph": [
|
|
41
|
+
{
|
|
42
|
+
"type": "mapping",
|
|
43
|
+
"id": "create-greeting",
|
|
44
|
+
"mapConfig": "{\"message\":{\"template\":\"Hello, ${initData.name}!\"}}"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Graph entries
|
|
51
|
+
|
|
52
|
+
Entries in the `graph` run in order. Each entry receives the previous entry's output, and the first entry receives the workflow input.
|
|
53
|
+
|
|
54
|
+
| Entry type | Description |
|
|
55
|
+
| ------------- | ------------------------------------------------------ |
|
|
56
|
+
| `agent` | Invoke a registered agent |
|
|
57
|
+
| `tool` | Invoke a registered tool |
|
|
58
|
+
| `mapping` | Reshape data between steps |
|
|
59
|
+
| `workflow` | Invoke a registered workflow as a nested step |
|
|
60
|
+
| `parallel` | Run several steps concurrently and merge their outputs |
|
|
61
|
+
| `conditional` | Run every branch whose predicate is true, concurrently |
|
|
62
|
+
| `foreach` | Run one step per item of an array input |
|
|
63
|
+
| `loop` | Repeat a step while or until a predicate holds |
|
|
64
|
+
| `sleep` | Pause for a fixed duration |
|
|
65
|
+
| `sleepUntil` | Pause until a fixed date |
|
|
66
|
+
|
|
67
|
+
Code-defined workflows that use [`.agent()`](https://mastra.ai/reference/workflows/workflow-methods/agent) and [`.tool()`](https://mastra.ai/reference/workflows/workflow-methods/tool) produce the same declarative entries when serialized.
|
|
68
|
+
|
|
69
|
+
### Agent steps
|
|
70
|
+
|
|
71
|
+
An `agent` entry invokes a registered agent by ID. Agent steps accept `{ prompt: string }` as input and return `{ text: string }` by default.
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"type": "agent",
|
|
76
|
+
"id": "summarize",
|
|
77
|
+
"agentId": "support-agent"
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The `id` identifies this call site within the workflow. Later steps address the result as `stepResults.summarize`, regardless of the agent's own ID.
|
|
82
|
+
|
|
83
|
+
Add an `outputSchema` to request structured output from the agent:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"type": "agent",
|
|
88
|
+
"id": "extract-subtopics",
|
|
89
|
+
"agentId": "support-agent",
|
|
90
|
+
"outputSchema": {
|
|
91
|
+
"type": "array",
|
|
92
|
+
"items": {
|
|
93
|
+
"type": "object",
|
|
94
|
+
"properties": { "title": { "type": "string" } },
|
|
95
|
+
"required": ["title"]
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Use a `mapping` entry before an agent to build its `{ prompt }` input from workflow data.
|
|
102
|
+
|
|
103
|
+
Agent entries accept an optional `description` and an `options` object:
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"type": "agent",
|
|
108
|
+
"id": "summarize",
|
|
109
|
+
"agentId": "support-agent",
|
|
110
|
+
"description": "Summarize the incoming request",
|
|
111
|
+
"options": { "retries": 2, "metadata": { "team": "support" } }
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Only `retries` and `metadata` persist. Function-valued options such as `onFinish` and function-valued `toolChoice` are rejected when a code-defined workflow is stored. Other agent call options don't persist.
|
|
116
|
+
|
|
117
|
+
### Tool steps
|
|
118
|
+
|
|
119
|
+
A `tool` entry invokes a tool by its registration key from the `Mastra` `tools` object. Mastra resolves the tool's input and output schemas from the registry when it registers the workflow.
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"type": "tool",
|
|
124
|
+
"id": "lookup",
|
|
125
|
+
"toolId": "lookup-customer"
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Tool entries accept the same optional `description` and `options` fields as agent entries. Only `retries` and `metadata` persist.
|
|
130
|
+
|
|
131
|
+
### Mapping steps
|
|
132
|
+
|
|
133
|
+
A `mapping` entry reshapes data. Its `mapConfig` is a JSON string that encodes an object. Each key becomes a key in the step output, and each descriptor defines one source.
|
|
134
|
+
|
|
135
|
+
| Descriptor | Description |
|
|
136
|
+
| -------------------------------------- | ----------------------------------------- |
|
|
137
|
+
| `{ "value": ... }` | A constant JSON value |
|
|
138
|
+
| `{ "template": "..." }` | A string built from `${...}` placeholders |
|
|
139
|
+
| `{ "initData": true, "path": "a.b" }` | A value from the workflow input |
|
|
140
|
+
| `{ "step": "step-id", "path": "a.b" }` | A value from a preceding step's output |
|
|
141
|
+
| `{ "requestContextPath": "a.b" }` | A value from the request context |
|
|
142
|
+
|
|
143
|
+
The `step` source also accepts an array of step IDs:
|
|
144
|
+
|
|
145
|
+
```json
|
|
146
|
+
{ "step": ["escalate", "auto-reply"], "path": "text" }
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The first listed step with a non-empty result supplies the value. This can select the branch that ran after a `conditional` entry.
|
|
150
|
+
|
|
151
|
+
Templates resolve placeholders against `initData`, `inputData`, `state`, `requestContext`, and `stepResults.<step-id>`:
|
|
152
|
+
|
|
153
|
+
```json
|
|
154
|
+
{
|
|
155
|
+
"type": "mapping",
|
|
156
|
+
"id": "build-prompt",
|
|
157
|
+
"mapConfig": "{\"prompt\":{\"template\":\"Summarize this request: ${initData.request}\"}}"
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Objects and arrays resolved by a template are stringified as JSON. A `null` value inside a present result renders as an empty string. A template that references a step without a successful output fails the run.
|
|
162
|
+
|
|
163
|
+
Mapping entries must be top-level graph entries. They can't be placed inside `parallel`, `conditional`, `foreach`, or `loop` containers.
|
|
164
|
+
|
|
165
|
+
### Nested workflow steps
|
|
166
|
+
|
|
167
|
+
A `workflow` entry invokes another registered workflow. The target can be code-defined or stored.
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"type": "workflow",
|
|
172
|
+
"id": "lookup-first",
|
|
173
|
+
"workflowId": "lookup-customer-workflow"
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
The `id` identifies the call site. The same nested workflow can appear several times under different call-site IDs, and later steps address each result as `stepResults.<id>`. A `workflow` entry also accepts an optional `description`.
|
|
178
|
+
|
|
179
|
+
### Parallel entries
|
|
180
|
+
|
|
181
|
+
A `parallel` entry runs several single steps concurrently and merges their outputs into an object keyed by step ID.
|
|
182
|
+
|
|
183
|
+
```json
|
|
184
|
+
{
|
|
185
|
+
"type": "parallel",
|
|
186
|
+
"steps": [
|
|
187
|
+
{ "type": "tool", "id": "first", "toolId": "lookup-customer" },
|
|
188
|
+
{ "type": "tool", "id": "second", "toolId": "lookup-customer" }
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Each child must be an `agent`, `tool`, or `workflow` entry. All children receive the parallel entry's input directly.
|
|
194
|
+
|
|
195
|
+
### Conditional entries
|
|
196
|
+
|
|
197
|
+
A `conditional` entry pairs each step with a declarative predicate and runs every branch whose predicate is true.
|
|
198
|
+
|
|
199
|
+
```json
|
|
200
|
+
{
|
|
201
|
+
"type": "conditional",
|
|
202
|
+
"steps": [
|
|
203
|
+
{ "type": "agent", "id": "escalate", "agentId": "support-agent" },
|
|
204
|
+
{ "type": "agent", "id": "auto-reply", "agentId": "support-agent" }
|
|
205
|
+
],
|
|
206
|
+
"predicates": [
|
|
207
|
+
{ "op": "eq", "left": { "path": "inputData.priority" }, "right": { "literal": "urgent" } },
|
|
208
|
+
{ "op": "ne", "left": { "path": "inputData.priority" }, "right": { "literal": "urgent" } }
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Each child must be an `agent`, `tool`, or `workflow` entry, and each child needs a predicate. All children receive the conditional entry's input directly.
|
|
214
|
+
|
|
215
|
+
### Predicates
|
|
216
|
+
|
|
217
|
+
Conditional entries and loops use a JSON predicate DSL. Operands are `{ "path": "..." }` references or `{ "literal": ... }` values. Paths resolve against `initData`, `inputData`, `stepResults`, and `state`.
|
|
218
|
+
|
|
219
|
+
| Operator | Shape |
|
|
220
|
+
| ------------------------------------ | -------------------------------------------- |
|
|
221
|
+
| `eq`, `ne`, `lt`, `lte`, `gt`, `gte` | `{ "op": "eq", "left": ..., "right": ... }` |
|
|
222
|
+
| `in`, `notIn` | `{ "op": "in", "value": ..., "set": [...] }` |
|
|
223
|
+
| `exists`, `notExists` | `{ "op": "exists", "path": "..." }` |
|
|
224
|
+
| `truthy`, `falsy` | `{ "op": "truthy", "value": ... }` |
|
|
225
|
+
| `and`, `or` | `{ "op": "and", "args": [...] }` |
|
|
226
|
+
| `not` | `{ "op": "not", "arg": ... }` |
|
|
227
|
+
|
|
228
|
+
Missing paths don't throw. Path-based operators return `false` when the path can't be resolved. Use `exists` or `notExists` to distinguish a missing value from a falsy value.
|
|
229
|
+
|
|
230
|
+
### Foreach entries
|
|
231
|
+
|
|
232
|
+
A `foreach` entry runs its body once for each item in an array input. The preceding entry must produce a raw array. Results preserve input order, and concurrency defaults to `1`.
|
|
233
|
+
|
|
234
|
+
```json
|
|
235
|
+
{
|
|
236
|
+
"type": "foreach",
|
|
237
|
+
"step": { "type": "workflow", "id": "write-blurb", "workflowId": "blurb-workflow" },
|
|
238
|
+
"opts": { "concurrency": 3 }
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
The body can be an `agent`, `tool`, or `workflow` entry, but not a `mapping` entry.
|
|
243
|
+
|
|
244
|
+
### Loop entries
|
|
245
|
+
|
|
246
|
+
A `loop` repeats one step while (`dowhile`) or until (`dountil`) a predicate holds.
|
|
247
|
+
|
|
248
|
+
```json
|
|
249
|
+
{
|
|
250
|
+
"type": "loop",
|
|
251
|
+
"loopType": "dountil",
|
|
252
|
+
"step": { "type": "tool", "id": "poll", "toolId": "check-status" },
|
|
253
|
+
"predicate": {
|
|
254
|
+
"op": "eq",
|
|
255
|
+
"left": { "path": "inputData.status" },
|
|
256
|
+
"right": { "literal": "done" }
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
The loop body must be a single step, and stored loops require a declarative predicate.
|
|
262
|
+
|
|
263
|
+
### Sleep entries
|
|
264
|
+
|
|
265
|
+
A `sleep` entry pauses for a fixed number of milliseconds. A `sleepUntil` entry pauses until a fixed date represented by an ISO date string. Stored definitions require literal values.
|
|
266
|
+
|
|
267
|
+
```json
|
|
268
|
+
{ "type": "sleep", "id": "wait", "duration": 5000 }
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
```json
|
|
272
|
+
{ "type": "sleepUntil", "id": "wait-for-launch", "date": "2027-01-01T00:00:00.000Z" }
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Use a code-defined workflow when the duration or date must be calculated at runtime.
|
|
276
|
+
|
|
277
|
+
## Validation
|
|
278
|
+
|
|
279
|
+
Mastra validates definitions before it persists or registers them:
|
|
280
|
+
|
|
281
|
+
- Structure: Entry shapes and required fields, including placement rules such as top-level-only mappings.
|
|
282
|
+
- References: Each `agentId` and `workflowId` must resolve against the live registries or the same bundle. A `toolId` must match a tool registration key.
|
|
283
|
+
- Schema flow: Each entry's input must be compatible with the preceding output, including inferred mapping outputs.
|
|
284
|
+
|
|
285
|
+
Validation errors include a dotted path, such as `graph.2.steps.0`, that identifies the invalid entry.
|
|
286
|
+
|
|
287
|
+
## Related
|
|
288
|
+
|
|
289
|
+
- [Use stored workflows](https://mastra.ai/docs/workflows/stored-workflows)
|
|
290
|
+
- [`Mastra.addStoredWorkflow()`](https://mastra.ai/reference/core/addStoredWorkflow)
|
|
291
|
+
- [`Mastra.addStoredWorkflows()`](https://mastra.ai/reference/core/addStoredWorkflows)
|
|
292
|
+
- [Client SDK workflows API](https://mastra.ai/reference/client-js/workflows)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Workflow\.agent()
|
|
4
|
+
|
|
5
|
+
The `.agent()` method adds an agent as a declarative step. The step accepts `{ prompt: string }` as input and returns `{ text: string }` by default. Use `.map()` before the agent to build the prompt from workflow data.
|
|
6
|
+
|
|
7
|
+
Unlike wrapping an agent with `createStep()`, `.agent()` records a declarative entry in the workflow graph. This makes the workflow portable: the same graph can be serialized and persisted as a [stored workflow](https://mastra.ai/docs/workflows/stored-workflows).
|
|
8
|
+
|
|
9
|
+
## Usage example
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
workflow
|
|
13
|
+
.map({ prompt: mapVariable({ initData: workflow, path: "topic" }) })
|
|
14
|
+
.agent(testAgent)
|
|
15
|
+
.commit();
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Parameters
|
|
19
|
+
|
|
20
|
+
**agentOrId** (`Agent | string`): An agent instance, or the ID of an agent registered on the Mastra instance. When passing an ID, the agent is resolved from the registry at execution time.
|
|
21
|
+
|
|
22
|
+
**options** (`AgentStepOptions & { structuredOutput?: { schema }, retries?: number, scorers?: DynamicArgument<MastraScorers>, metadata?: StepMetadata }`): Agent call options such as maxSteps, modelSettings, memory, and providerOptions, plus step-level retries, scorers, and metadata. Per-request fields such as requestContext, resourceId, threadId, and onStepFinish are managed by the workflow engine and excluded.
|
|
23
|
+
|
|
24
|
+
**stepOptions** (`{ id?: string }`): The step's call-site ID within the workflow. Defaults to the agent's ID. Set this when the same agent appears more than once in one workflow.
|
|
25
|
+
|
|
26
|
+
## Returns
|
|
27
|
+
|
|
28
|
+
**workflow** (`Workflow`): The workflow instance for method chaining
|
|
29
|
+
|
|
30
|
+
## Structured output
|
|
31
|
+
|
|
32
|
+
By default the step's output is `{ text: string }`. Pass `structuredOutput.schema` to make the step return that shape instead. The schema becomes the step's output schema, so later steps chain against it with full type safety:
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
workflow
|
|
36
|
+
.agent(testAgent, {
|
|
37
|
+
structuredOutput: {
|
|
38
|
+
schema: z.object({
|
|
39
|
+
subtopics: z.array(z.string()),
|
|
40
|
+
}),
|
|
41
|
+
},
|
|
42
|
+
})
|
|
43
|
+
.commit();
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Referencing an agent by ID
|
|
47
|
+
|
|
48
|
+
Pass a string to reference a registered agent without importing it. The agent must be registered on the Mastra instance when the workflow runs:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
workflow.agent("test-agent", { maxSteps: 3 }).commit();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Persisting agent steps
|
|
55
|
+
|
|
56
|
+
Workflows built with `.agent()` serialize to the same declarative entries that [stored workflows](https://mastra.ai/docs/workflows/stored-workflows) use. Only `retries` and `metadata` round-trip through storage. Options that hold functions, such as `onFinish` or a function-valued `toolChoice`, throw an error when the workflow is stored.
|
|
57
|
+
|
|
58
|
+
## Related
|
|
59
|
+
|
|
60
|
+
- [Agents and Tools](https://mastra.ai/docs/workflows/agents-and-tools)
|
|
61
|
+
- [Stored workflows](https://mastra.ai/docs/workflows/stored-workflows)
|
|
62
|
+
- [Workflow.tool()](https://mastra.ai/reference/workflows/workflow-methods/tool)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Workflow\.tool()
|
|
4
|
+
|
|
5
|
+
The `.tool()` method adds a tool as a declarative step. The tool's own input and output schemas apply, so the previous step's output must satisfy the tool's input schema. Use `.map()` to transform the data if they don't match.
|
|
6
|
+
|
|
7
|
+
Unlike wrapping a tool with `createStep()`, `.tool()` records a declarative entry in the workflow graph. This makes the workflow portable: the same graph can be serialized and persisted as a [stored workflow](https://mastra.ai/docs/workflows/stored-workflows).
|
|
8
|
+
|
|
9
|
+
## Usage example
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
workflow.tool(testTool).commit();
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
**toolOrId** (`Tool | string`): A tool instance, or the ID of a tool registered on the Mastra instance. When passing an ID, the tool is resolved from the registry at execution time.
|
|
18
|
+
|
|
19
|
+
**options** (`{ retries?: number, scorers?: DynamicArgument<MastraScorers>, metadata?: StepMetadata }`): Step-level retry count, scorers, and metadata for the tool step.
|
|
20
|
+
|
|
21
|
+
**stepOptions** (`{ id?: string }`): The step's call-site ID within the workflow. Defaults to the tool's ID. Set this when the same tool appears more than once in one workflow.
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
**workflow** (`Workflow`): The workflow instance for method chaining
|
|
26
|
+
|
|
27
|
+
## Referencing a tool by ID
|
|
28
|
+
|
|
29
|
+
Pass a string to reference a registered tool without importing it. The tool must be registered on the Mastra instance when the workflow runs:
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
workflow.tool("lookup-customer", { retries: 2 }).commit();
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Persisting tool steps
|
|
36
|
+
|
|
37
|
+
Workflows built with `.tool()` serialize to the same declarative entries that [stored workflows](https://mastra.ai/docs/workflows/stored-workflows) use. Only `retries` and `metadata` round-trip through storage. A function-valued `scorers` option throws an error when the workflow is stored.
|
|
38
|
+
|
|
39
|
+
## Related
|
|
40
|
+
|
|
41
|
+
- [Agents and Tools](https://mastra.ai/docs/workflows/agents-and-tools)
|
|
42
|
+
- [Stored workflows](https://mastra.ai/docs/workflows/stored-workflows)
|
|
43
|
+
- [Workflow.agent()](https://mastra.ai/reference/workflows/workflow-methods/agent)
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.2.14-alpha.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`810c7e7`](https://github.com/mastra-ai/mastra/commit/810c7e74929989d8b8b5db52cd3af22cd0998af4), [`f9f9884`](https://github.com/mastra-ai/mastra/commit/f9f98848ee194dc71a787a709ec430b065cdc41b), [`e0904dc`](https://github.com/mastra-ai/mastra/commit/e0904dc538792e54e1806b70172e5900ac49bff4), [`64d6781`](https://github.com/mastra-ai/mastra/commit/64d67814bccddd314f7e09643243821e57cb87b6), [`c848e65`](https://github.com/mastra-ai/mastra/commit/c848e655a64ff10331a8ceafafe7f18e70a0f092), [`0494489`](https://github.com/mastra-ai/mastra/commit/049448906e4c3d2d615bbe865b073a0d890ddb7c), [`8d1aeb8`](https://github.com/mastra-ai/mastra/commit/8d1aeb8acf7c20c4bb8e4d8e4bdc6569c83ac561), [`83065bf`](https://github.com/mastra-ai/mastra/commit/83065bfee9e47c3c6f09132a9034501f6cfb69cf), [`01b162f`](https://github.com/mastra-ai/mastra/commit/01b162fe435295881aa7ea55f1759407ad5175ad)]:
|
|
8
|
+
- @mastra/core@1.57.0-alpha.2
|
|
9
|
+
|
|
3
10
|
## 1.2.14-alpha.2
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.2.14-alpha.
|
|
3
|
+
"version": "1.2.14-alpha.4",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"jsdom": "^26.1.0",
|
|
29
29
|
"local-pkg": "^1.1.2",
|
|
30
30
|
"zod": "^4.4.3",
|
|
31
|
-
"@mastra/
|
|
32
|
-
"@mastra/
|
|
31
|
+
"@mastra/mcp": "^1.15.1",
|
|
32
|
+
"@mastra/core": "1.57.0-alpha.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@hono/node-server": "^1.19.14",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"tsx": "^4.23.1",
|
|
46
46
|
"typescript": "^6.0.3",
|
|
47
47
|
"vitest": "4.1.10",
|
|
48
|
-
"@internal/types-builder": "0.0.95",
|
|
49
48
|
"@internal/lint": "0.0.120",
|
|
50
|
-
"@
|
|
49
|
+
"@internal/types-builder": "0.0.95",
|
|
50
|
+
"@mastra/core": "1.57.0-alpha.2"
|
|
51
51
|
},
|
|
52
52
|
"homepage": "https://mastra.ai",
|
|
53
53
|
"repository": {
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
-
|
|
3
|
-
# Neon
|
|
4
|
-
|
|
5
|
-
Access 36 Neon models through Mastra's model router. Authentication is handled automatically using the `NEON_AI_GATEWAY_TOKEN` environment variable. Configure `NEON_AI_GATEWAY_BASE_URL` as well.
|
|
6
|
-
|
|
7
|
-
Learn more in the [Neon documentation](https://neon.com/docs).
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
NEON_AI_GATEWAY_BASE_URL=your-value
|
|
11
|
-
NEON_AI_GATEWAY_TOKEN=your-api-token
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
```typescript
|
|
15
|
-
import { Agent } from "@mastra/core/agent";
|
|
16
|
-
|
|
17
|
-
const agent = new Agent({
|
|
18
|
-
id: "my-agent",
|
|
19
|
-
name: "My Agent",
|
|
20
|
-
instructions: "You are a helpful assistant",
|
|
21
|
-
model: "neon/claude-haiku-4-5"
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
// Generate a response
|
|
25
|
-
const response = await agent.generate("Hello!");
|
|
26
|
-
|
|
27
|
-
// Stream a response
|
|
28
|
-
const stream = await agent.stream("Tell me a story");
|
|
29
|
-
for await (const chunk of stream) {
|
|
30
|
-
console.log(chunk);
|
|
31
|
-
}
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
> **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.
|
|
35
|
-
|
|
36
|
-
## Models
|
|
37
|
-
|
|
38
|
-
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
39
|
-
| ---------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
40
|
-
| `neon/claude-haiku-4-5` | 200K | | | | | | $1 | $5 |
|
|
41
|
-
| `neon/claude-opus-4-1` | 200K | | | | | | $15 | $75 |
|
|
42
|
-
| `neon/claude-opus-4-5` | 200K | | | | | | $5 | $25 |
|
|
43
|
-
| `neon/claude-opus-4-6` | 1.0M | | | | | | $5 | $25 |
|
|
44
|
-
| `neon/claude-opus-4-7` | 1.0M | | | | | | $5 | $25 |
|
|
45
|
-
| `neon/claude-opus-4-8` | 1.0M | | | | | | $5 | $25 |
|
|
46
|
-
| `neon/claude-sonnet-4` | 200K | | | | | | $3 | $15 |
|
|
47
|
-
| `neon/claude-sonnet-4-5` | 200K | | | | | | $3 | $15 |
|
|
48
|
-
| `neon/claude-sonnet-4-6` | 1.0M | | | | | | $3 | $15 |
|
|
49
|
-
| `neon/gemini-2-5-flash` | 1.0M | | | | | | $0.30 | $3 |
|
|
50
|
-
| `neon/gemini-2-5-pro` | 1.0M | | | | | | $1 | $10 |
|
|
51
|
-
| `neon/gemini-3-1-flash-lite` | 1.0M | | | | | | $0.25 | $2 |
|
|
52
|
-
| `neon/gemini-3-1-pro` | 1.0M | | | | | | $2 | $12 |
|
|
53
|
-
| `neon/gemini-3-5-flash` | 1.0M | | | | | | $2 | $9 |
|
|
54
|
-
| `neon/gemini-3-flash` | 1.0M | | | | | | $0.50 | $3 |
|
|
55
|
-
| `neon/gemini-3-pro` | 1.0M | | | | | | $2 | $12 |
|
|
56
|
-
| `neon/gemma-3-12b` | 131K | | | | | | $0.15 | $0.50 |
|
|
57
|
-
| `neon/gpt-5` | 400K | | | | | | $1 | $10 |
|
|
58
|
-
| `neon/gpt-5-1` | 400K | | | | | | $1 | $10 |
|
|
59
|
-
| `neon/gpt-5-1-codex-max` | 400K | | | | | | $1 | $10 |
|
|
60
|
-
| `neon/gpt-5-1-codex-mini` | 400K | | | | | | $0.25 | $2 |
|
|
61
|
-
| `neon/gpt-5-2` | 400K | | | | | | $2 | $14 |
|
|
62
|
-
| `neon/gpt-5-2-codex` | 400K | | | | | | $2 | $14 |
|
|
63
|
-
| `neon/gpt-5-3-codex` | 400K | | | | | | $2 | $14 |
|
|
64
|
-
| `neon/gpt-5-4` | 1.1M | | | | | | $3 | $15 |
|
|
65
|
-
| `neon/gpt-5-4-mini` | 400K | | | | | | $0.75 | $5 |
|
|
66
|
-
| `neon/gpt-5-4-nano` | 400K | | | | | | $0.20 | $1 |
|
|
67
|
-
| `neon/gpt-5-mini` | 400K | | | | | | $0.25 | $2 |
|
|
68
|
-
| `neon/gpt-5-nano` | 400K | | | | | | $0.05 | $0.40 |
|
|
69
|
-
| `neon/gpt-oss-120b` | 131K | | | | | | $0.07 | $0.28 |
|
|
70
|
-
| `neon/gpt-oss-20b` | 131K | | | | | | $0.05 | $0.20 |
|
|
71
|
-
| `neon/llama-4-maverick` | 1.0M | | | | | | $0.50 | $2 |
|
|
72
|
-
| `neon/meta-llama-3-1-8b-instruct` | 131K | | | | | | $0.15 | $0.45 |
|
|
73
|
-
| `neon/meta-llama-3-3-70b-instruct` | 128K | | | | | | $0.50 | $2 |
|
|
74
|
-
| `neon/qwen3-next-80b-a3b-instruct` | 131K | | | | | | $0.15 | $1 |
|
|
75
|
-
| `neon/qwen35-122b-a10b` | 262K | | | | | | $0.22 | $2 |
|
|
76
|
-
|
|
77
|
-
## Advanced configuration
|
|
78
|
-
|
|
79
|
-
### Custom headers
|
|
80
|
-
|
|
81
|
-
```typescript
|
|
82
|
-
const agent = new Agent({
|
|
83
|
-
id: "custom-agent",
|
|
84
|
-
name: "custom-agent",
|
|
85
|
-
model: {
|
|
86
|
-
url: "${NEON_AI_GATEWAY_BASE_URL}/v1",
|
|
87
|
-
id: "neon/claude-haiku-4-5",
|
|
88
|
-
apiKey: process.env.NEON_AI_GATEWAY_TOKEN,
|
|
89
|
-
headers: {
|
|
90
|
-
"X-Custom-Header": "value"
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### Dynamic model selection
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
const agent = new Agent({
|
|
100
|
-
id: "dynamic-agent",
|
|
101
|
-
name: "Dynamic Agent",
|
|
102
|
-
model: ({ requestContext }) => {
|
|
103
|
-
const useAdvanced = requestContext.task === "complex";
|
|
104
|
-
return useAdvanced
|
|
105
|
-
? "neon/qwen35-122b-a10b"
|
|
106
|
-
: "neon/claude-haiku-4-5";
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
```
|