@mastra/mcp-docs-server 1.2.7-alpha.10 → 1.2.7-alpha.3
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 +3 -4
- package/.docs/docs/agent-builder/skill-registries.md +3 -1
- package/.docs/docs/agent-controller/overview.md +2 -3
- package/.docs/docs/agent-controller/session.md +3 -1
- package/.docs/docs/agents/a2a.md +1 -2
- package/.docs/docs/agents/channels.md +225 -0
- package/.docs/docs/agents/code-mode.md +1 -1
- package/.docs/docs/agents/file-based-agents.md +297 -0
- package/.docs/docs/agents/guardrails.md +9 -10
- package/.docs/docs/agents/overview.md +4 -4
- package/.docs/docs/agents/skills.md +5 -3
- package/.docs/docs/agents/structured-output.md +1 -1
- package/.docs/docs/agents/supervisor-agents.md +4 -3
- package/.docs/docs/agents/using-tools.md +4 -2
- package/.docs/docs/browser/agent-browser.md +3 -1
- package/.docs/docs/browser/browser-viewer.md +3 -1
- package/.docs/docs/browser/overview.md +1 -2
- package/.docs/docs/browser/stagehand.md +1 -1
- package/.docs/docs/deployment/mastra-server.md +4 -2
- package/.docs/docs/editor/overview.md +6 -2
- package/.docs/docs/editor/prompts.md +1 -1
- package/.docs/docs/editor/tools.md +3 -1
- package/.docs/docs/evals/custom-scorers.md +3 -1
- package/.docs/docs/evals/datasets/overview.md +5 -4
- package/.docs/docs/evals/datasets/running-experiments.md +2 -4
- package/.docs/docs/evals/evals-with-memory.md +3 -1
- package/.docs/docs/evals/gates-and-verdicts.md +3 -1
- package/.docs/docs/evals/overview.md +1 -4
- package/.docs/docs/evals/quick-checks.md +3 -1
- package/.docs/docs/long-running-agents/background-tasks.md +1 -1
- package/.docs/docs/long-running-agents/durable-agents.md +5 -3
- package/.docs/docs/long-running-agents/goals.md +3 -1
- package/.docs/docs/long-running-agents/signal-providers.md +3 -1
- package/.docs/docs/long-running-agents/signals.md +22 -11
- package/.docs/docs/mastra-platform/observability.md +1 -5
- package/.docs/docs/mcp/mcp-apps.md +3 -3
- package/.docs/docs/mcp/overview.md +10 -6
- package/.docs/docs/memory/observational-memory.md +1 -2
- package/.docs/docs/memory/overview.md +4 -6
- package/.docs/docs/memory/semantic-recall.md +1 -1
- package/.docs/docs/memory/working-memory.md +3 -3
- package/.docs/docs/observability/integrations/exporters/mastra-platform.md +3 -1
- package/.docs/docs/observability/logging.md +1 -1
- package/.docs/docs/observability/tracing/overview.md +1 -1
- package/.docs/docs/server/auth/auth0.md +1 -1
- package/.docs/docs/server/auth/better-auth.md +2 -2
- package/.docs/docs/server/auth/clerk.md +1 -1
- package/.docs/docs/server/auth/firebase.md +1 -1
- package/.docs/docs/server/auth/google.md +2 -2
- package/.docs/docs/server/auth/jwt.md +2 -2
- package/.docs/docs/server/auth/okta.md +2 -2
- package/.docs/docs/server/auth/workos.md +1 -1
- package/.docs/docs/server/mastra-client.md +1 -1
- package/.docs/docs/server/mastra-server.md +1 -1
- package/.docs/docs/server/pubsub.md +1 -1
- package/.docs/docs/server/request-context.md +4 -4
- package/.docs/docs/server/server-adapters.md +8 -8
- package/.docs/docs/studio/auth.md +3 -1
- package/.docs/docs/studio/overview.md +1 -1
- package/.docs/docs/voice/livekit.md +3 -100
- package/.docs/docs/workflows/agents-and-tools.md +5 -3
- package/.docs/docs/workflows/control-flow.md +3 -1
- package/.docs/docs/workflows/overview.md +7 -6
- package/.docs/docs/workspace/overview.md +1 -2
- package/.docs/docs/workspace/sandbox.md +0 -2
- package/.docs/guides/build-your-ui/assistant-ui.md +1 -1
- package/.docs/guides/build-your-ui/copilotkit/overview.md +1 -1
- package/.docs/guides/concepts/streaming.md +3 -3
- package/.docs/guides/getting-started/quickstart.md +1 -3
- package/.docs/guides/guide/chef-michel.md +2 -0
- package/.docs/guides/guide/slack-assistant.md +2 -2
- package/.docs/guides/guide/stock-agent.md +2 -0
- package/.docs/models/environment-variables.md +0 -3
- package/.docs/models/gateways/netlify.md +1 -4
- package/.docs/models/gateways/openrouter.md +6 -10
- package/.docs/models/gateways/vercel.md +1 -7
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/google.md +1 -2
- package/.docs/models/providers/llmgateway.md +181 -184
- package/.docs/models/providers/nano-gpt.md +2 -2
- package/.docs/models/providers/neon.md +29 -40
- package/.docs/models/providers/openai.md +1 -5
- package/.docs/models/providers/opencode.md +1 -2
- package/.docs/models/providers/poolside.md +5 -6
- package/.docs/models/providers/routing-run.md +34 -20
- package/.docs/models/providers/the-grid-ai.md +3 -3
- package/.docs/models/providers/wandb.md +14 -21
- package/.docs/models/providers/xai.md +1 -2
- package/.docs/models/providers.md +0 -3
- 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 +10 -117
- package/.docs/reference/evals/create-scorer.md +0 -8
- package/.docs/reference/index.md +0 -15
- package/.docs/reference/memory/memory-class.md +1 -1
- package/.docs/reference/memory/serialized-memory-config.md +1 -1
- package/.docs/reference/project-structure.md +1 -1
- package/.docs/reference/pubsub/lease-provider.md +1 -1
- package/.docs/reference/server/express-adapter.md +3 -1
- package/.docs/reference/server/fastify-adapter.md +3 -1
- package/.docs/reference/server/hono-adapter.md +3 -1
- package/.docs/reference/server/koa-adapter.md +3 -1
- package/.docs/reference/server/nestjs-adapter.md +3 -1
- package/.docs/reference/storage/clickhouse.md +0 -32
- package/.docs/reference/storage/composite.md +1 -27
- package/.docs/reference/storage/retention.md +0 -11
- package/.docs/reference/tools/mcp-client.md +0 -22
- package/.docs/reference/tools/mcp-server.md +4 -161
- package/.docs/reference/voice/livekit.md +8 -272
- package/.docs/reference/workspace/agentcore-runtime-sandbox.md +3 -1
- package/.docs/reference/workspace/agentfs-filesystem.md +3 -1
- package/.docs/reference/workspace/apple-container-sandbox.md +3 -1
- package/.docs/reference/workspace/archil-filesystem.md +3 -1
- package/.docs/reference/workspace/azure-blob-filesystem.md +3 -1
- package/.docs/reference/workspace/blaxel-sandbox.md +3 -1
- package/.docs/reference/workspace/daytona-sandbox.md +3 -1
- package/.docs/reference/workspace/docker-sandbox.md +3 -1
- package/.docs/reference/workspace/e2b-sandbox.md +3 -1
- package/.docs/reference/workspace/files-sdk-filesystem.md +3 -1
- package/.docs/reference/workspace/gcs-filesystem.md +3 -1
- package/.docs/reference/workspace/google-drive-filesystem.md +3 -1
- package/.docs/reference/workspace/local-filesystem.md +3 -1
- package/.docs/reference/workspace/local-sandbox.md +3 -1
- package/.docs/reference/workspace/modal-sandbox.md +3 -1
- package/.docs/reference/workspace/railway-sandbox.md +3 -1
- package/.docs/reference/workspace/s3-filesystem.md +3 -1
- package/.docs/reference/workspace/vercel-sandbox.md +7 -5
- package/.docs/reference/workspace/vercel-serverless.md +3 -1
- package/CHANGELOG.md +0 -22
- package/package.json +5 -5
- package/.docs/docs/capabilities/channels/discord.md +0 -98
- package/.docs/docs/capabilities/channels/other-adapters.md +0 -68
- package/.docs/docs/capabilities/channels/overview.md +0 -255
- package/.docs/docs/capabilities/channels/slack.md +0 -225
- package/.docs/docs/capabilities/channels/teams.md +0 -100
- package/.docs/docs/capabilities/channels/telegram.md +0 -98
- package/.docs/docs/capabilities/channels/whatsapp.md +0 -99
- package/.docs/docs/getting-started/file-based-agents.md +0 -114
- package/.docs/models/providers/crossmodel.md +0 -109
- package/.docs/models/providers/meta.md +0 -101
- package/.docs/models/providers/zenifra.md +0 -73
- package/.docs/reference/file-based-agents/config.md +0 -97
- package/.docs/reference/file-based-agents/instructions.md +0 -54
- package/.docs/reference/file-based-agents/memory.md +0 -58
- package/.docs/reference/file-based-agents/observability.md +0 -32
- package/.docs/reference/file-based-agents/processors.md +0 -56
- package/.docs/reference/file-based-agents/server.md +0 -37
- package/.docs/reference/file-based-agents/skills.md +0 -56
- package/.docs/reference/file-based-agents/storage.md +0 -30
- package/.docs/reference/file-based-agents/studio.md +0 -56
- package/.docs/reference/file-based-agents/subagents.md +0 -123
- package/.docs/reference/file-based-agents/tools.md +0 -63
- package/.docs/reference/file-based-agents/workflows.md +0 -52
- package/.docs/reference/file-based-agents/workspace.md +0 -74
- package/.docs/reference/memory/summarizeConversation.md +0 -99
- package/.docs/reference/memory/summarizeThread.md +0 -93
|
@@ -1,73 +0,0 @@
|
|
|
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
|
-
```
|
|
@@ -1,97 +0,0 @@
|
|
|
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.
|
|
@@ -1,54 +0,0 @@
|
|
|
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.
|
|
@@ -1,58 +0,0 @@
|
|
|
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.
|
|
@@ -1,32 +0,0 @@
|
|
|
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`.
|
|
@@ -1,56 +0,0 @@
|
|
|
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.
|
|
@@ -1,37 +0,0 @@
|
|
|
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.
|
|
@@ -1,56 +0,0 @@
|
|
|
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.
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
-
|
|
3
|
-
# Storage
|
|
4
|
-
|
|
5
|
-
Mastra sets the project's default [storage](https://mastra.ai/docs/storage/overview) from a `storage.ts` file directly under `src/mastra/`. The file default-exports a store, which replaces the built-in in-memory store used for memory, workflows, observability, and other storage domains.
|
|
6
|
-
|
|
7
|
-
Use this page for the file-based convention. For backend choice, storage domains, retention, and provider details, see [storage overview](https://mastra.ai/docs/storage/overview).
|
|
8
|
-
|
|
9
|
-
## Quickstart
|
|
10
|
-
|
|
11
|
-
Use [`LibSQLStore`](https://mastra.ai/reference/storage/libsql) for a local file-backed store:
|
|
12
|
-
|
|
13
|
-
```typescript
|
|
14
|
-
import { LibSQLStore } from '@mastra/libsql'
|
|
15
|
-
|
|
16
|
-
export default new LibSQLStore({
|
|
17
|
-
id: 'mastra-storage',
|
|
18
|
-
url: 'file:./mastra.db',
|
|
19
|
-
})
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
Mastra registers the store before file-based agents and workflows, so storage-dependent primitives bind to this store instead of the default in-memory store.
|
|
23
|
-
|
|
24
|
-
## Production backends
|
|
25
|
-
|
|
26
|
-
`storage.ts` can export any Mastra storage adapter, such as LibSQL, PostgreSQL, or MongoDB. For setup patterns, provider support, and schema details, see [storage overview](https://mastra.ai/docs/storage/overview), [observability storage](https://mastra.ai/docs/observability/storage), and the [storage reference](https://mastra.ai/reference/storage/overview).
|
|
27
|
-
|
|
28
|
-
## Precedence with code
|
|
29
|
-
|
|
30
|
-
Code-registered storage wins over `storage.ts`. Use `storage.ts` when one project-wide store is enough; use code registration when setup depends on runtime wiring in `src/mastra/index.ts`.
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
-
|
|
3
|
-
# Studio
|
|
4
|
-
|
|
5
|
-
Mastra configures [Studio](https://mastra.ai/docs/studio/overview) from a `studio.ts` file directly under `src/mastra/`. The file default-exports a `StudioConfig` object for Studio authentication and authorization: who can access Studio, and what authenticated users can do.
|
|
6
|
-
|
|
7
|
-
Use this page for the file-based convention. For auth providers, role-based access control (RBAC), and fine-grained authorization (FGA), see [Studio auth](https://mastra.ai/docs/studio/auth).
|
|
8
|
-
|
|
9
|
-
## Quickstart
|
|
10
|
-
|
|
11
|
-
For local development, you don't need `studio.ts`. Start the dev server and open Studio:
|
|
12
|
-
|
|
13
|
-
**npm**:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm run dev
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
**pnpm**:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
pnpm run dev
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
**Yarn**:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
yarn dev
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
**Bun**:
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
bun run dev
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Studio opens without authentication in local development. Add `studio.ts` when you're ready to secure a shared or production deployment.
|
|
38
|
-
|
|
39
|
-
## Add authentication
|
|
40
|
-
|
|
41
|
-
Use an auth provider to require sign-in before users can access Studio. This example uses [WorkOS](https://mastra.ai/docs/server/auth/workos):
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
import { MastraAuthWorkos } from '@mastra/auth-workos'
|
|
45
|
-
import type { StudioConfig } from '@mastra/core/server'
|
|
46
|
-
|
|
47
|
-
export default {
|
|
48
|
-
auth: new MastraAuthWorkos(),
|
|
49
|
-
} satisfies StudioConfig
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
The auth provider handles who the user is. For what the user can do after sign-in, add RBAC or FGA in the same config. See [Studio auth](https://mastra.ai/docs/studio/auth) for full examples.
|
|
53
|
-
|
|
54
|
-
## Precedence with code
|
|
55
|
-
|
|
56
|
-
Code-registered Studio config wins over `studio.ts`. Use `studio.ts` when one project-wide Studio config is enough; use code registration when auth depends on runtime wiring in `src/mastra/index.ts`.
|