@mastra/mcp-docs-server 0.13.7 → 0.13.8-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +30 -30
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +67 -67
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +44 -44
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +34 -34
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +33 -33
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +78 -78
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +56 -56
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +52 -52
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +52 -52
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +81 -81
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +33 -33
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +36 -36
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +47 -47
- package/.docs/organized/changelogs/%40mastra%2Fgithub.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Flance.md +30 -0
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +50 -50
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +51 -51
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +43 -43
- package/.docs/organized/changelogs/%40mastra%2Fmem0.md +33 -33
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +51 -51
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +48 -48
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +32 -0
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +58 -58
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +58 -58
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Frag.md +46 -46
- package/.docs/organized/changelogs/%40mastra%2Fragie.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +65 -65
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +49 -49
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +33 -33
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +33 -33
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +33 -33
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +43 -43
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +35 -35
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +31 -31
- package/.docs/organized/changelogs/create-mastra.md +10 -10
- package/.docs/organized/changelogs/mastra.md +79 -79
- package/.docs/raw/agents/overview.mdx +52 -47
- package/.docs/raw/community/contributing-templates.mdx +1 -0
- package/.docs/raw/memory/overview.mdx +3 -1
- package/.docs/raw/memory/working-memory.mdx +67 -0
- package/.docs/raw/observability/logging.mdx +94 -19
- package/.docs/raw/reference/observability/logger.mdx +69 -50
- package/.docs/raw/reference/observability/providers/langfuse.mdx +47 -14
- package/.docs/raw/reference/workflows/dountil.mdx +1 -2
- package/.docs/raw/reference/workflows/dowhile.mdx +1 -2
- package/.docs/raw/reference/workflows/resume.mdx +13 -3
- package/.docs/raw/reference/workflows/step.mdx +0 -1
- package/.docs/raw/workflows/suspend-and-resume.mdx +13 -2
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/logger.d.ts +11 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/prepare-docs/code-examples.d.ts +5 -0
- package/dist/prepare-docs/code-examples.d.ts.map +1 -0
- package/dist/prepare-docs/copy-raw.d.ts +2 -0
- package/dist/prepare-docs/copy-raw.d.ts.map +1 -0
- package/dist/prepare-docs/package-changes.d.ts +5 -0
- package/dist/prepare-docs/package-changes.d.ts.map +1 -0
- package/dist/prepare-docs/prepare.d.ts +2 -1
- package/dist/prepare-docs/prepare.d.ts.map +1 -0
- package/dist/stdio.d.ts +2 -0
- package/dist/stdio.d.ts.map +1 -0
- package/dist/tools/__tests__/test-setup.d.ts +5 -0
- package/dist/tools/__tests__/test-setup.d.ts.map +1 -0
- package/dist/tools/blog.d.ts +22 -0
- package/dist/tools/blog.d.ts.map +1 -0
- package/dist/tools/changes.d.ts +22 -0
- package/dist/tools/changes.d.ts.map +1 -0
- package/dist/tools/course.d.ts +85 -0
- package/dist/tools/course.d.ts.map +1 -0
- package/dist/tools/docs.d.ts +28 -0
- package/dist/tools/docs.d.ts.map +1 -0
- package/dist/tools/examples.d.ts +28 -0
- package/dist/tools/examples.d.ts.map +1 -0
- package/dist/utils.d.ts +62 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +5 -5
- package/dist/_tsup-dts-rollup.d.ts +0 -304
|
@@ -1,5 +1,83 @@
|
|
|
1
1
|
# mastra
|
|
2
2
|
|
|
3
|
+
## 0.10.17-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9862477: Install specific ai v4 deps when scaffolding a project
|
|
8
|
+
- Updated dependencies [d0d9500]
|
|
9
|
+
- @mastra/core@0.12.1-alpha.1
|
|
10
|
+
- @mastra/deployer@0.12.1-alpha.1
|
|
11
|
+
|
|
12
|
+
## 0.10.17-alpha.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 33dcb07: dependencies updates:
|
|
17
|
+
- Updated dependency [`@opentelemetry/instrumentation@^0.203.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/instrumentation/v/0.203.0) (from `^0.202.0`, in `dependencies`)
|
|
18
|
+
- Updated dependency [`@opentelemetry/auto-instrumentations-node@^0.62.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/auto-instrumentations-node/v/0.62.0) (from `^0.60.1`, in `dependencies`)
|
|
19
|
+
- Updated dependency [`@opentelemetry/exporter-trace-otlp-grpc@^0.203.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/exporter-trace-otlp-grpc/v/0.203.0) (from `^0.202.0`, in `dependencies`)
|
|
20
|
+
- Updated dependency [`@opentelemetry/exporter-trace-otlp-http@^0.203.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/exporter-trace-otlp-http/v/0.203.0) (from `^0.202.0`, in `dependencies`)
|
|
21
|
+
- Updated dependency [`@opentelemetry/sdk-node@^0.203.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/sdk-node/v/0.203.0) (from `^0.202.0`, in `dependencies`)
|
|
22
|
+
- Updated dependency [`@opentelemetry/semantic-conventions@^1.36.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/semantic-conventions/v/1.36.0) (from `^1.34.0`, in `dependencies`)
|
|
23
|
+
- Updated dependencies [33dcb07]
|
|
24
|
+
- Updated dependencies [f90797b]
|
|
25
|
+
- Updated dependencies [d30b1a0]
|
|
26
|
+
- Updated dependencies [bff87f7]
|
|
27
|
+
- Updated dependencies [07fe7a2]
|
|
28
|
+
- Updated dependencies [b4a8df0]
|
|
29
|
+
- @mastra/core@0.12.1-alpha.0
|
|
30
|
+
- @mastra/mcp@0.10.9-alpha.0
|
|
31
|
+
- @mastra/deployer@0.12.1-alpha.0
|
|
32
|
+
|
|
33
|
+
## 0.10.16
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- bc6b44a: Extract tools import from `createHonoServer`; the function now receives tools via a prop on the `options` parameter.
|
|
38
|
+
- f442224: speech to text using voice config
|
|
39
|
+
- 7a7754f: Fast follow scorers fixing input types, improve llm scorer reliability, fix ui to display scores that are 0
|
|
40
|
+
- d8dec5e: add a cta to invite to deploy to cloud
|
|
41
|
+
- 6336993: Fix workflow input form overflow
|
|
42
|
+
- d5cc460: This change implements a fix to sourcemap mappings being off due to `removeDeployer` Babel plugin missing source map config.
|
|
43
|
+
- f42c4c2: update peer deps for packages to latest core range
|
|
44
|
+
- a5681f2: fix: pagination breaks trace grouping
|
|
45
|
+
- 89d2f4e: add TTS to the playground
|
|
46
|
+
- Updated dependencies [510e2c8]
|
|
47
|
+
- Updated dependencies [2f72fb2]
|
|
48
|
+
- Updated dependencies [27cc97a]
|
|
49
|
+
- Updated dependencies [832691b]
|
|
50
|
+
- Updated dependencies [557bb9d]
|
|
51
|
+
- Updated dependencies [27cc97a]
|
|
52
|
+
- Updated dependencies [3f89307]
|
|
53
|
+
- Updated dependencies [9eda7d4]
|
|
54
|
+
- Updated dependencies [9d49408]
|
|
55
|
+
- Updated dependencies [bc6b44a]
|
|
56
|
+
- Updated dependencies [41daa63]
|
|
57
|
+
- Updated dependencies [ad0a58b]
|
|
58
|
+
- Updated dependencies [254a36b]
|
|
59
|
+
- Updated dependencies [2ecf658]
|
|
60
|
+
- Updated dependencies [7a7754f]
|
|
61
|
+
- Updated dependencies [fc92d80]
|
|
62
|
+
- Updated dependencies [e0f73c6]
|
|
63
|
+
- Updated dependencies [0b89602]
|
|
64
|
+
- Updated dependencies [4d37822]
|
|
65
|
+
- Updated dependencies [23a6a7c]
|
|
66
|
+
- Updated dependencies [cda801d]
|
|
67
|
+
- Updated dependencies [a77c823]
|
|
68
|
+
- Updated dependencies [ff9c125]
|
|
69
|
+
- Updated dependencies [09bca64]
|
|
70
|
+
- Updated dependencies [9802f42]
|
|
71
|
+
- Updated dependencies [d5cc460]
|
|
72
|
+
- Updated dependencies [f42c4c2]
|
|
73
|
+
- Updated dependencies [b8efbb9]
|
|
74
|
+
- Updated dependencies [71466e7]
|
|
75
|
+
- Updated dependencies [0c99fbe]
|
|
76
|
+
- @mastra/core@0.12.0
|
|
77
|
+
- @mastra/deployer@0.12.0
|
|
78
|
+
- @mastra/loggers@0.10.5
|
|
79
|
+
- @mastra/mcp@0.10.8
|
|
80
|
+
|
|
3
81
|
## 0.10.16-alpha.3
|
|
4
82
|
|
|
5
83
|
### Patch Changes
|
|
@@ -220,83 +298,5 @@
|
|
|
220
298
|
- Updated dependency [`swr@^2.3.4` ↗︎](https://www.npmjs.com/package/swr/v/2.3.4) (from `^2.3.3`, in `dependencies`)
|
|
221
299
|
- 984887a: dependencies updates:
|
|
222
300
|
- Updated dependency [`prettier@^3.6.2` ↗︎](https://www.npmjs.com/package/prettier/v/3.6.2) (from `^3.5.3`, in `dependencies`)
|
|
223
|
-
- aa9528a: Display reasoning in playground
|
|
224
|
-
- 45174f3: share network list between core and cloud
|
|
225
|
-
- 48f5532: export workflow list for usage in cloud
|
|
226
|
-
- 3e484be: Added CLI template option
|
|
227
|
-
- 626b0f4: [Cloud-126] Working Memory Playground - Added working memory to playground to allow users to view/edit working memory
|
|
228
|
-
- e1d0080: abstract Link component between cloud and core
|
|
229
|
-
- f9b1508: add the same agent table as in cloud and export it from the playground
|
|
230
|
-
- dfbeec6: Fix navigation to vnext AgentNetwork agents
|
|
231
|
-
- Updated dependencies [7776324]
|
|
232
|
-
- Updated dependencies [0b56518]
|
|
233
|
-
- Updated dependencies [db5cc15]
|
|
234
|
-
- Updated dependencies [2ba5b76]
|
|
235
|
-
- Updated dependencies [7b57e2c]
|
|
236
|
-
- Updated dependencies [5237998]
|
|
237
|
-
- Updated dependencies [c3a30de]
|
|
238
|
-
- Updated dependencies [37c1acd]
|
|
239
|
-
- Updated dependencies [1aa60b1]
|
|
240
|
-
- Updated dependencies [89ec9d4]
|
|
241
|
-
- Updated dependencies [cf3a184]
|
|
242
|
-
- Updated dependencies [fe4bbd4]
|
|
243
|
-
- Updated dependencies [d6bfd60]
|
|
244
|
-
- Updated dependencies [626b0f4]
|
|
245
|
-
- Updated dependencies [c22a91f]
|
|
246
|
-
- Updated dependencies [f7403ab]
|
|
247
|
-
- Updated dependencies [6c89d7f]
|
|
248
|
-
- @mastra/deployer@0.10.15
|
|
249
|
-
- @mastra/core@0.10.15
|
|
250
|
-
|
|
251
|
-
## 0.10.13-alpha.2
|
|
252
|
-
|
|
253
|
-
### Patch Changes
|
|
254
301
|
|
|
255
|
-
|
|
256
|
-
- dfbeec6: Fix navigation to vnext AgentNetwork agents
|
|
257
|
-
|
|
258
|
-
## 0.10.13-alpha.1
|
|
259
|
-
|
|
260
|
-
### Patch Changes
|
|
261
|
-
|
|
262
|
-
- d49334d: export tool list for usage in cloud
|
|
263
|
-
- 9cdfcb5: fix infinite rerenders on agents table + share runtime context for cloud
|
|
264
|
-
- 45174f3: share network list between core and cloud
|
|
265
|
-
- 48f5532: export workflow list for usage in cloud
|
|
266
|
-
- 3e484be: Added CLI template option
|
|
267
|
-
- Updated dependencies [0b56518]
|
|
268
|
-
- Updated dependencies [2ba5b76]
|
|
269
|
-
- Updated dependencies [c3a30de]
|
|
270
|
-
- Updated dependencies [cf3a184]
|
|
271
|
-
- Updated dependencies [fe4bbd4]
|
|
272
|
-
- Updated dependencies [d6bfd60]
|
|
273
|
-
- @mastra/core@0.10.15-alpha.1
|
|
274
|
-
- @mastra/deployer@0.10.15-alpha.1
|
|
275
|
-
|
|
276
|
-
## 0.10.13-alpha.0
|
|
277
|
-
|
|
278
|
-
### Patch Changes
|
|
279
|
-
|
|
280
|
-
- 593631d: allow to pass ref to the link abstraction
|
|
281
|
-
- 5237998: Fix foreach output
|
|
282
|
-
- 1aa60b1: Pipe runtimeContext to vNext network agent stream and generate steps, wire up runtimeContext for vNext Networks in cliet SDK & playground
|
|
283
|
-
- 5130bcb: dependencies updates:
|
|
284
|
-
- Updated dependency [`swr@^2.3.4` ↗︎](https://www.npmjs.com/package/swr/v/2.3.4) (from `^2.3.3`, in `dependencies`)
|
|
285
|
-
- 984887a: dependencies updates:
|
|
286
|
-
- Updated dependency [`prettier@^3.6.2` ↗︎](https://www.npmjs.com/package/prettier/v/3.6.2) (from `^3.5.3`, in `dependencies`)
|
|
287
|
-
- aa9528a: Display reasoning in playground
|
|
288
|
-
- 626b0f4: [Cloud-126] Working Memory Playground - Added working memory to playground to allow users to view/edit working memory
|
|
289
|
-
- e1d0080: abstract Link component between cloud and core
|
|
290
|
-
- f9b1508: add the same agent table as in cloud and export it from the playground
|
|
291
|
-
- Updated dependencies [7776324]
|
|
292
|
-
- Updated dependencies [db5cc15]
|
|
293
|
-
- Updated dependencies [7b57e2c]
|
|
294
|
-
- Updated dependencies [5237998]
|
|
295
|
-
- Updated dependencies [37c1acd]
|
|
296
|
-
- Updated dependencies [1aa60b1]
|
|
297
|
-
- Updated dependencies [89ec9d4]
|
|
298
|
-
- Updated dependencies [626b0f4]
|
|
299
|
-
- Updated dependencies [c22a91f]
|
|
300
|
-
- Updated dependencies [f7403ab]
|
|
301
|
-
|
|
302
|
-
... 4605 more lines hidden. See full changelog in package directory.
|
|
302
|
+
... 4683 more lines hidden. See full changelog in package directory.
|
|
@@ -15,21 +15,21 @@ Additionally, agents support dynamic configuration, allowing you to change their
|
|
|
15
15
|
|
|
16
16
|
To create an agent in Mastra, you use the `Agent` class and define its properties:
|
|
17
17
|
|
|
18
|
-
```
|
|
19
|
-
import { Agent } from "@mastra/core/agent";
|
|
18
|
+
```typescript filename="src/mastra/agents/test-agent.ts" showLineNumbers copy
|
|
20
19
|
import { openai } from "@ai-sdk/openai";
|
|
20
|
+
import { Agent } from "@mastra/core/agent";
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
name: "
|
|
22
|
+
const testAgent = new Agent({
|
|
23
|
+
name: "test-agent",
|
|
24
24
|
instructions: "You are a helpful assistant.",
|
|
25
|
-
model: openai("gpt-4o
|
|
25
|
+
model: openai("gpt-4o")
|
|
26
26
|
});
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
**Note:** Ensure that you have set the necessary environment variables, such as your OpenAI API key, in your `.env` file:
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
OPENAI_API_KEY
|
|
31
|
+
```bash filename=".env" copy
|
|
32
|
+
OPENAI_API_KEY=<your-api-key>
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
Also, make sure you have the `@mastra/core` package installed:
|
|
@@ -44,12 +44,13 @@ All agent properties (instructions, model, tools, memory) can be configured dyna
|
|
|
44
44
|
|
|
45
45
|
Register your agent with Mastra to enable logging and access to configured tools and integrations:
|
|
46
46
|
|
|
47
|
-
```
|
|
47
|
+
```typescript showLineNumbers filename="src/mastra/index.ts" copy
|
|
48
48
|
import { Mastra } from "@mastra/core";
|
|
49
|
-
import {
|
|
49
|
+
import { testAgent } from './agents/test-agent';
|
|
50
50
|
|
|
51
51
|
export const mastra = new Mastra({
|
|
52
|
-
|
|
52
|
+
// ...
|
|
53
|
+
agents: { testAgent },
|
|
53
54
|
});
|
|
54
55
|
```
|
|
55
56
|
|
|
@@ -59,8 +60,8 @@ export const mastra = new Mastra({
|
|
|
59
60
|
|
|
60
61
|
Use the `.generate()` method to have your agent produce text responses:
|
|
61
62
|
|
|
62
|
-
```
|
|
63
|
-
const response = await
|
|
63
|
+
```typescript showLineNumbers copy
|
|
64
|
+
const response = await testAgent.generate([
|
|
64
65
|
{ role: "user", content: "Hello, how can you assist me today?" },
|
|
65
66
|
]);
|
|
66
67
|
|
|
@@ -73,8 +74,8 @@ For more details about the generate method and its options, see the [generate re
|
|
|
73
74
|
|
|
74
75
|
For more real-time responses, you can stream the agent's response:
|
|
75
76
|
|
|
76
|
-
```
|
|
77
|
-
const stream = await
|
|
77
|
+
```typescript showLineNumbers copy
|
|
78
|
+
const stream = await testAgent.stream([
|
|
78
79
|
{ role: "user", content: "Tell me a story." },
|
|
79
80
|
]);
|
|
80
81
|
|
|
@@ -87,13 +88,35 @@ for await (const chunk of stream.textStream) {
|
|
|
87
88
|
|
|
88
89
|
For more details about streaming responses, see the [stream reference documentation](/reference/agents/stream).
|
|
89
90
|
|
|
90
|
-
## 3.
|
|
91
|
+
## 3. Describing images
|
|
92
|
+
|
|
93
|
+
Agents can analyze and describe images by processing both the visual content and any text within them. To enable image analysis, pass an object with `type: 'image'` and the image URL in the content array. You can combine image content with text prompts to guide the agent's analysis.
|
|
94
|
+
|
|
95
|
+
```typescript showLineNumbers copy
|
|
96
|
+
await testAgent.generate([
|
|
97
|
+
{
|
|
98
|
+
role: 'user',
|
|
99
|
+
content: [
|
|
100
|
+
{
|
|
101
|
+
type: 'image',
|
|
102
|
+
image: "https://example.com/images/test-image.jpg",
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
type: 'text',
|
|
106
|
+
text: 'Describe the image in detail, and extract all the text in the image.',
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
]);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## 4. Structured Output
|
|
91
114
|
|
|
92
115
|
Agents can return structured data by providing a JSON Schema or using a Zod schema.
|
|
93
116
|
|
|
94
117
|
### Using JSON Schema
|
|
95
118
|
|
|
96
|
-
```typescript
|
|
119
|
+
```typescript showLineNumbers copy
|
|
97
120
|
const schema = {
|
|
98
121
|
type: "object",
|
|
99
122
|
properties: {
|
|
@@ -104,7 +127,7 @@ const schema = {
|
|
|
104
127
|
required: ["summary", "keywords"],
|
|
105
128
|
};
|
|
106
129
|
|
|
107
|
-
const response = await
|
|
130
|
+
const response = await testAgent.generate(
|
|
108
131
|
[
|
|
109
132
|
{
|
|
110
133
|
role: "user",
|
|
@@ -132,7 +155,7 @@ npm install zod
|
|
|
132
155
|
|
|
133
156
|
Then, define a Zod schema and use it with the agent:
|
|
134
157
|
|
|
135
|
-
```
|
|
158
|
+
```typescript showLineNumbers copy
|
|
136
159
|
import { z } from "zod";
|
|
137
160
|
|
|
138
161
|
// Define the Zod schema
|
|
@@ -142,7 +165,7 @@ const schema = z.object({
|
|
|
142
165
|
});
|
|
143
166
|
|
|
144
167
|
// Use the schema with the agent
|
|
145
|
-
const response = await
|
|
168
|
+
const response = await testAgent.generate(
|
|
146
169
|
[
|
|
147
170
|
{
|
|
148
171
|
role: "user",
|
|
@@ -162,13 +185,13 @@ console.log("Structured Output:", response.object);
|
|
|
162
185
|
|
|
163
186
|
If you need to generate structured output alongside tool calls, you'll need to use the `experimental_output` property instead of `output`. Here's how:
|
|
164
187
|
|
|
165
|
-
```typescript
|
|
188
|
+
```typescript showLineNumbers copy
|
|
166
189
|
const schema = z.object({
|
|
167
190
|
summary: z.string(),
|
|
168
191
|
keywords: z.array(z.string()),
|
|
169
192
|
});
|
|
170
193
|
|
|
171
|
-
const response = await
|
|
194
|
+
const response = await testAgent.generate(
|
|
172
195
|
[
|
|
173
196
|
{
|
|
174
197
|
role: "user",
|
|
@@ -189,7 +212,7 @@ console.log("Structured Output:", response.object);
|
|
|
189
212
|
|
|
190
213
|
This allows you to have strong typing and validation for the structured data returned by the agent.
|
|
191
214
|
|
|
192
|
-
##
|
|
215
|
+
## 5. Multi-step tool use
|
|
193
216
|
|
|
194
217
|
Agents can be enhanced with tools - functions that extend their capabilities beyond text generation. Tools allow agents to perform calculations, access external systems, and process data. Agents not only decide whether to call tools they're given, they determine the parameters that should be given to that tool.
|
|
195
218
|
|
|
@@ -199,26 +222,8 @@ For a detailed guide to creating and configuring tools, see the [Adding Tools do
|
|
|
199
222
|
|
|
200
223
|
The `maxSteps` parameter controls the maximum number of sequential LLM calls an agent can make, particularly important when using tool calls. By default, it is set to 1 to prevent infinite loops in case of misconfigured tools. You can increase this limit based on your use case:
|
|
201
224
|
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
import { openai } from "@ai-sdk/openai";
|
|
205
|
-
import * as mathjs from "mathjs";
|
|
206
|
-
import { z } from "zod";
|
|
207
|
-
|
|
208
|
-
export const myAgent = new Agent({
|
|
209
|
-
name: "My Agent",
|
|
210
|
-
instructions: "You are a helpful assistant that can solve math problems.",
|
|
211
|
-
model: openai("gpt-4o-mini"),
|
|
212
|
-
tools: {
|
|
213
|
-
calculate: {
|
|
214
|
-
description: "Calculator for mathematical expressions",
|
|
215
|
-
schema: z.object({ expression: z.string() }),
|
|
216
|
-
execute: async ({ expression }) => mathjs.evaluate(expression),
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
const response = await myAgent.generate(
|
|
225
|
+
```typescript showLineNumbers copy
|
|
226
|
+
const response = await testAgent.generate(
|
|
222
227
|
[
|
|
223
228
|
{
|
|
224
229
|
role: "user",
|
|
@@ -238,8 +243,8 @@ You can monitor the progress of multi-step operations using the `onStepFinish` c
|
|
|
238
243
|
|
|
239
244
|
`onStepFinish` is only available when streaming or generating text without structured output.
|
|
240
245
|
|
|
241
|
-
```
|
|
242
|
-
const response = await
|
|
246
|
+
```typescript showLineNumbers copy
|
|
247
|
+
const response = await testAgent.generate(
|
|
243
248
|
[{ role: "user", content: "Calculate the taxi driver's daily earnings." }],
|
|
244
249
|
{
|
|
245
250
|
maxSteps: 5,
|
|
@@ -255,8 +260,8 @@ const response = await myAgent.generate(
|
|
|
255
260
|
The `onFinish` callback is available when streaming responses and provides detailed information about the completed interaction. It is called after the LLM has finished generating its response and all tool executions have completed.
|
|
256
261
|
This callback receives the final response text, execution steps, token usage statistics, and other metadata that can be useful for monitoring and logging:
|
|
257
262
|
|
|
258
|
-
```
|
|
259
|
-
const stream = await
|
|
263
|
+
```typescript showLineNumbers copy
|
|
264
|
+
const stream = await testAgent.stream(
|
|
260
265
|
[{ role: "user", content: "Calculate the taxi driver's daily earnings." }],
|
|
261
266
|
{
|
|
262
267
|
maxSteps: 5,
|
|
@@ -277,7 +282,7 @@ const stream = await myAgent.stream(
|
|
|
277
282
|
);
|
|
278
283
|
```
|
|
279
284
|
|
|
280
|
-
##
|
|
285
|
+
## 6. Testing agents locally
|
|
281
286
|
|
|
282
287
|
Mastra provides a CLI command `mastra dev` to run your agents behind an API. By default, this looks for exported agents in files in the `src/mastra/agents` directory. It generates endpoints for testing your agent (eg `http://localhost:4111/api/agents/myAgent/generate`) and provides a visual playground where you can chat with an agent and view traces.
|
|
283
288
|
|
|
@@ -27,6 +27,7 @@ Create your template following the established patterns:
|
|
|
27
27
|
- Include comprehensive documentation
|
|
28
28
|
- Test thoroughly with fresh installations
|
|
29
29
|
- Follow all technical requirements
|
|
30
|
+
- Ensure the github repo is a template repo. [How to create a template repo](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-template-repository)
|
|
30
31
|
|
|
31
32
|
### 3. Submit for Review
|
|
32
33
|
|
|
@@ -68,7 +68,7 @@ Send a few messages and notice that it remembers information across turns:
|
|
|
68
68
|
|
|
69
69
|
Mastra organizes memory into threads, which are records that identify specific conversation histories, using two identifiers:
|
|
70
70
|
|
|
71
|
-
1. **`threadId`**: A
|
|
71
|
+
1. **`threadId`**: A globally unique conversation id (e.g., `support_123`). Thread IDs must be unique across all resources.
|
|
72
72
|
2. **`resourceId`**: The user or entity id that owns each thread (e.g., `user_123`, `org_456`).
|
|
73
73
|
|
|
74
74
|
The `resourceId` is particularly important for [resource-scoped working memory](./working-memory.mdx#resource-scoped-memory), which allows memory to persist across all conversation threads for the same user.
|
|
@@ -82,6 +82,8 @@ const response = await myMemoryAgent.stream("Hello, my name is Alice.", {
|
|
|
82
82
|
|
|
83
83
|
**Important:** without these ID's your agent will not use memory, even if memory is properly configured. The playground handles this for you, but you need to add ID's yourself when using memory in your application.
|
|
84
84
|
|
|
85
|
+
> **Thread ID Uniqueness:** Each thread ID must be globally unique across all resources. A thread is permanently associated with the resource that created it. If you need to have similar thread names for different resources (e.g., a "general" thread for multiple users), include the resource ID in the thread ID: `${resourceId}-general` or `user_alice_general`.
|
|
86
|
+
|
|
85
87
|
### Thread Title Generation
|
|
86
88
|
|
|
87
89
|
Mastra can automatically generate meaningful titles for conversation threads based on the user's first message. This helps organize and identify conversations in your application UI.
|
|
@@ -298,6 +298,73 @@ again because it has been stored in working memory.
|
|
|
298
298
|
If your agent is not properly updating working memory when you expect it to, you can add system
|
|
299
299
|
instructions on _how_ and _when_ to use this template in your agent's `instructions` setting.
|
|
300
300
|
|
|
301
|
+
## Setting Initial Working Memory
|
|
302
|
+
|
|
303
|
+
While agents typically update working memory through the `updateWorkingMemory` tool, you can also set initial working memory programmatically when creating or updating threads. This is useful for injecting user data (like their name, preferences, or other info) that you want available to the agent without passing it in every request.
|
|
304
|
+
|
|
305
|
+
### Setting Working Memory via Thread Metadata
|
|
306
|
+
|
|
307
|
+
When creating a thread, you can provide initial working memory through the metadata's `workingMemory` key:
|
|
308
|
+
|
|
309
|
+
```typescript filename="src/app/medical-consultation.ts" showLineNumbers copy
|
|
310
|
+
// Create a thread with initial working memory
|
|
311
|
+
const thread = await memory.createThread({
|
|
312
|
+
threadId: "thread-123",
|
|
313
|
+
resourceId: "user-456",
|
|
314
|
+
title: "Medical Consultation",
|
|
315
|
+
metadata: {
|
|
316
|
+
workingMemory: `# Patient Profile
|
|
317
|
+
- Name: John Doe
|
|
318
|
+
- Blood Type: O+
|
|
319
|
+
- Allergies: Penicillin
|
|
320
|
+
- Current Medications: None
|
|
321
|
+
- Medical History: Hypertension (controlled)
|
|
322
|
+
`
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
// The agent will now have access to this information in all messages
|
|
327
|
+
await agent.generate("What's my blood type?", {
|
|
328
|
+
threadId: thread.id,
|
|
329
|
+
resourceId: "user-456"
|
|
330
|
+
});
|
|
331
|
+
// Response: "Your blood type is O+."
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Updating Working Memory Programmatically
|
|
335
|
+
|
|
336
|
+
You can also update an existing thread's working memory:
|
|
337
|
+
|
|
338
|
+
```typescript filename="src/app/medical-consultation.ts" showLineNumbers copy
|
|
339
|
+
// Update thread metadata to add/modify working memory
|
|
340
|
+
await memory.updateThread({
|
|
341
|
+
id: "thread-123",
|
|
342
|
+
title: thread.title,
|
|
343
|
+
metadata: {
|
|
344
|
+
...thread.metadata,
|
|
345
|
+
workingMemory: `# Patient Profile
|
|
346
|
+
- Name: John Doe
|
|
347
|
+
- Blood Type: O+
|
|
348
|
+
- Allergies: Penicillin, Ibuprofen // Updated
|
|
349
|
+
- Current Medications: Lisinopril 10mg daily // Added
|
|
350
|
+
- Medical History: Hypertension (controlled)
|
|
351
|
+
`
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Direct Memory Update
|
|
357
|
+
|
|
358
|
+
Alternatively, use the `updateWorkingMemory` method directly:
|
|
359
|
+
|
|
360
|
+
```typescript filename="src/app/medical-consultation.ts" showLineNumbers copy
|
|
361
|
+
await memory.updateWorkingMemory({
|
|
362
|
+
threadId: "thread-123",
|
|
363
|
+
resourceId: "user-456", // Required for resource-scoped memory
|
|
364
|
+
workingMemory: "Updated memory content..."
|
|
365
|
+
});
|
|
366
|
+
```
|
|
367
|
+
|
|
301
368
|
## Examples
|
|
302
369
|
|
|
303
370
|
- [Streaming working memory](/examples/memory/streaming-working-memory)
|
|
@@ -1,38 +1,113 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Logging | Mastra Observability Documentation"
|
|
3
|
-
description:
|
|
3
|
+
description: Learn how to use logging in Mastra to monitor execution, capture application behavior, and improve the accuracy of AI applications.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import Image from "next/image";
|
|
7
|
-
|
|
8
6
|
# Logging
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
Mastra's logging system captures function execution, input data, and output responses in a structured format.
|
|
9
|
+
|
|
10
|
+
When deploying to Mastra Cloud, logs are shown on the [Logs](../mastra-cloud/observability.mdx) page. In self-hosted or custom environments, logs can be directed to files or external services depending on the configured transports.
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## PinoLogger
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
When [initializing a new Mastra project](../getting-started/installation.mdx) using the CLI, `PinoLogger` is included by default.
|
|
15
15
|
|
|
16
|
-
```typescript filename="mastra.
|
|
17
|
-
import { Mastra } from
|
|
18
|
-
import { PinoLogger } from
|
|
16
|
+
```typescript filename="src/mastra/index.ts" showLineNumbers copy
|
|
17
|
+
import { Mastra } from '@mastra/core/mastra';
|
|
18
|
+
import { PinoLogger } from '@mastra/loggers';
|
|
19
19
|
|
|
20
20
|
export const mastra = new Mastra({
|
|
21
|
-
//
|
|
21
|
+
// ...
|
|
22
22
|
logger: new PinoLogger({
|
|
23
|
-
name:
|
|
24
|
-
level:
|
|
23
|
+
name: 'Mastra',
|
|
24
|
+
level: 'info',
|
|
25
25
|
}),
|
|
26
26
|
});
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
> See the [PinoLogger](../../reference/observability/logger.mdx) API reference for all available configuration options.
|
|
30
|
+
|
|
31
|
+
## Logging from workflows and tools
|
|
32
|
+
|
|
33
|
+
Mastra provides access to a logger instance via the `mastra.getLogger()` method, available inside both workflow steps and tools. The logger supports standard severity levels: `debug`, `info`, `warn`, and `error`.
|
|
34
|
+
|
|
35
|
+
### Logging from workflow steps
|
|
36
|
+
|
|
37
|
+
Within a workflow step, access the logger via the `mastra` parameter inside the `execute` function. This allows you to log messages relevant to the step’s execution.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
```typescript {8-9} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
41
|
+
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
42
|
+
import { z } from "zod";
|
|
43
|
+
|
|
44
|
+
const step1 = createStep({
|
|
45
|
+
//...
|
|
46
|
+
execute: async ({ mastra }) => {
|
|
47
|
+
|
|
48
|
+
const logger = mastra.getLogger();
|
|
49
|
+
logger.info("workflow info log");
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
output: ""
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export const testWorkflow = createWorkflow({...})
|
|
58
|
+
.then(step1)
|
|
59
|
+
.commit();
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Logging from tools
|
|
63
|
+
|
|
64
|
+
Similarly, tools have access to the logger instance via the `mastra` parameter. Use this to log tool specific activity during execution.
|
|
30
65
|
|
|
31
|
-
-
|
|
32
|
-
|
|
66
|
+
```typescript {8-9} filename="src/mastra/tools/test-tool.ts" showLineNumbers copy
|
|
67
|
+
import { createTool } from "@mastra/core/tools";
|
|
68
|
+
import { z } from "zod";
|
|
33
69
|
|
|
34
|
-
|
|
70
|
+
export const testTool = createTool({
|
|
71
|
+
// ...
|
|
72
|
+
execute: async ({ mastra }) => {
|
|
35
73
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
74
|
+
const logger = mastra?.getLogger();
|
|
75
|
+
logger?.info("tool info log");
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
output: ""
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
## Logging with additional data
|
|
86
|
+
|
|
87
|
+
Logger methods accept an optional second argument for additional data. This can be any value, such as an object, string, or number.
|
|
88
|
+
|
|
89
|
+
In this example, the log message includes an object with a key of `agent` and a value of the `testAgent` instance.
|
|
90
|
+
|
|
91
|
+
```typescript {11} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
92
|
+
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
93
|
+
import { z } from "zod";
|
|
94
|
+
|
|
95
|
+
const step1 = createStep({
|
|
96
|
+
//...
|
|
97
|
+
execute: async ({ mastra }) => {
|
|
98
|
+
|
|
99
|
+
const testAgent = mastra.getAgent("testAgent");
|
|
100
|
+
|
|
101
|
+
const logger = mastra.getLogger();
|
|
102
|
+
logger.info("workflow info log", { agent: testAgent });
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
output: ""
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export const testWorkflow = createWorkflow({...})
|
|
111
|
+
.then(step1)
|
|
112
|
+
.commit();
|
|
113
|
+
```
|