@mastra/mcp-docs-server 1.0.0-beta.4 → 1.0.0-beta.5
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 +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +326 -126
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Flance.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Frag.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Freact.md +80 -1
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +36 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +92 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +67 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +201 -1
- package/.docs/organized/changelogs/create-mastra.md +201 -1
- package/.docs/organized/changelogs/mastra.md +201 -1
- package/.docs/organized/code-examples/memory-with-processors.md +1 -1
- package/.docs/organized/code-examples/quick-start.md +1 -1
- package/.docs/raw/agents/adding-voice.mdx +7 -10
- package/.docs/raw/agents/guardrails.mdx +19 -20
- package/.docs/raw/agents/human-in-the-loop-with-tools.mdx +6 -5
- package/.docs/raw/agents/networks.mdx +1 -2
- package/.docs/raw/agents/overview.mdx +5 -5
- package/.docs/raw/agents/using-tools.mdx +4 -5
- package/.docs/raw/course/01-first-agent/05-running-playground.md +5 -5
- package/.docs/raw/course/01-first-agent/09-testing-your-agent.md +3 -3
- package/.docs/raw/course/01-first-agent/13-testing-your-tool.md +3 -3
- package/.docs/raw/course/01-first-agent/17-testing-memory.md +2 -2
- package/.docs/raw/course/04-workflows/07-using-playground.md +1 -1
- package/.docs/raw/deployment/building-mastra.mdx +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 +1 -1
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/index.mdx +1 -1
- package/.docs/raw/deployment/mastra-cloud/observability.mdx +19 -17
- package/.docs/raw/deployment/mastra-cloud/setting-up.mdx +1 -1
- package/.docs/raw/deployment/overview.mdx +2 -2
- package/.docs/raw/deployment/web-framework.mdx +5 -5
- package/.docs/raw/evals/custom-scorers.mdx +3 -5
- package/.docs/raw/evals/overview.mdx +2 -3
- package/.docs/raw/getting-started/project-structure.mdx +1 -1
- package/.docs/raw/getting-started/start.mdx +72 -0
- package/.docs/raw/getting-started/studio.mdx +1 -1
- package/.docs/raw/{frameworks/agentic-uis/ai-sdk.mdx → guides/build-your-ui/ai-sdk-ui.mdx} +105 -11
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/astro.mdx +23 -25
- package/.docs/raw/{frameworks/servers → guides/getting-started}/express.mdx +3 -4
- package/.docs/raw/guides/{guide → getting-started}/manual-install.mdx +1 -1
- package/.docs/raw/guides/{quickstarts/nextjs.mdx → getting-started/next-js.mdx} +11 -11
- package/.docs/raw/guides/{quickstarts/standalone-server.mdx → getting-started/quickstart.mdx} +7 -7
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/sveltekit.mdx +23 -25
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/vite-react.mdx +7 -7
- package/.docs/raw/guides/guide/ai-recruiter.mdx +2 -3
- package/.docs/raw/guides/guide/chef-michel.mdx +2 -3
- package/.docs/raw/guides/guide/notes-mcp-server.mdx +2 -2
- package/.docs/raw/guides/guide/research-assistant.mdx +7 -8
- package/.docs/raw/guides/guide/stock-agent.mdx +4 -6
- package/.docs/raw/guides/guide/web-search.mdx +12 -10
- package/.docs/raw/guides/migrations/agentnetwork.mdx +4 -4
- package/.docs/raw/guides/migrations/ai-sdk-v4-to-v5.mdx +1 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +29 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/tools.mdx +5 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +22 -0
- package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +2 -2
- package/.docs/raw/index.mdx +2 -2
- package/.docs/raw/mcp/overview.mdx +3 -5
- package/.docs/raw/memory/memory-processors.mdx +1 -2
- package/.docs/raw/memory/semantic-recall.mdx +7 -7
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +2 -4
- package/.docs/raw/memory/storage/memory-with-mongodb.mdx +2 -4
- package/.docs/raw/memory/storage/memory-with-pg.mdx +2 -4
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +2 -4
- package/.docs/raw/memory/threads-and-resources.mdx +3 -3
- package/.docs/raw/memory/working-memory.mdx +4 -5
- package/.docs/raw/{logging.mdx → observability/logging.mdx} +1 -1
- package/.docs/raw/observability/overview.mdx +2 -2
- package/.docs/raw/observability/tracing/exporters/otel.mdx +21 -2
- package/.docs/raw/observability/tracing/exporters/posthog.mdx +107 -0
- package/.docs/raw/observability/tracing/overview.mdx +3 -2
- package/.docs/raw/rag/chunking-and-embedding.mdx +16 -17
- package/.docs/raw/rag/overview.mdx +3 -2
- package/.docs/raw/rag/retrieval.mdx +20 -32
- package/.docs/raw/reference/agents/agent.mdx +7 -10
- package/.docs/raw/reference/agents/generateLegacy.mdx +2 -2
- package/.docs/raw/reference/agents/getLLM.mdx +1 -1
- package/.docs/raw/reference/agents/network.mdx +2 -3
- package/.docs/raw/reference/cli/mastra.mdx +2 -1
- package/.docs/raw/reference/client-js/agents.mdx +3 -3
- package/.docs/raw/reference/core/getLogger.mdx +1 -1
- package/.docs/raw/reference/core/listLogs.mdx +1 -1
- package/.docs/raw/reference/core/listLogsByRunId.mdx +1 -1
- package/.docs/raw/reference/core/mastra-model-gateway.mdx +5 -19
- package/.docs/raw/reference/core/setLogger.mdx +1 -1
- package/.docs/raw/reference/core/setTelemetry.mdx +1 -1
- package/.docs/raw/reference/evals/answer-relevancy.mdx +28 -98
- package/.docs/raw/reference/evals/answer-similarity.mdx +12 -258
- package/.docs/raw/reference/evals/bias.mdx +29 -87
- package/.docs/raw/reference/evals/completeness.mdx +31 -90
- package/.docs/raw/reference/evals/content-similarity.mdx +28 -88
- package/.docs/raw/reference/evals/context-precision.mdx +28 -130
- package/.docs/raw/reference/evals/context-relevance.mdx +11 -11
- package/.docs/raw/reference/evals/faithfulness.mdx +28 -101
- package/.docs/raw/reference/evals/hallucination.mdx +28 -103
- package/.docs/raw/reference/evals/keyword-coverage.mdx +28 -107
- package/.docs/raw/reference/evals/noise-sensitivity.mdx +11 -11
- package/.docs/raw/reference/evals/prompt-alignment.mdx +15 -15
- package/.docs/raw/reference/evals/textual-difference.mdx +27 -100
- package/.docs/raw/reference/evals/tone-consistency.mdx +25 -98
- package/.docs/raw/reference/evals/tool-call-accuracy.mdx +7 -7
- package/.docs/raw/reference/evals/toxicity.mdx +29 -92
- package/.docs/raw/reference/memory/memory-class.mdx +5 -7
- package/.docs/raw/reference/observability/tracing/exporters/posthog.mdx +132 -0
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +1 -1
- package/.docs/raw/reference/processors/language-detector.mdx +1 -1
- package/.docs/raw/reference/processors/moderation-processor.mdx +2 -2
- package/.docs/raw/reference/processors/pii-detector.mdx +2 -2
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +1 -1
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +2 -3
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +2 -2
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +1 -1
- package/.docs/raw/reference/rag/embeddings.mdx +5 -5
- package/.docs/raw/reference/rag/rerank.mdx +1 -2
- package/.docs/raw/reference/rag/rerankWithScorer.mdx +0 -1
- package/.docs/raw/reference/streaming/agents/stream.mdx +8 -1
- package/.docs/raw/reference/templates/overview.mdx +1 -4
- package/.docs/raw/reference/tools/client.mdx +1 -2
- package/.docs/raw/reference/tools/create-tool.mdx +132 -0
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +5 -5
- package/.docs/raw/reference/tools/mcp-client.mdx +2 -4
- package/.docs/raw/reference/tools/mcp-server.mdx +1 -2
- package/.docs/raw/reference/tools/vector-query-tool.mdx +14 -15
- package/.docs/raw/reference/vectors/chroma.mdx +81 -1
- package/.docs/raw/reference/vectors/couchbase.mdx +24 -17
- package/.docs/raw/reference/vectors/lance.mdx +38 -22
- package/.docs/raw/reference/vectors/libsql.mdx +35 -2
- package/.docs/raw/reference/vectors/mongodb.mdx +35 -2
- package/.docs/raw/reference/vectors/opensearch.mdx +37 -16
- package/.docs/raw/reference/vectors/pg.mdx +43 -36
- package/.docs/raw/reference/vectors/pinecone.mdx +48 -1
- package/.docs/raw/reference/vectors/qdrant.mdx +36 -1
- package/.docs/raw/reference/vectors/turbopuffer.mdx +74 -0
- package/.docs/raw/reference/voice/openai-realtime.mdx +2 -2
- package/.docs/raw/reference/voice/voice.addInstructions.mdx +2 -3
- package/.docs/raw/reference/voice/voice.addTools.mdx +1 -1
- package/.docs/raw/reference/voice/voice.answer.mdx +1 -1
- package/.docs/raw/reference/voice/voice.close.mdx +1 -1
- package/.docs/raw/reference/voice/voice.connect.mdx +1 -1
- package/.docs/raw/reference/voice/voice.off.mdx +1 -1
- package/.docs/raw/reference/voice/voice.on.mdx +1 -1
- package/.docs/raw/reference/voice/voice.send.mdx +1 -1
- package/.docs/raw/reference/voice/voice.updateConfig.mdx +1 -1
- package/.docs/raw/server-db/mastra-client.mdx +1 -2
- package/.docs/raw/streaming/overview.mdx +20 -9
- package/.docs/raw/streaming/tool-streaming.mdx +47 -4
- package/.docs/raw/tools-mcp/advanced-usage.mdx +1 -2
- package/.docs/raw/tools-mcp/mcp-overview.mdx +3 -5
- package/.docs/raw/voice/overview.mdx +21 -41
- package/.docs/raw/voice/speech-to-speech.mdx +4 -4
- package/.docs/raw/voice/speech-to-text.mdx +1 -2
- package/.docs/raw/voice/text-to-speech.mdx +1 -2
- package/.docs/raw/workflows/control-flow.mdx +180 -0
- package/CHANGELOG.md +10 -0
- package/dist/{chunk-5NJC7NRO.js → chunk-4CM2BQNP.js} +24 -4
- package/dist/prepare-docs/package-changes.d.ts.map +1 -1
- package/dist/prepare-docs/prepare.js +1 -1
- package/dist/stdio.js +1 -1
- package/package.json +7 -7
- package/.docs/raw/frameworks/agentic-uis/cedar-os.mdx +0 -102
- package/.docs/raw/frameworks/agentic-uis/openrouter.mdx +0 -179
- package/.docs/raw/frameworks/web-frameworks/next-js.mdx +0 -379
- package/.docs/raw/getting-started/quickstart.mdx +0 -27
- package/.docs/raw/getting-started/templates.mdx +0 -73
- /package/.docs/raw/{frameworks/agentic-uis → guides/build-your-ui}/assistant-ui.mdx +0 -0
- /package/.docs/raw/{frameworks/agentic-uis → guides/build-your-ui}/copilotkit.mdx +0 -0
|
@@ -22,8 +22,7 @@ Use processors for content moderation, prompt injection prevention, response san
|
|
|
22
22
|
|
|
23
23
|
Import and instantiate the relevant processor class, and pass it to your agent’s configuration using either the `inputProcessors` or `outputProcessors` option:
|
|
24
24
|
|
|
25
|
-
```typescript {
|
|
26
|
-
import { openai } from "@ai-sdk/openai";
|
|
25
|
+
```typescript {2,8-16} title="src/mastra/agents/moderated-agent.ts" showLineNumbers copy
|
|
27
26
|
import { Agent } from "@mastra/core/agent";
|
|
28
27
|
import { ModerationProcessor } from "@mastra/core/processors";
|
|
29
28
|
|
|
@@ -31,10 +30,10 @@ export const moderatedAgent = new Agent({
|
|
|
31
30
|
id: "moderated-agent",
|
|
32
31
|
name: "Moderated Agent",
|
|
33
32
|
instructions: "You are a helpful assistant",
|
|
34
|
-
model: openai
|
|
33
|
+
model: "openai/gpt-5.1",
|
|
35
34
|
inputProcessors: [
|
|
36
35
|
new ModerationProcessor({
|
|
37
|
-
model: openai
|
|
36
|
+
model: "openai/gpt-4.1-nano",
|
|
38
37
|
categories: ["hate", "harassment", "violence"],
|
|
39
38
|
threshold: 0.7,
|
|
40
39
|
strategy: "block",
|
|
@@ -52,7 +51,7 @@ Input processors are applied before user messages reach the language model. They
|
|
|
52
51
|
|
|
53
52
|
The `UnicodeNormalizer` is an input processor that cleans and normalizes user input by unifying Unicode characters, standardizing whitespace, and removing problematic symbols, allowing the LLM to better understand user messages.
|
|
54
53
|
|
|
55
|
-
```typescript {
|
|
54
|
+
```typescript {8-11} title="src/mastra/agents/normalized-agent.ts" showLineNumbers copy
|
|
56
55
|
import { UnicodeNormalizer } from "@mastra/core/processors";
|
|
57
56
|
|
|
58
57
|
export const normalizedAgent = new Agent({
|
|
@@ -74,7 +73,7 @@ export const normalizedAgent = new Agent({
|
|
|
74
73
|
|
|
75
74
|
The `PromptInjectionDetector` is an input processor that scans user messages for prompt injection, jailbreak attempts, and system override patterns. It uses an LLM to classify risky input and can block or rewrite it before it reaches the model.
|
|
76
75
|
|
|
77
|
-
```typescript {
|
|
76
|
+
```typescript {8-13} title="src/mastra/agents/secure-agent.ts" showLineNumbers copy
|
|
78
77
|
import { PromptInjectionDetector } from "@mastra/core/processors";
|
|
79
78
|
|
|
80
79
|
export const secureAgent = new Agent({
|
|
@@ -83,7 +82,7 @@ export const secureAgent = new Agent({
|
|
|
83
82
|
// ...
|
|
84
83
|
inputProcessors: [
|
|
85
84
|
new PromptInjectionDetector({
|
|
86
|
-
model: openai
|
|
85
|
+
model: "openai/gpt-4.1-nano",
|
|
87
86
|
threshold: 0.8,
|
|
88
87
|
strategy: "rewrite",
|
|
89
88
|
detectionTypes: ["injection", "jailbreak", "system-override"],
|
|
@@ -98,7 +97,7 @@ export const secureAgent = new Agent({
|
|
|
98
97
|
|
|
99
98
|
The `LanguageDetector` is an input processor that detects and translates user messages into a target language, enabling multilingual support while maintaining consistent interaction. It uses an LLM to identify the language and perform the translation.
|
|
100
99
|
|
|
101
|
-
```typescript {
|
|
100
|
+
```typescript {8-13} title="src/mastra/agents/multilingual-agent.ts" showLineNumbers copy
|
|
102
101
|
import { LanguageDetector } from "@mastra/core/processors";
|
|
103
102
|
|
|
104
103
|
export const multilingualAgent = new Agent({
|
|
@@ -107,7 +106,7 @@ export const multilingualAgent = new Agent({
|
|
|
107
106
|
// ...
|
|
108
107
|
inputProcessors: [
|
|
109
108
|
new LanguageDetector({
|
|
110
|
-
model: openai
|
|
109
|
+
model: "openai/gpt-4.1-nano",
|
|
111
110
|
targetLanguages: ["English", "en"],
|
|
112
111
|
strategy: "translate",
|
|
113
112
|
threshold: 0.8,
|
|
@@ -126,7 +125,7 @@ Output processors are applied after the language model generates a response, but
|
|
|
126
125
|
|
|
127
126
|
The `BatchPartsProcessor` is an output processor that combines multiple stream parts before emitting them to the client. This reduces network overhead and improves the user experience by consolidating small chunks into larger batches.
|
|
128
127
|
|
|
129
|
-
```typescript {
|
|
128
|
+
```typescript {8-12} title="src/mastra/agents/batched-agent.ts" showLineNumbers copy
|
|
130
129
|
import { BatchPartsProcessor } from "@mastra/core/processors";
|
|
131
130
|
|
|
132
131
|
export const batchedAgent = new Agent({
|
|
@@ -149,7 +148,7 @@ export const batchedAgent = new Agent({
|
|
|
149
148
|
|
|
150
149
|
The `TokenLimiterProcessor` is an output processor that limits the number of tokens in model responses. It helps manage cost and performance by truncating or blocking messages when the limit is exceeded.
|
|
151
150
|
|
|
152
|
-
```typescript {
|
|
151
|
+
```typescript {8-12} title="src/mastra/agents/limited-agent.ts" showLineNumbers copy
|
|
153
152
|
import { TokenLimiterProcessor } from "@mastra/core/processors";
|
|
154
153
|
|
|
155
154
|
export const limitedAgent = new Agent({
|
|
@@ -172,7 +171,7 @@ export const limitedAgent = new Agent({
|
|
|
172
171
|
|
|
173
172
|
The `SystemPromptScrubber` is an output processor that detects and redacts system prompts or other internal instructions from model responses. It helps prevent unintended disclosure of prompt content or configuration details that could introduce security risks. It uses an LLM to identify and redact sensitive content based on configured detection types.
|
|
174
173
|
|
|
175
|
-
```typescript {
|
|
174
|
+
```typescript {7-16} title="src/mastra/agents/scrubbed-agent.ts" copy showLineNumbers
|
|
176
175
|
import { SystemPromptScrubber } from "@mastra/core/processors";
|
|
177
176
|
|
|
178
177
|
const scrubbedAgent = new Agent({
|
|
@@ -180,7 +179,7 @@ const scrubbedAgent = new Agent({
|
|
|
180
179
|
name: "Scrubbed Agent",
|
|
181
180
|
outputProcessors: [
|
|
182
181
|
new SystemPromptScrubber({
|
|
183
|
-
model: openai
|
|
182
|
+
model: "openai/gpt-4.1-nano",
|
|
184
183
|
strategy: "redact",
|
|
185
184
|
customPatterns: ["system prompt", "internal instructions"],
|
|
186
185
|
includeDetections: true,
|
|
@@ -203,7 +202,7 @@ Hybrid processors can be applied either before messages are sent to the language
|
|
|
203
202
|
|
|
204
203
|
The `ModerationProcessor` is a hybrid processor that detects inappropriate or harmful content across categories like hate, harassment, and violence. It can be used to moderate either user input or model output, depending on where it's applied. It uses an LLM to classify the message and can block or rewrite it based on your configuration.
|
|
205
204
|
|
|
206
|
-
```typescript {
|
|
205
|
+
```typescript {8-13,16-18} title="src/mastra/agents/moderated-agent.ts" showLineNumbers copy
|
|
207
206
|
import { ModerationProcessor } from "@mastra/core/processors";
|
|
208
207
|
|
|
209
208
|
export const moderatedAgent = new Agent({
|
|
@@ -212,7 +211,7 @@ export const moderatedAgent = new Agent({
|
|
|
212
211
|
// ...
|
|
213
212
|
inputProcessors: [
|
|
214
213
|
new ModerationProcessor({
|
|
215
|
-
model: openai
|
|
214
|
+
model: "openai/gpt-4.1-nano",
|
|
216
215
|
threshold: 0.7,
|
|
217
216
|
strategy: "block",
|
|
218
217
|
categories: ["hate", "harassment", "violence"],
|
|
@@ -232,7 +231,7 @@ export const moderatedAgent = new Agent({
|
|
|
232
231
|
|
|
233
232
|
The `PIIDetector` is a hybrid processor that detects and removes personally identifiable information such as emails, phone numbers, and credit cards. It can redact either user input or model output, depending on where it's applied. It uses an LLM to identify sensitive content based on configured detection types.
|
|
234
233
|
|
|
235
|
-
```typescript {
|
|
234
|
+
```typescript {8-15,18-20} title="src/mastra/agents/private-agent.ts" showLineNumbers copy
|
|
236
235
|
import { PIIDetector } from "@mastra/core/processors";
|
|
237
236
|
|
|
238
237
|
export const privateAgent = new Agent({
|
|
@@ -241,7 +240,7 @@ export const privateAgent = new Agent({
|
|
|
241
240
|
// ...
|
|
242
241
|
inputProcessors: [
|
|
243
242
|
new PIIDetector({
|
|
244
|
-
model: openai
|
|
243
|
+
model: "openai/gpt-4.1-nano",
|
|
245
244
|
threshold: 0.6,
|
|
246
245
|
strategy: "redact",
|
|
247
246
|
redactionMethod: "mask",
|
|
@@ -306,7 +305,7 @@ Many of the built-in processors support a `strategy` parameter that controls how
|
|
|
306
305
|
|
|
307
306
|
Most strategies allow the request to continue without interruption. When `block` is used, the processor calls its internal `abort()` function, which immediately stops the request and prevents any subsequent processors from running.
|
|
308
307
|
|
|
309
|
-
```typescript {
|
|
308
|
+
```typescript {10} title="src/mastra/agents/private-agent.ts" showLineNumbers copy
|
|
310
309
|
import { PIIDetector } from "@mastra/core/processors";
|
|
311
310
|
|
|
312
311
|
export const privateAgent = new Agent({
|
|
@@ -330,7 +329,7 @@ For example, if an agent uses the `PIIDetector` with `strategy: "block"` and the
|
|
|
330
329
|
|
|
331
330
|
#### `.generate()` example
|
|
332
331
|
|
|
333
|
-
```typescript
|
|
332
|
+
```typescript showLineNumbers
|
|
334
333
|
const result = await agent.generate(
|
|
335
334
|
"Is this credit card number valid?: 4543 1374 5089 4332",
|
|
336
335
|
);
|
|
@@ -341,7 +340,7 @@ console.error(result.tripwireReason);
|
|
|
341
340
|
|
|
342
341
|
#### `.stream()` example
|
|
343
342
|
|
|
344
|
-
```typescript
|
|
343
|
+
```typescript showLineNumbers
|
|
345
344
|
const stream = await agent.stream(
|
|
346
345
|
"Is this credit card number valid?: 4543 1374 5089 4332",
|
|
347
346
|
);
|
|
@@ -59,13 +59,13 @@ const findUserTool = createTool({
|
|
|
59
59
|
resumeSchema: z.object({
|
|
60
60
|
name: z.string(),
|
|
61
61
|
}),
|
|
62
|
-
execute: async (inputData, {
|
|
63
|
-
if (!
|
|
64
|
-
return
|
|
62
|
+
execute: async (inputData, { agent }) => {
|
|
63
|
+
if (!agent.resumeData) {
|
|
64
|
+
return agent.suspend({ message: "Please provide the name of the user" });
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
return {
|
|
68
|
-
name:
|
|
68
|
+
name: agent?.resumeData?.name,
|
|
69
69
|
email: "test@test.com",
|
|
70
70
|
};
|
|
71
71
|
},
|
|
@@ -73,11 +73,12 @@ const findUserTool = createTool({
|
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
To continue execution, call `resumeStream` with the run’s `runId` and the `resumeData` that satisfies the `resumeSchema`. The workflow resumes from the suspension point and the tool completes with the new data.
|
|
76
|
+
When using `suspend` directly in the tool, you don't need to add `requireToolApproval: true` to the agent `stream`/`generate` call, nor `requireApproval: true` to the tool creation.
|
|
76
77
|
|
|
77
78
|
```typescript {1} title="Resume a suspended tool call" showLineNumbers copy
|
|
78
79
|
const resumedStream = await myAgent.resumeStream(
|
|
79
80
|
{ name: "John Smith" },
|
|
80
|
-
{ runId: stream.runId }
|
|
81
|
+
{ runId: stream.runId }
|
|
81
82
|
);
|
|
82
83
|
```
|
|
83
84
|
|
|
@@ -24,7 +24,6 @@ Mastra agent networks operate using these principles:
|
|
|
24
24
|
An agent network is built around a top-level routing agent that delegates tasks to agents, workflows, and tools defined in its configuration. Memory is configured on the routing agent using the `memory` option, and `instructions` define the agent's routing behavior.
|
|
25
25
|
|
|
26
26
|
```typescript {22-23,26,29} title="src/mastra/agents/routing-agent.ts" showLineNumbers copy
|
|
27
|
-
import { openai } from "@ai-sdk/openai";
|
|
28
27
|
import { Agent } from "@mastra/core/agent";
|
|
29
28
|
import { Memory } from "@mastra/memory";
|
|
30
29
|
import { LibSQLStore } from "@mastra/libsql";
|
|
@@ -44,7 +43,7 @@ export const routingAgent = new Agent({
|
|
|
44
43
|
Always respond with a complete report—no bullet points.
|
|
45
44
|
Write in full paragraphs, like a blog post.
|
|
46
45
|
Do not answer with incomplete or uncertain information.`,
|
|
47
|
-
model: openai
|
|
46
|
+
model: "openai/gpt-5.1",
|
|
48
47
|
agents: {
|
|
49
48
|
researchAgent,
|
|
50
49
|
writingAgent,
|
|
@@ -63,7 +63,7 @@ export const testAgent = new Agent({
|
|
|
63
63
|
id: "test-agent",
|
|
64
64
|
name: "Test Agent",
|
|
65
65
|
instructions: "You are a helpful assistant.",
|
|
66
|
-
model: "openai/gpt-
|
|
66
|
+
model: "openai/gpt-5.1",
|
|
67
67
|
});
|
|
68
68
|
```
|
|
69
69
|
|
|
@@ -112,7 +112,7 @@ export const testAgent = new Agent({
|
|
|
112
112
|
id: "test-agent",
|
|
113
113
|
name: "Test Agent",
|
|
114
114
|
instructions: "You are a helpful assistant.",
|
|
115
|
-
model: openai("gpt-
|
|
115
|
+
model: openai("gpt-5.1"),
|
|
116
116
|
});
|
|
117
117
|
```
|
|
118
118
|
|
|
@@ -320,7 +320,7 @@ const response = await testAgentWithTools.generate(
|
|
|
320
320
|
summary: z.string(),
|
|
321
321
|
keywords: z.array(z.string()),
|
|
322
322
|
}),
|
|
323
|
-
model: "openai/gpt-
|
|
323
|
+
model: "openai/gpt-5.1",
|
|
324
324
|
},
|
|
325
325
|
},
|
|
326
326
|
);
|
|
@@ -444,8 +444,8 @@ export const testAgent = new Agent({
|
|
|
444
444
|
const userTier = requestContext.get("user-tier") as UserTier["user-tier"];
|
|
445
445
|
|
|
446
446
|
return userTier === "enterprise"
|
|
447
|
-
? openai
|
|
448
|
-
: openai
|
|
447
|
+
? "openai/gpt-5"
|
|
448
|
+
: "openai/gpt-4.1-nano";
|
|
449
449
|
},
|
|
450
450
|
});
|
|
451
451
|
```
|
|
@@ -47,8 +47,7 @@ To make a tool available to an agent, add it to `tools`. Mentioning available to
|
|
|
47
47
|
|
|
48
48
|
An agent can use multiple tools to handle more complex tasks by delegating specific parts to individual tools. The agent decides which tools to use based on the user's message, the agent's instructions, and the tool descriptions and schemas.
|
|
49
49
|
|
|
50
|
-
```typescript {
|
|
51
|
-
import { openai } from "@ai-sdk/openai";
|
|
50
|
+
```typescript {8,10} title="src/mastra/agents/weather-agent.ts" showLineNumbers copy
|
|
52
51
|
import { Agent } from "@mastra/core/agent";
|
|
53
52
|
import { weatherTool } from "../tools/weather-tool";
|
|
54
53
|
|
|
@@ -58,7 +57,7 @@ export const weatherAgent = new Agent({
|
|
|
58
57
|
instructions: `
|
|
59
58
|
You are a helpful weather assistant.
|
|
60
59
|
Use the weatherTool to fetch current weather data.`,
|
|
61
|
-
model: openai
|
|
60
|
+
model: "openai/gpt-5.1",
|
|
62
61
|
tools: { weatherTool },
|
|
63
62
|
});
|
|
64
63
|
```
|
|
@@ -67,7 +66,7 @@ export const weatherAgent = new Agent({
|
|
|
67
66
|
|
|
68
67
|
The agent uses the tool's `inputSchema` to infer what data the tool expects. In this case, it extracts `London` as the `location` from the message and passes it to the tool's inputData parameter.
|
|
69
68
|
|
|
70
|
-
```typescript
|
|
69
|
+
```typescript title="src/test-tool.ts" showLineNumbers copy
|
|
71
70
|
import { mastra } from "./mastra";
|
|
72
71
|
|
|
73
72
|
const agent = mastra.getAgent("weatherAgent");
|
|
@@ -79,7 +78,7 @@ const result = await agent.generate("What's the weather in London?");
|
|
|
79
78
|
|
|
80
79
|
When multiple tools are available, the agent may choose to use one, several, or none, depending on what's needed to answer the query.
|
|
81
80
|
|
|
82
|
-
```typescript {
|
|
81
|
+
```typescript {8} title="src/mastra/agents/weather-agent.ts" showLineNumbers copy
|
|
83
82
|
import { weatherTool } from "../tools/weather-tool";
|
|
84
83
|
import { activitiesTool } from "../tools/activities-tool";
|
|
85
84
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
# Running
|
|
1
|
+
# Running Mastra Studio
|
|
2
2
|
|
|
3
|
-
To test your agent as you build it, you'll need to run the Mastra
|
|
3
|
+
To test your agent as you build it, you'll need to run the Mastra Studio:
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npm run dev
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
This will start the
|
|
9
|
+
This will start the studio at `http://localhost:4111`, where you can interact with your agent and test its capabilities.
|
|
10
10
|
|
|
11
|
-
The
|
|
11
|
+
The studio provides a user-friendly interface for testing your agent, allowing you to:
|
|
12
12
|
|
|
13
13
|
- Send messages to your agent
|
|
14
14
|
- See the agent's responses
|
|
@@ -16,4 +16,4 @@ The playground provides a user-friendly interface for testing your agent, allowi
|
|
|
16
16
|
- Test tools directly
|
|
17
17
|
- Debug any issues that arise
|
|
18
18
|
|
|
19
|
-
In the next step, we'll create our first agent with a simple system prompt and test it in the
|
|
19
|
+
In the next step, we'll create our first agent with a simple system prompt and test it in the studio.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Testing Your Agent
|
|
2
2
|
|
|
3
|
-
Now let's test our agent in
|
|
3
|
+
Now let's test our agent in Mastra Studio:
|
|
4
4
|
|
|
5
5
|
1. Make sure your development server is running with `npm run dev`
|
|
6
|
-
2. Open the
|
|
6
|
+
2. Open the studio at http://localhost:4111/
|
|
7
7
|
3. You should see your "Financial Assistant Agent" in the list of agents
|
|
8
8
|
4. Try sending a message like "Hello, can you help me analyze my spending?"
|
|
9
9
|
|
|
10
10
|
At this point, your agent can respond to basic questions but doesn't have access to any transaction data. In the next step, we'll create a custom tool to fetch transaction data from a Google Sheet.
|
|
11
11
|
|
|
12
|
-
Testing your agent in the
|
|
12
|
+
Testing your agent in the studio is an important step in the development process. It allows you to see how your agent responds to different inputs and identify any issues that need to be addressed before deploying it to production.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Testing Your Tool
|
|
2
2
|
|
|
3
|
-
Let's test our tool and agent in
|
|
3
|
+
Let's test our tool and agent in Mastra Studio:
|
|
4
4
|
|
|
5
5
|
1. Make sure your development server is running with `npm run dev`
|
|
6
|
-
2. Open the
|
|
6
|
+
2. Open the studio at http://localhost:4111/
|
|
7
7
|
3. You can test the tool directly in the Tools tab to make sure it's working
|
|
8
8
|
4. Then, try asking your agent questions like:
|
|
9
9
|
- "Can you show me my recent transactions?"
|
|
@@ -12,4 +12,4 @@ Let's test our tool and agent in the playground:
|
|
|
12
12
|
|
|
13
13
|
Your agent should now be able to fetch the transaction data and answer questions about it. However, it doesn't yet have memory, so it won't remember previous conversations. We'll add that in the next step.
|
|
14
14
|
|
|
15
|
-
Testing your tool directly in the
|
|
15
|
+
Testing your tool directly in the studio is a great way to verify that it's working correctly before integrating it with your agent. This helps you identify and fix any issues with the tool itself before troubleshooting potential issues with the agent's use of the tool.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Testing Your Agent with Memory
|
|
2
2
|
|
|
3
|
-
Let's test our agent's memory capabilities in
|
|
3
|
+
Let's test our agent's memory capabilities in Mastra Studio:
|
|
4
4
|
|
|
5
5
|
1. Make sure your development server is running with `npm run dev`
|
|
6
|
-
2. Open the
|
|
6
|
+
2. Open the studio at http://localhost:4111/
|
|
7
7
|
3. Start a conversation with your agent by asking about transactions
|
|
8
8
|
4. Then, ask a follow-up question that references the previous conversation, like:
|
|
9
9
|
- "What was that largest transaction again?"
|
|
@@ -9,7 +9,7 @@ Mastra runs as a standard Node.js server and can be deployed across a wide range
|
|
|
9
9
|
|
|
10
10
|
## Default project structure
|
|
11
11
|
|
|
12
|
-
The [getting started guide](/guides/v1/
|
|
12
|
+
The [getting started guide](/guides/v1/getting-started/quickstart) scaffolds a project with sensible defaults to help you begin quickly. By default, the CLI organizes application files under the `src/mastra/` directory, resulting in a structure similar to the following:
|
|
13
13
|
|
|
14
14
|
```
|
|
15
15
|
src/
|
|
@@ -16,7 +16,7 @@ Deploy your Mastra applications to Amazon EC2 (Elastic Cloud Compute).
|
|
|
16
16
|
This guide assumes your Mastra application has been created using the default
|
|
17
17
|
`npx create-mastra@beta` command.
|
|
18
18
|
For more information on how to create a new Mastra application,
|
|
19
|
-
refer to our [getting started guide](/guides/v1/
|
|
19
|
+
refer to our [getting started guide](/guides/v1/getting-started/quickstart)
|
|
20
20
|
:::
|
|
21
21
|
|
|
22
22
|
## Prerequisites
|
|
@@ -15,7 +15,7 @@ This approach allows you to run your Mastra server as a containerized Lambda fun
|
|
|
15
15
|
This guide assumes your Mastra application has been created using the default
|
|
16
16
|
`npx create-mastra@beta` command.
|
|
17
17
|
For more information on how to create a new Mastra application,
|
|
18
|
-
refer to our [getting started guide](/guides/v1/
|
|
18
|
+
refer to our [getting started guide](/guides/v1/getting-started/quickstart)
|
|
19
19
|
:::
|
|
20
20
|
|
|
21
21
|
## Prerequisites
|
|
@@ -14,7 +14,7 @@ Deploy your Mastra applications to Azure App Services.
|
|
|
14
14
|
This guide assumes your Mastra application has been created using the default
|
|
15
15
|
`npx create-mastra@beta` command.
|
|
16
16
|
For more information on how to create a new Mastra application,
|
|
17
|
-
refer to our [getting started guide](/guides/v1/
|
|
17
|
+
refer to our [getting started guide](/guides/v1/getting-started/quickstart)
|
|
18
18
|
:::
|
|
19
19
|
|
|
20
20
|
## Prerequisites
|
|
@@ -16,7 +16,7 @@ Deploy your Mastra applications to Digital Ocean's App Platform and Droplets.
|
|
|
16
16
|
This guide assumes your Mastra application has been created using the default
|
|
17
17
|
`npx create-mastra@beta` command.
|
|
18
18
|
For more information on how to create a new Mastra application,
|
|
19
|
-
refer to our [getting started guide](/guides/v1/
|
|
19
|
+
refer to our [getting started guide](/guides/v1/getting-started/quickstart)
|
|
20
20
|
:::
|
|
21
21
|
|
|
22
22
|
<Tabs>
|
|
@@ -22,7 +22,7 @@ For self-hosted Node.js server deployment, see the [Creating A Mastra Server](/d
|
|
|
22
22
|
|
|
23
23
|
Before deploying to a cloud provider, ensure you have:
|
|
24
24
|
|
|
25
|
-
- A [Mastra application](/guides/v1/
|
|
25
|
+
- A [Mastra application](/guides/v1/getting-started/quickstart)
|
|
26
26
|
- Node.js `v22.13.0` or later
|
|
27
27
|
- A GitHub repository for your application (required for most CI/CD setups)
|
|
28
28
|
- Domain name management access (for SSL and HTTPS)
|
|
@@ -7,45 +7,47 @@ import { MastraCloudCallout } from "@site/src/components/MastraCloudCallout";
|
|
|
7
7
|
|
|
8
8
|
# Understanding Tracing and Logs
|
|
9
9
|
|
|
10
|
-
Mastra Cloud
|
|
10
|
+
Mastra Cloud provides full observability for production applications, giving you insight into how your agents and workflows behave. Observability can be enabled whether your application is deployed to Mastra Cloud, running locally, or hosted on your own infrastructure. Any Mastra project can send traces and logs to the platform regardless of where it's running.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
## Logs
|
|
12
|
+
For details on configuring observability, see the [Cloud Exporter](/docs/v1/observability/tracing/exporters/cloud) docs.
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-

|
|
19
|
-
|
|
20
|
-
Key features:
|
|
21
|
-
|
|
22
|
-
Each log entry includes its severity level and a detailed message showing agent, workflow, or storage activity.
|
|
14
|
+
<MastraCloudCallout />
|
|
23
15
|
|
|
24
16
|
## Traces
|
|
25
17
|
|
|
26
|
-
More detailed traces are available for both agents and workflows by
|
|
18
|
+
More detailed traces are available for both agents and workflows by enabling [observability](/docs/v1/observability/tracing/overview) using one of our [supported providers](/docs/v1/observability/tracing/overview#exporters).
|
|
27
19
|
|
|
28
20
|
### Agents
|
|
29
21
|
|
|
30
|
-
With
|
|
22
|
+
With observability enabled, you can view detailed outputs from your agents in the **Traces** section in Studio.
|
|
31
23
|
|
|
32
24
|

|
|
33
25
|
|
|
34
26
|
Key features:
|
|
35
27
|
|
|
36
|
-
|
|
28
|
+
Agent traces break a run into clear steps, model calls, tool calls, and intermediate chunks, each with timing, inputs, outputs, and errors. You can drill into any span to inspect prompts, token usage, and results, making it easy to diagnose issues and understand how the agent produced its output.
|
|
37
29
|
|
|
38
30
|
### Workflows
|
|
39
31
|
|
|
40
|
-
With
|
|
32
|
+
With observability enabled, you can view detailed outputs from your workflows in the **Traces** section in Studio.
|
|
41
33
|
|
|
42
34
|

|
|
43
35
|
|
|
44
36
|
Key features:
|
|
45
37
|
|
|
46
|
-
|
|
38
|
+
Workflow traces capture each step in the run, including transitions, branching, timing, and any tool calls inside the workflow. You can inspect inputs, outputs, and errors for every step, making it easy to debug long-running or multi-step processes and understand how data flows through the workflow.
|
|
39
|
+
|
|
40
|
+
## Logs
|
|
41
|
+
|
|
42
|
+
You can view detailed logs for debugging and monitoring your application's behavior on the [Logs](/docs/v1/deployment/mastra-cloud/dashboard#logs) page of the Dashboard.
|
|
43
|
+
|
|
44
|
+

|
|
45
|
+
|
|
46
|
+
Key features:
|
|
47
|
+
|
|
48
|
+
Each log entry includes its severity level and a detailed message showing agent, workflow, or storage activity.
|
|
47
49
|
|
|
48
50
|
## Next steps
|
|
49
51
|
|
|
50
|
-
- [Logging](/docs/v1/logging)
|
|
52
|
+
- [Logging](/docs/v1/observability/logging)
|
|
51
53
|
- [Tracing](/docs/v1/observability/tracing/overview)
|
|
@@ -18,7 +18,7 @@ This page explains how to set up a project on [Mastra Cloud](https://mastra.ai/c
|
|
|
18
18
|
- A [Mastra Cloud](https://mastra.ai/cloud) account
|
|
19
19
|
- A GitHub account / repository containing a Mastra application
|
|
20
20
|
|
|
21
|
-
> See our [Getting started](/guides/v1/
|
|
21
|
+
> See our [Getting started](/guides/v1/getting-started/quickstart) guide to scaffold out a new Mastra project with sensible defaults.
|
|
22
22
|
|
|
23
23
|
## Setup and Deploy process
|
|
24
24
|
|
|
@@ -41,8 +41,8 @@ Mastra Cloud is a deployment platform that connects to your GitHub repository, a
|
|
|
41
41
|
|
|
42
42
|
Mastra can be integrated with a variety of web frameworks. For example, see one of the following for a detailed guide.
|
|
43
43
|
|
|
44
|
-
- [With Next.js](
|
|
45
|
-
- [With Astro](
|
|
44
|
+
- [With Next.js](/guides/v1/getting-started/next-js)
|
|
45
|
+
- [With Astro](/guides/v1/getting-started/astro)
|
|
46
46
|
|
|
47
47
|
When integrated with a framework, Mastra typically requires no additional configuration for deployment.
|
|
48
48
|
|
|
@@ -7,14 +7,14 @@ description: "Learn how Mastra can be deployed when integrated with a Web Framew
|
|
|
7
7
|
|
|
8
8
|
This guide covers deploying integrated Mastra applications. Mastra can be integrated with a variety of web frameworks, see one of the following for a detailed guide.
|
|
9
9
|
|
|
10
|
-
- [With Next.js](/
|
|
11
|
-
- [With Astro](/
|
|
10
|
+
- [With Next.js](/guides/v1/getting-started/next-js)
|
|
11
|
+
- [With Astro](/guides/v1/getting-started/astro)
|
|
12
12
|
|
|
13
13
|
When integrated with a framework, Mastra typically requires no additional configuration for deployment.
|
|
14
14
|
|
|
15
15
|
## With Next.js on Vercel
|
|
16
16
|
|
|
17
|
-
If you've integrated Mastra with Next.js [by following our guide](/
|
|
17
|
+
If you've integrated Mastra with Next.js [by following our guide](/guides/v1/getting-started/next-js) and plan to deploy to Vercel, no additional setup is required.
|
|
18
18
|
|
|
19
19
|
The only thing to verify is that you've added the following to your `next.config.ts` and removed any usage of [LibSQLStore](/docs/v1/deployment/overview), which is not supported in serverless environments:
|
|
20
20
|
|
|
@@ -30,7 +30,7 @@ export default nextConfig;
|
|
|
30
30
|
|
|
31
31
|
## With Astro on Vercel
|
|
32
32
|
|
|
33
|
-
If you've integrated Mastra with Astro [by following our guide](/
|
|
33
|
+
If you've integrated Mastra with Astro [by following our guide](/guides/v1/getting-started/astro) and plan to deploy to Vercel, no additional setup is required.
|
|
34
34
|
|
|
35
35
|
The only thing to verify is that you've added the following to your `astro.config.mjs` and removed any usage of [LibSQLStore](/docs/v1/deployment/overview), which is not supported in serverless environments:
|
|
36
36
|
|
|
@@ -47,7 +47,7 @@ export default defineConfig({
|
|
|
47
47
|
|
|
48
48
|
## With Astro on Netlify
|
|
49
49
|
|
|
50
|
-
If you've integrated Mastra with Astro [by following our guide](/
|
|
50
|
+
If you've integrated Mastra with Astro [by following our guide](/guides/v1/getting-started/astro) and plan to deploy to Netlify, no additional setup is required.
|
|
51
51
|
|
|
52
52
|
The only thing to verify is that you've added the following to your `astro.config.mjs` and removed any usage of [LibSQLStore](/docs/v1/deployment/overview), which is not supported in serverless environments:
|
|
53
53
|
|
|
@@ -41,13 +41,12 @@ Every scorer starts with the `createScorer` factory function, which requires a n
|
|
|
41
41
|
|
|
42
42
|
```typescript
|
|
43
43
|
import { createScorer } from '@mastra/core/evals';
|
|
44
|
-
import { openai } from '@ai-sdk/openai';
|
|
45
44
|
|
|
46
45
|
const glutenCheckerScorer = createScorer({
|
|
47
46
|
name: 'Gluten Checker',
|
|
48
47
|
description: 'Check if recipes contain gluten ingredients',
|
|
49
48
|
judge: { // Optional: for prompt object steps
|
|
50
|
-
model: openai
|
|
49
|
+
model: 'openai/gpt-5.1',
|
|
51
50
|
instructions: 'You are a Chef that identifies if recipes contain gluten.'
|
|
52
51
|
}
|
|
53
52
|
})
|
|
@@ -245,7 +244,6 @@ Together, these components allow you to define custom evaluation logic using LLM
|
|
|
245
244
|
> See [createScorer](/reference/v1/evals/create-scorer) for the full API and configuration options.
|
|
246
245
|
|
|
247
246
|
```typescript title="src/mastra/scorers/gluten-checker.ts" showLineNumbers copy
|
|
248
|
-
import { openai } from "@ai-sdk/openai";
|
|
249
247
|
import { createScorer } from "@mastra/core/evals";
|
|
250
248
|
import { z } from "zod";
|
|
251
249
|
|
|
@@ -303,7 +301,7 @@ export const glutenCheckerScorer = createScorer({
|
|
|
303
301
|
name: "Gluten Checker",
|
|
304
302
|
description: "Check if the output contains any gluten",
|
|
305
303
|
judge: {
|
|
306
|
-
model: openai
|
|
304
|
+
model: "openai/gpt-4.1-nano",
|
|
307
305
|
instructions: GLUTEN_INSTRUCTIONS,
|
|
308
306
|
},
|
|
309
307
|
})
|
|
@@ -338,7 +336,7 @@ Sets up the LLM model and defines its role as a domain expert.
|
|
|
338
336
|
|
|
339
337
|
```typescript
|
|
340
338
|
judge: {
|
|
341
|
-
model: openai
|
|
339
|
+
model: 'openai/gpt-4.1-nano',
|
|
342
340
|
instructions: GLUTEN_INSTRUCTIONS,
|
|
343
341
|
}
|
|
344
342
|
```
|
|
@@ -37,7 +37,6 @@ You can add built-in scorers to your agents to automatically evaluate their outp
|
|
|
37
37
|
|
|
38
38
|
```typescript title="src/mastra/agents/evaluated-agent.ts" showLineNumbers copy
|
|
39
39
|
import { Agent } from "@mastra/core/agent";
|
|
40
|
-
import { openai } from "@ai-sdk/openai";
|
|
41
40
|
import {
|
|
42
41
|
createAnswerRelevancyScorer,
|
|
43
42
|
createToxicityScorer,
|
|
@@ -47,11 +46,11 @@ export const evaluatedAgent = new Agent({
|
|
|
47
46
|
// ...
|
|
48
47
|
scorers: {
|
|
49
48
|
relevancy: {
|
|
50
|
-
scorer: createAnswerRelevancyScorer({ model: openai
|
|
49
|
+
scorer: createAnswerRelevancyScorer({ model: "openai/gpt-4.1-nano" }),
|
|
51
50
|
sampling: { type: "ratio", rate: 0.5 },
|
|
52
51
|
},
|
|
53
52
|
safety: {
|
|
54
|
-
scorer: createToxicityScorer({ model: openai
|
|
53
|
+
scorer: createToxicityScorer({ model: "openai/gpt-4.1-nano" }),
|
|
55
54
|
sampling: { type: "ratio", rate: 1 },
|
|
56
55
|
},
|
|
57
56
|
},
|
|
@@ -62,6 +62,6 @@ Top-level files define how your Mastra project is configured, built, and connect
|
|
|
62
62
|
## Next steps
|
|
63
63
|
|
|
64
64
|
- Read more about [Mastra's features](/docs/v1#why-mastra).
|
|
65
|
-
- Integrate Mastra with your frontend framework: [Next.js](/
|
|
65
|
+
- Integrate Mastra with your frontend framework: [Next.js](/guides/v1/getting-started/next-js), [React](/guides/v1/getting-started/vite-react), or [Astro](/guides/v1/getting-started/astro).
|
|
66
66
|
- Build an agent from scratch following one of our [guides](/guides/v1).
|
|
67
67
|
- Watch conceptual guides on our [YouTube channel](https://www.youtube.com/@mastra-ai) and [subscribe](https://www.youtube.com/@mastra-ai?sub_confirmation=1)!
|