@mastra/mcp-docs-server 0.13.4 → 0.13.5-alpha.0
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 +38 -38
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +33 -33
- 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 +52 -52
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +7 -0
- 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 +12 -12
- 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 +55 -55
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +37 -37
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +13 -13
- package/.docs/organized/changelogs/create-mastra.md +27 -27
- package/.docs/organized/changelogs/mastra.md +63 -63
- 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/client-js/overview.mdx +16 -0
- package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +279 -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/local-dev/mastra-dev.mdx +10 -3
- package/.docs/raw/memory/overview.mdx +2 -1
- 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/workflows/create-run.mdx +4 -4
- package/.docs/raw/reference/workflows/sendEvent.mdx +49 -0
- package/.docs/raw/workflows/overview.mdx +1 -1
- package/.docs/raw/workflows/pausing-execution.mdx +74 -37
- package/package.json +4 -4
|
@@ -63,6 +63,7 @@ const memory = new Memory({
|
|
|
63
63
|
// Or use a different model for title generation
|
|
64
64
|
// generateTitle: {
|
|
65
65
|
// model: openai("gpt-4.1-nano"), // Use cheaper model for titles
|
|
66
|
+
// instructions: "Generate a concise title based on the initial user message.", // Custom instructions for title
|
|
66
67
|
// },
|
|
67
68
|
},
|
|
68
69
|
},
|
|
@@ -109,9 +110,9 @@ const memory = new Memory({
|
|
|
109
110
|
});
|
|
110
111
|
```
|
|
111
112
|
|
|
112
|
-
#### Cost Optimization with Custom Models
|
|
113
|
+
#### Cost Optimization with Custom Models and Instructions
|
|
113
114
|
|
|
114
|
-
You can specify a different (typically cheaper) model for title generation while using a high-quality model for the main conversation:
|
|
115
|
+
You can specify a different (typically cheaper) model and custom instructions for title generation while using a high-quality model for the main conversation:
|
|
115
116
|
|
|
116
117
|
```typescript copy showLineNumbers
|
|
117
118
|
import { openai } from "@ai-sdk/openai";
|
|
@@ -121,6 +122,7 @@ const memory = new Memory({
|
|
|
121
122
|
threads: {
|
|
122
123
|
generateTitle: {
|
|
123
124
|
model: openai("gpt-4.1-nano"), // Cheaper model for titles
|
|
125
|
+
instructions: "Generate a concise, friendly title based on the initial user message.", // Custom title instructions
|
|
124
126
|
},
|
|
125
127
|
},
|
|
126
128
|
},
|
|
@@ -132,9 +134,9 @@ const agent = new Agent({
|
|
|
132
134
|
});
|
|
133
135
|
```
|
|
134
136
|
|
|
135
|
-
#### Dynamic Model Selection
|
|
137
|
+
#### Dynamic Model Selection and Instructions
|
|
136
138
|
|
|
137
|
-
You can also use a function to dynamically determine the model based on runtime context:
|
|
139
|
+
You can also use a function to dynamically determine the model and instructions based on runtime context:
|
|
138
140
|
|
|
139
141
|
```typescript copy showLineNumbers
|
|
140
142
|
const memory = new Memory({
|
|
@@ -148,6 +150,10 @@ const memory = new Memory({
|
|
|
148
150
|
? openai("gpt-4.1")
|
|
149
151
|
: openai("gpt-4.1-nano");
|
|
150
152
|
},
|
|
153
|
+
instructions: (ctx: RuntimeContext) => {
|
|
154
|
+
const language = ctx.get("userLanguage") || "English";
|
|
155
|
+
return `Generate a concise, engaging title in ${language} based on the user's first message.`;
|
|
156
|
+
},
|
|
151
157
|
},
|
|
152
158
|
},
|
|
153
159
|
},
|
|
@@ -285,9 +291,9 @@ Mastra supports many embedding models through the [Vercel AI SDK](https://sdk.ve
|
|
|
285
291
|
},
|
|
286
292
|
{
|
|
287
293
|
name: "threads",
|
|
288
|
-
type: "{ generateTitle?: boolean | { model: LanguageModelV1 | ((ctx: RuntimeContext) => LanguageModelV1 | Promise<LanguageModelV1>) } }",
|
|
294
|
+
type: "{ generateTitle?: boolean | { model: LanguageModelV1 | ((ctx: RuntimeContext) => LanguageModelV1 | Promise<LanguageModelV1>), instructions?: string | ((ctx: RuntimeContext) => string | Promise<string>) } }",
|
|
289
295
|
description:
|
|
290
|
-
"Settings related to memory thread creation. `generateTitle` controls automatic thread title generation from the user's first message. Can be a boolean to enable/disable using the agent's model, or an object
|
|
296
|
+
"Settings related to memory thread creation. `generateTitle` controls automatic thread title generation from the user's first message. Can be a boolean to enable/disable using the agent's model, or an object specifying a custom model or custom instructions for title generation (useful for cost optimization or title customization). Example: { generateTitle: { model: openai('gpt-4.1-nano'), instructions: 'Concise title based on the initial user message.' } }",
|
|
291
297
|
isOptional: true,
|
|
292
298
|
defaultValue: "{ generateTitle: false }",
|
|
293
299
|
},
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference: Workflow.
|
|
3
|
-
description: Documentation for the `.
|
|
2
|
+
title: "Reference: Workflow.createRunAsync() | Building Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `.createRunAsync()` method in workflows, which creates a new workflow run instance.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Workflow.
|
|
6
|
+
# Workflow.createRunAsync()
|
|
7
7
|
|
|
8
|
-
The `.
|
|
8
|
+
The `.createRunAsync()` method creates a new workflow run instance, allowing you to execute the workflow with specific input data.
|
|
9
9
|
|
|
10
10
|
## Usage
|
|
11
11
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Workflow.sendEvent() | Building Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `.sendEvent()` method in workflows, which resumes execution when an event is sent.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Workflow.sendEvent()
|
|
7
|
+
|
|
8
|
+
The `.sendEvent()` resumes execution when an event is sent.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
workflow.sendEvent('my-event-name', step1);
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
<PropertiesTable
|
|
19
|
+
content={[
|
|
20
|
+
{
|
|
21
|
+
name: "eventName",
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "The name of the event to send",
|
|
24
|
+
isOptional: false,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "step",
|
|
28
|
+
type: "Step",
|
|
29
|
+
description: "The step to resume after the event is sent",
|
|
30
|
+
isOptional: false,
|
|
31
|
+
},
|
|
32
|
+
]}
|
|
33
|
+
/>
|
|
34
|
+
|
|
35
|
+
## Returns
|
|
36
|
+
|
|
37
|
+
<PropertiesTable
|
|
38
|
+
content={[
|
|
39
|
+
{
|
|
40
|
+
name: "workflow",
|
|
41
|
+
type: "Workflow",
|
|
42
|
+
description: "The workflow instance for method chaining",
|
|
43
|
+
},
|
|
44
|
+
]}
|
|
45
|
+
/>
|
|
46
|
+
|
|
47
|
+
## Related
|
|
48
|
+
|
|
49
|
+
- [Sleep & Events](../../docs/workflows/pausing-execution.mdx)
|
|
@@ -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/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-alpha.0",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -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-alpha.0"
|
|
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
50
|
"@internal/lint": "0.0.17",
|
|
51
|
-
"@mastra/core": "0.10.
|
|
51
|
+
"@mastra/core": "0.10.11-alpha.2"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@mastra/core": "^0.10.0-alpha.0"
|