@mastra/mcp-docs-server 1.0.0-beta.11 → 1.0.0-beta.13
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/%40mastra%2Fagent-builder.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +24 -24
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +83 -83
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +38 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +174 -174
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +27 -27
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Flance.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +15 -15
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +13 -13
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +75 -75
- package/.docs/organized/changelogs/%40mastra%2Freact.md +40 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +29 -29
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +39 -39
- package/.docs/organized/changelogs/create-mastra.md +29 -29
- package/.docs/organized/changelogs/mastra.md +35 -35
- package/.docs/organized/code-examples/quick-start.md +0 -4
- package/.docs/organized/code-examples/stock-price-tool.md +21 -2
- package/.docs/raw/agents/agent-approval.mdx +136 -2
- package/.docs/raw/agents/agent-memory.mdx +4 -4
- package/.docs/raw/agents/guardrails.mdx +1 -1
- package/.docs/raw/agents/networks.mdx +1 -1
- package/.docs/raw/agents/overview.mdx +2 -2
- package/.docs/raw/agents/using-tools.mdx +1 -1
- package/.docs/raw/course/01-first-agent/07-creating-your-agent.md +1 -2
- package/.docs/raw/course/01-first-agent/12-connecting-tool-to-agent.md +1 -1
- package/.docs/raw/course/01-first-agent/16-adding-memory-to-agent.md +1 -2
- package/.docs/raw/course/02-agent-tools-mcp/05-updating-your-agent.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/10-updating-agent-instructions-zapier.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/16-updating-agent-instructions-github.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/21-updating-agent-instructions-hackernews.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/27-updating-agent-instructions-filesystem.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/31-enhancing-memory-configuration.md +2 -2
- package/.docs/raw/course/03-agent-memory/04-creating-basic-memory-agent.md +1 -2
- package/.docs/raw/course/03-agent-memory/08-configuring-conversation-history.md +1 -2
- package/.docs/raw/course/03-agent-memory/16-configuring-semantic-recall.md +3 -4
- package/.docs/raw/course/03-agent-memory/21-configuring-working-memory.md +2 -3
- package/.docs/raw/course/03-agent-memory/22-custom-working-memory-templates.md +2 -3
- package/.docs/raw/course/03-agent-memory/25-combining-memory-features.md +1 -2
- package/.docs/raw/course/03-agent-memory/27-creating-learning-assistant.md +2 -3
- package/.docs/raw/course/04-workflows/11-creating-an-ai-agent.md +2 -3
- package/.docs/raw/deployment/cloud-providers.mdx +20 -0
- package/.docs/raw/deployment/{building-mastra.mdx → mastra-server.mdx} +2 -2
- package/.docs/raw/deployment/monorepo.mdx +23 -44
- package/.docs/raw/deployment/overview.mdx +28 -53
- package/.docs/raw/deployment/web-framework.mdx +12 -14
- package/.docs/raw/getting-started/start.mdx +10 -1
- package/.docs/raw/getting-started/studio.mdx +1 -1
- package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +1021 -67
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/aws-lambda.mdx +3 -6
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/azure-app-services.mdx +4 -6
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/cloudflare-deployer.mdx +4 -0
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/digital-ocean.mdx +3 -6
- package/.docs/raw/guides/deployment/index.mdx +32 -0
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/netlify-deployer.mdx +4 -0
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/vercel-deployer.mdx +4 -0
- package/.docs/raw/guides/getting-started/express.mdx +71 -152
- package/.docs/raw/guides/getting-started/hono.mdx +227 -0
- package/.docs/raw/guides/getting-started/next-js.mdx +173 -63
- package/.docs/raw/guides/getting-started/vite-react.mdx +307 -137
- package/.docs/raw/guides/guide/research-assistant.mdx +4 -4
- package/.docs/raw/guides/migrations/upgrade-to-v1/client.mdx +17 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/overview.mdx +6 -0
- package/.docs/raw/index.mdx +1 -1
- package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/dashboard.mdx +2 -6
- package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/observability.mdx +1 -5
- package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/overview.mdx +2 -6
- package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/setting-up.mdx +3 -6
- package/.docs/raw/memory/overview.mdx +1 -1
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +1 -1
- package/.docs/raw/memory/storage/memory-with-mongodb.mdx +1 -1
- package/.docs/raw/memory/storage/memory-with-pg.mdx +1 -1
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +1 -1
- package/.docs/raw/{server-db/storage.mdx → memory/storage/overview.mdx} +2 -2
- package/.docs/raw/observability/logging.mdx +1 -1
- package/.docs/raw/observability/tracing/exporters/cloud.mdx +1 -1
- package/.docs/raw/observability/tracing/exporters/default.mdx +1 -1
- package/.docs/raw/rag/chunking-and-embedding.mdx +12 -25
- package/.docs/raw/rag/graph-rag.mdx +220 -0
- package/.docs/raw/rag/overview.mdx +1 -2
- package/.docs/raw/rag/retrieval.mdx +13 -29
- package/.docs/raw/rag/vector-databases.mdx +7 -3
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +1 -1
- package/.docs/raw/reference/agents/getDefaultOptions.mdx +1 -1
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +1 -1
- package/.docs/raw/reference/agents/getInstructions.mdx +1 -1
- package/.docs/raw/reference/agents/getLLM.mdx +1 -1
- package/.docs/raw/reference/agents/getMemory.mdx +1 -1
- package/.docs/raw/reference/agents/getModel.mdx +1 -1
- package/.docs/raw/reference/agents/listScorers.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/chat-route.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/handle-chat-stream.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/handle-network-stream.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/handle-workflow-stream.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/network-route.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v4-messages.mdx +127 -0
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v5-messages.mdx +107 -0
- package/.docs/raw/reference/ai-sdk/workflow-route.mdx +1 -1
- package/.docs/raw/reference/auth/auth0.mdx +1 -1
- package/.docs/raw/reference/auth/clerk.mdx +1 -1
- package/.docs/raw/reference/auth/firebase.mdx +1 -1
- package/.docs/raw/reference/auth/jwt.mdx +1 -1
- package/.docs/raw/reference/auth/supabase.mdx +1 -1
- package/.docs/raw/reference/auth/workos.mdx +1 -1
- package/.docs/raw/reference/cli/mastra.mdx +1 -1
- package/.docs/raw/reference/client-js/mastra-client.mdx +1 -1
- package/.docs/raw/reference/client-js/workflows.mdx +20 -0
- package/.docs/raw/reference/core/getServer.mdx +2 -2
- package/.docs/raw/reference/core/getStorage.mdx +1 -1
- package/.docs/raw/reference/core/getStoredAgentById.mdx +1 -1
- package/.docs/raw/reference/core/listStoredAgents.mdx +1 -1
- package/.docs/raw/reference/core/setStorage.mdx +1 -1
- package/.docs/raw/reference/logging/pino-logger.mdx +1 -1
- package/.docs/raw/reference/rag/database-config.mdx +1 -1
- package/.docs/raw/reference/server/create-route.mdx +1 -1
- package/.docs/raw/reference/server/express-adapter.mdx +4 -4
- package/.docs/raw/reference/server/hono-adapter.mdx +4 -4
- package/.docs/raw/reference/server/mastra-server.mdx +2 -2
- package/.docs/raw/reference/server/routes.mdx +28 -1
- package/.docs/raw/reference/streaming/agents/stream.mdx +22 -0
- package/.docs/raw/reference/streaming/workflows/stream.mdx +33 -20
- package/.docs/raw/reference/tools/create-tool.mdx +23 -1
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +3 -3
- package/.docs/raw/reference/tools/vector-query-tool.mdx +3 -3
- package/.docs/raw/reference/workflows/run-methods/startAsync.mdx +143 -0
- package/.docs/raw/reference/workflows/workflow-methods/create-run.mdx +35 -0
- package/.docs/raw/reference/workflows/workflow.mdx +14 -0
- package/.docs/raw/{auth → server/auth}/auth0.mdx +1 -1
- package/.docs/raw/{auth → server/auth}/clerk.mdx +1 -1
- package/.docs/raw/{auth → server/auth}/firebase.mdx +1 -1
- package/.docs/raw/{auth → server/auth}/index.mdx +6 -6
- package/.docs/raw/{auth → server/auth}/jwt.mdx +1 -1
- package/.docs/raw/{auth → server/auth}/supabase.mdx +1 -1
- package/.docs/raw/{auth → server/auth}/workos.mdx +1 -1
- package/.docs/raw/{server-db → server}/custom-adapters.mdx +3 -3
- package/.docs/raw/{server-db → server}/custom-api-routes.mdx +1 -1
- package/.docs/raw/{server-db → server}/mastra-client.mdx +2 -2
- package/.docs/raw/{server-db → server}/mastra-server.mdx +5 -5
- package/.docs/raw/{server-db → server}/middleware.mdx +2 -2
- package/.docs/raw/{server-db → server}/request-context.mdx +3 -3
- package/.docs/raw/{server-db → server}/server-adapters.mdx +6 -6
- package/.docs/raw/tools-mcp/overview.mdx +2 -2
- package/.docs/raw/workflows/error-handling.mdx +162 -1
- package/.docs/raw/workflows/overview.mdx +2 -2
- package/CHANGELOG.md +14 -0
- package/package.json +3 -3
- package/.docs/organized/changelogs/%40internal%2Fai-sdk-v4.md +0 -1
- package/.docs/raw/deployment/cloud-providers/index.mdx +0 -55
- /package/.docs/raw/{deployment/cloud-providers → guides/deployment}/amazon-ec2.mdx +0 -0
|
@@ -7,7 +7,7 @@ import PropertiesTable from "@site/src/components/PropertiesTable";
|
|
|
7
7
|
|
|
8
8
|
# handleNetworkStream()
|
|
9
9
|
|
|
10
|
-
Framework-agnostic handler for streaming network execution in AI SDK-compatible format. Use this function directly when you need to handle network streaming outside Hono or Mastra's own [apiRoutes](/docs/v1/server
|
|
10
|
+
Framework-agnostic handler for streaming network execution in AI SDK-compatible format. Use this function directly when you need to handle network streaming outside Hono or Mastra's own [apiRoutes](/docs/v1/server/custom-api-routes) feature.
|
|
11
11
|
|
|
12
12
|
`handleNetworkStream()` returns a `ReadableStream` that you can wrap with [`createUIMessageStreamResponse()`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/create-ui-message-stream-response).
|
|
13
13
|
|
|
@@ -7,7 +7,7 @@ import PropertiesTable from "@site/src/components/PropertiesTable";
|
|
|
7
7
|
|
|
8
8
|
# handleWorkflowStream()
|
|
9
9
|
|
|
10
|
-
Framework-agnostic handler for streaming workflow execution in AI SDK-compatible format. Use this function directly when you need to handle workflow streaming outside Hono or Mastra's own [apiRoutes](/docs/v1/server
|
|
10
|
+
Framework-agnostic handler for streaming workflow execution in AI SDK-compatible format. Use this function directly when you need to handle workflow streaming outside Hono or Mastra's own [apiRoutes](/docs/v1/server/custom-api-routes) feature.
|
|
11
11
|
|
|
12
12
|
`handleWorkflowStream()` returns a `ReadableStream` that you can wrap with [`createUIMessageStreamResponse()`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/create-ui-message-stream-response).
|
|
13
13
|
|
|
@@ -7,7 +7,7 @@ import PropertiesTable from "@site/src/components/PropertiesTable";
|
|
|
7
7
|
|
|
8
8
|
# networkRoute()
|
|
9
9
|
|
|
10
|
-
Creates a network route handler for streaming network execution using the AI SDK format. This function registers an HTTP `POST` endpoint that accepts messages, executes an agent network, and streams the response back to the client in AI SDK-compatible format. Agent networks allow a routing agent to delegate tasks to other agents. You have to use it inside a [custom API route](/docs/v1/server
|
|
10
|
+
Creates a network route handler for streaming network execution using the AI SDK format. This function registers an HTTP `POST` endpoint that accepts messages, executes an agent network, and streams the response back to the client in AI SDK-compatible format. Agent networks allow a routing agent to delegate tasks to other agents. You have to use it inside a [custom API route](/docs/v1/server/custom-api-routes).
|
|
11
11
|
|
|
12
12
|
Use [`handleNetworkStream()`](/reference/v1/ai-sdk/handle-network-stream) if you need a framework-agnostic handler.
|
|
13
13
|
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: toAISdkV4Messages() | AI SDK"
|
|
3
|
+
description: API reference for toAISdkV4Messages(), a function to convert Mastra messages to AI SDK v4 UI messages.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import PropertiesTable from "@site/src/components/PropertiesTable";
|
|
7
|
+
|
|
8
|
+
# toAISdkV4Messages()
|
|
9
|
+
|
|
10
|
+
Converts messages from various input formats to AI SDK V4 UI message format. This function accepts messages in multiple formats (strings, AI SDK V4/V5 messages, Mastra DB messages, etc.) and normalizes them to the AI SDK V4 `UIMessage` format, which is suitable for use with AI SDK UI components like `useChat()`.
|
|
11
|
+
|
|
12
|
+
## Usage example
|
|
13
|
+
|
|
14
|
+
```typescript title="app/chat/page.tsx" copy
|
|
15
|
+
import { toAISdkV4Messages } from "@mastra/ai-sdk";
|
|
16
|
+
import { useChat } from "ai/react"; // AI SDK V4
|
|
17
|
+
|
|
18
|
+
// Stored messages from your database, memory or API
|
|
19
|
+
const storedMessages = [
|
|
20
|
+
{ id: "1", role: "user", parts: [{ type: "text", text: "Hello" }] },
|
|
21
|
+
{ id: "2", role: "assistant", parts: [{ type: "text", text: "Hi there!" }] }
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
export default function Chat() {
|
|
25
|
+
const { messages } = useChat({
|
|
26
|
+
initialMessages: toAISdkV4Messages(storedMessages)
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div>
|
|
31
|
+
{messages.map((message) => (
|
|
32
|
+
<div key={message.id}>
|
|
33
|
+
{message.role}: {message.content}
|
|
34
|
+
</div>
|
|
35
|
+
))}
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Parameters
|
|
42
|
+
|
|
43
|
+
<PropertiesTable
|
|
44
|
+
content={[
|
|
45
|
+
{
|
|
46
|
+
name: "messages",
|
|
47
|
+
type: "MessageListInput",
|
|
48
|
+
description: "Messages to convert. Can be a string, array of strings, a single message object, or an array of message objects in any supported format.",
|
|
49
|
+
isOptional: false,
|
|
50
|
+
},
|
|
51
|
+
]}
|
|
52
|
+
/>
|
|
53
|
+
|
|
54
|
+
## Returns
|
|
55
|
+
|
|
56
|
+
Returns an array of AI SDK V4 `UIMessage` objects with the following structure:
|
|
57
|
+
|
|
58
|
+
<PropertiesTable
|
|
59
|
+
content={[
|
|
60
|
+
{
|
|
61
|
+
name: "id",
|
|
62
|
+
type: "string",
|
|
63
|
+
description: "Unique message identifier.",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "role",
|
|
67
|
+
type: "'user' | 'assistant' | 'system'",
|
|
68
|
+
description: "The role of the message sender.",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "content",
|
|
72
|
+
type: "string",
|
|
73
|
+
description: "Text content of the message.",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "parts",
|
|
77
|
+
type: "UIMessagePart[]",
|
|
78
|
+
description: "Array of UI parts including text, tool-invocation, file, reasoning, source, and step markers.",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "createdAt",
|
|
82
|
+
type: "Date",
|
|
83
|
+
description: "Message creation timestamp.",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "toolInvocations",
|
|
87
|
+
type: "ToolInvocation[]",
|
|
88
|
+
description: "Array of tool invocations for assistant messages.",
|
|
89
|
+
isOptional: true,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "experimental_attachments",
|
|
93
|
+
type: "Attachment[]",
|
|
94
|
+
description: "File attachments on the message.",
|
|
95
|
+
isOptional: true,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "metadata",
|
|
99
|
+
type: "Record<string, unknown>",
|
|
100
|
+
description: "Custom metadata attached to the message.",
|
|
101
|
+
isOptional: true,
|
|
102
|
+
},
|
|
103
|
+
]}
|
|
104
|
+
/>
|
|
105
|
+
|
|
106
|
+
## Examples
|
|
107
|
+
|
|
108
|
+
### Converting simple text messages
|
|
109
|
+
|
|
110
|
+
```typescript copy
|
|
111
|
+
import { toAISdkV4Messages } from "@mastra/ai-sdk";
|
|
112
|
+
|
|
113
|
+
const messages = toAISdkV4Messages(["Hello", "How can I help you today?"]);
|
|
114
|
+
// Returns array of UIMessage objects with user role and content string
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Loading messages with Mastra client
|
|
118
|
+
|
|
119
|
+
```typescript copy
|
|
120
|
+
import { MastraClient } from "@mastra/client-js";
|
|
121
|
+
import { toAISdkV4Messages } from "@mastra/ai-sdk";
|
|
122
|
+
|
|
123
|
+
const client = new MastraClient();
|
|
124
|
+
|
|
125
|
+
const { messages } = await client.listThreadMessages("thread-id", { agentId: "myAgent" });
|
|
126
|
+
const uiMessages = toAISdkV4Messages(messages);
|
|
127
|
+
```
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: toAISdkV5Messages() | AI SDK"
|
|
3
|
+
description: API reference for toAISdkV5Messages(), a function to convert Mastra messages to AI SDK v5 UI messages.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import PropertiesTable from "@site/src/components/PropertiesTable";
|
|
7
|
+
|
|
8
|
+
# toAISdkV5Messages()
|
|
9
|
+
|
|
10
|
+
Converts messages from various input formats to AI SDK V5 UI message format. This function accepts messages in multiple formats (strings, AI SDK V4/V5 messages, Mastra DB messages, etc.) and normalizes them to the AI SDK V5 `UIMessage` format, which is suitable for use with AI SDK UI components like `useChat()`.
|
|
11
|
+
|
|
12
|
+
## Usage example
|
|
13
|
+
|
|
14
|
+
```typescript title="app/chat/page.tsx" copy
|
|
15
|
+
import { toAISdkV5Messages } from "@mastra/ai-sdk";
|
|
16
|
+
import { useChat } from "ai/react";
|
|
17
|
+
|
|
18
|
+
// Stored messages from your database, memory or API
|
|
19
|
+
const storedMessages = [
|
|
20
|
+
{ id: "1", role: "user", content: "Hello", parts: [{ type: "text", text: "Hello" }] },
|
|
21
|
+
{ id: "2", role: "assistant", content: "Hi there!", parts: [{ type: "text", text: "Hi there!" }] }
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
export default function Chat() {
|
|
25
|
+
const { messages } = useChat({
|
|
26
|
+
initialMessages: toAISdkV5Messages(storedMessages)
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div>
|
|
31
|
+
{messages.map((message) => (
|
|
32
|
+
<div key={message.id}>
|
|
33
|
+
{message.role}: {message.parts.map(part =>
|
|
34
|
+
part.type === "text" ? part.text : null
|
|
35
|
+
)}
|
|
36
|
+
</div>
|
|
37
|
+
))}
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Parameters
|
|
44
|
+
|
|
45
|
+
<PropertiesTable
|
|
46
|
+
content={[
|
|
47
|
+
{
|
|
48
|
+
name: "messages",
|
|
49
|
+
type: "MessageListInput",
|
|
50
|
+
description: "Messages to convert. Can be a string, array of strings, a single message object, or an array of message objects in any supported format.",
|
|
51
|
+
isOptional: false,
|
|
52
|
+
},
|
|
53
|
+
]}
|
|
54
|
+
/>
|
|
55
|
+
|
|
56
|
+
## Returns
|
|
57
|
+
|
|
58
|
+
Returns an array of AI SDK V5 `UIMessage` objects with the following structure:
|
|
59
|
+
|
|
60
|
+
<PropertiesTable
|
|
61
|
+
content={[
|
|
62
|
+
{
|
|
63
|
+
name: "id",
|
|
64
|
+
type: "string",
|
|
65
|
+
description: "Unique message identifier.",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "role",
|
|
69
|
+
type: "'user' | 'assistant' | 'system'",
|
|
70
|
+
description: "The role of the message sender.",
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "parts",
|
|
74
|
+
type: "UIMessagePart[]",
|
|
75
|
+
description: "Array of UI parts including text, tool results, files, reasoning, sources, and step markers.",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "metadata",
|
|
79
|
+
type: "Record<string, unknown>",
|
|
80
|
+
description: "Optional metadata including createdAt, threadId, resourceId, and custom fields.",
|
|
81
|
+
isOptional: true,
|
|
82
|
+
},
|
|
83
|
+
]}
|
|
84
|
+
/>
|
|
85
|
+
|
|
86
|
+
## Examples
|
|
87
|
+
|
|
88
|
+
### Converting simple text messages
|
|
89
|
+
|
|
90
|
+
```typescript copy
|
|
91
|
+
import { toAISdkV5Messages } from "@mastra/ai-sdk";
|
|
92
|
+
|
|
93
|
+
const messages = toAISdkV5Messages(["Hello", "How can I help you today?"]);
|
|
94
|
+
// Returns array of UIMessage objects with user role
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Loading messages with Mastra client
|
|
98
|
+
|
|
99
|
+
```typescript copy
|
|
100
|
+
import { MastraClient } from "@mastra/client-js";
|
|
101
|
+
import { toAISdkV5Messages } from "@mastra/ai-sdk";
|
|
102
|
+
|
|
103
|
+
const client = new MastraClient();
|
|
104
|
+
|
|
105
|
+
const { messages } = await client.listThreadMessages("thread-id", { agentId: "myAgent" });
|
|
106
|
+
const uiMessages = toAISdkV5Messages(messages);
|
|
107
|
+
```
|
|
@@ -7,7 +7,7 @@ import PropertiesTable from "@site/src/components/PropertiesTable";
|
|
|
7
7
|
|
|
8
8
|
# workflowRoute()
|
|
9
9
|
|
|
10
|
-
Creates a workflow route handler for streaming workflow execution using the AI SDK format. This function registers an HTTP `POST` endpoint that accepts input data, executes a workflow, and streams the response back to the client in AI SDK-compatible format. You have to use it inside a [custom API route](/docs/v1/server
|
|
10
|
+
Creates a workflow route handler for streaming workflow execution using the AI SDK format. This function registers an HTTP `POST` endpoint that accepts input data, executes a workflow, and streams the response back to the client in AI SDK-compatible format. You have to use it inside a [custom API route](/docs/v1/server/custom-api-routes).
|
|
11
11
|
|
|
12
12
|
Use [`handleWorkflowStream()`](/reference/v1/ai-sdk/handle-workflow-stream) if you need a framework-agnostic handler.
|
|
13
13
|
|
|
@@ -86,7 +86,7 @@ Under the hood Mastra's Rollup server locates your Mastra entry file and bundles
|
|
|
86
86
|
|
|
87
87
|
The output in `.mastra` can be deployed to any cloud server using [`mastra start`](#mastra-start).
|
|
88
88
|
|
|
89
|
-
If you're deploying to a [serverless platform](/
|
|
89
|
+
If you're deploying to a [serverless platform](/guides/v1/deployment) you need to install the correct deployer in order to receive the correct output in `.mastra`.
|
|
90
90
|
|
|
91
91
|
It accepts [common flags][common-flags].
|
|
92
92
|
|
|
@@ -5,7 +5,7 @@ description: Learn how to interact with Mastra using the client-js SDK.
|
|
|
5
5
|
|
|
6
6
|
# Mastra Client SDK
|
|
7
7
|
|
|
8
|
-
The Mastra Client SDK provides a simple and type-safe interface for interacting with your [Mastra Server](/docs/v1/deployment/
|
|
8
|
+
The Mastra Client SDK provides a simple and type-safe interface for interacting with your [Mastra Server](/docs/v1/deployment/mastra-server) from your client environment.
|
|
9
9
|
|
|
10
10
|
## Usage example
|
|
11
11
|
|
|
@@ -48,8 +48,16 @@ const run = await workflow.createRun();
|
|
|
48
48
|
|
|
49
49
|
// Or with an existing runId
|
|
50
50
|
const run = await workflow.createRun({ runId: "existing-run-id" });
|
|
51
|
+
|
|
52
|
+
// Or with a resourceId to associate the run with a specific resource
|
|
53
|
+
const run = await workflow.createRun({
|
|
54
|
+
runId: "my-run-id",
|
|
55
|
+
resourceId: "user-123"
|
|
56
|
+
});
|
|
51
57
|
```
|
|
52
58
|
|
|
59
|
+
The `resourceId` parameter associates the workflow run with a specific resource (e.g., user ID, tenant ID). This value is persisted with the run and can be used for filtering and querying runs later.
|
|
60
|
+
|
|
53
61
|
### startAsync()
|
|
54
62
|
|
|
55
63
|
Start a workflow run and await the full result:
|
|
@@ -80,6 +88,18 @@ const result = await run.startAsync({
|
|
|
80
88
|
|
|
81
89
|
The `initialState` object should match the structure defined in the workflow's `stateSchema`. See [Workflow State](/docs/v1/workflows/workflow-state) for more details.
|
|
82
90
|
|
|
91
|
+
To associate a run with a specific resource, pass `resourceId` to `createRun()`:
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
const run = await workflow.createRun({ resourceId: "user-123" });
|
|
95
|
+
|
|
96
|
+
const result = await run.startAsync({
|
|
97
|
+
inputData: {
|
|
98
|
+
city: "New York",
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
83
103
|
### start()
|
|
84
104
|
|
|
85
105
|
Start a workflow run without waiting for completion:
|
|
@@ -32,5 +32,5 @@ This method does not accept any parameters.
|
|
|
32
32
|
|
|
33
33
|
## Related
|
|
34
34
|
|
|
35
|
-
- [Server deployment](/docs/v1/deployment/
|
|
36
|
-
- [Server configuration](/docs/v1/server
|
|
35
|
+
- [Server deployment](/docs/v1/deployment/mastra-server)
|
|
36
|
+
- [Server configuration](/docs/v1/server/custom-api-routes)
|
|
@@ -179,5 +179,5 @@ When using `raw: true`, the returned object has the following structure:
|
|
|
179
179
|
## Related
|
|
180
180
|
|
|
181
181
|
- [Mastra.listStoredAgents()](/reference/v1/core/listStoredAgents)
|
|
182
|
-
- [Storage overview](/docs/v1/
|
|
182
|
+
- [Storage overview](/docs/v1/memory/storage/overview)
|
|
183
183
|
- [Agents overview](/docs/v1/agents/overview)
|
|
@@ -147,5 +147,5 @@ async function getAllStoredAgents(mastra: Mastra) {
|
|
|
147
147
|
## Related
|
|
148
148
|
|
|
149
149
|
- [Mastra.getStoredAgentById()](/reference/v1/core/getStoredAgentById)
|
|
150
|
-
- [Storage overview](/docs/v1/
|
|
150
|
+
- [Storage overview](/docs/v1/memory/storage/overview)
|
|
151
151
|
- [Agents overview](/docs/v1/agents/overview)
|
|
@@ -7,7 +7,7 @@ description: Documentation for PinoLogger, which provides methods to record even
|
|
|
7
7
|
|
|
8
8
|
A Logger instance is created using `new PinoLogger()` and provides methods to record events at various severity levels.
|
|
9
9
|
|
|
10
|
-
When deploying to Mastra Cloud, logs are displayed on the [Logs](/docs/v1/
|
|
10
|
+
When deploying to Mastra Cloud, logs are displayed on the [Logs](/docs/v1/mastra-cloud/dashboard#logs) page. In self-hosted or custom environments, logs can be directed to files or external services depending on the configured transports.
|
|
11
11
|
|
|
12
12
|
## Usage example
|
|
13
13
|
|
|
@@ -348,5 +348,5 @@ const vectorTool = createVectorQueryTool({
|
|
|
348
348
|
## Related
|
|
349
349
|
|
|
350
350
|
- [createVectorQueryTool()](/reference/v1/tools/vector-query-tool)
|
|
351
|
-
- [Hybrid Vector Search](/
|
|
351
|
+
- [Hybrid Vector Search](/docs/v1/rag/retrieval#metadata-filtering)
|
|
352
352
|
- [Metadata Filters](/reference/v1/rag/metadata-filters)
|
|
@@ -325,4 +325,4 @@ Common status codes:
|
|
|
325
325
|
|
|
326
326
|
- [Server Routes](/reference/v1/server/routes) - Default Mastra routes
|
|
327
327
|
- [MastraServer](/reference/v1/server/mastra-server) - Server adapter class
|
|
328
|
-
- [Server Adapters](/docs/v1/server
|
|
328
|
+
- [Server Adapters](/docs/v1/server/server-adapters) - Using adapters
|
|
@@ -13,7 +13,7 @@ The `@mastra/express` package provides a server adapter for running Mastra with
|
|
|
13
13
|
|
|
14
14
|
:::info
|
|
15
15
|
|
|
16
|
-
For general adapter concepts (constructor options, initialization flow, etc.), see [Server Adapters](/docs/v1/server
|
|
16
|
+
For general adapter concepts (constructor options, initialization flow, etc.), see [Server Adapters](/docs/v1/server/server-adapters).
|
|
17
17
|
|
|
18
18
|
:::
|
|
19
19
|
|
|
@@ -26,7 +26,7 @@ For general adapter concepts (constructor options, initialization flow, etc.), s
|
|
|
26
26
|
Install the Express adapter and Express framework:
|
|
27
27
|
|
|
28
28
|
```bash copy
|
|
29
|
-
npm install @mastra/express express
|
|
29
|
+
npm install @mastra/express@beta express
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
</StepItem>
|
|
@@ -246,7 +246,7 @@ app.use((req, res, next) => {
|
|
|
246
246
|
|
|
247
247
|
## Manual initialization
|
|
248
248
|
|
|
249
|
-
For custom middleware ordering, call each method separately instead of `init()`. See [Server Adapters: Manual initialization](/docs/v1/server
|
|
249
|
+
For custom middleware ordering, call each method separately instead of `init()`. See [Server Adapters: Manual initialization](/docs/v1/server/server-adapters#manual-initialization) for details.
|
|
250
250
|
|
|
251
251
|
## Examples
|
|
252
252
|
|
|
@@ -254,7 +254,7 @@ For custom middleware ordering, call each method separately instead of `init()`.
|
|
|
254
254
|
|
|
255
255
|
## Related
|
|
256
256
|
|
|
257
|
-
- [Server Adapters](/docs/v1/server
|
|
257
|
+
- [Server Adapters](/docs/v1/server/server-adapters) - Shared adapter concepts
|
|
258
258
|
- [Hono Adapter](/reference/v1/server/hono-adapter) - Alternative adapter
|
|
259
259
|
- [MastraServer Reference](/reference/v1/server/mastra-server) - Full API reference
|
|
260
260
|
- [createRoute() Reference](/reference/v1/server/create-route) - Creating type-safe custom routes
|
|
@@ -13,7 +13,7 @@ The `@mastra/hono` package provides a server adapter for running Mastra with [Ho
|
|
|
13
13
|
|
|
14
14
|
:::info
|
|
15
15
|
|
|
16
|
-
For general adapter concepts (constructor options, initialization flow, etc.), see [Server Adapters](/docs/v1/server
|
|
16
|
+
For general adapter concepts (constructor options, initialization flow, etc.), see [Server Adapters](/docs/v1/server/server-adapters).
|
|
17
17
|
|
|
18
18
|
:::
|
|
19
19
|
|
|
@@ -26,7 +26,7 @@ For general adapter concepts (constructor options, initialization flow, etc.), s
|
|
|
26
26
|
Install the Hono adapter and Hono framework:
|
|
27
27
|
|
|
28
28
|
```bash copy
|
|
29
|
-
npm install @mastra/hono hono
|
|
29
|
+
npm install @mastra/hono@beta hono
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
</StepItem>
|
|
@@ -228,7 +228,7 @@ app.use('*', async (c, next) => {
|
|
|
228
228
|
|
|
229
229
|
## Manual initialization
|
|
230
230
|
|
|
231
|
-
For custom middleware ordering, call each method separately instead of `init()`. See [Server Adapters: Manual initialization](/docs/v1/server
|
|
231
|
+
For custom middleware ordering, call each method separately instead of `init()`. See [Server Adapters: Manual initialization](/docs/v1/server/server-adapters#manual-initialization) for details.
|
|
232
232
|
|
|
233
233
|
## Examples
|
|
234
234
|
|
|
@@ -236,7 +236,7 @@ For custom middleware ordering, call each method separately instead of `init()`.
|
|
|
236
236
|
|
|
237
237
|
## Related
|
|
238
238
|
|
|
239
|
-
- [Server Adapters](/docs/v1/server
|
|
239
|
+
- [Server Adapters](/docs/v1/server/server-adapters) - Shared adapter concepts
|
|
240
240
|
- [Express Adapter](/reference/v1/server/express-adapter) - Alternative adapter
|
|
241
241
|
- [MastraServer Reference](/reference/v1/server/mastra-server) - Full API reference
|
|
242
242
|
- [createRoute() Reference](/reference/v1/server/create-route) - Creating type-safe custom routes
|
|
@@ -340,6 +340,6 @@ export class MyServer extends MastraServer<MyApp, MyRequest, MyResponse> {
|
|
|
340
340
|
|
|
341
341
|
## Related
|
|
342
342
|
|
|
343
|
-
- [Server Adapters](/docs/v1/server
|
|
344
|
-
- [Custom Adapters](/docs/v1/server
|
|
343
|
+
- [Server Adapters](/docs/v1/server/server-adapters) - Using adapters
|
|
344
|
+
- [Custom Adapters](/docs/v1/server/custom-adapters) - Creating custom adapters
|
|
345
345
|
- [createRoute()](/reference/v1/server/create-route) - Creating custom routes
|
|
@@ -58,16 +58,43 @@ Server adapters register these routes when you call `server.init()`. All routes
|
|
|
58
58
|
|--------|------|-------------|
|
|
59
59
|
| `GET` | `/api/workflows` | List all workflows |
|
|
60
60
|
| `GET` | `/api/workflows/:workflowId` | Get workflow by ID |
|
|
61
|
+
| `POST` | `/api/workflows/:workflowId/create-run` | Create a new workflow run |
|
|
62
|
+
| `POST` | `/api/workflows/:workflowId/start-async` | Start workflow and await result |
|
|
61
63
|
| `POST` | `/api/workflows/:workflowId/stream` | Stream workflow execution |
|
|
62
64
|
| `POST` | `/api/workflows/:workflowId/resume` | Resume suspended workflow |
|
|
63
65
|
| `POST` | `/api/workflows/:workflowId/resume-async` | Resume asynchronously |
|
|
64
66
|
| `GET` | `/api/workflows/:workflowId/runs` | List workflow runs |
|
|
65
67
|
| `GET` | `/api/workflows/:workflowId/runs/:runId` | Get specific run |
|
|
66
68
|
|
|
69
|
+
### Create run request body
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
{
|
|
73
|
+
resourceId?: string; // Associate run with a resource (e.g., user ID)
|
|
74
|
+
disableScorers?: boolean; // Disable scorers for this run
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Start-async request body
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
{
|
|
82
|
+
resourceId?: string; // Associate run with a resource (e.g., user ID)
|
|
83
|
+
inputData?: unknown;
|
|
84
|
+
initialState?: unknown;
|
|
85
|
+
requestContext?: Record<string, unknown>;
|
|
86
|
+
tracingOptions?: {
|
|
87
|
+
spanName?: string;
|
|
88
|
+
attributes?: Record<string, unknown>;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
67
93
|
### Stream workflow request body
|
|
68
94
|
|
|
69
95
|
```typescript
|
|
70
96
|
{
|
|
97
|
+
resourceId?: string; // Associate run with a resource (e.g., user ID)
|
|
71
98
|
inputData?: unknown;
|
|
72
99
|
initialState?: unknown;
|
|
73
100
|
requestContext?: Record<string, unknown>;
|
|
@@ -247,4 +274,4 @@ Common status codes:
|
|
|
247
274
|
## Related
|
|
248
275
|
|
|
249
276
|
- [createRoute()](/reference/v1/server/create-route) - Creating custom routes
|
|
250
|
-
- [Server Adapters](/docs/v1/server
|
|
277
|
+
- [Server Adapters](/docs/v1/server/server-adapters) - Using adapters
|
|
@@ -477,6 +477,27 @@ const stream = await agent.stream("message for agent");
|
|
|
477
477
|
description:
|
|
478
478
|
"Save messages incrementally after each stream step completes (default: false).",
|
|
479
479
|
},
|
|
480
|
+
{
|
|
481
|
+
name: "requireToolApproval",
|
|
482
|
+
type: "boolean",
|
|
483
|
+
isOptional: true,
|
|
484
|
+
description:
|
|
485
|
+
"When true, all tool calls require explicit approval before execution. The stream will emit `tool-call-approval` chunks and pause until `approveToolCall()` or `declineToolCall()` is called.",
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
name: "autoResumeSuspendedTools",
|
|
489
|
+
type: "boolean",
|
|
490
|
+
isOptional: true,
|
|
491
|
+
description:
|
|
492
|
+
"When true, automatically resumes suspended tools when the user sends a new message on the same thread. The agent extracts `resumeData` from the user's message based on the tool's `resumeSchema`. Requires memory to be configured.",
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
name: "toolCallConcurrency",
|
|
496
|
+
type: "number",
|
|
497
|
+
isOptional: true,
|
|
498
|
+
description:
|
|
499
|
+
"Maximum number of tool calls to execute concurrently. Defaults to 1 when approval may be required, otherwise 10.",
|
|
500
|
+
},
|
|
480
501
|
{
|
|
481
502
|
name: "providerOptions",
|
|
482
503
|
type: "Record<string, Record<string, JSONValue>>",
|
|
@@ -765,3 +786,4 @@ await agent.stream("message for agent", {
|
|
|
765
786
|
|
|
766
787
|
- [Generating responses](/docs/v1/agents/overview#generating-responses)
|
|
767
788
|
- [Streaming responses](/docs/v1/agents/overview#generating-responses)
|
|
789
|
+
- [Agent Approval](/docs/v1/agents/agent-approval)
|