@mastra/mcp-docs-server 1.1.17-alpha.9 → 1.1.17
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/memory/observational-memory.md +49 -4
- package/.docs/docs/server/mastra-client.md +17 -0
- package/.docs/docs/server/server-adapters.md +15 -1
- package/.docs/models/gateways/openrouter.md +1 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/bailing.md +1 -1
- package/.docs/models/providers/cloudflare-workers-ai.md +4 -3
- package/.docs/models/providers/firmware.md +2 -2
- package/.docs/models/providers/friendli.md +1 -1
- package/.docs/models/providers/github-models.md +1 -1
- package/.docs/models/providers/google.md +7 -2
- package/.docs/models/providers/groq.md +24 -16
- package/.docs/models/providers/huggingface.md +1 -1
- package/.docs/models/providers/mistral.md +3 -2
- package/.docs/models/providers/nano-gpt.md +3 -1
- package/.docs/models/providers/openai.md +2 -1
- package/.docs/models/providers/poe.md +3 -1
- package/.docs/models/providers/zai-coding-plan.md +3 -2
- package/.docs/models/providers/zhipuai-coding-plan.md +3 -2
- package/.docs/reference/ai-sdk/handle-chat-stream.md +2 -0
- package/.docs/reference/client-js/agents.md +11 -6
- package/.docs/reference/client-js/mastra-client.md +1 -1
- package/.docs/reference/client-js/memory.md +1 -1
- package/.docs/reference/configuration.md +24 -0
- package/.docs/reference/core/mastra-model-gateway.md +2 -0
- package/.docs/reference/deployer/cloudflare.md +31 -1
- package/.docs/reference/evals/scorer-utils.md +9 -5
- package/.docs/reference/evals/trajectory-accuracy.md +29 -15
- package/.docs/reference/index.md +0 -2
- package/.docs/reference/logging/pino-logger.md +58 -0
- package/.docs/reference/memory/observational-memory.md +32 -6
- package/CHANGELOG.md +37 -0
- package/package.json +6 -6
- package/.docs/reference/core/getStoredAgentById.md +0 -87
- package/.docs/reference/core/listStoredAgents.md +0 -91
|
@@ -95,27 +95,72 @@ The result is a three-tier system:
|
|
|
95
95
|
|
|
96
96
|
Normal OM compresses messages into observations, which is great for staying on task — but the original wording is gone. Retrieval mode fixes this by keeping each observation group linked to the raw messages that produced it. When the agent needs exact wording, tool output, or chronology that the summary compressed away, it can call a `recall` tool to page through the source messages.
|
|
97
97
|
|
|
98
|
+
#### Browsing only
|
|
99
|
+
|
|
100
|
+
Set `retrieval: true` to enable the recall tool for browsing raw messages. No vector store needed. By default, the recall tool can browse across all threads for the current resource.
|
|
101
|
+
|
|
98
102
|
```typescript
|
|
99
103
|
const memory = new Memory({
|
|
100
104
|
options: {
|
|
101
105
|
observationalMemory: {
|
|
102
106
|
model: 'google/gemini-2.5-flash',
|
|
103
|
-
scope: 'thread',
|
|
104
107
|
retrieval: true,
|
|
105
108
|
},
|
|
106
109
|
},
|
|
107
110
|
})
|
|
108
111
|
```
|
|
109
112
|
|
|
113
|
+
#### With semantic search
|
|
114
|
+
|
|
115
|
+
Set `retrieval: { vector: true }` to also enable semantic search. This reuses the vector store and embedder already configured on your Memory instance:
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
const memory = new Memory({
|
|
119
|
+
storage,
|
|
120
|
+
vector: myVectorStore,
|
|
121
|
+
embedder: myEmbedder,
|
|
122
|
+
options: {
|
|
123
|
+
observationalMemory: {
|
|
124
|
+
model: 'google/gemini-2.5-flash',
|
|
125
|
+
retrieval: { vector: true },
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
})
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
When vector search is configured, new observation groups are automatically indexed at buffer time and during synchronous observation (fire-and-forget, non-blocking). Semantic search returns observation-group matches with their raw source message ID ranges, so the recall tool can show the summarized memory alongside where it came from.
|
|
132
|
+
|
|
133
|
+
#### Restricting to the current thread
|
|
134
|
+
|
|
135
|
+
By default, the recall tool scope is `'resource'` — the agent can list threads, browse other threads, and search across all conversations. Set `scope: 'thread'` to restrict the agent to only the current thread:
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
const memory = new Memory({
|
|
139
|
+
options: {
|
|
140
|
+
observationalMemory: {
|
|
141
|
+
model: 'google/gemini-2.5-flash',
|
|
142
|
+
retrieval: { vector: true, scope: 'thread' },
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
})
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
#### What retrieval enables
|
|
149
|
+
|
|
110
150
|
With retrieval mode enabled, OM:
|
|
111
151
|
|
|
112
152
|
- Stores a `range` (e.g. `startId:endId`) on each observation group pointing to the messages it was derived from
|
|
153
|
+
|
|
113
154
|
- Keeps range metadata visible in the agent's context so the agent knows which observations map to which messages
|
|
114
|
-
- Registers a `recall` tool the agent can call to page through the raw messages behind any range
|
|
115
155
|
|
|
116
|
-
|
|
156
|
+
- Registers a `recall` tool the agent can call to:
|
|
157
|
+
|
|
158
|
+
- Page through the raw messages behind any observation group range
|
|
159
|
+
- Search by semantic similarity (`mode: "search"` with a `query` string) — requires `vector: true`
|
|
160
|
+
- List all threads (`mode: "threads"`), browse other threads (`threadId`), and search across all threads (default `scope: 'resource'`)
|
|
161
|
+
- When `scope: 'thread'`: restrict browsing and search to the current thread only
|
|
117
162
|
|
|
118
|
-
See the [recall tool reference](https://mastra.ai/reference/memory/observational-memory) for the full API (detail levels, part indexing, pagination, and token limiting).
|
|
163
|
+
See the [recall tool reference](https://mastra.ai/reference/memory/observational-memory) for the full API (detail levels, part indexing, pagination, cross-thread browsing, and token limiting).
|
|
119
164
|
|
|
120
165
|
## Models
|
|
121
166
|
|
|
@@ -133,6 +133,23 @@ export const mastraClient = new MastraClient({
|
|
|
133
133
|
|
|
134
134
|
> **Info:** Visit [MastraClient](https://mastra.ai/reference/client-js/mastra-client) for more configuration options.
|
|
135
135
|
|
|
136
|
+
## Credentials and session cookies
|
|
137
|
+
|
|
138
|
+
**Authenticate Mastra API calls with session cookies** when your UI and Mastra API are not on the same origin—different host, subdomain, or port (for example Mastra Studio on one port and a custom server on another). Add **`credentials: 'include'`** to `MastraClient` so each request carries the cookies the user already has after sign-in. Skip this and you will often get **`401`** responses from Mastra even though login succeeded in the browser.
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
import { MastraClient } from '@mastra/client-js'
|
|
142
|
+
|
|
143
|
+
export const mastraClient = new MastraClient({
|
|
144
|
+
baseUrl: process.env.MASTRA_API_URL || 'http://localhost:4111',
|
|
145
|
+
credentials: 'include',
|
|
146
|
+
})
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Allow credentialed cross-origin requests on your server**—see [CORS: requests with credentials](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS#requests_with_credentials). You need a concrete `Access-Control-Allow-Origin` (not `*`) and `Access-Control-Allow-Credentials: true`, or the browser will block the call before it reaches Mastra.
|
|
150
|
+
|
|
151
|
+
**Using `@mastra/react`?** Wrap your app with `MastraReactProvider`, set `baseUrl` and `apiPrefix` to match your server, and rely on the default `credentials: 'include'`. Change `credentials` only when you deliberately want `same-origin` or `omit` behavior.
|
|
152
|
+
|
|
136
153
|
## Adding request cancelling
|
|
137
154
|
|
|
138
155
|
`MastraClient` supports request cancellation using the standard Node.js `AbortSignal` API. Useful for canceling in-flight requests, such as when users abort an operation or to clean up stale network calls.
|
|
@@ -521,7 +521,21 @@ The adapter registers routes for both HTTP and SSE (Server-Sent Events) transpor
|
|
|
521
521
|
|
|
522
522
|
### Serverless mode
|
|
523
523
|
|
|
524
|
-
For serverless environments like Cloudflare Workers or Vercel Edge, enable stateless mode via `mcpOptions
|
|
524
|
+
For serverless environments like Cloudflare Workers or Vercel Edge, enable stateless mode via `mcpOptions`.
|
|
525
|
+
|
|
526
|
+
When using the Mastra deployer (the standard `mastra dev` / `mastra build` path), set `mcpOptions` in your server config:
|
|
527
|
+
|
|
528
|
+
```typescript
|
|
529
|
+
const mastra = new Mastra({
|
|
530
|
+
server: {
|
|
531
|
+
mcpOptions: {
|
|
532
|
+
serverless: true,
|
|
533
|
+
},
|
|
534
|
+
},
|
|
535
|
+
})
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
When manually creating a server adapter, pass `mcpOptions` directly:
|
|
525
539
|
|
|
526
540
|
```typescript
|
|
527
541
|
const server = new MastraServer({
|
|
@@ -117,7 +117,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
117
117
|
| `nousresearch/hermes-4-70b` |
|
|
118
118
|
| `nvidia/nemotron-3-nano-30b-a3b:free` |
|
|
119
119
|
| `nvidia/nemotron-3-super-120b-a12b` |
|
|
120
|
-
| `nvidia/nemotron-3-super-120b-a12b
|
|
120
|
+
| `nvidia/nemotron-3-super-120b-a12b:free` |
|
|
121
121
|
| `nvidia/nemotron-nano-12b-v2-vl:free` |
|
|
122
122
|
| `nvidia/nemotron-nano-9b-v2` |
|
|
123
123
|
| `nvidia/nemotron-nano-9b-v2:free` |
|
package/.docs/models/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Model Providers
|
|
2
2
|
|
|
3
|
-
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to
|
|
3
|
+
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to 3616 models from 95 providers through a single API.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -5,7 +5,7 @@ Access 2 Bailing models through Mastra's model router. Authentication is handled
|
|
|
5
5
|
Learn more in the [Bailing documentation](https://alipaytbox.yuque.com/sxs0ba/ling/intro).
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
BAILING_API_TOKEN=your-api-
|
|
8
|
+
BAILING_API_TOKEN=your-api-token
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# Cloudflare Workers AI
|
|
2
2
|
|
|
3
|
-
Access 42 Cloudflare Workers AI models through Mastra's model router. Authentication is handled automatically using the `
|
|
3
|
+
Access 42 Cloudflare Workers AI models through Mastra's model router. Authentication is handled automatically using the `CLOUDFLARE_API_KEY` environment variable. Configure `CLOUDFLARE_ACCOUNT_ID` as well.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Cloudflare Workers AI documentation](https://developers.cloudflare.com/workers-ai/models/).
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
CLOUDFLARE_ACCOUNT_ID=your-
|
|
8
|
+
CLOUDFLARE_ACCOUNT_ID=your-account-id
|
|
9
|
+
CLOUDFLARE_API_KEY=your-api-key
|
|
9
10
|
```
|
|
10
11
|
|
|
11
12
|
```typescript
|
|
@@ -88,7 +89,7 @@ const agent = new Agent({
|
|
|
88
89
|
model: {
|
|
89
90
|
url: "https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/ai/v1",
|
|
90
91
|
id: "cloudflare-workers-ai/@cf/ai4bharat/indictrans2-en-indic-1B",
|
|
91
|
-
apiKey: process.env.
|
|
92
|
+
apiKey: process.env.CLOUDFLARE_API_KEY,
|
|
92
93
|
headers: {
|
|
93
94
|
"X-Custom-Header": "value"
|
|
94
95
|
}
|
|
@@ -45,7 +45,6 @@ for await (const chunk of stream) {
|
|
|
45
45
|
| `firmware/gemini-3-1-pro-preview` | 1.0M | | | | | | $2 | $12 |
|
|
46
46
|
| `firmware/gemini-3-flash-preview` | 1.0M | | | | | | $0.50 | $3 |
|
|
47
47
|
| `firmware/gemini-3-pro-preview` | 1.0M | | | | | | $2 | $12 |
|
|
48
|
-
| `firmware/glm-5` | 198K | | | | | | $1 | $3 |
|
|
49
48
|
| `firmware/gpt-4o` | 128K | | | | | | $3 | $10 |
|
|
50
49
|
| `firmware/gpt-5-3-codex` | 400K | | | | | | $2 | $14 |
|
|
51
50
|
| `firmware/gpt-5-4` | 272K | | | | | | $3 | $15 |
|
|
@@ -58,6 +57,7 @@ for await (const chunk of stream) {
|
|
|
58
57
|
| `firmware/grok-code-fast-1` | 256K | | | | | | $0.20 | $2 |
|
|
59
58
|
| `firmware/kimi-k2.5` | 256K | | | | | | $0.60 | $3 |
|
|
60
59
|
| `firmware/minimax-m2-5` | 192K | | | | | | $0.30 | $1 |
|
|
60
|
+
| `firmware/zai-glm-5` | 198K | | | | | | $1 | $3 |
|
|
61
61
|
|
|
62
62
|
## Advanced configuration
|
|
63
63
|
|
|
@@ -87,7 +87,7 @@ const agent = new Agent({
|
|
|
87
87
|
model: ({ requestContext }) => {
|
|
88
88
|
const useAdvanced = requestContext.task === "complex";
|
|
89
89
|
return useAdvanced
|
|
90
|
-
? "firmware/
|
|
90
|
+
? "firmware/zai-glm-5"
|
|
91
91
|
: "firmware/claude-haiku-4-5";
|
|
92
92
|
}
|
|
93
93
|
});
|
|
@@ -5,7 +5,7 @@ Access 7 Friendli models through Mastra's model router. Authentication is handle
|
|
|
5
5
|
Learn more in the [Friendli documentation](https://friendli.ai/docs/guides/serverless_endpoints/introduction).
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
FRIENDLI_TOKEN=your-api-
|
|
8
|
+
FRIENDLI_TOKEN=your-api-token
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
@@ -5,7 +5,7 @@ Access 55 GitHub Models models through Mastra's model router. Authentication is
|
|
|
5
5
|
Learn more in the [GitHub Models documentation](https://docs.github.com/en/github-models).
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
GITHUB_TOKEN=your-api-
|
|
8
|
+
GITHUB_TOKEN=your-api-token
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Google
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 35 Google models through Mastra's model router. Authentication is handled automatically using the `GOOGLE_GENERATIVE_AI_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Google documentation](https://ai.google.dev/gemini-api/docs/pricing).
|
|
6
6
|
|
|
@@ -62,6 +62,11 @@ for await (const chunk of stream) {
|
|
|
62
62
|
| `google/gemini-flash-lite-latest` | 1.0M | | | | | | $0.10 | $0.40 |
|
|
63
63
|
| `google/gemini-live-2.5-flash` | 128K | | | | | | $0.50 | $2 |
|
|
64
64
|
| `google/gemini-live-2.5-flash-preview-native-audio` | 131K | | | | | | $0.50 | $2 |
|
|
65
|
+
| `google/gemma-3-12b-it` | 33K | | | | | | — | — |
|
|
66
|
+
| `google/gemma-3-27b-it` | 131K | | | | | | — | — |
|
|
67
|
+
| `google/gemma-3-4b-it` | 33K | | | | | | — | — |
|
|
68
|
+
| `google/gemma-3n-e2b-it` | 8K | | | | | | — | — |
|
|
69
|
+
| `google/gemma-3n-e4b-it` | 8K | | | | | | — | — |
|
|
65
70
|
|
|
66
71
|
## Advanced configuration
|
|
67
72
|
|
|
@@ -90,7 +95,7 @@ const agent = new Agent({
|
|
|
90
95
|
model: ({ requestContext }) => {
|
|
91
96
|
const useAdvanced = requestContext.task === "complex";
|
|
92
97
|
return useAdvanced
|
|
93
|
-
? "google/
|
|
98
|
+
? "google/gemma-3n-e4b-it"
|
|
94
99
|
: "google/gemini-1.5-flash";
|
|
95
100
|
}
|
|
96
101
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Groq
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 17 Groq models through Mastra's model router. Authentication is handled automatically using the `GROQ_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Groq documentation](https://console.groq.com/docs/models).
|
|
6
6
|
|
|
@@ -15,7 +15,7 @@ const agent = new Agent({
|
|
|
15
15
|
id: "my-agent",
|
|
16
16
|
name: "My Agent",
|
|
17
17
|
instructions: "You are a helpful assistant",
|
|
18
|
-
model: "groq/
|
|
18
|
+
model: "groq/allam-2-7b"
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
// Generate a response
|
|
@@ -30,17 +30,25 @@ for await (const chunk of stream) {
|
|
|
30
30
|
|
|
31
31
|
## Models
|
|
32
32
|
|
|
33
|
-
| Model
|
|
34
|
-
|
|
|
35
|
-
| `groq/
|
|
36
|
-
| `groq/
|
|
37
|
-
| `groq/
|
|
38
|
-
| `groq/
|
|
39
|
-
| `groq/
|
|
40
|
-
| `groq/
|
|
41
|
-
| `groq/
|
|
42
|
-
| `groq/
|
|
43
|
-
| `groq/
|
|
33
|
+
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
34
|
+
| ------------------------------------------------ | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
35
|
+
| `groq/allam-2-7b` | 4K | | | | | | — | — |
|
|
36
|
+
| `groq/canopylabs/orpheus-arabic-saudi` | 4K | | | | | | $40 | — |
|
|
37
|
+
| `groq/canopylabs/orpheus-v1-english` | 4K | | | | | | — | — |
|
|
38
|
+
| `groq/groq/compound` | 131K | | | | | | — | — |
|
|
39
|
+
| `groq/groq/compound-mini` | 131K | | | | | | — | — |
|
|
40
|
+
| `groq/llama-3.1-8b-instant` | 131K | | | | | | $0.05 | $0.08 |
|
|
41
|
+
| `groq/llama-3.3-70b-versatile` | 131K | | | | | | $0.59 | $0.79 |
|
|
42
|
+
| `groq/meta-llama/llama-4-scout-17b-16e-instruct` | 131K | | | | | | $0.11 | $0.34 |
|
|
43
|
+
| `groq/meta-llama/llama-prompt-guard-2-22m` | 512 | | | | | | $0.03 | $0.03 |
|
|
44
|
+
| `groq/meta-llama/llama-prompt-guard-2-86m` | 512 | | | | | | $0.04 | $0.04 |
|
|
45
|
+
| `groq/moonshotai/kimi-k2-instruct-0905` | 262K | | | | | | $1 | $3 |
|
|
46
|
+
| `groq/openai/gpt-oss-120b` | 131K | | | | | | $0.15 | $0.60 |
|
|
47
|
+
| `groq/openai/gpt-oss-20b` | 131K | | | | | | $0.07 | $0.30 |
|
|
48
|
+
| `groq/openai/gpt-oss-safeguard-20b` | 131K | | | | | | $0.07 | $0.30 |
|
|
49
|
+
| `groq/qwen/qwen3-32b` | 131K | | | | | | $0.29 | $0.59 |
|
|
50
|
+
| `groq/whisper-large-v3` | 448 | | | | | | — | — |
|
|
51
|
+
| `groq/whisper-large-v3-turbo` | 448 | | | | | | — | — |
|
|
44
52
|
|
|
45
53
|
## Advanced configuration
|
|
46
54
|
|
|
@@ -52,7 +60,7 @@ const agent = new Agent({
|
|
|
52
60
|
name: "custom-agent",
|
|
53
61
|
model: {
|
|
54
62
|
url: "https://api.groq.com/openai/v1",
|
|
55
|
-
id: "groq/
|
|
63
|
+
id: "groq/allam-2-7b",
|
|
56
64
|
apiKey: process.env.GROQ_API_KEY,
|
|
57
65
|
headers: {
|
|
58
66
|
"X-Custom-Header": "value"
|
|
@@ -70,8 +78,8 @@ const agent = new Agent({
|
|
|
70
78
|
model: ({ requestContext }) => {
|
|
71
79
|
const useAdvanced = requestContext.task === "complex";
|
|
72
80
|
return useAdvanced
|
|
73
|
-
? "groq/
|
|
74
|
-
: "groq/
|
|
81
|
+
? "groq/whisper-large-v3-turbo"
|
|
82
|
+
: "groq/allam-2-7b";
|
|
75
83
|
}
|
|
76
84
|
});
|
|
77
85
|
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Mistral
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 27 Mistral models through Mastra's model router. Authentication is handled automatically using the `MISTRAL_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Mistral documentation](https://docs.mistral.ai/getting-started/models/).
|
|
6
6
|
|
|
@@ -52,7 +52,8 @@ for await (const chunk of stream) {
|
|
|
52
52
|
| `mistral/mistral-medium-latest` | 128K | | | | | | $0.40 | $2 |
|
|
53
53
|
| `mistral/mistral-nemo` | 128K | | | | | | $0.15 | $0.15 |
|
|
54
54
|
| `mistral/mistral-small-2506` | 128K | | | | | | $0.10 | $0.30 |
|
|
55
|
-
| `mistral/mistral-small-
|
|
55
|
+
| `mistral/mistral-small-2603` | 256K | | | | | | $0.15 | $0.60 |
|
|
56
|
+
| `mistral/mistral-small-latest` | 256K | | | | | | $0.15 | $0.60 |
|
|
56
57
|
| `mistral/open-mistral-7b` | 8K | | | | | | $0.25 | $0.25 |
|
|
57
58
|
| `mistral/open-mixtral-8x22b` | 64K | | | | | | $2 | $6 |
|
|
58
59
|
| `mistral/open-mixtral-8x7b` | 32K | | | | | | $0.70 | $0.70 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# NanoGPT
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 519 NanoGPT models through Mastra's model router. Authentication is handled automatically using the `NANO_GPT_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [NanoGPT documentation](https://docs.nano-gpt.com).
|
|
6
6
|
|
|
@@ -551,6 +551,8 @@ for await (const chunk of stream) {
|
|
|
551
551
|
| `nano-gpt/zai-org/glm-4.7-flash` | 200K | | | | | | $0.07 | $0.40 |
|
|
552
552
|
| `nano-gpt/zai-org/glm-5` | 200K | | | | | | $0.30 | $3 |
|
|
553
553
|
| `nano-gpt/zai-org/glm-5:thinking` | 200K | | | | | | $0.30 | $3 |
|
|
554
|
+
| `nano-gpt/zai-org/glm-5.1` | 200K | | | | | | $0.30 | $3 |
|
|
555
|
+
| `nano-gpt/zai-org/glm-5.1:thinking` | 200K | | | | | | $0.30 | $3 |
|
|
554
556
|
|
|
555
557
|
## Advanced configuration
|
|
556
558
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenAI
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 47 OpenAI models through Mastra's model router. Authentication is handled automatically using the `OPENAI_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [OpenAI documentation](https://platform.openai.com/docs/models).
|
|
6
6
|
|
|
@@ -59,6 +59,7 @@ for await (const chunk of stream) {
|
|
|
59
59
|
| `openai/gpt-5.2-chat-latest` | 128K | | | | | | $2 | $14 |
|
|
60
60
|
| `openai/gpt-5.2-codex` | 400K | | | | | | $2 | $14 |
|
|
61
61
|
| `openai/gpt-5.2-pro` | 400K | | | | | | $21 | $168 |
|
|
62
|
+
| `openai/gpt-5.3-chat-latest` | 128K | | | | | | $2 | $14 |
|
|
62
63
|
| `openai/gpt-5.3-codex` | 400K | | | | | | $2 | $14 |
|
|
63
64
|
| `openai/gpt-5.3-codex-spark` | 128K | | | | | | $2 | $14 |
|
|
64
65
|
| `openai/gpt-5.4` | 1.1M | | | | | | $3 | $15 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Poe
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 124 Poe models through Mastra's model router. Authentication is handled automatically using the `POE_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Poe documentation](https://creator.poe.com/docs/external-applications/openai-compatible-api).
|
|
6
6
|
|
|
@@ -83,6 +83,7 @@ for await (const chunk of stream) {
|
|
|
83
83
|
| `poe/ideogramai/ideogram-v2a` | 150 | | | | | | — | — |
|
|
84
84
|
| `poe/ideogramai/ideogram-v2a-turbo` | 150 | | | | | | — | — |
|
|
85
85
|
| `poe/lumalabs/ray2` | 5K | | | | | | — | — |
|
|
86
|
+
| `poe/novita/deepseek-v3.2` | 128K | | | | | | $0.27 | $0.40 |
|
|
86
87
|
| `poe/novita/glm-4.6` | — | | | | | | — | — |
|
|
87
88
|
| `poe/novita/glm-4.6v` | 131K | | | | | | — | — |
|
|
88
89
|
| `poe/novita/glm-4.7` | 205K | | | | | | — | — |
|
|
@@ -155,6 +156,7 @@ for await (const chunk of stream) {
|
|
|
155
156
|
| `poe/xai/grok-4-fast-reasoning` | 2.0M | | | | | | $0.20 | $0.50 |
|
|
156
157
|
| `poe/xai/grok-4.1-fast-non-reasoning` | 2.0M | | | | | | — | — |
|
|
157
158
|
| `poe/xai/grok-4.1-fast-reasoning` | 2.0M | | | | | | — | — |
|
|
159
|
+
| `poe/xai/grok-4.20-multi-agent` | 128K | | | | | | $2 | $6 |
|
|
158
160
|
| `poe/xai/grok-code-fast-1` | 256K | | | | | | $0.20 | $2 |
|
|
159
161
|
|
|
160
162
|
## Advanced configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Z.AI Coding Plan
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 12 Z.AI Coding Plan models through Mastra's model router. Authentication is handled automatically using the `ZHIPU_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Z.AI Coding Plan documentation](https://docs.z.ai/devpack/overview).
|
|
6
6
|
|
|
@@ -45,6 +45,7 @@ for await (const chunk of stream) {
|
|
|
45
45
|
| `zai-coding-plan/glm-4.7-flashx` | 200K | | | | | | $0.07 | $0.40 |
|
|
46
46
|
| `zai-coding-plan/glm-5` | 205K | | | | | | — | — |
|
|
47
47
|
| `zai-coding-plan/glm-5-turbo` | 200K | | | | | | — | — |
|
|
48
|
+
| `zai-coding-plan/glm-5.1` | 200K | | | | | | — | — |
|
|
48
49
|
|
|
49
50
|
## Advanced configuration
|
|
50
51
|
|
|
@@ -74,7 +75,7 @@ const agent = new Agent({
|
|
|
74
75
|
model: ({ requestContext }) => {
|
|
75
76
|
const useAdvanced = requestContext.task === "complex";
|
|
76
77
|
return useAdvanced
|
|
77
|
-
? "zai-coding-plan/glm-5
|
|
78
|
+
? "zai-coding-plan/glm-5.1"
|
|
78
79
|
: "zai-coding-plan/glm-4.5";
|
|
79
80
|
}
|
|
80
81
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Zhipu AI Coding Plan
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 13 Zhipu AI Coding Plan models through Mastra's model router. Authentication is handled automatically using the `ZHIPU_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Zhipu AI Coding Plan documentation](https://docs.bigmodel.cn/cn/coding-plan/overview).
|
|
6
6
|
|
|
@@ -46,6 +46,7 @@ for await (const chunk of stream) {
|
|
|
46
46
|
| `zhipuai-coding-plan/glm-4.7-flashx` | 200K | | | | | | $0.07 | $0.40 |
|
|
47
47
|
| `zhipuai-coding-plan/glm-5` | 205K | | | | | | — | — |
|
|
48
48
|
| `zhipuai-coding-plan/glm-5-turbo` | 200K | | | | | | — | — |
|
|
49
|
+
| `zhipuai-coding-plan/glm-5.1` | 200K | | | | | | — | — |
|
|
49
50
|
|
|
50
51
|
## Advanced configuration
|
|
51
52
|
|
|
@@ -75,7 +76,7 @@ const agent = new Agent({
|
|
|
75
76
|
model: ({ requestContext }) => {
|
|
76
77
|
const useAdvanced = requestContext.task === "complex";
|
|
77
78
|
return useAdvanced
|
|
78
|
-
? "zhipuai-coding-plan/glm-5
|
|
79
|
+
? "zhipuai-coding-plan/glm-5.1"
|
|
79
80
|
: "zhipuai-coding-plan/glm-4.5";
|
|
80
81
|
}
|
|
81
82
|
});
|
|
@@ -59,4 +59,6 @@ export async function POST(req: Request) {
|
|
|
59
59
|
|
|
60
60
|
**sendSources** (`boolean`): Whether to include source citations in the stream. (Default: `false`)
|
|
61
61
|
|
|
62
|
+
**onError** (`(error: unknown) => string`): Called when the stream encounters an error. Return the string that will be sent to the client as the error message. Use this to sanitize errors before they reach the client — for example, to prevent internal infrastructure details from leaking to end users.
|
|
63
|
+
|
|
62
64
|
**messageMetadata** (`(options: { part: UIMessageStreamPart }) => Record<string, unknown> | undefined`): A function that receives the current stream part and returns metadata to attach to start and finish chunks. See the \[AI SDK message metadata docs]\(https\://ai-sdk.dev/docs/ai-sdk-ui/message-metadata) for details.
|
|
@@ -308,7 +308,7 @@ response.processDataStream({
|
|
|
308
308
|
|
|
309
309
|
## Stored agents
|
|
310
310
|
|
|
311
|
-
Stored agents are agent configurations stored in a database that can be created, updated, and deleted at runtime. They reference primitives (tools, workflows, other agents,
|
|
311
|
+
Stored agents are agent configurations stored in a database that can be created, updated, and deleted at runtime. They reference primitives (tools, workflows, other agents, scorers) by key, which are resolved from the Mastra registry when the agent is instantiated. Memory is configured inline as a `SerializedMemoryConfig` object with options such as `lastMessages` and `semanticRecall`.
|
|
312
312
|
|
|
313
313
|
### `listStoredAgents()`
|
|
314
314
|
|
|
@@ -361,10 +361,15 @@ const agent = await mastraClient.createStoredAgent({
|
|
|
361
361
|
provider: 'openai',
|
|
362
362
|
name: 'gpt-5.4',
|
|
363
363
|
},
|
|
364
|
-
tools:
|
|
365
|
-
workflows:
|
|
366
|
-
agents:
|
|
367
|
-
memory:
|
|
364
|
+
tools: { calculator: {}, weather: {} },
|
|
365
|
+
workflows: { 'data-processing': {} },
|
|
366
|
+
agents: { 'subagent-1': {} },
|
|
367
|
+
memory: {
|
|
368
|
+
options: {
|
|
369
|
+
lastMessages: 20,
|
|
370
|
+
semanticRecall: false,
|
|
371
|
+
},
|
|
372
|
+
},
|
|
368
373
|
scorers: {
|
|
369
374
|
'quality-scorer': {
|
|
370
375
|
sampling: { type: 'ratio', rate: 0.1 },
|
|
@@ -415,7 +420,7 @@ const updated = await storedAgent.update({
|
|
|
415
420
|
```typescript
|
|
416
421
|
// Update just the tools
|
|
417
422
|
await storedAgent.update({
|
|
418
|
-
tools:
|
|
423
|
+
tools: { 'new-tool-1': {}, 'new-tool-2': {} },
|
|
419
424
|
})
|
|
420
425
|
|
|
421
426
|
// Update metadata
|
|
@@ -32,7 +32,7 @@ export const mastraClient = new MastraClient({
|
|
|
32
32
|
|
|
33
33
|
**getAgent(agentId)** (`Agent`): Retrieves a specific agent instance by ID.
|
|
34
34
|
|
|
35
|
-
**
|
|
35
|
+
**listMemoryThreads(params)** (`Promise<StorageThreadType[]>`): Retrieves memory threads for the specified resource and agent. Requires a \`resourceId\` and an \`agentId\`.
|
|
36
36
|
|
|
37
37
|
**createMemoryThread(params)** (`Promise<MemoryThread>`): Creates a new memory thread with the given parameters.
|
|
38
38
|
|
|
@@ -7,7 +7,7 @@ The Memory API provides methods to manage conversation threads and message histo
|
|
|
7
7
|
Retrieve all memory threads for a specific resource:
|
|
8
8
|
|
|
9
9
|
```typescript
|
|
10
|
-
const threads = await mastraClient.
|
|
10
|
+
const threads = await mastraClient.listMemoryThreads({
|
|
11
11
|
resourceId: 'resource-1',
|
|
12
12
|
agentId: 'agent-1', // Optional - can be omitted if storage is configured
|
|
13
13
|
})
|
|
@@ -566,6 +566,30 @@ export const mastra = new Mastra({
|
|
|
566
566
|
})
|
|
567
567
|
```
|
|
568
568
|
|
|
569
|
+
### server.mcpOptions
|
|
570
|
+
|
|
571
|
+
**Type:** `object`\
|
|
572
|
+
**Default:** `undefined`
|
|
573
|
+
|
|
574
|
+
MCP transport options applied to all MCP HTTP and SSE routes. Use this to enable stateless mode for serverless environments (Cloudflare Workers, Vercel Edge, AWS Lambda, etc.) where persistent connections and in-memory session state are not available.
|
|
575
|
+
|
|
576
|
+
| Property | Type | Default | Description |
|
|
577
|
+
| -------------------- | -------------- | ----------- | ---------------------------------------------------- |
|
|
578
|
+
| `serverless` | `boolean` | `false` | Run MCP in stateless mode without session management |
|
|
579
|
+
| `sessionIdGenerator` | `() => string` | `undefined` | Custom session ID generator function |
|
|
580
|
+
|
|
581
|
+
```typescript
|
|
582
|
+
import { Mastra } from '@mastra/core'
|
|
583
|
+
|
|
584
|
+
export const mastra = new Mastra({
|
|
585
|
+
server: {
|
|
586
|
+
mcpOptions: {
|
|
587
|
+
serverless: true,
|
|
588
|
+
},
|
|
589
|
+
},
|
|
590
|
+
})
|
|
591
|
+
```
|
|
592
|
+
|
|
569
593
|
### server.build
|
|
570
594
|
|
|
571
595
|
Build-time configuration for server features. These options control development tools like Swagger UI and request logging, which are enabled during local development but disabled in production by default.
|
|
@@ -87,6 +87,8 @@ Fetches provider configurations from the gateway.
|
|
|
87
87
|
|
|
88
88
|
Builds the API URL for a specific model/provider combination.
|
|
89
89
|
|
|
90
|
+
If your provider URL contains placeholders such as `${ACCOUNT_ID}`, resolve them inside `buildUrl()` from `envVars` or `process.env` before returning the final URL.
|
|
91
|
+
|
|
90
92
|
**Parameters:**
|
|
91
93
|
|
|
92
94
|
**modelId** (`string`): Full model ID (e.g., "custom/my-provider/model-1")
|
|
@@ -87,4 +87,34 @@ Use `vars` in the `CloudflareDeployer` constructor only for non-sensitive config
|
|
|
87
87
|
|
|
88
88
|
## Build output
|
|
89
89
|
|
|
90
|
-
After running `mastra build`, the deployer generates a `wrangler.jsonc` file conforming to Cloudflare's [wrangler configuration](https://developers.cloudflare.com/workers/wrangler/configuration/). It points to files inside `.mastra/output` so you need to run `mastra build` before deploying with Wrangler.
|
|
90
|
+
After running `mastra build`, the deployer generates a `wrangler.jsonc` file conforming to Cloudflare's [wrangler configuration](https://developers.cloudflare.com/workers/wrangler/configuration/). It points to files inside `.mastra/output` so you need to run `mastra build` before deploying with Wrangler.
|
|
91
|
+
|
|
92
|
+
## Cloudflare bindings
|
|
93
|
+
|
|
94
|
+
When you use the Cloudflare deployer, you can import runtime bindings from `cloudflare:workers` in your Mastra config file. Mastra automatically preserves protocol-based runtime imports like `cloudflare:workers` during `mastra build` without trying to install them as npm dependencies.
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { env } from 'cloudflare:workers'
|
|
98
|
+
import { Mastra } from '@mastra/core'
|
|
99
|
+
import { registerApiRoute } from '@mastra/core/server'
|
|
100
|
+
import { CloudflareDeployer } from '@mastra/deployer-cloudflare'
|
|
101
|
+
|
|
102
|
+
export const mastra = new Mastra({
|
|
103
|
+
deployer: new CloudflareDeployer({
|
|
104
|
+
name: 'my-worker',
|
|
105
|
+
kv_namespaces: [{ binding: 'CACHE', id: 'your-kv-namespace-id' }],
|
|
106
|
+
}),
|
|
107
|
+
server: {
|
|
108
|
+
apiRoutes: [
|
|
109
|
+
registerApiRoute('/bindings', {
|
|
110
|
+
method: 'GET',
|
|
111
|
+
requiresAuth: false,
|
|
112
|
+
handler: async c => {
|
|
113
|
+
await env.CACHE.put('status', 'ok')
|
|
114
|
+
return c.json({ status: await env.CACHE.get('status') })
|
|
115
|
+
},
|
|
116
|
+
}),
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
})
|
|
120
|
+
```
|
|
@@ -367,10 +367,11 @@ The `expected` parameter accepts either a `Trajectory` (actual trajectory) or `{
|
|
|
367
367
|
import { compareTrajectories } from '@mastra/evals/scorers/utils'
|
|
368
368
|
|
|
369
369
|
// Using ExpectedStep[] (recommended for expectations)
|
|
370
|
+
// Data fields (e.g. toolArgs) are auto-compared when present on expected steps
|
|
370
371
|
const result = compareTrajectories(
|
|
371
372
|
actualTrajectory,
|
|
372
373
|
{ steps: [{ name: 'search' }, { name: 'summarize', stepType: 'tool_call' }] },
|
|
373
|
-
{
|
|
374
|
+
{ allowRepeatedSteps: true },
|
|
374
375
|
)
|
|
375
376
|
// result.score — 0.0 to 1.0
|
|
376
377
|
// result.missingSteps — step names not found
|
|
@@ -412,7 +413,9 @@ const result = checkTrajectoryEfficiency(trajectory, {
|
|
|
412
413
|
})
|
|
413
414
|
// result.score — 1.0 if within all budgets, lower with penalties
|
|
414
415
|
// result.redundantCalls — duplicate tool+args combos
|
|
415
|
-
// result.
|
|
416
|
+
// result.overStepBudget — true if maxSteps exceeded
|
|
417
|
+
// result.overTokenBudget — true if maxTotalTokens exceeded
|
|
418
|
+
// result.overDurationBudget — true if maxTotalDurationMs exceeded
|
|
416
419
|
```
|
|
417
420
|
|
|
418
421
|
**Returns:** `TrajectoryEfficiencyResult`
|
|
@@ -428,8 +431,9 @@ const result = checkTrajectoryBlacklist(trajectory, {
|
|
|
428
431
|
blacklistedTools: ['deleteAll', 'admin-override'],
|
|
429
432
|
blacklistedSequences: [['escalate', 'admin-override']],
|
|
430
433
|
})
|
|
431
|
-
// result.
|
|
432
|
-
// result.
|
|
434
|
+
// result.score — 1.0 if no violations, 0.0 if any found
|
|
435
|
+
// result.violatedTools — blacklisted tools that were called
|
|
436
|
+
// result.violatedSequences — blacklisted sequences that were detected
|
|
433
437
|
```
|
|
434
438
|
|
|
435
439
|
**Returns:** `TrajectoryBlacklistResult`
|
|
@@ -442,7 +446,7 @@ Detects tool failure patterns including retries, fallbacks, and argument correct
|
|
|
442
446
|
import { analyzeToolFailures } from '@mastra/evals/scorers/utils'
|
|
443
447
|
|
|
444
448
|
const result = analyzeToolFailures(trajectory, {
|
|
445
|
-
maxRetriesPerTool:
|
|
449
|
+
maxRetriesPerTool: 2,
|
|
446
450
|
})
|
|
447
451
|
// result.score — 1.0 if no failure patterns, lower if patterns detected
|
|
448
452
|
// result.patterns — detected patterns (retry, fallback, arg_correction)
|
|
@@ -103,13 +103,15 @@ All step types share the base properties `name`, `durationMs`, `metadata`, and `
|
|
|
103
103
|
|
|
104
104
|
## Expected steps
|
|
105
105
|
|
|
106
|
-
When defining expected trajectories, use `ExpectedStep` instead of the full `TrajectoryStep` discriminated union. `ExpectedStep` is a
|
|
106
|
+
When defining expected trajectories, use `ExpectedStep` instead of the full `TrajectoryStep` discriminated union. `ExpectedStep` is a discriminated union that mirrors `TrajectoryStep` — when you specify a `stepType`, you get autocomplete for that variant's fields (e.g., `toolArgs` for `tool_call`, `modelId` for `model_generation`). All variant-specific fields are optional, so you only assert against what you care about.
|
|
107
|
+
|
|
108
|
+
Omit `stepType` entirely to match any step by name only.
|
|
107
109
|
|
|
108
110
|
**name** (`string`): Step name to match (tool name, agent ID, workflow step name, etc.).
|
|
109
111
|
|
|
110
|
-
**stepType** (`TrajectoryStepType`): Step type
|
|
112
|
+
**stepType** (`TrajectoryStepType`): Step type discriminant. When set, enables autocomplete for that variant's fields. If omitted, matches any step type with the given name.
|
|
111
113
|
|
|
112
|
-
**
|
|
114
|
+
**(variant fields)** (`varies`): Type-specific fields from the corresponding TrajectoryStep variant. For example, \`toolArgs\` and \`toolResult\` for \`tool\_call\`, \`modelId\` for \`model\_generation\`, \`output\` for \`workflow\_step\`. All optional — only specified fields are compared.
|
|
113
115
|
|
|
114
116
|
**children** (`TrajectoryExpectation`): Nested expectation config for this step's children. Overrides the parent config for evaluating children of this step.
|
|
115
117
|
|
|
@@ -120,11 +122,14 @@ const steps: ExpectedStep[] = [
|
|
|
120
122
|
// Match by name only (any step type)
|
|
121
123
|
{ name: 'search' },
|
|
122
124
|
|
|
123
|
-
// Match by name and step type
|
|
125
|
+
// Match by name and step type (autocomplete for tool_call fields)
|
|
124
126
|
{ name: 'search', stepType: 'tool_call' },
|
|
125
127
|
|
|
126
|
-
// Match with
|
|
127
|
-
{ name: 'search', stepType: 'tool_call',
|
|
128
|
+
// Match with specific toolArgs (auto-compared when present)
|
|
129
|
+
{ name: 'search', stepType: 'tool_call', toolArgs: { query: 'weather' } },
|
|
130
|
+
|
|
131
|
+
// Match a model generation step by model ID
|
|
132
|
+
{ name: 'gpt-4o', stepType: 'model_generation', modelId: 'gpt-4o' },
|
|
128
133
|
]
|
|
129
134
|
```
|
|
130
135
|
|
|
@@ -182,7 +187,7 @@ The `createTrajectoryAccuracyScorerCode()` function from `@mastra/evals/scorers/
|
|
|
182
187
|
|
|
183
188
|
### Parameters
|
|
184
189
|
|
|
185
|
-
**expectedTrajectory** (`
|
|
190
|
+
**expectedTrajectory** (`Trajectory | ExpectedStep[]`): Static expected trajectory to compare against. Accepts a full Trajectory or an array of ExpectedStep matchers. When omitted, the scorer reads expectedTrajectory from each dataset item at runtime.
|
|
186
191
|
|
|
187
192
|
**comparisonOptions** (`TrajectoryComparisonOptions`): Controls how the comparison is performed.
|
|
188
193
|
|
|
@@ -368,8 +373,8 @@ const scorer = createTrajectoryAccuracyScorerCode({
|
|
|
368
373
|
},
|
|
369
374
|
],
|
|
370
375
|
},
|
|
371
|
-
comparisonOptions: { compareStepData: true },
|
|
372
376
|
})
|
|
377
|
+
// Data fields like toolArgs are auto-compared when present on expected steps
|
|
373
378
|
```
|
|
374
379
|
|
|
375
380
|
## LLM-based trajectory accuracy scorer
|
|
@@ -380,7 +385,7 @@ The `createTrajectoryAccuracyScorerLLM()` function from `@mastra/evals/scorers/p
|
|
|
380
385
|
|
|
381
386
|
**model** (`MastraModelConfig`): The LLM model to use for evaluating trajectory quality.
|
|
382
387
|
|
|
383
|
-
**expectedTrajectory** (`
|
|
388
|
+
**expectedTrajectory** (`Trajectory | ExpectedStep[]`): Optional static expected trajectory to compare against. Accepts a full Trajectory or an array of ExpectedStep matchers. When omitted, the LLM evaluates the trajectory based on the task requirements alone. Can also come from dataset items at runtime.
|
|
384
389
|
|
|
385
390
|
### Features
|
|
386
391
|
|
|
@@ -461,7 +466,7 @@ The `createTrajectoryScorerCode()` function from `@mastra/evals/scorers/prebuilt
|
|
|
461
466
|
|
|
462
467
|
**defaults** (`TrajectoryExpectation`): Default expectations applied to all dataset items. Per-item expectedTrajectory values override these defaults.
|
|
463
468
|
|
|
464
|
-
**weights** (`
|
|
469
|
+
**weights** (`TrajectoryScoreWeights`): Custom weights for combining dimension scores. Weights are normalized to sum to 1.0.
|
|
465
470
|
|
|
466
471
|
### Scoring behavior
|
|
467
472
|
|
|
@@ -472,7 +477,7 @@ The unified scorer evaluates four dimensions:
|
|
|
472
477
|
3. **Blacklist** — Checks for forbidden tools or sequences. Any violation immediately results in a score of **0.0** regardless of other dimensions.
|
|
473
478
|
4. **Tool failures** — Detects retry patterns, fallback patterns, and argument correction patterns.
|
|
474
479
|
|
|
475
|
-
The final score is a weighted
|
|
480
|
+
The final score is a weighted combination of active dimensions, normalized by which dimensions are active. Default weights are accuracy 0.4, efficiency 0.3, tool failures 0.2, blacklist 0.1, but you can customize them via the `weights` option. Blacklist violations override everything to 0. When nested evaluations are present, the score is 70% top-level and 30% nested average.
|
|
476
481
|
|
|
477
482
|
### Unified scorer results
|
|
478
483
|
|
|
@@ -481,11 +486,13 @@ The final score is a weighted average of accuracy, efficiency, and tool failures
|
|
|
481
486
|
runId: string,
|
|
482
487
|
preprocessStepResult: {
|
|
483
488
|
accuracy?: TrajectoryComparisonResult,
|
|
484
|
-
efficiency
|
|
485
|
-
blacklist
|
|
486
|
-
toolFailures
|
|
489
|
+
efficiency?: TrajectoryEfficiencyResult,
|
|
490
|
+
blacklist?: TrajectoryBlacklistResult,
|
|
491
|
+
toolFailures?: ToolFailureAnalysisResult,
|
|
492
|
+
nested?: NestedEvaluationResult[],
|
|
487
493
|
},
|
|
488
|
-
score: number
|
|
494
|
+
score: number,
|
|
495
|
+
reason: string
|
|
489
496
|
}
|
|
490
497
|
```
|
|
491
498
|
|
|
@@ -542,6 +549,13 @@ const scorer = createTrajectoryScorerCode({
|
|
|
542
549
|
noRedundantCalls: true,
|
|
543
550
|
maxRetriesPerTool: 2,
|
|
544
551
|
},
|
|
552
|
+
// Customize how dimensions contribute to the final score
|
|
553
|
+
weights: {
|
|
554
|
+
accuracy: 0.5, // prioritize step accuracy
|
|
555
|
+
efficiency: 0.3,
|
|
556
|
+
toolFailures: 0.1,
|
|
557
|
+
blacklist: 0.1,
|
|
558
|
+
},
|
|
545
559
|
})
|
|
546
560
|
```
|
|
547
561
|
|
package/.docs/reference/index.md
CHANGED
|
@@ -66,7 +66,6 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
66
66
|
- [.getScorerById()](https://mastra.ai/reference/core/getScorerById)
|
|
67
67
|
- [.getServer()](https://mastra.ai/reference/core/getServer)
|
|
68
68
|
- [.getStorage()](https://mastra.ai/reference/core/getStorage)
|
|
69
|
-
- [.getStoredAgentById()](https://mastra.ai/reference/core/getStoredAgentById)
|
|
70
69
|
- [.getTelemetry()](https://mastra.ai/reference/core/getTelemetry)
|
|
71
70
|
- [.getVector()](https://mastra.ai/reference/core/getVector)
|
|
72
71
|
- [.getWorkflow()](https://mastra.ai/reference/core/getWorkflow)
|
|
@@ -77,7 +76,6 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
77
76
|
- [.listMCPServers()](https://mastra.ai/reference/core/listMCPServers)
|
|
78
77
|
- [.listMemory()](https://mastra.ai/reference/core/listMemory)
|
|
79
78
|
- [.listScorers()](https://mastra.ai/reference/core/listScorers)
|
|
80
|
-
- [.listStoredAgents()](https://mastra.ai/reference/core/listStoredAgents)
|
|
81
79
|
- [.listVectors()](https://mastra.ai/reference/core/listVectors)
|
|
82
80
|
- [.listWorkflows()](https://mastra.ai/reference/core/listWorkflows)
|
|
83
81
|
- [.setLogger()](https://mastra.ai/reference/core/setLogger)
|
|
@@ -30,6 +30,64 @@ export const mastra = new Mastra({
|
|
|
30
30
|
|
|
31
31
|
**formatters** (`pino.LoggerOptions['formatters']`): Custom Pino formatters for log serialization.
|
|
32
32
|
|
|
33
|
+
**redact** (`pino.LoggerOptions['redact']`): Paths or options for redacting sensitive fields from log output (Pino \`redact\`).
|
|
34
|
+
|
|
35
|
+
**prettyPrint** (`boolean`): When false, disables \`pino-pretty\` and writes raw JSON lines (useful for log aggregators). (Default: `true`)
|
|
36
|
+
|
|
37
|
+
**mixin** (`pino.MixinFn`): Pino mixin function merged into every log object (for example request-scoped \`traceId\` or other shared metadata).
|
|
38
|
+
|
|
39
|
+
**customLevels** (`Record<string, number>`): Custom log levels and numeric values, forwarded to Pino. Standard severity is still logged via \`debug\`, \`info\`, \`warn\`, and \`error\`; extra levels follow Pino’s custom-level behavior.
|
|
40
|
+
|
|
41
|
+
## Log enrichment with `mixin`
|
|
42
|
+
|
|
43
|
+
Use `mixin` when you want the same structured fields on every line (for correlation with the rest of your services):
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { Mastra } from '@mastra/core'
|
|
47
|
+
import { PinoLogger } from '@mastra/loggers'
|
|
48
|
+
|
|
49
|
+
function getTraceContext() {
|
|
50
|
+
return { traceId: 'abc-123' }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const mastra = new Mastra({
|
|
54
|
+
logger: new PinoLogger({
|
|
55
|
+
name: 'Mastra',
|
|
56
|
+
level: 'info',
|
|
57
|
+
mixin() {
|
|
58
|
+
return getTraceContext()
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Custom levels
|
|
65
|
+
|
|
66
|
+
`customLevels` is passed through to Pino. `PinoLogger` only exposes `debug`, `info`, `warn`, and `error`; for any extra level name (for example `audit`), subclass and forward to the underlying Pino instance:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { Mastra } from '@mastra/core'
|
|
70
|
+
import { PinoLogger } from '@mastra/loggers'
|
|
71
|
+
|
|
72
|
+
type AuditLevel = 'audit'
|
|
73
|
+
|
|
74
|
+
class MastraPinoWithAudit extends PinoLogger<AuditLevel> {
|
|
75
|
+
audit(message: string, meta: Record<string, unknown> = {}) {
|
|
76
|
+
this.logger.audit(meta, message)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const logger = new MastraPinoWithAudit({
|
|
81
|
+
name: 'Mastra',
|
|
82
|
+
level: 'info',
|
|
83
|
+
customLevels: { audit: 35 },
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
export const mastra = new Mastra({ logger })
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Numeric values follow Pino’s ordering (built-in levels use 10–60). A level of `35` sits between `info` (30) and `warn` (40), so with `level: 'info'` both `info` and `audit` lines are emitted.
|
|
90
|
+
|
|
33
91
|
## File transport (structured logs)
|
|
34
92
|
|
|
35
93
|
Writes structured logs to a file using the `FileTransport`. The logger accepts a plain message as the first argument and structured metadata as the second argument. These are internally converted to a `BaseLogMessage` and persisted to the configured file path.
|
|
@@ -38,7 +38,7 @@ OM performs thresholding with fast local token estimation. Text uses `tokenx`, a
|
|
|
38
38
|
|
|
39
39
|
**shareTokenBudget** (`boolean`): Share the token budget between messages and observations. When enabled, the total budget is \`observation.messageTokens + reflection.observationTokens\`. Messages can use more space when observations are small, and vice versa. This maximizes context usage through flexible allocation. \`shareTokenBudget\` is not yet compatible with async buffering. You must set \`observation: { bufferTokens: false }\` when using this option (this is a temporary limitation). (Default: `false`)
|
|
40
40
|
|
|
41
|
-
**retrieval** (`boolean`): \*\*Experimental.\*\* Enable retrieval-mode observation groups as durable pointers to raw message history.
|
|
41
|
+
**retrieval** (`boolean | { vector?: boolean; scope?: 'thread' | 'resource' }`): \*\*Experimental.\*\* Enable retrieval-mode observation groups as durable pointers to raw message history. \`true\` enables cross-thread browsing by default. \`{ vector: true }\` also enables semantic search using Memory's vector store and embedder. \`{ scope: 'thread' }\` restricts the recall tool to the current thread only. Default scope is \`'resource'\`. (Default: `false`)
|
|
42
42
|
|
|
43
43
|
**observation** (`ObservationalMemoryObservationConfig`): Configuration for the observation step. Controls when the Observer agent runs and how it behaves.
|
|
44
44
|
|
|
@@ -578,21 +578,31 @@ The standalone `ObservationalMemory` class accepts all the same options as the `
|
|
|
578
578
|
|
|
579
579
|
## Recall tool
|
|
580
580
|
|
|
581
|
-
When `retrieval
|
|
581
|
+
When `retrieval` is set (any truthy value), a `recall` tool is registered so the agent can page through raw messages behind observation group ranges. By default (scope `'resource'`), the tool supports listing threads (`mode: "threads"`), browsing other threads (`threadId`), and cross-thread search. With `retrieval: { vector: true }`, semantic search is available (`mode: "search"`). Set `scope: 'thread'` to restrict the tool to the current thread only. The tool is automatically added to the agent's tool list — no manual registration is needed.
|
|
582
582
|
|
|
583
583
|
### Parameters
|
|
584
584
|
|
|
585
|
-
**
|
|
585
|
+
**mode** (`'messages' | 'threads' | 'search'`): What to retrieve. \`"messages"\` (default) pages through message history. \`"threads"\` lists all threads for the current user. \`"search"\` finds messages by semantic similarity across all threads (requires vector store and embedder). (Default: `'messages'`)
|
|
586
586
|
|
|
587
|
-
**
|
|
587
|
+
**query** (`string`): Search query for \`mode: "search"\`. Finds messages semantically similar to this text across all threads for the current user.
|
|
588
588
|
|
|
589
|
-
**
|
|
589
|
+
**cursor** (`string`): A message ID to anchor the recall query. Required for \`mode: "messages"\` when browsing the current thread. Extract the start or end ID from an observation group range (e.g. from \`\_range: \\\`startId:endId\\\`\_\`, use either \`startId\` or \`endId\`). If a range string is passed directly, the tool returns a hint explaining how to extract the correct ID. Can be omitted when \`threadId\` is provided to start reading from the beginning of that thread.
|
|
590
|
+
|
|
591
|
+
**threadId** (`string`): Browse a different thread by its ID. Use \`mode: "threads"\` first to discover thread IDs. When provided without a \`cursor\`, reading starts from the beginning of the thread.
|
|
592
|
+
|
|
593
|
+
**page** (`number`): Pagination offset. For messages: positive values page forward from cursor, negative values page backward. For threads: page number (0-indexed). \`0\` is treated as \`1\` for messages. (Default: `1`)
|
|
594
|
+
|
|
595
|
+
**limit** (`number`): Maximum number of items to return per page. (Default: `20`)
|
|
590
596
|
|
|
591
597
|
**detail** (`'low' | 'high'`): Controls how much content is shown per message part. \`'low'\` shows truncated text and tool names with positional indices (\`\[p0]\`, \`\[p1]\`). \`'high'\` shows full content including tool arguments and results, clamped to one part per call with continuation hints. (Default: `'low'`)
|
|
592
598
|
|
|
593
599
|
**partIndex** (`number`): Fetch a single message part at full detail by its positional index. Use this when a low-detail recall shows an interesting part at \`\[p1]\` — call again with \`partIndex: 1\` to see the full content without loading every part.
|
|
594
600
|
|
|
595
|
-
|
|
601
|
+
**before** (`string`): For \`mode: "threads"\` only. Filter to threads created before this date. Accepts ISO 8601 format (e.g. \`"2026-03-15"\`, \`"2026-03-10T00:00:00Z"\`).
|
|
602
|
+
|
|
603
|
+
**after** (`string`): For \`mode: "threads"\` only. Filter to threads created after this date. Accepts ISO 8601 format (e.g. \`"2026-03-01"\`, \`"2026-03-10T00:00:00Z"\`).
|
|
604
|
+
|
|
605
|
+
### Returns (messages mode)
|
|
596
606
|
|
|
597
607
|
**messages** (`string`): Formatted message content. Format depends on the \`detail\` level.
|
|
598
608
|
|
|
@@ -612,6 +622,22 @@ When `retrieval: true` is set with `scope: 'thread'`, OM registers a `recall` to
|
|
|
612
622
|
|
|
613
623
|
**tokenOffset** (`number`): Approximate number of tokens that were trimmed when \`truncated\` is true.
|
|
614
624
|
|
|
625
|
+
### Returns (threads mode)
|
|
626
|
+
|
|
627
|
+
**threads** (`string`): Formatted thread listing. Each thread shows its title, ID, and dates. The current thread is marked with \`← current\`.
|
|
628
|
+
|
|
629
|
+
**count** (`number`): Number of threads returned.
|
|
630
|
+
|
|
631
|
+
**page** (`number`): The page number returned.
|
|
632
|
+
|
|
633
|
+
**hasMore** (`boolean`): Whether more threads exist on the next page.
|
|
634
|
+
|
|
635
|
+
### Returns (search mode)
|
|
636
|
+
|
|
637
|
+
**results** (`string`): Formatted search results grouped by thread. Each result shows the thread title, thread ID, relevance score, message preview, and a cursor ID for browsing into that thread.
|
|
638
|
+
|
|
639
|
+
**count** (`number`): Number of matching messages found.
|
|
640
|
+
|
|
615
641
|
### ModelByInputTokens
|
|
616
642
|
|
|
617
643
|
`ModelByInputTokens` selects a model based on the input token count. It chooses the model for the smallest threshold that covers the actual input size.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.1.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`dc514a8`](https://github.com/mastra-ai/mastra/commit/dc514a83dba5f719172dddfd2c7b858e4943d067), [`e333b77`](https://github.com/mastra-ai/mastra/commit/e333b77e2d76ba57ccec1818e08cebc1993469ff), [`dc9fc19`](https://github.com/mastra-ai/mastra/commit/dc9fc19da4437f6b508cc355f346a8856746a76b), [`60a224d`](https://github.com/mastra-ai/mastra/commit/60a224dd497240e83698cfa5bfd02e3d1d854844), [`fbf22a7`](https://github.com/mastra-ai/mastra/commit/fbf22a7ad86bcb50dcf30459f0d075e51ddeb468), [`f16d92c`](https://github.com/mastra-ai/mastra/commit/f16d92c677a119a135cebcf7e2b9f51ada7a9df4), [`949b7bf`](https://github.com/mastra-ai/mastra/commit/949b7bfd4e40f2b2cba7fef5eb3f108a02cfe938), [`404fea1`](https://github.com/mastra-ai/mastra/commit/404fea13042181f0b0c73a101392ac87c79ceae2), [`ebf5047`](https://github.com/mastra-ai/mastra/commit/ebf5047e825c38a1a356f10b214c1d4260dfcd8d), [`12c647c`](https://github.com/mastra-ai/mastra/commit/12c647cf3a26826eb72d40b42e3c8356ceae16ed), [`d084b66`](https://github.com/mastra-ai/mastra/commit/d084b6692396057e83c086b954c1857d20b58a14), [`79c699a`](https://github.com/mastra-ai/mastra/commit/79c699acf3cd8a77e11c55530431f48eb48456e9), [`62757b6`](https://github.com/mastra-ai/mastra/commit/62757b6db6e8bb86569d23ad0b514178f57053f8), [`675f15b`](https://github.com/mastra-ai/mastra/commit/675f15b7eaeea649158d228ea635be40480c584d), [`b174c63`](https://github.com/mastra-ai/mastra/commit/b174c63a093108d4e53b9bc89a078d9f66202b3f), [`819f03c`](https://github.com/mastra-ai/mastra/commit/819f03c25823373b32476413bd76be28a5d8705a), [`04160ee`](https://github.com/mastra-ai/mastra/commit/04160eedf3130003cf842ad08428c8ff69af4cc1), [`2c27503`](https://github.com/mastra-ai/mastra/commit/2c275032510d131d2cde47f99953abf0fe02c081), [`424a1df`](https://github.com/mastra-ai/mastra/commit/424a1df7bee59abb5c83717a54807fdd674a6224), [`3d70b0b`](https://github.com/mastra-ai/mastra/commit/3d70b0b3524d817173ad870768f259c06d61bd23), [`eef7cb2`](https://github.com/mastra-ai/mastra/commit/eef7cb2abe7ef15951e2fdf792a5095c6c643333), [`43595bf`](https://github.com/mastra-ai/mastra/commit/43595bf7b8df1a6edce7a23b445b5124d2a0b473), [`260fe12`](https://github.com/mastra-ai/mastra/commit/260fe1295fe7354e39d6def2775e0797a7a277f0), [`12c88a6`](https://github.com/mastra-ai/mastra/commit/12c88a6e32bf982c2fe0c6af62e65a3414519a75), [`43595bf`](https://github.com/mastra-ai/mastra/commit/43595bf7b8df1a6edce7a23b445b5124d2a0b473), [`78670e9`](https://github.com/mastra-ai/mastra/commit/78670e97e76d7422cf7025faf371b2aeafed860d), [`e8a5b0b`](https://github.com/mastra-ai/mastra/commit/e8a5b0b9bc94d12dee4150095512ca27a288d778), [`3b45a13`](https://github.com/mastra-ai/mastra/commit/3b45a138d09d040779c0aba1edbbfc1b57442d23), [`d400e7c`](https://github.com/mastra-ai/mastra/commit/d400e7c8b8d7afa6ba2c71769eace4048e3cef8e), [`f58d1a7`](https://github.com/mastra-ai/mastra/commit/f58d1a7a457588a996c3ecb53201a68f3d28c432), [`a49a929`](https://github.com/mastra-ai/mastra/commit/a49a92904968b4fc67e01effee8c7c8d0464ba85), [`8127d96`](https://github.com/mastra-ai/mastra/commit/8127d96280492e335d49b244501088dfdd59a8f1)]:
|
|
8
|
+
- @mastra/core@1.18.0
|
|
9
|
+
- @mastra/mcp@1.3.2
|
|
10
|
+
|
|
11
|
+
## 1.1.17-alpha.17
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`12c647c`](https://github.com/mastra-ai/mastra/commit/12c647cf3a26826eb72d40b42e3c8356ceae16ed), [`819f03c`](https://github.com/mastra-ai/mastra/commit/819f03c25823373b32476413bd76be28a5d8705a)]:
|
|
16
|
+
- @mastra/core@1.18.0-alpha.5
|
|
17
|
+
|
|
18
|
+
## 1.1.17-alpha.15
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [[`fbf22a7`](https://github.com/mastra-ai/mastra/commit/fbf22a7ad86bcb50dcf30459f0d075e51ddeb468), [`04160ee`](https://github.com/mastra-ai/mastra/commit/04160eedf3130003cf842ad08428c8ff69af4cc1), [`2c27503`](https://github.com/mastra-ai/mastra/commit/2c275032510d131d2cde47f99953abf0fe02c081), [`424a1df`](https://github.com/mastra-ai/mastra/commit/424a1df7bee59abb5c83717a54807fdd674a6224), [`43595bf`](https://github.com/mastra-ai/mastra/commit/43595bf7b8df1a6edce7a23b445b5124d2a0b473), [`12c88a6`](https://github.com/mastra-ai/mastra/commit/12c88a6e32bf982c2fe0c6af62e65a3414519a75), [`43595bf`](https://github.com/mastra-ai/mastra/commit/43595bf7b8df1a6edce7a23b445b5124d2a0b473), [`78670e9`](https://github.com/mastra-ai/mastra/commit/78670e97e76d7422cf7025faf371b2aeafed860d), [`d400e7c`](https://github.com/mastra-ai/mastra/commit/d400e7c8b8d7afa6ba2c71769eace4048e3cef8e), [`f58d1a7`](https://github.com/mastra-ai/mastra/commit/f58d1a7a457588a996c3ecb53201a68f3d28c432), [`a49a929`](https://github.com/mastra-ai/mastra/commit/a49a92904968b4fc67e01effee8c7c8d0464ba85)]:
|
|
23
|
+
- @mastra/core@1.18.0-alpha.4
|
|
24
|
+
- @mastra/mcp@1.3.2-alpha.0
|
|
25
|
+
|
|
26
|
+
## 1.1.17-alpha.12
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [[`e333b77`](https://github.com/mastra-ai/mastra/commit/e333b77e2d76ba57ccec1818e08cebc1993469ff), [`60a224d`](https://github.com/mastra-ai/mastra/commit/60a224dd497240e83698cfa5bfd02e3d1d854844), [`949b7bf`](https://github.com/mastra-ai/mastra/commit/949b7bfd4e40f2b2cba7fef5eb3f108a02cfe938), [`d084b66`](https://github.com/mastra-ai/mastra/commit/d084b6692396057e83c086b954c1857d20b58a14), [`79c699a`](https://github.com/mastra-ai/mastra/commit/79c699acf3cd8a77e11c55530431f48eb48456e9), [`62757b6`](https://github.com/mastra-ai/mastra/commit/62757b6db6e8bb86569d23ad0b514178f57053f8), [`3d70b0b`](https://github.com/mastra-ai/mastra/commit/3d70b0b3524d817173ad870768f259c06d61bd23), [`3b45a13`](https://github.com/mastra-ai/mastra/commit/3b45a138d09d040779c0aba1edbbfc1b57442d23), [`8127d96`](https://github.com/mastra-ai/mastra/commit/8127d96280492e335d49b244501088dfdd59a8f1)]:
|
|
31
|
+
- @mastra/core@1.18.0-alpha.3
|
|
32
|
+
|
|
33
|
+
## 1.1.17-alpha.10
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [[`f16d92c`](https://github.com/mastra-ai/mastra/commit/f16d92c677a119a135cebcf7e2b9f51ada7a9df4)]:
|
|
38
|
+
- @mastra/core@1.18.0-alpha.2
|
|
39
|
+
|
|
3
40
|
## 1.1.17-alpha.8
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.1.17
|
|
3
|
+
"version": "1.1.17",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"jsdom": "^26.1.0",
|
|
30
30
|
"local-pkg": "^1.1.2",
|
|
31
31
|
"zod": "^4.3.6",
|
|
32
|
-
"@mastra/core": "1.18.0
|
|
33
|
-
"@mastra/mcp": "^1.3.
|
|
32
|
+
"@mastra/core": "1.18.0",
|
|
33
|
+
"@mastra/mcp": "^1.3.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@hono/node-server": "^1.19.11",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"tsx": "^4.21.0",
|
|
47
47
|
"typescript": "^5.9.3",
|
|
48
48
|
"vitest": "4.0.18",
|
|
49
|
-
"@internal/
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
49
|
+
"@internal/types-builder": "0.0.50",
|
|
50
|
+
"@mastra/core": "1.18.0",
|
|
51
|
+
"@internal/lint": "0.0.75"
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://mastra.ai",
|
|
54
54
|
"repository": {
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
# Mastra.getStoredAgentById()
|
|
2
|
-
|
|
3
|
-
The `.getStoredAgentById()` method retrieves an agent configuration from storage by its ID and creates an executable `Agent` instance. Stored agents allow you to persist agent configurations in a database and dynamically load them at runtime.
|
|
4
|
-
|
|
5
|
-
## Usage example
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
// Get an Agent instance from storage
|
|
9
|
-
const agent = await mastra.getStoredAgentById('my-stored-agent')
|
|
10
|
-
|
|
11
|
-
if (agent) {
|
|
12
|
-
const response = await agent.generate('Hello')
|
|
13
|
-
console.log(response.text)
|
|
14
|
-
}
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
```typescript
|
|
18
|
-
// Get the raw storage data instead of an Agent instance
|
|
19
|
-
const storedConfig = await mastra.getStoredAgentById('my-stored-agent', { raw: true })
|
|
20
|
-
|
|
21
|
-
if (storedConfig) {
|
|
22
|
-
console.log(storedConfig.instructions)
|
|
23
|
-
console.log(storedConfig.createdAt)
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Parameters
|
|
28
|
-
|
|
29
|
-
**id** (`string`): The unique identifier of the stored agent to retrieve.
|
|
30
|
-
|
|
31
|
-
**options** (`{ raw?: boolean }`): Optional configuration object.
|
|
32
|
-
|
|
33
|
-
**options.raw** (`boolean`): When \`true\`, returns the raw \`StorageAgentType\` object from storage instead of creating an \`Agent\` instance. Useful for inspecting stored configuration or metadata.
|
|
34
|
-
|
|
35
|
-
## Returns
|
|
36
|
-
|
|
37
|
-
**result** (`Agent | StorageAgentType | null`): Returns an \`Agent\` instance by default, or \`StorageAgentType\` when \`raw: true\`. Returns \`null\` if no agent with the given ID exists.
|
|
38
|
-
|
|
39
|
-
## Primitive resolution
|
|
40
|
-
|
|
41
|
-
When creating an `Agent` instance from stored configuration, the method resolves references to registered primitives:
|
|
42
|
-
|
|
43
|
-
- **Tools**: Resolved from `tools` registered in Mastra config
|
|
44
|
-
- **Workflows**: Resolved from `workflows` registered in Mastra config
|
|
45
|
-
- **Subagents**: Resolved from `agents` registered in Mastra config
|
|
46
|
-
- **Memory**: Resolved from `memory` registered in Mastra config
|
|
47
|
-
- **Scorers**: Resolved from `scorers` registered in Mastra config, including sampling configuration
|
|
48
|
-
|
|
49
|
-
If a referenced primitive isn't found in the registry, a warning is logged but the agent is still created.
|
|
50
|
-
|
|
51
|
-
## `StorageAgentType`
|
|
52
|
-
|
|
53
|
-
When using `raw: true`, the returned object has the following structure:
|
|
54
|
-
|
|
55
|
-
**id** (`string`): Unique identifier for the agent.
|
|
56
|
-
|
|
57
|
-
**name** (`string`): Display name of the agent.
|
|
58
|
-
|
|
59
|
-
**description** (`string`): Optional description of the agent.
|
|
60
|
-
|
|
61
|
-
**instructions** (`string`): System instructions for the agent.
|
|
62
|
-
|
|
63
|
-
**model** (`Record<string, unknown>`): Model configuration with provider and name.
|
|
64
|
-
|
|
65
|
-
**tools** (`Record<string, unknown>`): Tool references to resolve from registry.
|
|
66
|
-
|
|
67
|
-
**workflows** (`Record<string, unknown>`): Workflow references to resolve from registry.
|
|
68
|
-
|
|
69
|
-
**agents** (`Record<string, unknown>`): Subagent references to resolve from registry.
|
|
70
|
-
|
|
71
|
-
**memory** (`Record<string, unknown>`): Memory reference to resolve from registry.
|
|
72
|
-
|
|
73
|
-
**scorers** (`Record<string, unknown>`): Scorer references with optional sampling config.
|
|
74
|
-
|
|
75
|
-
**defaultOptions** (`Record<string, unknown>`): Default options passed to agent execution.
|
|
76
|
-
|
|
77
|
-
**metadata** (`Record<string, unknown>`): Custom metadata stored with the agent.
|
|
78
|
-
|
|
79
|
-
**createdAt** (`Date`): Timestamp when the agent was created.
|
|
80
|
-
|
|
81
|
-
**updatedAt** (`Date`): Timestamp when the agent was last updated.
|
|
82
|
-
|
|
83
|
-
## Related
|
|
84
|
-
|
|
85
|
-
- [Mastra.listStoredAgents()](https://mastra.ai/reference/core/listStoredAgents)
|
|
86
|
-
- [Storage overview](https://mastra.ai/reference/storage/overview)
|
|
87
|
-
- [Agents overview](https://mastra.ai/docs/agents/overview)
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
# Mastra.listStoredAgents()
|
|
2
|
-
|
|
3
|
-
The `.listStoredAgents()` method retrieves a paginated list of agent configurations from storage. By default, it returns executable `Agent` instances, but can also return raw storage data.
|
|
4
|
-
|
|
5
|
-
## Usage example
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
// Get Agent instances from storage
|
|
9
|
-
const { agents, total, hasMore } = await mastra.listStoredAgents()
|
|
10
|
-
|
|
11
|
-
for (const agent of agents) {
|
|
12
|
-
console.log(agent.id, agent.name)
|
|
13
|
-
// Each agent is ready to use
|
|
14
|
-
// const response = await agent.generate("Hello");
|
|
15
|
-
}
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
```typescript
|
|
19
|
-
// Get paginated results with raw storage data
|
|
20
|
-
const result = await mastra.listStoredAgents({
|
|
21
|
-
page: 0,
|
|
22
|
-
perPage: 10,
|
|
23
|
-
raw: true,
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
console.log(`Showing ${result.agents.length} of ${result.total} agents`)
|
|
27
|
-
console.log(`Has more: ${result.hasMore}`)
|
|
28
|
-
|
|
29
|
-
for (const config of result.agents) {
|
|
30
|
-
console.log(config.id, config.name, config.createdAt)
|
|
31
|
-
}
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Parameters
|
|
35
|
-
|
|
36
|
-
**args** (`object`): Optional configuration object for pagination and output format.
|
|
37
|
-
|
|
38
|
-
**args.page** (`number`): Zero-indexed page number for pagination.
|
|
39
|
-
|
|
40
|
-
**args.perPage** (`number | false`): Number of items per page. Set to \`false\` to fetch all records without pagination.
|
|
41
|
-
|
|
42
|
-
**args.raw** (`boolean`): When \`true\`, returns raw \`StorageAgentType\` objects instead of \`Agent\` instances.
|
|
43
|
-
|
|
44
|
-
## Returns
|
|
45
|
-
|
|
46
|
-
**agents** (`Agent[] | StorageAgentType[]`): Array of \`Agent\` instances by default, or \`StorageAgentType\` objects when \`raw: true\`.
|
|
47
|
-
|
|
48
|
-
**total** (`number`): Total number of stored agents across all pages.
|
|
49
|
-
|
|
50
|
-
**page** (`number`): Current page number (zero-indexed).
|
|
51
|
-
|
|
52
|
-
**perPage** (`number | false`): Number of items per page, or \`false\` if fetching all.
|
|
53
|
-
|
|
54
|
-
**hasMore** (`boolean`): Whether there are more pages available.
|
|
55
|
-
|
|
56
|
-
## Primitive resolution
|
|
57
|
-
|
|
58
|
-
When creating `Agent` instances (default behavior), each stored agent's configuration is resolved against registered primitives:
|
|
59
|
-
|
|
60
|
-
- **Tools**: Resolved from `tools` registered in Mastra config
|
|
61
|
-
- **Workflows**: Resolved from `workflows` registered in Mastra config
|
|
62
|
-
- **Subagents**: Resolved from `agents` registered in Mastra config
|
|
63
|
-
- **Memory**: Resolved from `memory` registered in Mastra config
|
|
64
|
-
- **Scorers**: Resolved from `scorers` registered in Mastra config
|
|
65
|
-
|
|
66
|
-
If a referenced primitive isn't found, a warning is logged but the agent is still created.
|
|
67
|
-
|
|
68
|
-
## Example: Iterating through all stored agents
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
async function getAllStoredAgents(mastra: Mastra) {
|
|
72
|
-
const allAgents: Agent[] = []
|
|
73
|
-
let page = 0
|
|
74
|
-
let hasMore = true
|
|
75
|
-
|
|
76
|
-
while (hasMore) {
|
|
77
|
-
const result = await mastra.listStoredAgents({ page, perPage: 50 })
|
|
78
|
-
allAgents.push(...result.agents)
|
|
79
|
-
hasMore = result.hasMore
|
|
80
|
-
page++
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return allAgents
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Related
|
|
88
|
-
|
|
89
|
-
- [Mastra.getStoredAgentById()](https://mastra.ai/reference/core/getStoredAgentById)
|
|
90
|
-
- [Storage overview](https://mastra.ai/reference/storage/overview)
|
|
91
|
-
- [Agents overview](https://mastra.ai/docs/agents/overview)
|