@mastra/mcp-docs-server 1.2.7-alpha.3 → 1.2.7-alpha.6
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/agent-builder/overview.md +4 -3
- package/.docs/docs/agent-controller/overview.md +2 -1
- package/.docs/docs/agents/a2a.md +2 -1
- package/.docs/docs/agents/guardrails.md +2 -1
- package/.docs/docs/agents/overview.md +2 -2
- package/.docs/docs/agents/skills.md +1 -1
- package/.docs/docs/agents/supervisor-agents.md +2 -1
- package/.docs/docs/browser/overview.md +2 -1
- package/.docs/docs/capabilities/channels/discord.md +98 -0
- package/.docs/docs/capabilities/channels/other-adapters.md +68 -0
- package/.docs/docs/capabilities/channels/overview.md +257 -0
- package/.docs/docs/capabilities/channels/slack.md +225 -0
- package/.docs/docs/capabilities/channels/teams.md +100 -0
- package/.docs/docs/capabilities/channels/telegram.md +98 -0
- package/.docs/docs/capabilities/channels/whatsapp.md +99 -0
- package/.docs/docs/evals/datasets/overview.md +2 -1
- package/.docs/docs/evals/datasets/running-experiments.md +2 -0
- package/.docs/docs/evals/overview.md +4 -1
- package/.docs/docs/getting-started/file-based-agents.md +114 -0
- package/.docs/docs/long-running-agents/signals.md +4 -1
- package/.docs/docs/mastra-platform/observability.md +5 -1
- package/.docs/docs/memory/observational-memory.md +2 -1
- package/.docs/docs/memory/overview.md +2 -0
- package/.docs/docs/memory/semantic-recall.md +1 -1
- package/.docs/docs/memory/working-memory.md +3 -3
- package/.docs/docs/studio/overview.md +1 -1
- package/.docs/docs/voice/livekit.md +100 -3
- package/.docs/docs/workflows/control-flow.md +0 -2
- package/.docs/docs/workflows/overview.md +2 -3
- package/.docs/docs/workspace/overview.md +2 -1
- package/.docs/docs/workspace/sandbox.md +2 -0
- package/.docs/guides/getting-started/quickstart.md +3 -1
- package/.docs/guides/guide/chef-michel.md +0 -2
- package/.docs/guides/guide/slack-assistant.md +2 -2
- package/.docs/guides/guide/stock-agent.md +0 -2
- package/.docs/models/environment-variables.md +1 -0
- package/.docs/models/gateways/openrouter.md +3 -2
- package/.docs/models/gateways/vercel.md +3 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/google.md +2 -1
- package/.docs/models/providers/llmgateway.md +180 -181
- package/.docs/models/providers/neon.md +40 -29
- package/.docs/models/providers/opencode.md +2 -1
- package/.docs/models/providers/wandb.md +21 -14
- package/.docs/models/providers/xai.md +2 -1
- package/.docs/models/providers/zenifra.md +73 -0
- package/.docs/models/providers.md +1 -0
- package/.docs/reference/agents/channels.md +2 -2
- package/.docs/reference/channels/channel-provider.md +1 -1
- package/.docs/reference/channels/slack-provider.md +2 -2
- package/.docs/reference/cli/mastra.md +1 -0
- package/.docs/reference/file-based-agents/config.md +97 -0
- package/.docs/reference/file-based-agents/instructions.md +54 -0
- package/.docs/reference/file-based-agents/memory.md +58 -0
- package/.docs/reference/file-based-agents/observability.md +32 -0
- package/.docs/reference/file-based-agents/processors.md +56 -0
- package/.docs/reference/file-based-agents/server.md +37 -0
- package/.docs/reference/file-based-agents/skills.md +56 -0
- package/.docs/reference/file-based-agents/storage.md +30 -0
- package/.docs/reference/file-based-agents/studio.md +56 -0
- package/.docs/reference/file-based-agents/subagents.md +123 -0
- package/.docs/reference/file-based-agents/tools.md +63 -0
- package/.docs/reference/file-based-agents/workflows.md +52 -0
- package/.docs/reference/file-based-agents/workspace.md +74 -0
- package/.docs/reference/index.md +15 -0
- package/.docs/reference/memory/memory-class.md +1 -1
- package/.docs/reference/memory/serialized-memory-config.md +1 -1
- package/.docs/reference/memory/summarizeConversation.md +99 -0
- package/.docs/reference/memory/summarizeThread.md +93 -0
- package/.docs/reference/project-structure.md +1 -1
- package/.docs/reference/pubsub/lease-provider.md +1 -1
- package/.docs/reference/storage/clickhouse.md +32 -0
- package/.docs/reference/storage/composite.md +27 -1
- package/.docs/reference/storage/retention.md +11 -0
- package/.docs/reference/voice/livekit.md +272 -8
- package/CHANGELOG.md +7 -0
- package/package.json +5 -5
- package/.docs/docs/agents/channels.md +0 -225
- package/.docs/docs/agents/file-based-agents.md +0 -297
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Weights & Biases
|
|
4
4
|
|
|
5
|
-
Access
|
|
5
|
+
Access 25 Weights & Biases models through Mastra's model router. Authentication is handled automatically using the `WANDB_API_KEY` environment variable.
|
|
6
6
|
|
|
7
7
|
Learn more in the [Weights & Biases documentation](https://docs.wandb.ai).
|
|
8
8
|
|
|
@@ -17,7 +17,7 @@ const agent = new Agent({
|
|
|
17
17
|
id: "my-agent",
|
|
18
18
|
name: "My Agent",
|
|
19
19
|
instructions: "You are a helpful assistant",
|
|
20
|
-
model: "wandb/
|
|
20
|
+
model: "wandb/JetBrains/Mellum2-12B-A2.5B-Instruct"
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
// Generate a response
|
|
@@ -37,23 +37,30 @@ for await (const chunk of stream) {
|
|
|
37
37
|
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
38
38
|
| ---------------------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
39
39
|
| `wandb/deepseek-ai/DeepSeek-V3.1` | 161K | | | | | | $0.55 | $2 |
|
|
40
|
+
| `wandb/deepseek-ai/DeepSeek-V4-Flash` | 1.0M | | | | | | $0.14 | $0.28 |
|
|
41
|
+
| `wandb/deepseek-ai/DeepSeek-V4-Pro` | 1.0M | | | | | | $2 | $3 |
|
|
42
|
+
| `wandb/google/gemma-4-31B-it` | 262K | | | | | | $0.12 | $0.35 |
|
|
43
|
+
| `wandb/ibm-granite/granite-4.1-8b` | 131K | | | | | | $0.05 | $0.10 |
|
|
44
|
+
| `wandb/JetBrains/Mellum2-12B-A2.5B-Instruct` | 131K | | | | | | $0.05 | $0.10 |
|
|
40
45
|
| `wandb/meta-llama/Llama-3.1-70B-Instruct` | 128K | | | | | | $0.80 | $0.80 |
|
|
41
46
|
| `wandb/meta-llama/Llama-3.1-8B-Instruct` | 128K | | | | | | $0.22 | $0.22 |
|
|
42
47
|
| `wandb/meta-llama/Llama-3.3-70B-Instruct` | 128K | | | | | | $0.71 | $0.71 |
|
|
43
|
-
| `wandb/meta-llama/Llama-4-Scout-17B-16E-Instruct` | 64K | | | | | | $0.17 | $0.66 |
|
|
44
|
-
| `wandb/microsoft/Phi-4-mini-instruct` | 128K | | | | | | $0.08 | $0.35 |
|
|
45
48
|
| `wandb/MiniMaxAI/MiniMax-M2.5` | 197K | | | | | | $0.30 | $1 |
|
|
46
|
-
| `wandb/moonshotai/Kimi-K2.5` | 262K | | | | | | $0.
|
|
49
|
+
| `wandb/moonshotai/Kimi-K2.5` | 262K | | | | | | $0.60 | $3 |
|
|
50
|
+
| `wandb/moonshotai/Kimi-K2.6` | 262K | | | | | | $0.95 | $4 |
|
|
51
|
+
| `wandb/moonshotai/Kimi-K2.7-Code` | 262K | | | | | | $0.94 | $4 |
|
|
47
52
|
| `wandb/nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-FP8` | 262K | | | | | | $0.20 | $0.80 |
|
|
48
|
-
| `wandb/
|
|
49
|
-
| `wandb/openai/gpt-oss-
|
|
53
|
+
| `wandb/nvidia/NVIDIA-Nemotron-3-Ultra-550B-A55B` | 262K | | | | | | $0.75 | $3 |
|
|
54
|
+
| `wandb/openai/gpt-oss-120b` | 131K | | | | | | $0.04 | $0.14 |
|
|
55
|
+
| `wandb/openai/gpt-oss-20b` | 131K | | | | | | $0.03 | $0.13 |
|
|
50
56
|
| `wandb/OpenPipe/Qwen3-14B-Instruct` | 33K | | | | | | $0.05 | $0.22 |
|
|
51
|
-
| `wandb/Qwen/Qwen3-235B-A22B-Instruct-2507` | 262K | | | | | | $0.10 | $0.10 |
|
|
52
|
-
| `wandb/Qwen/Qwen3-235B-A22B-Thinking-2507` | 262K | | | | | | $0.10 | $0.10 |
|
|
53
57
|
| `wandb/Qwen/Qwen3-30B-A3B-Instruct-2507` | 262K | | | | | | $0.10 | $0.30 |
|
|
54
58
|
| `wandb/Qwen/Qwen3-Coder-480B-A35B-Instruct` | 262K | | | | | | $1 | $2 |
|
|
55
|
-
| `wandb/
|
|
56
|
-
| `wandb/
|
|
59
|
+
| `wandb/Qwen/Qwen3.5-35B-A3B` | 262K | | | | | | $0.25 | $1 |
|
|
60
|
+
| `wandb/Qwen/Qwen3.6-27B` | 262K | | | | | | $0.60 | $4 |
|
|
61
|
+
| `wandb/Qwen/Qwen3.6-35B-A3B` | 262K | | | | | | $0.25 | $1 |
|
|
62
|
+
| `wandb/zai-org/GLM-5.1` | 203K | | | | | | $1 | $4 |
|
|
63
|
+
| `wandb/zai-org/GLM-5.2` | 262K | | | | | | $1 | $4 |
|
|
57
64
|
|
|
58
65
|
## Advanced configuration
|
|
59
66
|
|
|
@@ -65,7 +72,7 @@ const agent = new Agent({
|
|
|
65
72
|
name: "custom-agent",
|
|
66
73
|
model: {
|
|
67
74
|
url: "https://api.inference.wandb.ai/v1",
|
|
68
|
-
id: "wandb/
|
|
75
|
+
id: "wandb/JetBrains/Mellum2-12B-A2.5B-Instruct",
|
|
69
76
|
apiKey: process.env.WANDB_API_KEY,
|
|
70
77
|
headers: {
|
|
71
78
|
"X-Custom-Header": "value"
|
|
@@ -83,8 +90,8 @@ const agent = new Agent({
|
|
|
83
90
|
model: ({ requestContext }) => {
|
|
84
91
|
const useAdvanced = requestContext.task === "complex";
|
|
85
92
|
return useAdvanced
|
|
86
|
-
? "wandb/zai-org/GLM-5.
|
|
87
|
-
: "wandb/
|
|
93
|
+
? "wandb/zai-org/GLM-5.2"
|
|
94
|
+
: "wandb/JetBrains/Mellum2-12B-A2.5B-Instruct";
|
|
88
95
|
}
|
|
89
96
|
});
|
|
90
97
|
```
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# xAI
|
|
4
4
|
|
|
5
|
-
Access
|
|
5
|
+
Access 9 xAI models through Mastra's model router. Authentication is handled automatically using the `XAI_API_KEY` environment variable.
|
|
6
6
|
|
|
7
7
|
Learn more in the [xAI documentation](https://docs.x.ai/docs/models).
|
|
8
8
|
|
|
@@ -38,6 +38,7 @@ for await (const chunk of stream) {
|
|
|
38
38
|
| `xai/grok-4.20-0309-reasoning` | 1.0M | | | | | | $1 | $3 |
|
|
39
39
|
| `xai/grok-4.20-multi-agent-0309` | 1.0M | | | | | | $1 | $3 |
|
|
40
40
|
| `xai/grok-4.3` | 1.0M | | | | | | $1 | $3 |
|
|
41
|
+
| `xai/grok-4.5` | 500K | | | | | | $2 | $6 |
|
|
41
42
|
| `xai/grok-build-0.1` | 256K | | | | | | $1 | $2 |
|
|
42
43
|
| `xai/grok-imagine-image` | 8K | | | | | | — | — |
|
|
43
44
|
| `xai/grok-imagine-image-quality` | 8K | | | | | | — | — |
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Zenifra
|
|
4
|
+
|
|
5
|
+
Access 1 Zenifra model through Mastra's model router. Authentication is handled automatically using the `ZENIFRA_AI_KEY` environment variable.
|
|
6
|
+
|
|
7
|
+
Learn more in the [Zenifra documentation](https://docs.zenifra.com).
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
ZENIFRA_AI_KEY=your-api-key
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Agent } from "@mastra/core/agent";
|
|
15
|
+
|
|
16
|
+
const agent = new Agent({
|
|
17
|
+
id: "my-agent",
|
|
18
|
+
name: "My Agent",
|
|
19
|
+
instructions: "You are a helpful assistant",
|
|
20
|
+
model: "zenifra/alibaba/qwen3.6-35b-a3b"
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Generate a response
|
|
24
|
+
const response = await agent.generate("Hello!");
|
|
25
|
+
|
|
26
|
+
// Stream a response
|
|
27
|
+
const stream = await agent.stream("Tell me a story");
|
|
28
|
+
for await (const chunk of stream) {
|
|
29
|
+
console.log(chunk);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
> **Info:** Mastra uses the OpenAI-compatible `/chat/completions` endpoint. Some provider-specific features may not be available. Check the [Zenifra documentation](https://docs.zenifra.com) for details.
|
|
34
|
+
|
|
35
|
+
## Models
|
|
36
|
+
|
|
37
|
+
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
38
|
+
| --------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
39
|
+
| `zenifra/alibaba/qwen3.6-35b-a3b` | 262K | | | | | | $0.19 | $0.48 |
|
|
40
|
+
|
|
41
|
+
## Advanced configuration
|
|
42
|
+
|
|
43
|
+
### Custom headers
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
const agent = new Agent({
|
|
47
|
+
id: "custom-agent",
|
|
48
|
+
name: "custom-agent",
|
|
49
|
+
model: {
|
|
50
|
+
url: "https://ai.zenifra.com/v1",
|
|
51
|
+
id: "zenifra/alibaba/qwen3.6-35b-a3b",
|
|
52
|
+
apiKey: process.env.ZENIFRA_AI_KEY,
|
|
53
|
+
headers: {
|
|
54
|
+
"X-Custom-Header": "value"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Dynamic model selection
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
const agent = new Agent({
|
|
64
|
+
id: "dynamic-agent",
|
|
65
|
+
name: "Dynamic Agent",
|
|
66
|
+
model: ({ requestContext }) => {
|
|
67
|
+
const useAdvanced = requestContext.task === "complex";
|
|
68
|
+
return useAdvanced
|
|
69
|
+
? "zenifra/alibaba/qwen3.6-35b-a3b"
|
|
70
|
+
: "zenifra/alibaba/qwen3.6-35b-a3b";
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
```
|
|
@@ -136,6 +136,7 @@ Direct access to individual AI model providers. Each provider offers unique mode
|
|
|
136
136
|
- [Z.AI](https://mastra.ai/models/providers/zai)
|
|
137
137
|
- [Z.AI Coding Plan](https://mastra.ai/models/providers/zai-coding-plan)
|
|
138
138
|
- [Zeldoc](https://mastra.ai/models/providers/zeldoc)
|
|
139
|
+
- [Zenifra](https://mastra.ai/models/providers/zenifra)
|
|
139
140
|
- [ZenMux](https://mastra.ai/models/providers/zenmux)
|
|
140
141
|
- [Zhipu AI](https://mastra.ai/models/providers/zhipuai)
|
|
141
142
|
- [Zhipu AI Coding Plan](https://mastra.ai/models/providers/zhipuai-coding-plan)
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
**Added in:** `@mastra/core@1.22.0`
|
|
6
6
|
|
|
7
|
-
Channels connect agents to messaging platforms. Configure them via the `channels` property on the `Agent` constructor. The object you pass is a `ChannelConfig`. See the [Channels
|
|
7
|
+
Channels connect agents to messaging platforms. Configure them via the `channels` property on the `Agent` constructor. The object you pass is a `ChannelConfig`. See the [Channels overview](https://mastra.ai/docs/capabilities/channels/overview) for concepts and platform setup instructions.
|
|
8
8
|
|
|
9
9
|
## Usage example
|
|
10
10
|
|
|
@@ -291,6 +291,6 @@ type InlineLinkEntry =
|
|
|
291
291
|
|
|
292
292
|
## Related
|
|
293
293
|
|
|
294
|
-
- [Channels
|
|
294
|
+
- [Channels overview](https://mastra.ai/docs/capabilities/channels/overview): Concepts, quickstart, and platform setup
|
|
295
295
|
- [Agent class](https://mastra.ai/reference/agents/agent): Constructor parameters and methods
|
|
296
296
|
- [Chat SDK adapters](https://chat-sdk.dev/adapters): Adapter configuration and platform setup
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# SlackProvider
|
|
4
4
|
|
|
5
|
-
`SlackProvider` is the managed path for connecting agents to Slack. Register it on `Mastra.channels` and it provisions Slack apps via the Manifest API, runs the OAuth install flow, rotates configuration tokens, and routes Slack events to your agents. Use it when you want Mastra to own app creation and installation. For the lower-level path where you create the Slack app and configure scopes and webhooks yourself, use [`createSlackAdapter`](https://mastra.ai/docs/
|
|
5
|
+
`SlackProvider` is the managed path for connecting agents to Slack. Register it on `Mastra.channels` and it provisions Slack apps via the Manifest API, runs the OAuth install flow, rotates configuration tokens, and routes Slack events to your agents. Use it when you want Mastra to own app creation and installation. For the lower-level path where you create the Slack app and configure scopes and webhooks yourself, use [`createSlackAdapter`](https://mastra.ai/docs/capabilities/channels/slack) on the agent's `channels.adapters` instead.
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
@@ -224,5 +224,5 @@ const result = await slack.connect('support-agent')
|
|
|
224
224
|
## Related
|
|
225
225
|
|
|
226
226
|
- [ChannelProvider](https://mastra.ai/reference/channels/channel-provider): the interface `SlackProvider` implements
|
|
227
|
-
- [Channels](https://mastra.ai/docs/
|
|
227
|
+
- [Channels](https://mastra.ai/docs/capabilities/channels/overview): concepts, platform setup, and the `createSlackAdapter` path
|
|
228
228
|
- [Channels reference](https://mastra.ai/reference/agents/channels): the `channels` config on the `Agent` constructor
|
|
@@ -736,6 +736,7 @@ Runs database migrations to update your storage schema. This command is useful w
|
|
|
736
736
|
The command bundles your project, connects to your configured storage backend, and executes any pending migrations. Currently supports:
|
|
737
737
|
|
|
738
738
|
- **Duplicate spans migration**: Removes duplicate `(traceId, spanId)` entries and adds a unique constraint to ensure data integrity.
|
|
739
|
+
- **ClickHouse legacy-to-vNext span migration**: Copies historical spans from the legacy `mastra_ai_spans` table to the vNext `mastra_span_events` schema. Runs in batches to stay within memory limits. See the [ClickHouse storage reference](https://mastra.ai/reference/storage/clickhouse) for details.
|
|
739
740
|
|
|
740
741
|
```bash
|
|
741
742
|
mastra migrate
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# config.ts
|
|
4
|
+
|
|
5
|
+
An agent's `config.ts` sets its model and runtime options. Use it for options that belong to the [`Agent`](https://mastra.ai/reference/agents/agent) itself, while sibling files provide instructions, tools, skills, et cetera.
|
|
6
|
+
|
|
7
|
+
## What belongs in `config.ts`
|
|
8
|
+
|
|
9
|
+
`config.ts` is the required entry point for a file-based agent's model and runtime options. Put agent-level settings here when they don't need their own file, such as the model, description, default execution options, retry behavior, scorers, and display identity.
|
|
10
|
+
|
|
11
|
+
Keep adjacent concerns in sibling files when you want file-based routing to merge them into the agent. For example, use `instructions.md` for the always-on prompt and `tools/` for model-callable actions.
|
|
12
|
+
|
|
13
|
+
## Quickstart
|
|
14
|
+
|
|
15
|
+
The following `config.ts` plus an `instructions.md` file creates a working file-based agent:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { agentConfig } from '@mastra/core/agent'
|
|
19
|
+
|
|
20
|
+
export default agentConfig({
|
|
21
|
+
model: 'openai/gpt-5.5',
|
|
22
|
+
})
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```markdown
|
|
26
|
+
You are a helpful weather assistant. Answer questions about current conditions and forecasts.
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Mastra uses the `weather` directory name as the default agent `id` and `name`. The sibling `instructions.md` supplies the required instructions.
|
|
30
|
+
|
|
31
|
+
## Set the model
|
|
32
|
+
|
|
33
|
+
The `model` field is the only required field in `agentConfig()`. The build fails when an agent directory doesn't provide a model. Other capabilities either come from sibling files or have defaults.
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { agentConfig } from '@mastra/core/agent'
|
|
37
|
+
|
|
38
|
+
export default agentConfig({
|
|
39
|
+
model: 'openai/gpt-5.5',
|
|
40
|
+
})
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Identity from the directory
|
|
44
|
+
|
|
45
|
+
A file-based agent's `id` and `name` default to the directory name. For `src/mastra/agents/weather/`, Mastra registers the agent as `weather` unless you override those fields.
|
|
46
|
+
|
|
47
|
+
Override `id` or `name` when the stable routing key and the display name should differ.
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { agentConfig } from '@mastra/core/agent'
|
|
51
|
+
|
|
52
|
+
export default agentConfig({
|
|
53
|
+
id: 'weather-assistant',
|
|
54
|
+
name: 'Weather Assistant',
|
|
55
|
+
model: 'openai/gpt-5.5',
|
|
56
|
+
})
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Set runtime options
|
|
60
|
+
|
|
61
|
+
`agentConfig()` accepts [`Agent` constructor options](https://mastra.ai/reference/agents/agent), except that `id`, `name`, and sibling-file fields can be supplied by the file-based convention. Use the Agent reference for the full option list.
|
|
62
|
+
|
|
63
|
+
Please note:
|
|
64
|
+
|
|
65
|
+
- File-based subagents require a non-empty `description` because the parent model uses it for delegation routing.
|
|
66
|
+
- `defaultOptions`, `maxRetries`, `scorers`, and other Agent options can live in `config.ts` when they don't need their own file.
|
|
67
|
+
|
|
68
|
+
## Where adjacent settings live
|
|
69
|
+
|
|
70
|
+
Keep `config.ts` focused on runtime options. Use sibling files for concerns that benefit from their own location.
|
|
71
|
+
|
|
72
|
+
| Setting | File or folder | Why it lives there |
|
|
73
|
+
| ------------ | ------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
|
|
74
|
+
| Instructions | [`instructions.md`](https://mastra.ai/reference/file-based-agents/instructions) | Keeps the always-on prompt readable as markdown |
|
|
75
|
+
| Tools | [`tools/`](https://mastra.ai/reference/file-based-agents/tools) | Gives each callable action its own typed module |
|
|
76
|
+
| Skills | [`skills/`](https://mastra.ai/reference/file-based-agents/skills) | Keeps load-on-demand procedures separate from always-on instructions |
|
|
77
|
+
| Memory | [`memory.ts`](https://mastra.ai/reference/file-based-agents/memory) | Configures persistent memory without crowding runtime options |
|
|
78
|
+
| Workspace | [`workspace.ts`](https://mastra.ai/reference/file-based-agents/workspace) | Configures files and sandbox behavior separately from model settings |
|
|
79
|
+
| Processors | [`processors/`](https://mastra.ai/reference/file-based-agents/processors) | Separates input and output processing pipelines |
|
|
80
|
+
| Subagents | [`subagents/`](https://mastra.ai/reference/file-based-agents/subagents) | Gives each specialist child agent its own directory |
|
|
81
|
+
|
|
82
|
+
## Precedence
|
|
83
|
+
|
|
84
|
+
`config.ts` merges with the agent's other files according to these rules:
|
|
85
|
+
|
|
86
|
+
| Domain | Source A | Source B | Winner |
|
|
87
|
+
| ------------ | ----------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------- |
|
|
88
|
+
| Instructions | Dynamic `config.instructions` | [`instructions.md`](https://mastra.ai/reference/file-based-agents/instructions) | Dynamic `config.instructions` |
|
|
89
|
+
| Instructions | Static `config.instructions` | [`instructions.md`](https://mastra.ai/reference/file-based-agents/instructions) | `instructions.md` |
|
|
90
|
+
| Tools | `config.tools` | [`tools/`](https://mastra.ai/reference/file-based-agents/tools) | Both merge; `config.tools` wins on key collisions |
|
|
91
|
+
| Tools | Function `config.tools` | [`tools/`](https://mastra.ai/reference/file-based-agents/tools) | Function `config.tools`; discovered tools are ignored |
|
|
92
|
+
| Skills | `config.skills` | [`skills/`](https://mastra.ai/reference/file-based-agents/skills) | Both merge; `config.skills` wins on name collisions |
|
|
93
|
+
| Skills | Function `config.skills` | [`skills/`](https://mastra.ai/reference/file-based-agents/skills) | Function `config.skills`; discovered skills are ignored |
|
|
94
|
+
| Memory | `config.memory` | [`memory.ts`](https://mastra.ai/reference/file-based-agents/memory) | `config.memory` |
|
|
95
|
+
| Workspace | `config.workspace` | [`workspace.ts`](https://mastra.ai/reference/file-based-agents/workspace) | `config.workspace` |
|
|
96
|
+
|
|
97
|
+
Missing both `instructions.md` and `config.instructions` fails the build. Missing both `config.memory` and `memory.ts` leaves the agent without memory.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Instructions
|
|
4
|
+
|
|
5
|
+
An agent's `instructions.md` holds its always-on system prompt: the model reads it on every turn. Use it to define the agent's identity, tone, role, and standing rules.
|
|
6
|
+
|
|
7
|
+
Instructions are always in context, so keep them for stable behavior that applies to every request. Move anything conditional, large, or action-oriented out of `instructions.md` and into [`tools/`](https://mastra.ai/reference/file-based-agents/tools) or [`skills/`](https://mastra.ai/reference/file-based-agents/skills), which the model uses only when relevant.
|
|
8
|
+
|
|
9
|
+
## Quickstart
|
|
10
|
+
|
|
11
|
+
Add an `instructions.md` at the agent root. Whatever you write becomes the prompt, so the shortest version is a single sentence.
|
|
12
|
+
|
|
13
|
+
```markdown
|
|
14
|
+
You are a helpful weather assistant. Answer questions about current conditions and forecasts.
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## What goes in instructions
|
|
18
|
+
|
|
19
|
+
Effective instructions cover the parts of an agent's behavior that don't change between requests:
|
|
20
|
+
|
|
21
|
+
- Role and identity
|
|
22
|
+
- Tone and style
|
|
23
|
+
- Standing rules
|
|
24
|
+
- Output format
|
|
25
|
+
|
|
26
|
+
Move conditional, large, or action-oriented guidance into [`tools/`](https://mastra.ai/reference/file-based-agents/tools) or [`skills/`](https://mastra.ai/reference/file-based-agents/skills), which the model uses only when relevant.
|
|
27
|
+
|
|
28
|
+
## Dynamic instructions
|
|
29
|
+
|
|
30
|
+
When the prompt needs to change per request, for example based on the current user or runtime context, set a dynamic `instructions` function in [`config.ts`](https://mastra.ai/reference/file-based-agents/config) instead of using `instructions.md`. A function `instructions` wins over `instructions.md`, so the static file is ignored when both are present.
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { agentConfig } from '@mastra/core/agent'
|
|
34
|
+
|
|
35
|
+
export default agentConfig({
|
|
36
|
+
model: 'openai/gpt-5.5',
|
|
37
|
+
instructions: ({ runtimeContext }) => {
|
|
38
|
+
const tier = runtimeContext.get('tier') ?? 'standard'
|
|
39
|
+
return `You are a support agent. Treat this as a ${tier}-tier customer.`
|
|
40
|
+
},
|
|
41
|
+
})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Build-time behavior
|
|
45
|
+
|
|
46
|
+
Mastra reads `instructions.md` and inlines its contents into the generated code when the bundler builds your project. The deployed agent doesn't read the file at runtime, so changes to `instructions.md` take effect only after the next build.
|
|
47
|
+
|
|
48
|
+
## Precedence with config
|
|
49
|
+
|
|
50
|
+
Instructions can come from `instructions.md` or from the `instructions` field in [`config.ts`](https://mastra.ai/reference/file-based-agents/config):
|
|
51
|
+
|
|
52
|
+
- A dynamic (function) `instructions` in `config.ts` wins over `instructions.md`.
|
|
53
|
+
- Otherwise `instructions.md` wins over a static `instructions` string.
|
|
54
|
+
- If neither is present, the build fails and names the agent directory.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Memory
|
|
4
|
+
|
|
5
|
+
A file-based agent gets [memory](https://mastra.ai/docs/memory/overview) from a `memory.ts` file that default-exports a [`Memory`](https://mastra.ai/reference/memory/memory-class) instance. Use this page for the file-based convention; use the memory docs for message history, semantic recall, storage, and processors.
|
|
6
|
+
|
|
7
|
+
Without `memory.ts` or `config.memory`, the agent has no memory by default. Each `generate()` or `stream()` call starts without remembered conversation state unless you pass the prior context yourself.
|
|
8
|
+
|
|
9
|
+
## Quickstart
|
|
10
|
+
|
|
11
|
+
Create `memory.ts` next to the agent's `config.ts`:
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Memory } from '@mastra/memory'
|
|
15
|
+
|
|
16
|
+
export default new Memory()
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The exported instance becomes the agent's `memory`. If your app configures a storage provider on the main Mastra instance, memory data is stored there. See [storage](https://mastra.ai/docs/storage/overview) for more information.
|
|
20
|
+
|
|
21
|
+
Use the same `resource` and `thread` values when calling the agent to continue a conversation:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
const response = await weatherAgent.generate('Remember that I prefer Celsius.', {
|
|
25
|
+
memory: {
|
|
26
|
+
resource: 'user-123',
|
|
27
|
+
thread: 'weather-chat',
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Configure memory
|
|
33
|
+
|
|
34
|
+
Pass options to `new Memory()` when the default behavior isn't enough.
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { Memory } from '@mastra/memory'
|
|
38
|
+
|
|
39
|
+
export default new Memory({
|
|
40
|
+
options: {
|
|
41
|
+
lastMessages: 20,
|
|
42
|
+
workingMemory: {
|
|
43
|
+
enabled: true,
|
|
44
|
+
scope: 'resource',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
})
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Visit the [`Memory` reference](https://mastra.ai/reference/memory/memory-class) for constructor options. Use these pages for related memory features:
|
|
51
|
+
|
|
52
|
+
- [Storage](https://mastra.ai/docs/storage/overview): configure persistence for memory data.
|
|
53
|
+
- [Semantic recall](https://mastra.ai/docs/memory/semantic-recall): retrieve relevant past messages by semantic meaning.
|
|
54
|
+
- [Memory processors](https://mastra.ai/docs/memory/memory-processors): filter, trim, or transform messages before memory adds them to model context.
|
|
55
|
+
|
|
56
|
+
## Precedence with config
|
|
57
|
+
|
|
58
|
+
`config.memory` wins over `memory.ts`. If neither is present, the assembled file-based agent has no memory. See [`config.ts` precedence](https://mastra.ai/reference/file-based-agents/config) for the full merge table.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Observability
|
|
4
|
+
|
|
5
|
+
Mastra configures [observability](https://mastra.ai/docs/observability/overview) from an `observability.ts` file directly under `src/mastra/`. The file default-exports an `Observability` instance that sets up tracing, logging, metrics, and feedback for the project.
|
|
6
|
+
|
|
7
|
+
Use this page for the file-based convention. For the signal model, exporters, storage, and multi-config setup, see [Observability overview](https://mastra.ai/docs/observability/overview) and [Observability configuration](https://mastra.ai/docs/observability/config).
|
|
8
|
+
|
|
9
|
+
## Quickstart
|
|
10
|
+
|
|
11
|
+
Create `src/mastra/observability.ts` and default-export an `Observability` instance:
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { MastraStorageExporter, Observability } from '@mastra/observability'
|
|
15
|
+
|
|
16
|
+
export default new Observability({
|
|
17
|
+
configs: {
|
|
18
|
+
default: {
|
|
19
|
+
serviceName: 'mastra',
|
|
20
|
+
exporters: [new MastraStorageExporter()],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Observability and storage
|
|
27
|
+
|
|
28
|
+
`observability.ts` configures which signals are collected and where they're exported. [`storage.ts`](https://mastra.ai/reference/file-based-agents/storage) configures the project store that can persist observability records. For storage support by signal, see [Observability storage](https://mastra.ai/docs/observability/storage).
|
|
29
|
+
|
|
30
|
+
## Precedence with code
|
|
31
|
+
|
|
32
|
+
Code-registered observability wins over `observability.ts`. Use `observability.ts` when one project-wide configuration is enough; use code registration when setup depends on runtime wiring in `src/mastra/index.ts`.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Processors
|
|
4
|
+
|
|
5
|
+
A file-based agent discovers [processors](https://mastra.ai/docs/agents/processors) from its `processors/` directory. Use this page for the file-based convention; use the processors guide for built-in processors, custom processors, streaming behavior, and advanced patterns.
|
|
6
|
+
|
|
7
|
+
Files under `processors/input/` run before messages reach the model. Files under `processors/output/` run after the model responds. Each file default-exports one [`Processor`](https://mastra.ai/reference/processors/processor-interface), and the filename becomes its discovery key.
|
|
8
|
+
|
|
9
|
+
## Quickstart
|
|
10
|
+
|
|
11
|
+
Add an input processor by placing a processor file under `processors/input/`:
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { PIIDetector } from '@mastra/core/processors'
|
|
15
|
+
|
|
16
|
+
export default new PIIDetector({
|
|
17
|
+
strategy: 'block',
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This processor runs before user messages reach the model.
|
|
22
|
+
|
|
23
|
+
## Add an output processor
|
|
24
|
+
|
|
25
|
+
Output processors are good for filtering or transforming model responses before they're returned. This example redacts PII from the final response.
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { PIIDetector } from '@mastra/core/processors'
|
|
29
|
+
|
|
30
|
+
export default new PIIDetector({
|
|
31
|
+
strategy: 'redact',
|
|
32
|
+
})
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Ordering
|
|
36
|
+
|
|
37
|
+
Discovered processors are added after any processors defined in [`config.ts`](https://mastra.ai/reference/file-based-agents/config). That means config processors run first.
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
config.inputProcessors → processors/input/* → model
|
|
41
|
+
model → config.outputProcessors → processors/output/* → response
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
If `config.inputProcessors` or `config.outputProcessors` is a function, discovered processors of that type are ignored with a warning because function-valued processors can't be statically merged.
|
|
45
|
+
|
|
46
|
+
## Precedence with config
|
|
47
|
+
|
|
48
|
+
Use `config.ts` for processors that need to be created dynamically or shared across agents. Use file-based processors for static, per-agent processors that should be reviewed alongside the agent.
|
|
49
|
+
|
|
50
|
+
Precedence is:
|
|
51
|
+
|
|
52
|
+
1. Function-valued `config.inputProcessors` or `config.outputProcessors`
|
|
53
|
+
2. Array-valued `config.inputProcessors` or `config.outputProcessors`
|
|
54
|
+
3. Discovered files under `processors/input/` or `processors/output/`
|
|
55
|
+
|
|
56
|
+
Visit the [`Processor` reference](https://mastra.ai/reference/processors/processor-interface) for the full interface.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Server
|
|
4
|
+
|
|
5
|
+
Mastra configures its HTTP [server](https://mastra.ai/docs/server/mastra-server) from a `server.ts` file directly under `src/mastra/`. The server exposes agents, workflows, and other registered primitives as REST endpoints, and the file default-exports the same `ServerConfig` shape you'd pass to [`new Mastra()`](https://mastra.ai/reference/core/mastra-class).
|
|
6
|
+
|
|
7
|
+
Use this page for the file-based convention. For server features, middleware, custom routes, generated API docs, and deployment behavior, see [Server overview](https://mastra.ai/docs/server/mastra-server).
|
|
8
|
+
|
|
9
|
+
## Quickstart
|
|
10
|
+
|
|
11
|
+
Create `src/mastra/server.ts` and default-export a `ServerConfig` object:
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import type { ServerConfig } from '@mastra/core/server'
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
port: 4111,
|
|
18
|
+
host: '0.0.0.0',
|
|
19
|
+
} satisfies ServerConfig
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Common configurations
|
|
23
|
+
|
|
24
|
+
`server.ts` can configure the same server options as code registration:
|
|
25
|
+
|
|
26
|
+
| Need | Use |
|
|
27
|
+
| ------------------------------------- | ----------------------------------------- |
|
|
28
|
+
| Bind to a deployment platform address | `host` and `port` |
|
|
29
|
+
| Restrict browser access | `cors` |
|
|
30
|
+
| Add webhooks or health checks | `apiRoutes` |
|
|
31
|
+
| Enable generated API docs | `build.openAPIDocs` and `build.swaggerUI` |
|
|
32
|
+
|
|
33
|
+
See [Mastra server](https://mastra.ai/docs/server/mastra-server), [middleware](https://mastra.ai/docs/server/middleware), and [custom API routes](https://mastra.ai/docs/server/custom-api-routes) for examples.
|
|
34
|
+
|
|
35
|
+
## Precedence with code
|
|
36
|
+
|
|
37
|
+
Code-registered server config wins over `server.ts`. Routes added during startup, such as channel webhooks, are preserved when file-based server config is applied.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Skills
|
|
4
|
+
|
|
5
|
+
A file-based agent discovers skills from its `skills/` directory and bundles them at build time. Skills are reusable procedures or reference material that the agent can load when relevant, instead of putting every detail into the always-on prompt.
|
|
6
|
+
|
|
7
|
+
Use this page for the file-based convention. For code-defined skills, see [Agent skills](https://mastra.ai/docs/agents/skills). For the `SKILL.md` package format, see [Workspace skills](https://mastra.ai/docs/workspace/skills).
|
|
8
|
+
|
|
9
|
+
## Quickstart
|
|
10
|
+
|
|
11
|
+
The simplest skill is one markdown file under `skills/`. The filename becomes the skill name, and `description` tells the agent when to load it.
|
|
12
|
+
|
|
13
|
+
```markdown
|
|
14
|
+
---
|
|
15
|
+
description: Use when reporting temperatures or comparing forecast units.
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
Always report temperatures in Celsius and Fahrenheit. Include the user's preferred unit first when known.
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Skills vs tools vs instructions
|
|
22
|
+
|
|
23
|
+
| Need | Use | Why |
|
|
24
|
+
| ---------------------------------------------------- | ------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
|
|
25
|
+
| Always-on identity, tone, or rules | [`instructions.md`](https://mastra.ai/reference/file-based-agents/instructions) | The model should see the guidance every turn. |
|
|
26
|
+
| Callable action with inputs and outputs | [`tools/`](https://mastra.ai/reference/file-based-agents/tools) | The model needs to execute code, call APIs, or perform side effects. |
|
|
27
|
+
| Detailed reference or procedure loaded when relevant | `skills/` | The model only needs the full guidance for specific tasks. |
|
|
28
|
+
|
|
29
|
+
## Skill formats
|
|
30
|
+
|
|
31
|
+
Mastra supports three file-based skill formats:
|
|
32
|
+
|
|
33
|
+
| Format | Use it when |
|
|
34
|
+
| ----------------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
|
35
|
+
| TypeScript/JavaScript module | You want to default-export a [`createSkill()`](https://mastra.ai/reference/agents/createSkill) result from code. |
|
|
36
|
+
| Packaged `SKILL.md` directory | The skill has instructions plus supporting files under `references/`. |
|
|
37
|
+
| Flat markdown file | The skill is one markdown file with frontmatter and instructions. |
|
|
38
|
+
|
|
39
|
+
For packaged skills, `description` is required in `SKILL.md` frontmatter. Flat markdown skills also require `description` in frontmatter. Write when to use the skill, not only what the skill contains.
|
|
40
|
+
|
|
41
|
+
## What gets loaded
|
|
42
|
+
|
|
43
|
+
File-based Agents skills are read at build time and added to the generated bundle. The deployed agent doesn't need to read those skill files from disk at runtime.
|
|
44
|
+
|
|
45
|
+
For packaged skills, Mastra reads:
|
|
46
|
+
|
|
47
|
+
- `SKILL.md` for metadata and instructions.
|
|
48
|
+
- Files directly under `references/` as supporting reference content.
|
|
49
|
+
|
|
50
|
+
Reference files are keyed by filename. Symlinked files and directories under `references/` are skipped during discovery.
|
|
51
|
+
|
|
52
|
+
## Precedence with config
|
|
53
|
+
|
|
54
|
+
Discovered skills merge with any `skills` in [`config.ts`](https://mastra.ai/reference/file-based-agents/config). On a name collision, `config.skills` wins and a warning is logged.
|
|
55
|
+
|
|
56
|
+
If `config.skills` is a function, discovered skills are ignored with a warning because function-valued skills can't be statically merged.
|