@mastra/mcp-docs-server 0.13.4 → 0.13.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/organized/changelogs/%40internal%2Fstorage-test-utils.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fagui.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +55 -55
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +47 -47
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +42 -42
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +24 -24
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +24 -24
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +72 -72
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +7 -0
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +9 -9
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +77 -77
- package/.docs/organized/changelogs/%40mastra%2Frag.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +54 -54
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +13 -13
- package/.docs/organized/changelogs/create-mastra.md +34 -34
- package/.docs/organized/changelogs/mastra.md +79 -79
- package/.docs/organized/code-examples/bird-checker-with-express.md +1 -1
- package/.docs/organized/code-examples/crypto-chatbot.md +9 -9
- package/.docs/organized/code-examples/fireworks-r1.md +1 -1
- package/.docs/organized/code-examples/memory-per-resource-example.md +1 -1
- package/.docs/organized/code-examples/memory-with-pg.md +1 -1
- package/.docs/organized/code-examples/memory-with-upstash.md +1 -1
- package/.docs/organized/code-examples/openapi-spec-writer.md +4 -4
- package/.docs/raw/agents/overview.mdx +16 -33
- package/.docs/raw/community/licensing.mdx +27 -19
- package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +279 -0
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +1 -1
- package/.docs/raw/deployment/server-deployment.mdx +56 -0
- package/.docs/raw/deployment/serverless-platforms/index.mdx +0 -1
- package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +97 -0
- package/.docs/raw/frameworks/agentic-uis/assistant-ui.mdx +34 -0
- package/.docs/raw/memory/overview.mdx +2 -1
- package/.docs/raw/rag/retrieval.mdx +24 -5
- package/.docs/raw/reference/agents/generate.mdx +3 -2
- package/.docs/raw/reference/agents/stream.mdx +3 -2
- package/.docs/raw/reference/cli/dev.mdx +12 -0
- package/.docs/raw/reference/legacyWorkflows/createRun.mdx +0 -4
- package/.docs/raw/reference/memory/Memory.mdx +12 -6
- package/.docs/raw/reference/rag/rerankWithScorer.mdx +213 -0
- package/.docs/raw/reference/workflows/create-run.mdx +4 -4
- package/.docs/raw/reference/workflows/sendEvent.mdx +49 -0
- package/.docs/raw/{local-dev/mastra-dev.mdx → server-db/local-dev-playground.mdx} +10 -3
- package/.docs/raw/{client-js/overview.mdx → server-db/mastra-client.mdx} +16 -0
- package/.docs/raw/server-db/production-server.mdx +66 -0
- package/.docs/raw/tools-mcp/mcp-overview.mdx +4 -6
- package/.docs/raw/workflows/control-flow.mdx +34 -34
- package/.docs/raw/workflows/overview.mdx +1 -1
- package/.docs/raw/workflows/pausing-execution.mdx +74 -37
- package/LICENSE.md +11 -42
- package/package.json +6 -6
- package/.docs/raw/deployment/server.mdx +0 -116
- /package/.docs/raw/{deployment → server-db}/custom-api-routes.mdx +0 -0
- /package/.docs/raw/{deployment → server-db}/middleware.mdx +0 -0
- /package/.docs/raw/{storage/overview.mdx → server-db/storage.mdx} +0 -0
|
@@ -10,9 +10,9 @@ When you build a workflow, you typically break down operations into smaller task
|
|
|
10
10
|
- If the schemas match, the `outputSchema` from each step is automatically passed to the `inputSchema` of the next step.
|
|
11
11
|
- If the schemas don't match, use [Input data mapping](./input-data-mapping.mdx) to transform the `outputSchema` into the expected `inputSchema`.
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Chaining steps with `.then()`
|
|
14
14
|
|
|
15
|
-
Chain steps to execute
|
|
15
|
+
Chain steps to execute sequentially using `.then()`:
|
|
16
16
|
|
|
17
17
|
```typescript {8-9} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
18
18
|
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
@@ -27,7 +27,9 @@ export const testWorkflow = createWorkflow({...})
|
|
|
27
27
|
.commit();
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
This does what you'd expect: it executes `step1`, then it executes `step2`.
|
|
31
|
+
|
|
32
|
+
## Parallel steps with `.parallel()`:
|
|
31
33
|
|
|
32
34
|
Execute steps in parallel using `.parallel()`:
|
|
33
35
|
|
|
@@ -37,17 +39,19 @@ import { z } from "zod";
|
|
|
37
39
|
|
|
38
40
|
const step1 = createStep({...});
|
|
39
41
|
const step2 = createStep({...});
|
|
42
|
+
const step3 = createStep({...});
|
|
40
43
|
|
|
41
44
|
export const testWorkflow = createWorkflow({...})
|
|
42
45
|
.parallel([step1, step2])
|
|
46
|
+
.then(step3)
|
|
43
47
|
.commit();
|
|
44
48
|
```
|
|
45
49
|
|
|
46
|
-
This executes
|
|
50
|
+
This executes `step1` and `step2` concurrently, then continues to `step3` after both complete.
|
|
47
51
|
|
|
48
52
|
> See [Parallel Execution with Steps](/examples/workflows/parallel-steps) for more information.
|
|
49
53
|
|
|
50
|
-
##
|
|
54
|
+
## Conditional branching (`.branch()`)
|
|
51
55
|
|
|
52
56
|
Create conditional branches using `.branch()`:
|
|
53
57
|
|
|
@@ -60,8 +64,8 @@ const greaterThanStep = createStep({...});
|
|
|
60
64
|
|
|
61
65
|
export const testWorkflow = createWorkflow({...})
|
|
62
66
|
.branch([
|
|
63
|
-
[async ({ inputData: {
|
|
64
|
-
[async ({ inputData: {
|
|
67
|
+
[async ({ inputData: { value } }) => (value < 9), lessThanStep],
|
|
68
|
+
[async ({ inputData: { value } }) => (value >= 9), greaterThanStep]
|
|
65
69
|
])
|
|
66
70
|
.commit();
|
|
67
71
|
```
|
|
@@ -70,17 +74,13 @@ Branch conditions are evaluated sequentially, but steps with matching conditions
|
|
|
70
74
|
|
|
71
75
|
> See [Workflow with Conditional Branching](/examples/workflows/conditional-branching) for more information.
|
|
72
76
|
|
|
73
|
-
##
|
|
77
|
+
## Looping commands
|
|
74
78
|
|
|
75
79
|
Workflows support two types of loops. When looping a step, or any step-compatible construct like a nested workflow, the initial `inputData` is sourced from the output of the previous step.
|
|
76
80
|
|
|
77
|
-
To ensure compatibility, the loop’s initial input must either
|
|
78
|
-
|
|
79
|
-
- Match the shape of the previous step’s output, or
|
|
80
|
-
- Be explicitly transformed using the `map` function.
|
|
81
|
+
To ensure compatibility, the loop’s initial input must either match the shape of the previous step’s output, or be explicitly transformed using the `map` function.
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
### Dowhile
|
|
83
|
+
### `.dowhile()`
|
|
84
84
|
|
|
85
85
|
Executes a step repeatedly while a condition is true.
|
|
86
86
|
|
|
@@ -95,7 +95,7 @@ export const testWorkflow = createWorkflow({...})
|
|
|
95
95
|
.commit();
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
-
###
|
|
98
|
+
### `.dountil()`
|
|
99
99
|
|
|
100
100
|
Executes a step repeatedly until a condition becomes true.
|
|
101
101
|
|
|
@@ -110,8 +110,7 @@ export const testWorkflow = createWorkflow({...})
|
|
|
110
110
|
.commit();
|
|
111
111
|
```
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
### Foreach
|
|
113
|
+
### `.foreach()`
|
|
115
114
|
|
|
116
115
|
Sequentially executes the same step for each item from the `inputSchema`.
|
|
117
116
|
|
|
@@ -126,7 +125,7 @@ export const testWorkflow = createWorkflow({...})
|
|
|
126
125
|
.commit();
|
|
127
126
|
```
|
|
128
127
|
|
|
129
|
-
### Early exit
|
|
128
|
+
### Early exit with `.bail()`
|
|
130
129
|
|
|
131
130
|
You can bail out of a workflow execution successfully by calling `bail()` in a step. This returns whatever payload is passed to the `bail()` function as the result of the workflow.
|
|
132
131
|
|
|
@@ -167,6 +166,7 @@ export const testWorkflow = createWorkflow({...})
|
|
|
167
166
|
.then(step1)
|
|
168
167
|
.commit();
|
|
169
168
|
```
|
|
169
|
+
|
|
170
170
|
#### Example Run Instance
|
|
171
171
|
|
|
172
172
|
The following example demonstrates how to start a run with multiple inputs. Each input will pass through the `mapStep` sequentially.
|
|
@@ -202,44 +202,44 @@ export const testWorkflow = createWorkflow({...})
|
|
|
202
202
|
.commit();
|
|
203
203
|
```
|
|
204
204
|
|
|
205
|
-
##
|
|
205
|
+
## Using a workflow as a step
|
|
206
206
|
|
|
207
|
-
|
|
207
|
+
For greater composability, you can re-use a workflow as a step in another workflow.
|
|
208
208
|
|
|
209
|
-
|
|
209
|
+
In the example below, `nestedWorkflow` is used as a step within `testWorkflow`. The `testWorkflow` uses `step1` while the `nestedWorkflow` composes `step2` and `step3`:
|
|
210
|
+
|
|
211
|
+
```typescript {4,7} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
210
212
|
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
211
213
|
import { z } from "zod";
|
|
212
214
|
|
|
213
|
-
const
|
|
214
|
-
const workflow2 = createWorkflow({...});
|
|
215
|
+
export const nestedWorkflow = createWorkflow({...})
|
|
215
216
|
|
|
216
217
|
export const testWorkflow = createWorkflow({...})
|
|
217
|
-
.
|
|
218
|
+
.then(nestedWorkflow)
|
|
218
219
|
.commit();
|
|
219
220
|
```
|
|
220
221
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
## Nested Workflows
|
|
222
|
+
When using `.branch()` or `.parallel()` to build more complex control flows, executing more than one step requires wrapping those steps in a nested workflow, along with a clear definition of how they should be executed.
|
|
224
223
|
|
|
225
|
-
|
|
224
|
+
## Running nested workflows in parallel
|
|
226
225
|
|
|
226
|
+
Workflows themselves can also be executed in parallel.
|
|
227
227
|
|
|
228
|
-
```typescript {4,
|
|
228
|
+
```typescript {4-5,8} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
229
229
|
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
230
230
|
import { z } from "zod";
|
|
231
231
|
|
|
232
|
-
|
|
232
|
+
const workflow1 = createWorkflow({...});
|
|
233
|
+
const workflow2 = createWorkflow({...});
|
|
233
234
|
|
|
234
235
|
export const testWorkflow = createWorkflow({...})
|
|
235
|
-
.
|
|
236
|
+
.parallel([workflow1, workflow2])
|
|
236
237
|
.commit();
|
|
237
238
|
```
|
|
238
239
|
|
|
239
|
-
|
|
240
|
-
|
|
240
|
+
Parallel steps receive previous step results as input. Their outputs are passed into the next step input as an object where the key is the step `id` and the value is the step `output`.
|
|
241
241
|
|
|
242
|
-
##
|
|
242
|
+
## Cloning workflows
|
|
243
243
|
|
|
244
244
|
In the example below, `clonedWorkflow` is a clone of `workflow1` and is used as a step within `testWorkflow`. The `clonedWorkflow` is run sequentially after `step1`.
|
|
245
245
|
|
|
@@ -5,56 +5,93 @@ description: "Pausing execution in Mastra workflows allows you to pause executio
|
|
|
5
5
|
|
|
6
6
|
# Sleep & Events
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Mastra lets you pause workflow execution when waiting for external input or timing conditions. This can be useful for things like polling, delayed retries, or waiting on user actions.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
You can pause execution using:
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
- `sleep()`: Pause for a set number of milliseconds
|
|
13
|
+
- `sleepUntil()`: Pause until a specific timestamp
|
|
14
|
+
- `waitForEvent()`: Pause until an external event is received
|
|
15
|
+
- `sendEvent()`: Send an event to resume a waiting workflow
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
When using any of these methods, the workflow status is set to `waiting` until execution resumes.
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
## sleep
|
|
20
|
+
|
|
21
|
+
The `sleep()` method pauses execution between steps for a specified number of milliseconds.
|
|
22
|
+
|
|
23
|
+
```typescript {9} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
24
|
+
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
25
|
+
import { z } from "zod";
|
|
26
|
+
|
|
27
|
+
const step1 = createStep({...});
|
|
28
|
+
const step2 = createStep({...});
|
|
29
|
+
|
|
30
|
+
export const testWorkflow = createWorkflow({...})
|
|
31
|
+
.then(step1)
|
|
32
|
+
.sleep(1000)
|
|
33
|
+
.then(step2)
|
|
34
|
+
.commit();
|
|
22
35
|
```
|
|
23
36
|
|
|
24
|
-
## sleepUntil
|
|
37
|
+
## sleepUntil
|
|
25
38
|
|
|
26
|
-
`sleepUntil()` pauses execution until a specified date.
|
|
39
|
+
The `sleepUntil()` method pauses execution between steps until a specified date.
|
|
27
40
|
|
|
28
|
-
```typescript
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
```typescript {9} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
42
|
+
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
43
|
+
import { z } from "zod";
|
|
44
|
+
|
|
45
|
+
const step1 = createStep({...});
|
|
46
|
+
const step2 = createStep({...});
|
|
47
|
+
|
|
48
|
+
export const testWorkflow = createWorkflow({...})
|
|
49
|
+
.then(step1)
|
|
50
|
+
.sleepUntil(new Date(Date.now() + 5000))
|
|
51
|
+
.then(step2)
|
|
52
|
+
.commit();
|
|
34
53
|
```
|
|
35
54
|
|
|
36
|
-
|
|
55
|
+
> `Date.now()` is evaluated when the workflow starts, not at the moment the `sleepUntil()` method is called.
|
|
37
56
|
|
|
38
|
-
|
|
57
|
+
## waitForEvent
|
|
39
58
|
|
|
40
|
-
|
|
59
|
+
The `waitForEvent()` method pauses execution until a specific event is received. Use `run.sendEvent()` to send the event. You must provide both the event name and the step to resume.
|
|
41
60
|
|
|
42
|
-
```typescript
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
.waitForEvent('my-event-name', step2)
|
|
46
|
-
.then(step3)
|
|
47
|
-
.commit();
|
|
61
|
+
```typescript {10} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
62
|
+
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
63
|
+
import { z } from "zod";
|
|
48
64
|
|
|
49
|
-
const
|
|
50
|
-
|
|
65
|
+
const step1 = createStep({...});
|
|
66
|
+
const step2 = createStep({...});
|
|
67
|
+
const step3 = createStep({...});
|
|
68
|
+
|
|
69
|
+
export const testWorkflow = createWorkflow({...})
|
|
70
|
+
.then(step1)
|
|
71
|
+
.waitForEvent("my-event-name", step2)
|
|
72
|
+
.then(step3)
|
|
73
|
+
.commit();
|
|
74
|
+
```
|
|
75
|
+
## sendEvent
|
|
76
|
+
|
|
77
|
+
The `.sendEvent()` method sends an event to the workflow. It accepts the event name and optional event data, which can be any JSON-serializable value.
|
|
78
|
+
|
|
79
|
+
```typescript {5,12,15} filename="src/test-workflow.ts" showLineNumbers copy
|
|
80
|
+
import { mastra } from "./mastra";
|
|
81
|
+
|
|
82
|
+
const run = await mastra.getWorkflow("testWorkflow").createRunAsync();
|
|
83
|
+
|
|
84
|
+
const result = run.start({
|
|
85
|
+
inputData: {
|
|
86
|
+
value: "hello"
|
|
87
|
+
}
|
|
88
|
+
});
|
|
51
89
|
|
|
52
90
|
setTimeout(() => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
```
|
|
91
|
+
run.sendEvent("my-event-name", { value: "from event" });
|
|
92
|
+
}, 3000);
|
|
93
|
+
|
|
94
|
+
console.log(JSON.stringify(await result, null, 2));
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
> In this example, avoid using `await run.start()` directly, it would block sending the event before the workflow reaches its waiting state.
|
package/LICENSE.md
CHANGED
|
@@ -1,46 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Apache License 2.0
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025
|
|
3
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
|
|
17
|
-
|
|
18
|
-
**Patents**
|
|
19
|
-
The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
20
|
-
|
|
21
|
-
**Notices**
|
|
22
|
-
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
|
|
23
|
-
|
|
24
|
-
If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
|
|
25
|
-
|
|
26
|
-
**No Other Rights**
|
|
27
|
-
These terms do not imply any licenses other than those expressly granted in these terms.
|
|
28
|
-
|
|
29
|
-
**Termination**
|
|
30
|
-
If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
|
|
31
|
-
|
|
32
|
-
**No Liability**
|
|
33
|
-
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
|
|
34
|
-
|
|
35
|
-
**Definitions**
|
|
36
|
-
The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
|
|
37
|
-
|
|
38
|
-
_you_ refers to the individual or entity agreeing to these terms.
|
|
39
|
-
|
|
40
|
-
_your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
41
|
-
|
|
42
|
-
_your licenses_ are all the licenses granted to you for the software under these terms.
|
|
43
|
-
|
|
44
|
-
_use_ means anything you do with the software requiring one of your licenses.
|
|
45
|
-
|
|
46
|
-
_trademark_ means trademarks, service marks, and similar rights.
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.5",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"keywords": [],
|
|
24
24
|
"author": "",
|
|
25
|
-
"license": "
|
|
25
|
+
"license": "Apache-2.0",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@modelcontextprotocol/sdk": "^1.13.0",
|
|
28
28
|
"date-fns": "^4.1.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"uuid": "^11.1.0",
|
|
33
33
|
"zod": "^3.25.67",
|
|
34
34
|
"zod-to-json-schema": "^3.24.5",
|
|
35
|
-
"@mastra/mcp": "^0.10.
|
|
35
|
+
"@mastra/mcp": "^0.10.6"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@hono/node-server": "^1.14.4",
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
"@wong2/mcp-cli": "^1.10.0",
|
|
43
43
|
"cross-env": "^7.0.3",
|
|
44
44
|
"eslint": "^9.29.0",
|
|
45
|
-
"hono": "^4.8.
|
|
45
|
+
"hono": "^4.8.4",
|
|
46
46
|
"tsup": "^8.5.0",
|
|
47
47
|
"tsx": "^4.19.4",
|
|
48
48
|
"typescript": "^5.8.3",
|
|
49
49
|
"vitest": "^3.2.4",
|
|
50
|
-
"@internal/lint": "0.0.
|
|
51
|
-
"@mastra/core": "0.10.
|
|
50
|
+
"@internal/lint": "0.0.18",
|
|
51
|
+
"@mastra/core": "0.10.11"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@mastra/core": "^0.10.0-alpha.0"
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Creating A Mastra Server"
|
|
3
|
-
description: "Configure and customize the Mastra server with middleware and other options"
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Creating A Mastra Server
|
|
7
|
-
|
|
8
|
-
While developing or when you deploy a Mastra application, it runs as an HTTP server that exposes your agents, workflows, and other functionality as API endpoints. This page explains how to configure and customize the server behavior.
|
|
9
|
-
|
|
10
|
-
## Server Architecture
|
|
11
|
-
|
|
12
|
-
Mastra uses [Hono](https://hono.dev) as its underlying HTTP server framework. When you build a Mastra application using `mastra build`, it generates a Hono-based HTTP server in the `.mastra` directory.
|
|
13
|
-
|
|
14
|
-
The server provides:
|
|
15
|
-
|
|
16
|
-
- API endpoints for all registered agents
|
|
17
|
-
- API endpoints for all registered workflows
|
|
18
|
-
- Custom api route supports
|
|
19
|
-
- Custom middleware support
|
|
20
|
-
- Configuration of timeout
|
|
21
|
-
- Configuration of port
|
|
22
|
-
- Configuration of body limit
|
|
23
|
-
|
|
24
|
-
See the [Middleware](/docs/deployment/middleware) and
|
|
25
|
-
[Custom API Routes](/docs/deployment/custom-api-routes) pages for details on
|
|
26
|
-
adding additional server behaviour.
|
|
27
|
-
|
|
28
|
-
## Server configuration
|
|
29
|
-
|
|
30
|
-
You can configure server `port` and `timeout` in the Mastra instance.
|
|
31
|
-
|
|
32
|
-
```typescript copy showLineNumbers
|
|
33
|
-
import { Mastra } from "@mastra/core";
|
|
34
|
-
|
|
35
|
-
export const mastra = new Mastra({
|
|
36
|
-
server: {
|
|
37
|
-
port: 3000, // Defaults to 4111
|
|
38
|
-
timeout: 10000, // Defaults to 30000 (30s)
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
The `method` option can be one of `"GET"`, `"POST"`, `"PUT"`,
|
|
44
|
-
`"DELETE"` or `"ALL"`. Using `"ALL"` will cause the handler to be
|
|
45
|
-
invoked for any HTTP method that matches the path.
|
|
46
|
-
|
|
47
|
-
## Custom CORS Config
|
|
48
|
-
|
|
49
|
-
Mastra allows you to configure CORS (Cross-Origin Resource Sharing) settings for your server.
|
|
50
|
-
|
|
51
|
-
```typescript copy showLineNumbers
|
|
52
|
-
import { Mastra } from "@mastra/core";
|
|
53
|
-
|
|
54
|
-
export const mastra = new Mastra({
|
|
55
|
-
server: {
|
|
56
|
-
cors: {
|
|
57
|
-
origin: ["https://example.com"], // Allow specific origins or '*' for all
|
|
58
|
-
allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
|
59
|
-
allowHeaders: ["Content-Type", "Authorization"],
|
|
60
|
-
credentials: false,
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Deployment
|
|
67
|
-
|
|
68
|
-
Since Mastra builds to a standard Node.js server, you can deploy to any platform that runs Node.js applications:
|
|
69
|
-
|
|
70
|
-
- Cloud VMs (AWS EC2, DigitalOcean Droplets, GCP Compute Engine)
|
|
71
|
-
- Container platforms (Docker, Kubernetes)
|
|
72
|
-
- Platform as a Service (Heroku, Railway)
|
|
73
|
-
- Self-hosted servers
|
|
74
|
-
|
|
75
|
-
### Building
|
|
76
|
-
|
|
77
|
-
Build the application:
|
|
78
|
-
|
|
79
|
-
```bash copy
|
|
80
|
-
# Build from current directory
|
|
81
|
-
mastra build
|
|
82
|
-
|
|
83
|
-
# Or specify a directory
|
|
84
|
-
mastra build --dir ./my-project
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
The build process:
|
|
88
|
-
|
|
89
|
-
1. Locates entry file (`src/mastra/index.ts` or `src/mastra/index.js`)
|
|
90
|
-
2. Creates `.mastra` output directory
|
|
91
|
-
3. Bundles code using Rollup with tree shaking and source maps
|
|
92
|
-
4. Generates [Hono](https://hono.dev) HTTP server
|
|
93
|
-
|
|
94
|
-
See [`mastra build`](/reference/cli/build) for all options.
|
|
95
|
-
|
|
96
|
-
### Running the Server
|
|
97
|
-
|
|
98
|
-
Start the HTTP server:
|
|
99
|
-
|
|
100
|
-
```bash copy
|
|
101
|
-
node .mastra/output/index.mjs
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### Enable Telemetry for build output
|
|
105
|
-
|
|
106
|
-
Load instrumentation for the build output like so:
|
|
107
|
-
|
|
108
|
-
```bash copy
|
|
109
|
-
node --import=./.mastra/output/instrumentation.mjs .mastra/output/index.mjs
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
## Serverless Deployment
|
|
113
|
-
|
|
114
|
-
Mastra also supports serverless deployment on Cloudflare Workers, Vercel, and Netlify.
|
|
115
|
-
|
|
116
|
-
See our [Serverless Deployment](/docs/deployment/deployment) guide for setup instructions.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|