@mastra/mcp-docs-server 1.0.0-beta.0 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +8 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +32 -32
- package/.docs/organized/changelogs/%40mastra%2Freact.md +15 -15
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +15 -15
- package/.docs/organized/changelogs/create-mastra.md +7 -7
- package/.docs/organized/changelogs/mastra.md +13 -13
- package/.docs/raw/agents/agent-memory.mdx +1 -1
- package/.docs/raw/agents/overview.mdx +2 -2
- package/.docs/raw/auth/auth0.mdx +1 -1
- package/.docs/raw/auth/clerk.mdx +1 -1
- package/.docs/raw/auth/firebase.mdx +1 -1
- package/.docs/raw/auth/jwt.mdx +1 -1
- package/.docs/raw/auth/supabase.mdx +1 -1
- package/.docs/raw/auth/workos.mdx +1 -1
- package/.docs/raw/course/01-first-agent/03-verifying-installation.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/02-installing-mcp.md +1 -1
- package/.docs/raw/course/03-agent-memory/03-installing-memory.md +1 -1
- package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +2 -2
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +1 -1
- package/.docs/raw/deployment/serverless-platforms/cloudflare-deployer.mdx +1 -1
- package/.docs/raw/deployment/serverless-platforms/netlify-deployer.mdx +1 -1
- package/.docs/raw/deployment/serverless-platforms/vercel-deployer.mdx +1 -1
- package/.docs/raw/evals/overview.mdx +1 -1
- package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +8 -4
- package/.docs/raw/frameworks/agentic-uis/assistant-ui.mdx +1 -1
- package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +9 -9
- package/.docs/raw/frameworks/agentic-uis/openrouter.mdx +1 -1
- package/.docs/raw/frameworks/servers/express.mdx +1 -1
- package/.docs/raw/frameworks/web-frameworks/astro.mdx +12 -12
- package/.docs/raw/frameworks/web-frameworks/next-js.mdx +4 -4
- package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +12 -12
- package/.docs/raw/frameworks/web-frameworks/vite-react.mdx +5 -5
- package/.docs/raw/getting-started/installation.mdx +13 -13
- package/.docs/raw/getting-started/templates.mdx +5 -5
- package/.docs/raw/guides/guide/notes-mcp-server.mdx +1 -1
- package/.docs/raw/guides/guide/research-assistant.mdx +1 -10
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +16 -6
- package/.docs/raw/guides/migrations/upgrade-to-v1/client.mdx +42 -2
- package/.docs/raw/guides/migrations/upgrade-to-v1/evals.mdx +31 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/mastra.mdx +28 -4
- package/.docs/raw/guides/migrations/upgrade-to-v1/mcp.mdx +3 -3
- package/.docs/raw/guides/migrations/upgrade-to-v1/memory.mdx +28 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/overview.mdx +50 -36
- package/.docs/raw/guides/migrations/upgrade-to-v1/storage.mdx +80 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/tools.mdx +2 -2
- package/.docs/raw/guides/migrations/upgrade-to-v1/tracing.mdx +13 -13
- package/.docs/raw/guides/migrations/upgrade-to-v1/vectors.mdx +25 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/voice.mdx +1 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +32 -2
- package/.docs/raw/guides/quickstarts/nextjs.mdx +275 -0
- package/.docs/raw/index.mdx +1 -1
- package/.docs/raw/logging.mdx +3 -3
- package/.docs/raw/mastra-cloud/observability.mdx +6 -6
- package/.docs/raw/memory/overview.mdx +2 -2
- package/.docs/raw/memory/semantic-recall.mdx +2 -2
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +2 -2
- package/.docs/raw/memory/storage/memory-with-mongodb.mdx +152 -0
- package/.docs/raw/memory/storage/memory-with-pg.mdx +2 -2
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +2 -2
- package/.docs/raw/observability/overview.mdx +5 -5
- package/.docs/raw/observability/tracing/exporters/arize.mdx +2 -2
- package/.docs/raw/observability/tracing/exporters/braintrust.mdx +2 -2
- package/.docs/raw/observability/tracing/exporters/cloud.mdx +2 -2
- package/.docs/raw/observability/tracing/exporters/default.mdx +5 -5
- package/.docs/raw/observability/tracing/exporters/langfuse.mdx +2 -2
- package/.docs/raw/observability/tracing/exporters/langsmith.mdx +2 -2
- package/.docs/raw/observability/tracing/exporters/otel.mdx +5 -5
- package/.docs/raw/observability/tracing/overview.mdx +21 -21
- package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +2 -2
- package/.docs/raw/rag/overview.mdx +1 -1
- package/.docs/raw/reference/agents/agent.mdx +2 -2
- package/.docs/raw/reference/cli/create-mastra.mdx +10 -10
- package/.docs/raw/reference/cli/mastra.mdx +7 -7
- package/.docs/raw/reference/core/getLogger.mdx +2 -2
- package/.docs/raw/reference/core/getMCPServer.mdx +2 -2
- package/.docs/raw/reference/core/getMCPServerById.mdx +4 -4
- package/.docs/raw/reference/core/getTelemetry.mdx +2 -2
- package/.docs/raw/reference/core/listLogs.mdx +2 -2
- package/.docs/raw/reference/core/listLogsByRunId.mdx +2 -2
- package/.docs/raw/reference/core/listMCPServers.mdx +4 -4
- package/.docs/raw/reference/core/setLogger.mdx +2 -2
- package/.docs/raw/reference/core/setTelemetry.mdx +2 -2
- package/.docs/raw/reference/evals/create-scorer.mdx +58 -49
- package/.docs/raw/reference/evals/mastra-scorer.mdx +2 -0
- package/.docs/raw/reference/observability/tracing/configuration.mdx +12 -12
- package/.docs/raw/reference/observability/tracing/exporters/arize.mdx +1 -1
- package/.docs/raw/reference/observability/tracing/exporters/cloud-exporter.mdx +8 -8
- package/.docs/raw/reference/observability/tracing/exporters/console-exporter.mdx +8 -8
- package/.docs/raw/reference/observability/tracing/exporters/default-exporter.mdx +8 -8
- package/.docs/raw/reference/observability/tracing/instances.mdx +8 -8
- package/.docs/raw/reference/observability/tracing/interfaces.mdx +7 -7
- package/.docs/raw/reference/observability/tracing/spans.mdx +7 -7
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +8 -2
- package/.docs/raw/reference/processors/language-detector.mdx +8 -2
- package/.docs/raw/reference/processors/moderation-processor.mdx +8 -2
- package/.docs/raw/reference/processors/pii-detector.mdx +8 -2
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +8 -2
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +8 -2
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +8 -2
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +8 -2
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +1 -1
- package/.docs/raw/reference/storage/cloudflare.mdx +1 -1
- package/.docs/raw/reference/storage/dynamodb.mdx +3 -3
- package/.docs/raw/reference/storage/lance.mdx +1 -1
- package/.docs/raw/reference/storage/libsql.mdx +1 -1
- package/.docs/raw/reference/storage/mongodb.mdx +1 -1
- package/.docs/raw/reference/storage/mssql.mdx +1 -1
- package/.docs/raw/reference/storage/postgresql.mdx +1 -1
- package/.docs/raw/reference/storage/upstash.mdx +1 -1
- package/.docs/raw/reference/templates/overview.mdx +1 -1
- package/.docs/raw/reference/tools/mcp-server.mdx +49 -0
- package/.docs/raw/reference/vectors/couchbase.mdx +8 -2
- package/.docs/raw/reference/vectors/libsql.mdx +1 -1
- package/.docs/raw/reference/vectors/mongodb.mdx +7 -1
- package/.docs/raw/reference/vectors/s3vectors.mdx +1 -1
- package/.docs/raw/server-db/mastra-client.mdx +4 -4
- package/.docs/raw/tools-mcp/mcp-overview.mdx +1 -1
- package/.docs/raw/voice/speech-to-text.mdx +1 -1
- package/.docs/raw/voice/text-to-speech.mdx +1 -1
- package/.docs/raw/workflows/inngest-workflow.mdx +1 -1
- package/CHANGELOG.md +17 -0
- package/dist/stdio.js +11 -15
- package/package.json +4 -4
|
@@ -84,7 +84,7 @@ For tools that are executed inside a workflow, access workflow-specific properti
|
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
:::note
|
|
87
|
-
For MCP-specific tool context changes, see the [MCP migration guide]/guides/v1/migrations/upgrade-to-v1/mcp).
|
|
87
|
+
For MCP-specific tool context changes, see the [MCP migration guide](/guides/v1/migrations/upgrade-to-v1/mcp).
|
|
88
88
|
:::
|
|
89
89
|
|
|
90
90
|
### `RuntimeContext` to `RequestContext`
|
|
@@ -109,7 +109,7 @@ To migrate, update references from `runtimeContext` to `requestContext` in tool
|
|
|
109
109
|
You can use Mastra's codemod CLI to update your imports automatically:
|
|
110
110
|
|
|
111
111
|
```shell
|
|
112
|
-
npx @mastra/codemod v1/runtime-context .
|
|
112
|
+
npx @mastra/codemod@beta v1/runtime-context .
|
|
113
113
|
```
|
|
114
114
|
|
|
115
115
|
:::
|
|
@@ -46,14 +46,14 @@ export const mastra = new Mastra({
|
|
|
46
46
|
});
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
This minimal configuration automatically includes the `DefaultExporter`, `CloudExporter`, and `SensitiveDataFilter` processor. See the [observability tracing documentation]/docs/v1/observability/tracing/overview) for full configuration options.
|
|
49
|
+
This minimal configuration automatically includes the `DefaultExporter`, `CloudExporter`, and `SensitiveDataFilter` processor. See the [observability tracing documentation](/docs/v1/observability/tracing/overview) for full configuration options.
|
|
50
50
|
|
|
51
51
|
**After (v1 with custom configuration):**
|
|
52
52
|
|
|
53
53
|
If you need to configure specific exporters (like OTLP), install the exporter package and configure it:
|
|
54
54
|
|
|
55
55
|
```bash
|
|
56
|
-
npm install @mastra/otel-exporter @opentelemetry/exporter-trace-otlp-proto
|
|
56
|
+
npm install @mastra/otel-exporter@beta @opentelemetry/exporter-trace-otlp-proto
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
```typescript
|
|
@@ -89,7 +89,7 @@ Key changes:
|
|
|
89
89
|
3. Use `default: { enabled: true }` for quick setup, or `configs:` for custom configuration
|
|
90
90
|
4. Export types change from string literals (`'otlp'`) to exporter class instances (`new OtelExporter()`)
|
|
91
91
|
|
|
92
|
-
See the [exporters documentation]/docs/v1/observability/tracing/overview#exporters) for all available exporters.
|
|
92
|
+
See the [exporters documentation](/docs/v1/observability/tracing/overview#exporters) for all available exporters.
|
|
93
93
|
|
|
94
94
|
### From AI Tracing
|
|
95
95
|
|
|
@@ -134,7 +134,7 @@ The observability functionality has moved to a dedicated `@mastra/observability`
|
|
|
134
134
|
To migrate, install the package and update your import statements:
|
|
135
135
|
|
|
136
136
|
```bash
|
|
137
|
-
npm install @mastra/observability
|
|
137
|
+
npm install @mastra/observability@beta
|
|
138
138
|
```
|
|
139
139
|
|
|
140
140
|
```diff
|
|
@@ -204,13 +204,13 @@ To migrate, update method implementations in custom exporters.
|
|
|
204
204
|
|
|
205
205
|
The OTEL-based `telemetry` configuration from 0.x has been removed. The old system with `serviceName`, `sampling.type`, and `export.type` properties is no longer supported.
|
|
206
206
|
|
|
207
|
-
To migrate, follow the "From OTEL-based Telemetry" section above. For detailed configuration options, see the [observability tracing documentation]/docs/v1/observability/tracing/overview).
|
|
207
|
+
To migrate, follow the "From OTEL-based Telemetry" section above. For detailed configuration options, see the [observability tracing documentation](/docs/v1/observability/tracing/overview).
|
|
208
208
|
|
|
209
209
|
### Custom instrumentation files
|
|
210
210
|
|
|
211
211
|
The automatic detection of instrumentation files in `/mastra` (with `.ts`, `.js`, or `.mjs` extensions) has been removed. Custom instrumentation is no longer supported through separate files.
|
|
212
212
|
|
|
213
|
-
To migrate, use the built-in exporter system or implement custom exporters using the `ObservabilityExporter` interface. See the [exporters documentation]/docs/v1/observability/tracing/overview#exporters) for details.
|
|
213
|
+
To migrate, use the built-in exporter system or implement custom exporters using the `ObservabilityExporter` interface. See the [exporters documentation](/docs/v1/observability/tracing/overview#exporters) for details.
|
|
214
214
|
|
|
215
215
|
### `instrumentation.mjs` files
|
|
216
216
|
|
|
@@ -258,11 +258,11 @@ If you were using OTEL-based telemetry with specific providers in 0.x, here's ho
|
|
|
258
258
|
|
|
259
259
|
| Provider | Exporter | Guide | Reference |
|
|
260
260
|
|----------|----------|-------|-----------|
|
|
261
|
-
| Arize AX, Arize Phoenix | **Arize** | [Guide]/docs/v1/observability/tracing/exporters/arize) | [Reference]/reference/v1/observability/tracing/exporters/arize) |
|
|
262
|
-
| Braintrust | **Braintrust** | [Guide]/docs/v1/observability/tracing/exporters/braintrust) | [Reference]/reference/v1/observability/tracing/exporters/braintrust) |
|
|
263
|
-
| Langfuse | **Langfuse** | [Guide]/docs/v1/observability/tracing/exporters/langfuse) | [Reference]/reference/v1/observability/tracing/exporters/langfuse) |
|
|
264
|
-
| LangSmith | **LangSmith** | [Guide]/docs/v1/observability/tracing/exporters/langsmith) | [Reference]/reference/v1/observability/tracing/exporters/langsmith) |
|
|
265
|
-
| Dash0, Laminar, New Relic, SigNoz, Traceloop, Custom OTEL | **OpenTelemetry** | [Guide]/docs/v1/observability/tracing/exporters/otel) | [Reference]/reference/v1/observability/tracing/exporters/otel) |
|
|
261
|
+
| Arize AX, Arize Phoenix | **Arize** | [Guide](/docs/v1/observability/tracing/exporters/arize) | [Reference](/reference/v1/observability/tracing/exporters/arize) |
|
|
262
|
+
| Braintrust | **Braintrust** | [Guide](/docs/v1/observability/tracing/exporters/braintrust) | [Reference](/reference/v1/observability/tracing/exporters/braintrust) |
|
|
263
|
+
| Langfuse | **Langfuse** | [Guide](/docs/v1/observability/tracing/exporters/langfuse) | [Reference](/reference/v1/observability/tracing/exporters/langfuse) |
|
|
264
|
+
| LangSmith | **LangSmith** | [Guide](/docs/v1/observability/tracing/exporters/langsmith) | [Reference](/reference/v1/observability/tracing/exporters/langsmith) |
|
|
265
|
+
| Dash0, Laminar, New Relic, SigNoz, Traceloop, Custom OTEL | **OpenTelemetry** | [Guide](/docs/v1/observability/tracing/exporters/otel) | [Reference](/reference/v1/observability/tracing/exporters/otel) |
|
|
266
266
|
| LangWatch | \<coming soon\> | - | - |
|
|
267
267
|
|
|
268
268
|
### Installation
|
|
@@ -274,7 +274,7 @@ npm install @mastra/[exporter-name]-exporter
|
|
|
274
274
|
|
|
275
275
|
**OpenTelemetry exporter** (Dash0, Laminar, New Relic, SigNoz, Traceloop):
|
|
276
276
|
```bash
|
|
277
|
-
npm install @mastra/otel-exporter
|
|
277
|
+
npm install @mastra/otel-exporter@beta
|
|
278
278
|
```
|
|
279
279
|
|
|
280
|
-
Plus the required protocol package for your provider (see [OTEL guide]/docs/v1/observability/tracing/exporters/otel#installation)).
|
|
280
|
+
Plus the required protocol package for your provider (see [OTEL guide](/docs/v1/observability/tracing/exporters/otel#installation)).
|
|
@@ -5,10 +5,34 @@ description: "Learn how to migrate vector-related changes when upgrading to v1."
|
|
|
5
5
|
|
|
6
6
|
# Vectors
|
|
7
7
|
|
|
8
|
-
Vector store methods have been renamed to follow consistent naming conventions.
|
|
8
|
+
Vector store constructors now require an `id` property, and vector store methods have been renamed to follow consistent naming conventions.
|
|
9
9
|
|
|
10
10
|
## Changed
|
|
11
11
|
|
|
12
|
+
### Required `id` property for vector store instances
|
|
13
|
+
|
|
14
|
+
Vector store instances now require an `id` property. This unique identifier is used for tracking and managing vector store instances within Mastra. The `id` should be a descriptive, unique string for each vector store in your application.
|
|
15
|
+
|
|
16
|
+
To migrate, add an `id` field to your vector store constructor.
|
|
17
|
+
|
|
18
|
+
```diff
|
|
19
|
+
const vectorStore = new PgVector({
|
|
20
|
+
+ id: 'main-vector-store',
|
|
21
|
+
connectionString: process.env.POSTGRES_CONNECTION_STRING,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const chromaStore = new ChromaVector({
|
|
25
|
+
+ id: 'chroma-embeddings',
|
|
26
|
+
url: process.env.CHROMA_URL,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const pineconeStore = new PineconeVector({
|
|
30
|
+
+ id: 'pinecone-production',
|
|
31
|
+
apiKey: process.env.PINECONE_API_KEY,
|
|
32
|
+
environment: process.env.PINECONE_ENVIRONMENT,
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
12
36
|
### `getVectors` to `listVectors`
|
|
13
37
|
|
|
14
38
|
The `getVectors()` method has been renamed to `listVectors()`. This change aligns with the naming convention used across the API where plural getter methods use the `list` prefix.
|
|
@@ -33,7 +33,7 @@ To migrate, update configuration property names when configuring agents with voi
|
|
|
33
33
|
You can use Mastra's codemod CLI to update your code automatically:
|
|
34
34
|
|
|
35
35
|
```shell
|
|
36
|
-
npx @mastra/codemod v1/voice-property-names .
|
|
36
|
+
npx @mastra/codemod@beta v1/voice-property-names .
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
:::
|
|
@@ -25,7 +25,7 @@ To migrate, replace all calls to `mastra.getWorkflows()` with `mastra.listWorkfl
|
|
|
25
25
|
You can use Mastra's codemod CLI to update your imports automatically:
|
|
26
26
|
|
|
27
27
|
```shell
|
|
28
|
-
npx @mastra/codemod v1/
|
|
28
|
+
npx @mastra/codemod@beta v1/mastra-plural-apis .
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
:::
|
|
@@ -52,7 +52,7 @@ To migrate, update references from `runtimeContext` to `requestContext` in step
|
|
|
52
52
|
You can use Mastra's codemod CLI to update your imports automatically:
|
|
53
53
|
|
|
54
54
|
```shell
|
|
55
|
-
npx @mastra/codemod v1/runtime-context .
|
|
55
|
+
npx @mastra/codemod@beta v1/runtime-context .
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
:::
|
|
@@ -68,6 +68,16 @@ To migrate, rename method calls from `createRunAsync` to `createRun`.
|
|
|
68
68
|
+ await workflow.createRun({ input: { ... } });
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
+
:::tip[Codemod]
|
|
72
|
+
|
|
73
|
+
You can use Mastra's codemod CLI to update your code automatically:
|
|
74
|
+
|
|
75
|
+
```shell
|
|
76
|
+
npx @mastra/codemod@beta v1/workflow-create-run-async .
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
:::
|
|
80
|
+
|
|
71
81
|
### `runCount` to `retryCount` (deprecated)
|
|
72
82
|
|
|
73
83
|
The `runCount` parameter has been deprecated in favor of `retryCount` in workflow step execution. This change provides clearer naming that better describes retry behavior. The old `runCount` still works but shows deprecation warnings.
|
|
@@ -83,6 +93,16 @@ To migrate, rename `runCount` to `retryCount` in step execution functions.
|
|
|
83
93
|
});
|
|
84
94
|
```
|
|
85
95
|
|
|
96
|
+
:::tip[Codemod]
|
|
97
|
+
|
|
98
|
+
You can use Mastra's codemod CLI to update your code automatically:
|
|
99
|
+
|
|
100
|
+
```shell
|
|
101
|
+
npx @mastra/codemod@beta v1/workflow-run-count .
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
:::
|
|
105
|
+
|
|
86
106
|
### `getWorkflowRuns` to `listWorkflowRuns`
|
|
87
107
|
|
|
88
108
|
The `getWorkflowRuns()` method has been renamed to `listWorkflowRuns()`. This change aligns with the convention that `list*` methods return collections.
|
|
@@ -94,6 +114,16 @@ To migrate, rename method calls from `getWorkflowRuns` to `listWorkflowRuns`.
|
|
|
94
114
|
+ const runs = await workflow.listWorkflowRuns({ fromDate, toDate });
|
|
95
115
|
```
|
|
96
116
|
|
|
117
|
+
:::tip[Codemod]
|
|
118
|
+
|
|
119
|
+
You can use Mastra's codemod CLI to update your code automatically:
|
|
120
|
+
|
|
121
|
+
```shell
|
|
122
|
+
npx @mastra/codemod@beta v1/workflow-list-runs .
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
:::
|
|
126
|
+
|
|
97
127
|
## Removed
|
|
98
128
|
|
|
99
129
|
### Legacy workflows export
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Next.js Quickstart"
|
|
3
|
+
description: "Get started with Mastra, Next.js, and AS SDK UI. Quickly."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Next.js Quickstart
|
|
7
|
+
|
|
8
|
+
In this quickstart, you'll build an AI agent with tool-calling capabilities using [Mastra](/docs/v1), then connect it to Next.js by importing and calling the agent directly within your routes.
|
|
9
|
+
|
|
10
|
+
You'll use [AI SDK UI](https://ai-sdk.dev/docs/ai-sdk-ui/overview) and [AI Elements](https://ai-sdk.dev/elements) to create a beautiful, interactive chat experience.
|
|
11
|
+
|
|
12
|
+
In ~5 minutes, you'll have a functional AI-powered app ready to extend with your own tools and logic.
|
|
13
|
+
|
|
14
|
+
<figure>
|
|
15
|
+

|
|
16
|
+
<figcaption class="text-sm text-center">What you'll build: an agent that can call a weather tool, display the JSON result, stream a weather summary in the chat UI, and persist conversation history across reloads.</figcaption>
|
|
17
|
+
</figure>
|
|
18
|
+
|
|
19
|
+
## Before you begin
|
|
20
|
+
|
|
21
|
+
* You'll need an API key from a supported [model provider](/models/v1). If you don't have a preference, use [OpenAI](https://platform.openai.com/api-keys).
|
|
22
|
+
|
|
23
|
+
## Create a new Next.js app
|
|
24
|
+
|
|
25
|
+
Run the following command to [create a new Next.js app](https://nextjs.org/docs/app/getting-started/installation):
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx create-next-app \
|
|
29
|
+
my-nextjs-agent \
|
|
30
|
+
--yes \
|
|
31
|
+
--ts \
|
|
32
|
+
--eslint \
|
|
33
|
+
--tailwind \
|
|
34
|
+
--src-dir \
|
|
35
|
+
--app \
|
|
36
|
+
--turbopack \
|
|
37
|
+
--no-react-compiler \
|
|
38
|
+
--no-import-alias
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This creates a project called `my-nextjs-agent`, but you can replace it with any name you want.
|
|
42
|
+
|
|
43
|
+
## Initialize Mastra
|
|
44
|
+
`cd` and run [`mastra init`](/reference/v1/cli/create-mastra).
|
|
45
|
+
|
|
46
|
+
When prompted, choose a provider (e.g. OpenAI) and enter your key:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
cd my-nextjs-agent
|
|
50
|
+
npx --force mastra@beta init
|
|
51
|
+
```
|
|
52
|
+
This creates a `src/mastra` folder with an example weather agent and the following files:
|
|
53
|
+
|
|
54
|
+
- `index.ts` - Mastra config, including memory
|
|
55
|
+
- `tools/weather-tool.ts` - a tool to fetch weather for a given location
|
|
56
|
+
- `agents/weather-agent.ts`- a weather agent with a prompt that uses the tool
|
|
57
|
+
|
|
58
|
+
You'll call `weather-agent.ts` from your Next.js routes in the next steps.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
## Install AI SDK UI and AI Elements
|
|
62
|
+
|
|
63
|
+
Install AI SDK UI along with the Mastra adapter:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm install \
|
|
67
|
+
@mastra/ai-sdk \
|
|
68
|
+
@ai-sdk/react
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Next, initialize AI Elements. When prompted, choose the default options:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx ai-elements@latest
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
This downloads the entire AI Elements UI component library into a `@/components/ai-elements` folder.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
## Create a chat route
|
|
81
|
+
|
|
82
|
+
Create `src/app/api/chat/route.ts`:
|
|
83
|
+
|
|
84
|
+
```ts title="src/app/api/chat/route.ts"
|
|
85
|
+
import { mastra } from "@/mastra";
|
|
86
|
+
import { NextResponse } from "next/server";
|
|
87
|
+
import { toAISdkFormat } from "@mastra/ai-sdk";
|
|
88
|
+
import { convertMessages } from "@mastra/core/agent";
|
|
89
|
+
import { createUIMessageStreamResponse } from "ai";
|
|
90
|
+
|
|
91
|
+
const weatherAgent = mastra.getAgent("weatherAgent");
|
|
92
|
+
|
|
93
|
+
export async function POST(req: Request) {
|
|
94
|
+
const { messages } = await req.json();
|
|
95
|
+
|
|
96
|
+
const stream = await weatherAgent.stream(messages, {
|
|
97
|
+
memory: {
|
|
98
|
+
thread: "example-user-id",
|
|
99
|
+
resource: "weather-chat",
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return createUIMessageStreamResponse({
|
|
104
|
+
stream: toAISdkFormat(stream, { from: "agent" }),
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export async function GET() {
|
|
109
|
+
const memory = await weatherAgent.getMemory();
|
|
110
|
+
const response = await memory?.query({
|
|
111
|
+
threadId: "example-user-id",
|
|
112
|
+
resourceId: "weather-chat",
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const uiMessages =
|
|
116
|
+
convertMessages(response?.uiMessages ?? []).to("AIV5.UI");
|
|
117
|
+
return NextResponse.json(uiMessages);
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The POST route accepts a prompt and streams the agent's response back in AI SDK format, while the GET route fetches message history from memory so the UI can be hydrated when the client reloads.
|
|
122
|
+
|
|
123
|
+
## Create a chat page
|
|
124
|
+
|
|
125
|
+
Create `src/app/chat/page.tsx`:
|
|
126
|
+
|
|
127
|
+
```tsx title="src/app/chat/page.tsx"
|
|
128
|
+
'use client';
|
|
129
|
+
|
|
130
|
+
import '@/app/globals.css';
|
|
131
|
+
import { useEffect, useState } from 'react';
|
|
132
|
+
import { DefaultChatTransport } from 'ai';
|
|
133
|
+
import { useChat } from '@ai-sdk/react';
|
|
134
|
+
|
|
135
|
+
import {
|
|
136
|
+
PromptInput,
|
|
137
|
+
PromptInputBody,
|
|
138
|
+
PromptInputTextarea,
|
|
139
|
+
} from '@/components/ai-elements/prompt-input';
|
|
140
|
+
|
|
141
|
+
import {
|
|
142
|
+
Conversation,
|
|
143
|
+
ConversationContent,
|
|
144
|
+
ConversationScrollButton,
|
|
145
|
+
} from '@/components/ai-elements/conversation';
|
|
146
|
+
|
|
147
|
+
import { Message, MessageContent, MessageResponse } from '@/components/ai-elements/message';
|
|
148
|
+
|
|
149
|
+
import {
|
|
150
|
+
Tool,
|
|
151
|
+
ToolHeader,
|
|
152
|
+
ToolContent,
|
|
153
|
+
ToolInput,
|
|
154
|
+
ToolOutput,
|
|
155
|
+
} from '@/components/ai-elements/tool';
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
function Chat() {
|
|
159
|
+
const [input, setInput] = useState<string>('');
|
|
160
|
+
|
|
161
|
+
const { messages, setMessages, sendMessage, status } = useChat({
|
|
162
|
+
transport: new DefaultChatTransport({
|
|
163
|
+
api: '/api/chat',
|
|
164
|
+
}),
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
const fetchMessages = async () => {
|
|
169
|
+
const res = await fetch('/api/chat');
|
|
170
|
+
const data = await res.json();
|
|
171
|
+
setMessages([...data]);
|
|
172
|
+
};
|
|
173
|
+
fetchMessages();
|
|
174
|
+
}, [setMessages]);
|
|
175
|
+
|
|
176
|
+
const handleSubmit = async () => {
|
|
177
|
+
if (!input.trim()) return;
|
|
178
|
+
|
|
179
|
+
sendMessage({ text: input });
|
|
180
|
+
setInput('');
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
return (
|
|
184
|
+
<div className="w-full p-6 relative size-full h-screen">
|
|
185
|
+
<div className="flex flex-col h-full">
|
|
186
|
+
<Conversation className="h-full">
|
|
187
|
+
<ConversationContent>
|
|
188
|
+
{messages.map((message: any) => (
|
|
189
|
+
<div key={message.id}>
|
|
190
|
+
{message.parts?.map((part: any, i: number) => {
|
|
191
|
+
if (part.type === 'text') {
|
|
192
|
+
return (
|
|
193
|
+
<Message
|
|
194
|
+
key={`${message.id}-${i}`}
|
|
195
|
+
from={message.role}>
|
|
196
|
+
<MessageContent>
|
|
197
|
+
<MessageResponse>{part.text}</MessageResponse>
|
|
198
|
+
</MessageContent>
|
|
199
|
+
</Message>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (part.type?.startsWith('tool-')) {
|
|
204
|
+
return (
|
|
205
|
+
<Tool key={`${message.id}-${i}`}>
|
|
206
|
+
<ToolHeader
|
|
207
|
+
type={part.type}
|
|
208
|
+
state={part.state || 'output-available'}
|
|
209
|
+
className="cursor-pointer"
|
|
210
|
+
/>
|
|
211
|
+
<ToolContent>
|
|
212
|
+
<ToolInput input={part.input || part.args || {}} />
|
|
213
|
+
<ToolOutput
|
|
214
|
+
output={part.output || part.result}
|
|
215
|
+
errorText={part.errorText || part.error}
|
|
216
|
+
/>
|
|
217
|
+
</ToolContent>
|
|
218
|
+
</Tool>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return null;
|
|
223
|
+
})}
|
|
224
|
+
</div>
|
|
225
|
+
))}
|
|
226
|
+
<ConversationScrollButton />
|
|
227
|
+
</ConversationContent>
|
|
228
|
+
</Conversation>
|
|
229
|
+
|
|
230
|
+
<PromptInput onSubmit={handleSubmit} className="mt-20">
|
|
231
|
+
<PromptInputBody>
|
|
232
|
+
<PromptInputTextarea
|
|
233
|
+
onChange={(e: any) => setInput(e.target.value)}
|
|
234
|
+
className="md:leading-10"
|
|
235
|
+
value={input}
|
|
236
|
+
placeholder="Type your message..."
|
|
237
|
+
disabled={status !== 'ready'}
|
|
238
|
+
/>
|
|
239
|
+
</PromptInputBody>
|
|
240
|
+
</PromptInput>
|
|
241
|
+
</div>
|
|
242
|
+
</div>
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export default Chat;
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
This component connects [`useChat()`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat) to the `api/chat` endpoint, sending prompts there and streaming the response back in chunks.
|
|
250
|
+
|
|
251
|
+
It renders the response text using the [`<MessageResponse>`](https://ai-sdk.dev/elements/components/message#messageresponse-) component, and shows any tool invocations with the [`<Tool>`](https://ai-sdk.dev/elements/components/tool) component.
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
## Test your agent
|
|
255
|
+
1. Run your Next.js app with `npm run dev`
|
|
256
|
+
|
|
257
|
+
2. Open the chat at http://localhost:3000/chat
|
|
258
|
+
|
|
259
|
+
3. Try asking about the weather. If your API key is set up correctly, you'll get a response.
|
|
260
|
+
|
|
261
|
+
## Next steps
|
|
262
|
+
|
|
263
|
+
Congratulations on building your Mastra agent with Next.js! 🎉
|
|
264
|
+
|
|
265
|
+
From here, you can extend the project with your own tools and logic:
|
|
266
|
+
|
|
267
|
+
- Learn more about [agents](/docs/v1/agents/overview)
|
|
268
|
+
- Give your agent its own [tools](/docs/v1/agents/using-tools)
|
|
269
|
+
- Add human-like [memory](/docs/v1/agents/agent-memory) to your agent
|
|
270
|
+
|
|
271
|
+
When you're ready, read more about how Mastra integrates with AI SDK and Next.js, and how to deploy to Vercel:
|
|
272
|
+
|
|
273
|
+
- Integrate Mastra with [AI SDK](/docs/v1/frameworks/agentic-uis/ai-sdk)
|
|
274
|
+
- Use Mastra in your [Next.js app](/docs/v1/frameworks/web-frameworks/next-js)
|
|
275
|
+
- Deploy your agent to [Vercel](/docs/v1/deployment/serverless-platforms/vercel-deployer)
|
package/.docs/raw/index.mdx
CHANGED
|
@@ -27,7 +27,7 @@ Some highlights include:
|
|
|
27
27
|
|
|
28
28
|
- [**Workflows**](/docs/v1/workflows/overview) - When you need explicit control over execution, use Mastra's graph-based workflow engine to orchestrate complex multi-step processes. Mastra workflows use an intuitive syntax for control flow (`.then()`, `.branch()`, `.parallel()`).
|
|
29
29
|
|
|
30
|
-
- [**Human-in-the-loop**]/docs/v1/workflows/suspend-and-resume) - Suspend an agent or workflow and await user input or approval before resuming. Mastra uses [storage](/docs/v1/server-db/storage) to remember execution state, so you can pause indefinitely and resume where you left off.
|
|
30
|
+
- [**Human-in-the-loop**](/docs/v1/workflows/suspend-and-resume) - Suspend an agent or workflow and await user input or approval before resuming. Mastra uses [storage](/docs/v1/server-db/storage) to remember execution state, so you can pause indefinitely and resume where you left off.
|
|
31
31
|
|
|
32
32
|
- **Context management** - Give your agents the right context at the right time. Provide [conversation history](/docs/v1/memory/conversation-history), [retrieve](/docs/v1/rag/overview) data from your sources (APIs, databases, files), and add human-like [working](/docs/v1/memory/working-memory) and [semantic](/docs/v1/memory/semantic-recall) memory so your agents behave coherently.
|
|
33
33
|
|
package/.docs/raw/logging.mdx
CHANGED
|
@@ -7,11 +7,11 @@ description: Learn how to use logging in Mastra to monitor execution, capture ap
|
|
|
7
7
|
|
|
8
8
|
Mastra's logging system captures function execution, input data, and output responses in a structured format.
|
|
9
9
|
|
|
10
|
-
When deploying to Mastra Cloud, logs are shown on the [Logs]/docs/v1/mastra-cloud/observability) page. In self-hosted or custom environments, logs can be directed to files or external services depending on the configured transports.
|
|
10
|
+
When deploying to Mastra Cloud, logs are shown on the [Logs](/docs/v1/mastra-cloud/observability) 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
|
-
When [initializing a new Mastra project]/docs/v1/getting-started/installation) using the CLI, `PinoLogger` is included by default.
|
|
14
|
+
When [initializing a new Mastra project](/docs/v1/getting-started/installation) using the CLI, `PinoLogger` is included by default.
|
|
15
15
|
|
|
16
16
|
```typescript title="src/mastra/index.ts" showLineNumbers copy
|
|
17
17
|
import { Mastra } from "@mastra/core";
|
|
@@ -26,7 +26,7 @@ export const mastra = new Mastra({
|
|
|
26
26
|
});
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
> See the [PinoLogger]/reference/v1/logging/pino-logger) API reference for all available configuration options.
|
|
29
|
+
> See the [PinoLogger](/reference/v1/logging/pino-logger) API reference for all available configuration options.
|
|
30
30
|
|
|
31
31
|
## Logging from workflows and tools
|
|
32
32
|
|
|
@@ -13,7 +13,7 @@ Mastra Cloud captures execution data to help you monitor your application's beha
|
|
|
13
13
|
|
|
14
14
|
## Logs
|
|
15
15
|
|
|
16
|
-
You can view detailed logs for debugging and monitoring your application's behavior on the [Logs]/docs/v1/mastra-cloud/dashboard#logs) page of the Dashboard.
|
|
16
|
+
You can view detailed logs for debugging and monitoring your application's behavior on the [Logs](/docs/v1/mastra-cloud/dashboard#logs) page of the Dashboard.
|
|
17
17
|
|
|
18
18
|

|
|
19
19
|
|
|
@@ -23,11 +23,11 @@ Each log entry includes its severity level and a detailed message showing agent,
|
|
|
23
23
|
|
|
24
24
|
## Traces
|
|
25
25
|
|
|
26
|
-
More detailed traces are available for both agents and workflows by using a [logger]/docs/v1/logging) or enabling [observability]/docs/v1/observability/tracing/overview) using one of our [supported providers]/docs/v1/observability/tracing/overview#exporters).
|
|
26
|
+
More detailed traces are available for both agents and workflows by using a [logger](/docs/v1/logging) or enabling [observability](/docs/v1/observability/tracing/overview) using one of our [supported providers](/docs/v1/observability/tracing/overview#exporters).
|
|
27
27
|
|
|
28
28
|
### Agents
|
|
29
29
|
|
|
30
|
-
With a [logger]/docs/v1/logging) enabled, you can view detailed outputs from your agents in the **Traces** section in Studio.
|
|
30
|
+
With a [logger](/docs/v1/logging) enabled, you can view detailed outputs from your agents in the **Traces** section in Studio.
|
|
31
31
|
|
|
32
32
|

|
|
33
33
|
|
|
@@ -37,7 +37,7 @@ Tools passed to the agent during generation are standardized using `convertTools
|
|
|
37
37
|
|
|
38
38
|
### Workflows
|
|
39
39
|
|
|
40
|
-
With a [logger]/docs/v1/logging) enabled, you can view detailed outputs from your workflows in the **Traces** section in Studio.
|
|
40
|
+
With a [logger](/docs/v1/logging) enabled, you can view detailed outputs from your workflows in the **Traces** section in Studio.
|
|
41
41
|
|
|
42
42
|

|
|
43
43
|
|
|
@@ -47,5 +47,5 @@ Workflows are created using `createWorkflow`, which sets up steps, metadata, and
|
|
|
47
47
|
|
|
48
48
|
## Next steps
|
|
49
49
|
|
|
50
|
-
- [Logging]/docs/v1/logging)
|
|
51
|
-
- [Tracing]/docs/v1/observability/tracing/overview)
|
|
50
|
+
- [Logging](/docs/v1/logging)
|
|
51
|
+
- [Tracing](/docs/v1/observability/tracing/overview)
|
|
@@ -16,7 +16,7 @@ Mastra's memory system uses [storage providers](#memory-storage-adapters) to per
|
|
|
16
16
|
First install the required dependencies:
|
|
17
17
|
|
|
18
18
|
```bash copy
|
|
19
|
-
npm install @mastra/core @mastra/memory @mastra/libsql
|
|
19
|
+
npm install @mastra/core@beta @mastra/memory@beta @mastra/libsql@beta
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
Then add a storage adapter to the main Mastra instance. Any agent with memory enabled will use this shared storage to store and recall interactions.
|
|
@@ -69,7 +69,7 @@ All memory types are [resource-scoped](./working-memory#resource-scoped-memory-d
|
|
|
69
69
|
|
|
70
70
|
To persist and recall information between conversations, memory requires a storage adapter.
|
|
71
71
|
|
|
72
|
-
Supported options include [LibSQL](/docs/v1/memory/storage/memory-with-libsql), [MongoDB](/
|
|
72
|
+
Supported options include [LibSQL](/docs/v1/memory/storage/memory-with-libsql), [MongoDB](/docs/v1/memory/storage/memory-with-mongodb), [Postgres](/docs/v1/memory/storage/memory-with-pg), and [Upstash](/docs/v1/memory/storage/memory-with-upstash)
|
|
73
73
|
|
|
74
74
|
We use LibSQL out of the box because it is file-based or in-memory, so it is easy to install and works well with Studio.
|
|
75
75
|
|
|
@@ -94,7 +94,7 @@ const agent = new Agent({
|
|
|
94
94
|
**Storage/vector code Examples**:
|
|
95
95
|
|
|
96
96
|
- [LibSQL](/docs/v1/memory/storage/memory-with-libsql)
|
|
97
|
-
- [MongoDB](/
|
|
97
|
+
- [MongoDB](/docs/v1/memory/storage/memory-with-mongodb)
|
|
98
98
|
- [Postgres](/docs/v1/memory/storage/memory-with-pg)
|
|
99
99
|
- [Upstash](/docs/v1/memory/storage/memory-with-upstash)
|
|
100
100
|
|
|
@@ -147,7 +147,7 @@ const agent = new Agent({
|
|
|
147
147
|
To use FastEmbed (a local embedding model), install `@mastra/fastembed`:
|
|
148
148
|
|
|
149
149
|
```bash npm2yarn copy
|
|
150
|
-
npm install @mastra/fastembed
|
|
150
|
+
npm install @mastra/fastembed@beta
|
|
151
151
|
```
|
|
152
152
|
|
|
153
153
|
Then configure it in your memory:
|
|
@@ -18,7 +18,7 @@ OPENAI_API_KEY=<your-api-key>
|
|
|
18
18
|
And install the following package:
|
|
19
19
|
|
|
20
20
|
```bash copy
|
|
21
|
-
npm install @mastra/libsql
|
|
21
|
+
npm install @mastra/libsql@beta
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
## Adding memory to an agent
|
|
@@ -56,7 +56,7 @@ Embeddings are numeric vectors used by memory’s `semanticRecall` to retrieve r
|
|
|
56
56
|
Install `fastembed` to get started:
|
|
57
57
|
|
|
58
58
|
```bash copy
|
|
59
|
-
npm install @mastra/fastembed
|
|
59
|
+
npm install @mastra/fastembed@beta
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
Add the following to your agent:
|