@mastra/mcp-docs-server 1.0.0-beta.11 → 1.0.0-beta.14
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%2Fagent-builder.md +29 -29
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +51 -51
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +180 -180
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +68 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +331 -331
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +41 -41
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Flance.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +24 -24
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +24 -24
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +96 -96
- package/.docs/organized/changelogs/%40mastra%2Frag.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Freact.md +49 -2
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +122 -122
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +39 -39
- package/.docs/organized/changelogs/create-mastra.md +31 -31
- package/.docs/organized/changelogs/mastra.md +51 -51
- package/.docs/organized/code-examples/agent-v6.md +151 -0
- package/.docs/organized/code-examples/ai-elements.md +1 -1
- package/.docs/organized/code-examples/quick-start.md +0 -4
- package/.docs/organized/code-examples/stock-price-tool.md +21 -2
- package/.docs/raw/agents/adding-voice.mdx +2 -3
- package/.docs/raw/agents/agent-approval.mdx +139 -6
- package/.docs/raw/agents/agent-memory.mdx +24 -32
- package/.docs/raw/agents/guardrails.mdx +61 -51
- package/.docs/raw/agents/networks.mdx +9 -13
- package/.docs/raw/agents/overview.mdx +40 -24
- package/.docs/raw/agents/processors.mdx +20 -19
- package/.docs/raw/agents/structured-output.mdx +11 -7
- package/.docs/raw/agents/using-tools.mdx +5 -6
- package/.docs/raw/course/01-first-agent/07-creating-your-agent.md +1 -2
- package/.docs/raw/course/01-first-agent/12-connecting-tool-to-agent.md +1 -1
- package/.docs/raw/course/01-first-agent/16-adding-memory-to-agent.md +1 -2
- package/.docs/raw/course/02-agent-tools-mcp/05-updating-your-agent.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/10-updating-agent-instructions-zapier.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/16-updating-agent-instructions-github.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/21-updating-agent-instructions-hackernews.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/27-updating-agent-instructions-filesystem.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/31-enhancing-memory-configuration.md +2 -2
- package/.docs/raw/course/03-agent-memory/04-creating-basic-memory-agent.md +1 -2
- package/.docs/raw/course/03-agent-memory/08-configuring-conversation-history.md +1 -2
- package/.docs/raw/course/03-agent-memory/16-configuring-semantic-recall.md +3 -4
- package/.docs/raw/course/03-agent-memory/21-configuring-working-memory.md +2 -3
- package/.docs/raw/course/03-agent-memory/22-custom-working-memory-templates.md +2 -3
- package/.docs/raw/course/03-agent-memory/25-combining-memory-features.md +1 -2
- package/.docs/raw/course/03-agent-memory/27-creating-learning-assistant.md +2 -3
- package/.docs/raw/course/04-workflows/11-creating-an-ai-agent.md +2 -3
- package/.docs/raw/deployment/cloud-providers.mdx +20 -0
- package/.docs/raw/deployment/{building-mastra.mdx → mastra-server.mdx} +5 -5
- package/.docs/raw/deployment/monorepo.mdx +23 -44
- package/.docs/raw/deployment/overview.mdx +32 -50
- package/.docs/raw/deployment/web-framework.mdx +15 -19
- package/.docs/raw/evals/custom-scorers.mdx +9 -6
- package/.docs/raw/evals/overview.mdx +3 -6
- package/.docs/raw/evals/running-in-ci.mdx +2 -2
- package/.docs/raw/getting-started/manual-install.mdx +20 -20
- package/.docs/raw/getting-started/mcp-docs-server.mdx +2 -2
- package/.docs/raw/getting-started/start.mdx +10 -1
- package/.docs/raw/getting-started/studio.mdx +1 -1
- package/.docs/raw/guides/agent-frameworks/ai-sdk.mdx +4 -4
- package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +1033 -79
- package/.docs/raw/guides/build-your-ui/assistant-ui.mdx +8 -8
- package/.docs/raw/guides/build-your-ui/copilotkit.mdx +11 -11
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/amazon-ec2.mdx +9 -9
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/aws-lambda.mdx +13 -16
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/azure-app-services.mdx +5 -7
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/cloudflare-deployer.mdx +8 -5
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/digital-ocean.mdx +12 -15
- package/.docs/raw/guides/deployment/index.mdx +32 -0
- package/.docs/raw/guides/deployment/inngest.mdx +386 -0
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/netlify-deployer.mdx +7 -3
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/vercel-deployer.mdx +8 -5
- package/.docs/raw/guides/getting-started/astro.mdx +292 -451
- package/.docs/raw/guides/getting-started/express.mdx +72 -153
- package/.docs/raw/guides/getting-started/hono.mdx +227 -0
- package/.docs/raw/guides/getting-started/next-js.mdx +170 -61
- package/.docs/raw/guides/getting-started/quickstart.mdx +4 -4
- package/.docs/raw/guides/getting-started/sveltekit.mdx +238 -409
- package/.docs/raw/guides/getting-started/vite-react.mdx +317 -147
- package/.docs/raw/guides/guide/ai-recruiter.mdx +10 -10
- package/.docs/raw/guides/guide/chef-michel.mdx +9 -11
- package/.docs/raw/guides/guide/notes-mcp-server.mdx +15 -15
- package/.docs/raw/guides/guide/research-assistant.mdx +17 -17
- package/.docs/raw/guides/guide/stock-agent.mdx +5 -5
- package/.docs/raw/guides/guide/web-search.mdx +8 -8
- package/.docs/raw/guides/guide/whatsapp-chat-bot.mdx +7 -7
- package/.docs/raw/guides/migrations/ai-sdk-v4-to-v5.mdx +2 -2
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +1 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/client.mdx +17 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/overview.mdx +6 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +0 -2
- package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +21 -23
- package/.docs/raw/index.mdx +2 -2
- package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/dashboard.mdx +2 -6
- package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/observability.mdx +1 -5
- package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/overview.mdx +2 -6
- package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/setting-up.mdx +8 -7
- package/.docs/raw/mcp/overview.mdx +31 -13
- package/.docs/raw/mcp/publishing-mcp-server.mdx +2 -2
- package/.docs/raw/memory/memory-processors.mdx +9 -9
- package/.docs/raw/memory/message-history.mdx +69 -0
- package/.docs/raw/memory/overview.mdx +34 -76
- package/.docs/raw/memory/semantic-recall.mdx +58 -49
- package/.docs/raw/memory/storage.mdx +188 -0
- package/.docs/raw/memory/working-memory.mdx +7 -7
- package/.docs/raw/observability/logging.mdx +10 -11
- package/.docs/raw/observability/overview.mdx +0 -1
- package/.docs/raw/observability/tracing/bridges/otel.mdx +2 -2
- package/.docs/raw/observability/tracing/exporters/cloud.mdx +1 -1
- package/.docs/raw/observability/tracing/exporters/default.mdx +3 -3
- package/.docs/raw/observability/tracing/exporters/langfuse.mdx +1 -2
- package/.docs/raw/observability/tracing/overview.mdx +23 -25
- package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +3 -3
- package/.docs/raw/rag/chunking-and-embedding.mdx +18 -31
- package/.docs/raw/rag/graph-rag.mdx +220 -0
- package/.docs/raw/rag/overview.mdx +2 -3
- package/.docs/raw/rag/retrieval.mdx +34 -51
- package/.docs/raw/rag/vector-databases.mdx +29 -25
- package/.docs/raw/reference/agents/agent.mdx +3 -3
- package/.docs/raw/reference/agents/generate.mdx +1 -1
- package/.docs/raw/reference/agents/generateLegacy.mdx +2 -2
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +3 -3
- package/.docs/raw/reference/agents/getDefaultOptions.mdx +3 -3
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +3 -3
- package/.docs/raw/reference/agents/getDescription.mdx +1 -1
- package/.docs/raw/reference/agents/getInstructions.mdx +3 -3
- package/.docs/raw/reference/agents/getLLM.mdx +3 -3
- package/.docs/raw/reference/agents/getMemory.mdx +3 -3
- package/.docs/raw/reference/agents/getModel.mdx +3 -3
- package/.docs/raw/reference/agents/getTools.mdx +2 -2
- package/.docs/raw/reference/agents/getVoice.mdx +2 -2
- package/.docs/raw/reference/agents/listAgents.mdx +2 -2
- package/.docs/raw/reference/agents/listScorers.mdx +3 -3
- package/.docs/raw/reference/agents/listTools.mdx +2 -2
- package/.docs/raw/reference/agents/listWorkflows.mdx +2 -2
- package/.docs/raw/reference/agents/network.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/chat-route.mdx +3 -3
- package/.docs/raw/reference/ai-sdk/handle-chat-stream.mdx +2 -2
- package/.docs/raw/reference/ai-sdk/handle-network-stream.mdx +2 -2
- package/.docs/raw/reference/ai-sdk/handle-workflow-stream.mdx +2 -2
- package/.docs/raw/reference/ai-sdk/network-route.mdx +3 -3
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-stream.mdx +6 -6
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v4-messages.mdx +127 -0
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v5-messages.mdx +107 -0
- package/.docs/raw/reference/ai-sdk/with-mastra.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/workflow-route.mdx +3 -3
- package/.docs/raw/reference/auth/auth0.mdx +2 -3
- package/.docs/raw/reference/auth/clerk.mdx +2 -3
- package/.docs/raw/reference/auth/firebase.mdx +3 -5
- package/.docs/raw/reference/auth/jwt.mdx +2 -3
- package/.docs/raw/reference/auth/supabase.mdx +2 -3
- package/.docs/raw/reference/auth/workos.mdx +2 -3
- package/.docs/raw/reference/cli/create-mastra.mdx +10 -10
- package/.docs/raw/reference/cli/mastra.mdx +10 -10
- package/.docs/raw/reference/client-js/agents.mdx +1 -2
- package/.docs/raw/reference/client-js/mastra-client.mdx +2 -2
- package/.docs/raw/reference/client-js/workflows.mdx +20 -0
- package/.docs/raw/reference/core/getAgent.mdx +1 -1
- package/.docs/raw/reference/core/getAgentById.mdx +1 -1
- package/.docs/raw/reference/core/getDeployer.mdx +1 -1
- package/.docs/raw/reference/core/getLogger.mdx +1 -1
- package/.docs/raw/reference/core/getMCPServer.mdx +1 -1
- package/.docs/raw/reference/core/getMCPServerById.mdx +1 -1
- package/.docs/raw/reference/core/getMemory.mdx +2 -2
- package/.docs/raw/reference/core/getServer.mdx +3 -3
- package/.docs/raw/reference/core/getStorage.mdx +2 -2
- package/.docs/raw/reference/core/getStoredAgentById.mdx +3 -3
- package/.docs/raw/reference/core/getTelemetry.mdx +1 -1
- package/.docs/raw/reference/core/getVector.mdx +1 -1
- package/.docs/raw/reference/core/getWorkflow.mdx +1 -1
- package/.docs/raw/reference/core/listAgents.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/listMCPServers.mdx +1 -1
- package/.docs/raw/reference/core/listMemory.mdx +2 -2
- package/.docs/raw/reference/core/listStoredAgents.mdx +4 -4
- package/.docs/raw/reference/core/listVectors.mdx +1 -1
- package/.docs/raw/reference/core/listWorkflows.mdx +1 -1
- package/.docs/raw/reference/core/setLogger.mdx +1 -1
- package/.docs/raw/reference/core/setStorage.mdx +2 -2
- package/.docs/raw/reference/core/setTelemetry.mdx +1 -1
- package/.docs/raw/reference/deployer/cloudflare.mdx +1 -2
- package/.docs/raw/reference/deployer/deployer.mdx +0 -1
- package/.docs/raw/reference/deployer/netlify.mdx +1 -1
- package/.docs/raw/reference/deployer/vercel.mdx +2 -4
- package/.docs/raw/reference/evals/answer-relevancy.mdx +1 -1
- package/.docs/raw/reference/evals/answer-similarity.mdx +1 -1
- package/.docs/raw/reference/evals/bias.mdx +1 -1
- package/.docs/raw/reference/evals/completeness.mdx +1 -1
- package/.docs/raw/reference/evals/content-similarity.mdx +1 -1
- package/.docs/raw/reference/evals/context-precision.mdx +1 -1
- package/.docs/raw/reference/evals/faithfulness.mdx +1 -1
- package/.docs/raw/reference/evals/hallucination.mdx +1 -1
- package/.docs/raw/reference/evals/keyword-coverage.mdx +1 -1
- package/.docs/raw/reference/evals/prompt-alignment.mdx +7 -7
- package/.docs/raw/reference/evals/textual-difference.mdx +1 -1
- package/.docs/raw/reference/evals/tone-consistency.mdx +1 -1
- package/.docs/raw/reference/evals/tool-call-accuracy.mdx +10 -10
- package/.docs/raw/reference/evals/toxicity.mdx +1 -1
- package/.docs/raw/reference/logging/pino-logger.mdx +7 -8
- package/.docs/raw/reference/memory/createThread.mdx +2 -2
- package/.docs/raw/reference/memory/deleteMessages.mdx +2 -2
- package/.docs/raw/reference/memory/listThreadsByResourceId.mdx +2 -2
- package/.docs/raw/reference/memory/memory-class.mdx +3 -3
- package/.docs/raw/reference/memory/query.mdx +2 -2
- package/.docs/raw/reference/memory/recall.mdx +2 -2
- package/.docs/raw/reference/observability/tracing/exporters/langfuse.mdx +1 -1
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +2 -2
- package/.docs/raw/reference/processors/language-detector.mdx +2 -2
- package/.docs/raw/reference/processors/message-history-processor.mdx +2 -2
- package/.docs/raw/reference/processors/moderation-processor.mdx +3 -3
- package/.docs/raw/reference/processors/pii-detector.mdx +3 -3
- package/.docs/raw/reference/processors/processor-interface.mdx +13 -13
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +2 -2
- package/.docs/raw/reference/processors/semantic-recall-processor.mdx +2 -2
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +2 -2
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +2 -2
- package/.docs/raw/reference/processors/tool-call-filter.mdx +3 -3
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +2 -2
- package/.docs/raw/reference/processors/working-memory-processor.mdx +3 -3
- package/.docs/raw/reference/rag/chunk.mdx +1 -1
- package/.docs/raw/reference/rag/database-config.mdx +1 -1
- package/.docs/raw/reference/rag/extract-params.mdx +2 -2
- package/.docs/raw/reference/rag/metadata-filters.mdx +7 -7
- package/.docs/raw/reference/server/create-route.mdx +14 -14
- package/.docs/raw/reference/server/express-adapter.mdx +10 -11
- package/.docs/raw/reference/server/hono-adapter.mdx +10 -11
- package/.docs/raw/reference/server/mastra-server.mdx +22 -22
- package/.docs/raw/reference/server/routes.mdx +28 -1
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +3 -3
- package/.docs/raw/reference/storage/cloudflare.mdx +2 -2
- package/.docs/raw/reference/storage/convex.mdx +6 -6
- package/.docs/raw/reference/storage/dynamodb.mdx +4 -4
- package/.docs/raw/reference/storage/lance.mdx +3 -3
- package/.docs/raw/reference/storage/libsql.mdx +69 -54
- package/.docs/raw/reference/storage/mongodb.mdx +80 -7
- package/.docs/raw/reference/storage/mssql.mdx +4 -4
- package/.docs/raw/{server-db/storage.mdx → reference/storage/overview.mdx} +13 -111
- package/.docs/raw/reference/storage/postgresql.mdx +78 -7
- package/.docs/raw/reference/storage/upstash.mdx +74 -2
- package/.docs/raw/reference/streaming/agents/stream.mdx +27 -5
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +2 -2
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +1 -1
- package/.docs/raw/reference/streaming/workflows/resumeStream.mdx +1 -1
- package/.docs/raw/reference/streaming/workflows/stream.mdx +35 -22
- package/.docs/raw/reference/streaming/workflows/timeTravelStream.mdx +4 -4
- package/.docs/raw/reference/templates/overview.mdx +1 -2
- package/.docs/raw/reference/tools/create-tool.mdx +24 -5
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +3 -3
- package/.docs/raw/reference/tools/vector-query-tool.mdx +4 -4
- package/.docs/raw/reference/vectors/astra.mdx +3 -3
- package/.docs/raw/reference/vectors/chroma.mdx +3 -3
- package/.docs/raw/reference/vectors/convex.mdx +12 -12
- package/.docs/raw/reference/vectors/couchbase.mdx +5 -5
- package/.docs/raw/reference/vectors/duckdb.mdx +10 -10
- package/.docs/raw/reference/vectors/elasticsearch.mdx +4 -4
- package/.docs/raw/reference/vectors/lance.mdx +4 -4
- package/.docs/raw/reference/vectors/libsql.mdx +61 -11
- package/.docs/raw/reference/vectors/mongodb.mdx +58 -5
- package/.docs/raw/reference/vectors/pg.mdx +53 -6
- package/.docs/raw/reference/vectors/pinecone.mdx +3 -3
- package/.docs/raw/reference/vectors/qdrant.mdx +3 -3
- package/.docs/raw/reference/vectors/s3vectors.mdx +6 -6
- package/.docs/raw/reference/vectors/turbopuffer.mdx +4 -4
- package/.docs/raw/reference/vectors/upstash.mdx +55 -6
- package/.docs/raw/reference/vectors/vectorize.mdx +3 -3
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +2 -2
- package/.docs/raw/reference/workflows/run-methods/restart.mdx +1 -3
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +2 -2
- package/.docs/raw/reference/workflows/run-methods/start.mdx +2 -2
- package/.docs/raw/reference/workflows/run-methods/startAsync.mdx +143 -0
- package/.docs/raw/reference/workflows/run-methods/timeTravel.mdx +5 -5
- package/.docs/raw/reference/workflows/run.mdx +1 -1
- package/.docs/raw/reference/workflows/step.mdx +3 -3
- package/.docs/raw/reference/workflows/workflow-methods/branch.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/commit.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/create-run.mdx +37 -2
- package/.docs/raw/reference/workflows/workflow-methods/dountil.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/dowhile.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +6 -6
- package/.docs/raw/reference/workflows/workflow-methods/map.mdx +7 -7
- package/.docs/raw/reference/workflows/workflow-methods/parallel.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/sendEvent.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/sleep.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/then.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow.mdx +17 -3
- package/.docs/raw/{auth → server/auth}/auth0.mdx +20 -14
- package/.docs/raw/{auth → server/auth}/clerk.mdx +16 -9
- package/.docs/raw/{auth → server/auth}/firebase.mdx +21 -15
- package/.docs/raw/{auth → server/auth}/index.mdx +6 -6
- package/.docs/raw/{auth → server/auth}/jwt.mdx +14 -7
- package/.docs/raw/{auth → server/auth}/supabase.mdx +16 -9
- package/.docs/raw/{auth → server/auth}/workos.mdx +19 -13
- package/.docs/raw/{server-db → server}/custom-adapters.mdx +13 -13
- package/.docs/raw/{server-db → server}/custom-api-routes.mdx +3 -5
- package/.docs/raw/{server-db → server}/mastra-client.mdx +26 -15
- package/.docs/raw/{server-db → server}/mastra-server.mdx +8 -8
- package/.docs/raw/{server-db → server}/middleware.mdx +9 -9
- package/.docs/raw/{server-db → server}/request-context.mdx +33 -32
- package/.docs/raw/{server-db → server}/server-adapters.mdx +12 -12
- package/.docs/raw/streaming/events.mdx +14 -7
- package/.docs/raw/streaming/overview.mdx +21 -10
- package/.docs/raw/streaming/tool-streaming.mdx +6 -6
- package/.docs/raw/streaming/workflow-streaming.mdx +6 -8
- package/.docs/raw/tools-mcp/advanced-usage.mdx +2 -2
- package/.docs/raw/tools-mcp/mcp-overview.mdx +31 -12
- package/.docs/raw/tools-mcp/overview.mdx +10 -11
- package/.docs/raw/voice/overview.mdx +1 -1
- package/.docs/raw/workflows/agents-and-tools.mdx +28 -19
- package/.docs/raw/workflows/control-flow.mdx +27 -40
- package/.docs/raw/workflows/error-handling.mdx +172 -18
- package/.docs/raw/workflows/human-in-the-loop.mdx +6 -7
- package/.docs/raw/workflows/inngest-workflow.mdx +8 -9
- package/.docs/raw/workflows/input-data-mapping.mdx +7 -7
- package/.docs/raw/workflows/overview.mdx +34 -23
- package/.docs/raw/workflows/snapshots.mdx +14 -44
- package/.docs/raw/workflows/suspend-and-resume.mdx +7 -7
- package/.docs/raw/workflows/time-travel.mdx +16 -16
- package/.docs/raw/workflows/workflow-state.mdx +5 -8
- package/CHANGELOG.md +23 -0
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/stdio.js +53 -0
- package/package.json +4 -4
- package/.docs/organized/changelogs/%40internal%2Fai-sdk-v4.md +0 -1
- package/.docs/raw/deployment/cloud-providers/index.mdx +0 -55
- package/.docs/raw/memory/conversation-history.mdx +0 -24
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +0 -140
- package/.docs/raw/memory/storage/memory-with-mongodb.mdx +0 -150
- package/.docs/raw/memory/storage/memory-with-pg.mdx +0 -138
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +0 -146
- package/.docs/raw/memory/threads-and-resources.mdx +0 -95
|
@@ -31,7 +31,7 @@ To create an agent in Mastra use the `Agent` class to define it and then registe
|
|
|
31
31
|
|
|
32
32
|
Create a new file `src/mastra/agents/chefAgent.ts` and define your agent:
|
|
33
33
|
|
|
34
|
-
```ts
|
|
34
|
+
```ts title="src/mastra/agents/chefAgent.ts"
|
|
35
35
|
import { Agent } from "@mastra/core/agent";
|
|
36
36
|
|
|
37
37
|
export const chefAgent = new Agent({
|
|
@@ -50,7 +50,7 @@ export const chefAgent = new Agent({
|
|
|
50
50
|
|
|
51
51
|
In your `src/mastra/index.ts` file, register the agent:
|
|
52
52
|
|
|
53
|
-
```ts
|
|
53
|
+
```ts title="src/mastra/index.ts" {2, 5}
|
|
54
54
|
import { Mastra } from "@mastra/core";
|
|
55
55
|
import { chefAgent } from "./agents/chefAgent";
|
|
56
56
|
|
|
@@ -73,7 +73,7 @@ Depending on your requirements you can interact and get responses from the agent
|
|
|
73
73
|
|
|
74
74
|
Create a new file `src/index.ts` and add a `main()` function to it. Inside, craft a query to ask the agent and log its response.
|
|
75
75
|
|
|
76
|
-
```ts
|
|
76
|
+
```ts title="src/index.ts"
|
|
77
77
|
import { chefAgent } from "./mastra/agents/chefAgent";
|
|
78
78
|
|
|
79
79
|
async function main() {
|
|
@@ -90,7 +90,7 @@ main();
|
|
|
90
90
|
|
|
91
91
|
Afterwards, run the script:
|
|
92
92
|
|
|
93
|
-
```bash
|
|
93
|
+
```bash
|
|
94
94
|
npx bun src/index.ts
|
|
95
95
|
```
|
|
96
96
|
|
|
@@ -108,7 +108,7 @@ Query: In my kitchen I have: pasta, canned tomatoes, garlic, olive oil, and some
|
|
|
108
108
|
|
|
109
109
|
In the previous example you might have waited a bit for the response without any sign of progress. To show the agent's output as it creates it you should instead stream its response to the terminal.
|
|
110
110
|
|
|
111
|
-
```ts
|
|
111
|
+
```ts title="src/index.ts"
|
|
112
112
|
import { chefAgent } from "./mastra/agents/chefAgent";
|
|
113
113
|
|
|
114
114
|
async function main() {
|
|
@@ -132,7 +132,7 @@ main();
|
|
|
132
132
|
|
|
133
133
|
Afterwards, run the script again:
|
|
134
134
|
|
|
135
|
-
```bash
|
|
135
|
+
```bash
|
|
136
136
|
npx bun src/index.ts
|
|
137
137
|
```
|
|
138
138
|
|
|
@@ -155,7 +155,7 @@ Instead of showing the agent's response to a human you might want to pass it alo
|
|
|
155
155
|
|
|
156
156
|
Change your `src/index.ts` to the following:
|
|
157
157
|
|
|
158
|
-
```ts
|
|
158
|
+
```ts title="src/index.ts"
|
|
159
159
|
import { chefAgent } from "./mastra/agents/chefAgent";
|
|
160
160
|
import { z } from "zod";
|
|
161
161
|
|
|
@@ -198,12 +198,10 @@ Query: I want to make lasagna, can you generate a lasagna recipe for me?
|
|
|
198
198
|
ingredients: [
|
|
199
199
|
{ name: "Lasagna noodles", amount: "12 sheets" },
|
|
200
200
|
{ name: "Ground beef", amount: "1 pound" },
|
|
201
|
-
// ...
|
|
202
201
|
],
|
|
203
202
|
steps: [
|
|
204
203
|
"Preheat oven to 375°F (190°C).",
|
|
205
204
|
"Cook the lasagna noodles according to package instructions.",
|
|
206
|
-
// ...
|
|
207
205
|
]
|
|
208
206
|
}
|
|
209
207
|
```
|
|
@@ -222,7 +220,7 @@ Learn how to interact with your agent through Mastra's API.
|
|
|
222
220
|
|
|
223
221
|
You can run your agent as a service using the `mastra dev` command:
|
|
224
222
|
|
|
225
|
-
```bash
|
|
223
|
+
```bash
|
|
226
224
|
mastra dev
|
|
227
225
|
```
|
|
228
226
|
|
|
@@ -244,7 +242,7 @@ POST http://localhost:4111/api/agents/chefAgent/generate
|
|
|
244
242
|
|
|
245
243
|
You can interact with the agent using `curl` from the command line:
|
|
246
244
|
|
|
247
|
-
```bash
|
|
245
|
+
```bash
|
|
248
246
|
curl -X POST http://localhost:4111/api/agents/chefAgent/generate \
|
|
249
247
|
-H "Content-Type: application/json" \
|
|
250
248
|
-d '{
|
|
@@ -30,7 +30,7 @@ Before you can create an MCP server you first need to install additional depende
|
|
|
30
30
|
|
|
31
31
|
Add `@mastra/mcp` to your project:
|
|
32
32
|
|
|
33
|
-
```bash
|
|
33
|
+
```bash
|
|
34
34
|
npm install @mastra/mcp@beta
|
|
35
35
|
```
|
|
36
36
|
|
|
@@ -40,13 +40,13 @@ npm install @mastra/mcp@beta
|
|
|
40
40
|
|
|
41
41
|
After following the default [installation guide](/guides/v1/getting-started/quickstart) your project will include files that are not relevant for this guide. You can safely remove them:
|
|
42
42
|
|
|
43
|
-
```bash
|
|
43
|
+
```bash
|
|
44
44
|
rm -rf src/mastra/agents src/mastra/workflows src/mastra/tools/weather-tool.ts
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
You should also change the `src/mastra/index.ts` file like so:
|
|
48
48
|
|
|
49
|
-
```ts
|
|
49
|
+
```ts title="src/mastra/index.ts"
|
|
50
50
|
import { Mastra } from "@mastra/core";
|
|
51
51
|
import { PinoLogger } from "@mastra/loggers";
|
|
52
52
|
import { LibSQLStore } from "@mastra/libsql";
|
|
@@ -70,13 +70,13 @@ export const mastra = new Mastra({
|
|
|
70
70
|
|
|
71
71
|
Create a dedicated directory for your MCP server's logic and a `notes` directory for your notes:
|
|
72
72
|
|
|
73
|
-
```bash
|
|
73
|
+
```bash
|
|
74
74
|
mkdir notes src/mastra/mcp
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
Create the following files:
|
|
78
78
|
|
|
79
|
-
```bash
|
|
79
|
+
```bash
|
|
80
80
|
touch src/mastra/mcp/{server,resources,prompts}.ts
|
|
81
81
|
```
|
|
82
82
|
|
|
@@ -113,7 +113,7 @@ Let's add the MCP server!
|
|
|
113
113
|
|
|
114
114
|
In `src/mastra/mcp/server.ts`, define the MCP server instance:
|
|
115
115
|
|
|
116
|
-
```typescript
|
|
116
|
+
```typescript title="src/mastra/mcp/server.ts"
|
|
117
117
|
import { MCPServer } from "@mastra/mcp";
|
|
118
118
|
|
|
119
119
|
export const notes = new MCPServer({
|
|
@@ -126,7 +126,7 @@ export const notes = new MCPServer({
|
|
|
126
126
|
|
|
127
127
|
Register this MCP server in your Mastra instance at `src/mastra/index.ts`. The key `notes` is the public identifier for your MCP server:
|
|
128
128
|
|
|
129
|
-
```typescript
|
|
129
|
+
```typescript title="src/mastra/index.ts" {4, 15-17}
|
|
130
130
|
import { Mastra } from "@mastra/core";
|
|
131
131
|
import { PinoLogger } from "@mastra/loggers";
|
|
132
132
|
import { LibSQLStore } from "@mastra/libsql";
|
|
@@ -154,7 +154,7 @@ export const mastra = new Mastra({
|
|
|
154
154
|
|
|
155
155
|
Resource handlers allow clients to discover and read the content your server manages. Implement handlers to work with markdown files in the `notes` directory. Add to the `src/mastra/mcp/resources.ts` file:
|
|
156
156
|
|
|
157
|
-
```typescript
|
|
157
|
+
```typescript title="src/mastra/mcp/resources.ts"
|
|
158
158
|
import fs from "fs/promises";
|
|
159
159
|
import path from "path";
|
|
160
160
|
import { fileURLToPath } from "url";
|
|
@@ -210,7 +210,7 @@ export const resourceHandlers: MCPServerResources = {
|
|
|
210
210
|
|
|
211
211
|
Register these resource handlers in `src/mastra/mcp/server.ts`:
|
|
212
212
|
|
|
213
|
-
```typescript
|
|
213
|
+
```typescript title="src/mastra/mcp/server.ts" {2, 8}
|
|
214
214
|
import { MCPServer } from "@mastra/mcp";
|
|
215
215
|
import { resourceHandlers } from "./resources";
|
|
216
216
|
|
|
@@ -230,7 +230,7 @@ export const notes = new MCPServer({
|
|
|
230
230
|
Tools are the actions your server can perform. Let's create a `write` tool.
|
|
231
231
|
First, define the tool in `src/mastra/tools/write-note.ts`:
|
|
232
232
|
|
|
233
|
-
```typescript
|
|
233
|
+
```typescript title="src/mastra/tools/write-note.ts"
|
|
234
234
|
import { createTool } from "@mastra/core/tools";
|
|
235
235
|
import { z } from "zod";
|
|
236
236
|
import { fileURLToPath } from "url";
|
|
@@ -271,7 +271,7 @@ export const writeNoteTool = createTool({
|
|
|
271
271
|
|
|
272
272
|
Register this tool in `src/mastra/mcp/server.ts`:
|
|
273
273
|
|
|
274
|
-
```typescript
|
|
274
|
+
```typescript title="src/mastra/mcp/server.ts"
|
|
275
275
|
import { MCPServer } from "@mastra/mcp";
|
|
276
276
|
import { resourceHandlers } from "./resources";
|
|
277
277
|
import { writeNoteTool } from "../tools/write-note";
|
|
@@ -299,13 +299,13 @@ Prompt handlers provide ready-to-use prompts for clients. You'll add these three
|
|
|
299
299
|
|
|
300
300
|
This requires a few markdown-parsing libraries you need to install:
|
|
301
301
|
|
|
302
|
-
```bash
|
|
302
|
+
```bash
|
|
303
303
|
npm install unified remark-parse gray-matter @types/unist
|
|
304
304
|
```
|
|
305
305
|
|
|
306
306
|
Implement the prompts in `src/mastra/mcp/prompts.ts`:
|
|
307
307
|
|
|
308
|
-
```typescript
|
|
308
|
+
```typescript title="src/mastra/mcp/prompts.ts"
|
|
309
309
|
import type { MCPServerPrompts } from "@mastra/mcp";
|
|
310
310
|
import { unified } from "unified";
|
|
311
311
|
import remarkParse from "remark-parse";
|
|
@@ -413,7 +413,7 @@ export const promptHandlers: MCPServerPrompts = {
|
|
|
413
413
|
|
|
414
414
|
Register these prompt handlers in `src/mastra/mcp/server.ts`:
|
|
415
415
|
|
|
416
|
-
```typescript
|
|
416
|
+
```typescript title="src/mastra/mcp/server.ts"
|
|
417
417
|
import { MCPServer } from "@mastra/mcp";
|
|
418
418
|
import { resourceHandlers } from "./resources";
|
|
419
419
|
import { writeNoteTool } from "../tools/write-note";
|
|
@@ -439,7 +439,7 @@ export const notes = new MCPServer({
|
|
|
439
439
|
|
|
440
440
|
Great, you've authored your first MCP server! Now you can try it out by starting the Mastra dev server and opening [Studio](/docs/v1/getting-started/studio):
|
|
441
441
|
|
|
442
|
-
```bash
|
|
442
|
+
```bash
|
|
443
443
|
npm run dev
|
|
444
444
|
```
|
|
445
445
|
|
|
@@ -10,7 +10,7 @@ import StepItem from "@site/src/components/StepItem";
|
|
|
10
10
|
|
|
11
11
|
In this guide, you'll create an AI research assistant that can analyze academic papers and answer specific questions about their content using Retrieval Augmented Generation (RAG).
|
|
12
12
|
|
|
13
|
-
You'll use the foundational Transformer paper ["Attention Is All You Need"](https://arxiv.org/html/1706.03762) as your example. As a database you'll use a local
|
|
13
|
+
You'll use the foundational Transformer paper ["Attention Is All You Need"](https://arxiv.org/html/1706.03762) as your example. As a database you'll use a local libSQL database.
|
|
14
14
|
|
|
15
15
|
## Prerequisites
|
|
16
16
|
|
|
@@ -59,7 +59,7 @@ Install additional dependencies
|
|
|
59
59
|
|
|
60
60
|
After running the [installation guide](/guides/v1/getting-started/quickstart) you'll need to install additional dependencies:
|
|
61
61
|
|
|
62
|
-
```bash
|
|
62
|
+
```bash
|
|
63
63
|
npm install @mastra/rag@beta ai@^4.0.0
|
|
64
64
|
```
|
|
65
65
|
</StepItem>
|
|
@@ -74,7 +74,7 @@ Now you'll create your RAG-enabled research assistant. The agent uses:
|
|
|
74
74
|
|
|
75
75
|
Create a new file `src/mastra/agents/researchAgent.ts` and define your agent:
|
|
76
76
|
|
|
77
|
-
```ts
|
|
77
|
+
```ts title="src/mastra/agents/researchAgent.ts"
|
|
78
78
|
import { Agent } from "@mastra/core/agent";
|
|
79
79
|
import { ModelRouterEmbeddingModel } from "@mastra/core/llm";
|
|
80
80
|
import { createVectorQueryTool } from "@mastra/rag";
|
|
@@ -114,7 +114,7 @@ In the root of your project, grab the absolute path with the `pwd` command. The
|
|
|
114
114
|
|
|
115
115
|
In your `src/mastra/index.ts` file, add the following to your existing file and configuration:
|
|
116
116
|
|
|
117
|
-
```ts
|
|
117
|
+
```ts title="src/mastra/index.ts" {2, 4-6, 9}
|
|
118
118
|
import { Mastra } from "@mastra/core";
|
|
119
119
|
import { LibSQLVector } from "@mastra/libsql";
|
|
120
120
|
|
|
@@ -133,7 +133,7 @@ For the `connectionUrl` use the absolute path you got from the `pwd` command. Th
|
|
|
133
133
|
:::note
|
|
134
134
|
|
|
135
135
|
For the purpose of this guide you are using a hardcoded absolute path to your
|
|
136
|
-
local
|
|
136
|
+
local libSQL file, however for production usage this won't work. You should
|
|
137
137
|
use a remote persistent database then.
|
|
138
138
|
|
|
139
139
|
:::
|
|
@@ -144,7 +144,7 @@ use a remote persistent database then.
|
|
|
144
144
|
|
|
145
145
|
In the `src/mastra/index.ts` file, add the agent to Mastra:
|
|
146
146
|
|
|
147
|
-
```ts
|
|
147
|
+
```ts title="src/mastra/index.ts" {3, 10}
|
|
148
148
|
import { Mastra } from "@mastra/core";
|
|
149
149
|
import { LibSQLVector } from "@mastra/libsql";
|
|
150
150
|
import { researchAgent } from "./agents/researchAgent";
|
|
@@ -176,7 +176,7 @@ In this step the research paper is retrieved by providing an URL, then converted
|
|
|
176
176
|
|
|
177
177
|
Create a new file `src/store.ts` and add the following:
|
|
178
178
|
|
|
179
|
-
```ts
|
|
179
|
+
```ts title="src/store.ts"
|
|
180
180
|
import { MDocument } from "@mastra/rag";
|
|
181
181
|
|
|
182
182
|
// Load the paper
|
|
@@ -198,7 +198,7 @@ console.log("Number of chunks:", chunks.length);
|
|
|
198
198
|
|
|
199
199
|
Run the file in your terminal:
|
|
200
200
|
|
|
201
|
-
```bash
|
|
201
|
+
```bash
|
|
202
202
|
npx bun src/store.ts
|
|
203
203
|
```
|
|
204
204
|
|
|
@@ -229,7 +229,7 @@ This allows the agent to efficiently search and retrieve relevant information.
|
|
|
229
229
|
|
|
230
230
|
Open the `src/store.ts` file and add the following:
|
|
231
231
|
|
|
232
|
-
```ts
|
|
232
|
+
```ts title="src/store.ts"
|
|
233
233
|
import { MDocument } from "@mastra/rag";
|
|
234
234
|
import { embedMany } from "ai";
|
|
235
235
|
import { mastra } from "./mastra";
|
|
@@ -276,7 +276,7 @@ await vectorStore.upsert({
|
|
|
276
276
|
|
|
277
277
|
Lastly, you'll now need to store the embeddings by running the script again:
|
|
278
278
|
|
|
279
|
-
```bash
|
|
279
|
+
```bash
|
|
280
280
|
npx bun src/store.ts
|
|
281
281
|
```
|
|
282
282
|
|
|
@@ -292,7 +292,7 @@ Now that the vector database has all embeddings, you can test the research assis
|
|
|
292
292
|
|
|
293
293
|
Create a new file `src/ask-agent.ts` and add different types of queries:
|
|
294
294
|
|
|
295
|
-
```ts title="src/ask-agent.ts"
|
|
295
|
+
```ts title="src/ask-agent.ts"
|
|
296
296
|
import { mastra } from "./mastra";
|
|
297
297
|
const agent = mastra.getAgent("researchAgent");
|
|
298
298
|
|
|
@@ -306,7 +306,7 @@ console.log("Response:", response1.text);
|
|
|
306
306
|
|
|
307
307
|
Run the script:
|
|
308
308
|
|
|
309
|
-
```bash
|
|
309
|
+
```bash
|
|
310
310
|
npx bun src/ask-agent.ts
|
|
311
311
|
```
|
|
312
312
|
|
|
@@ -323,7 +323,7 @@ Response: Sequence modeling with neural networks faces several key challenges:
|
|
|
323
323
|
|
|
324
324
|
Try another question:
|
|
325
325
|
|
|
326
|
-
```ts title="src/ask-agent.ts"
|
|
326
|
+
```ts title="src/ask-agent.ts"
|
|
327
327
|
import { mastra } from "./mastra";
|
|
328
328
|
const agent = mastra.getAgent("researchAgent");
|
|
329
329
|
|
|
@@ -373,7 +373,7 @@ curl -X POST http://localhost:4111/api/agents/researchAgent/generate \
|
|
|
373
373
|
|
|
374
374
|
Explore these examples for more advanced RAG techniques:
|
|
375
375
|
|
|
376
|
-
- [Filter RAG](/examples/
|
|
377
|
-
- [Cleanup RAG](/examples/
|
|
378
|
-
- [Chain of Thought RAG](/examples/
|
|
379
|
-
- [Rerank RAG](/examples/
|
|
376
|
+
- [Filter RAG](https://github.com/mastra-ai/mastra/tree/main/examples/basics/rag/filter-rag) for filtering results using metadata
|
|
377
|
+
- [Cleanup RAG](https://github.com/mastra-ai/mastra/tree/main/examples/basics/rag/cleanup-rag) for optimizing information density
|
|
378
|
+
- [Chain of Thought RAG](https://github.com/mastra-ai/mastra/tree/main/examples/basics/rag/cot-rag) for complex reasoning queries using workflows
|
|
379
|
+
- [Rerank RAG](https://github.com/mastra-ai/mastra/tree/main/examples/basics/rag/rerank-rag) for improved result relevance
|
|
@@ -29,7 +29,7 @@ To create an agent in Mastra use the `Agent` class to define it and then registe
|
|
|
29
29
|
|
|
30
30
|
Create a new file `src/mastra/agents/stockAgent.ts` and define your agent:
|
|
31
31
|
|
|
32
|
-
```ts
|
|
32
|
+
```ts title="src/mastra/agents/stockAgent.ts"
|
|
33
33
|
import { Agent } from "@mastra/core/agent";
|
|
34
34
|
|
|
35
35
|
export const stockAgent = new Agent({
|
|
@@ -47,7 +47,7 @@ export const stockAgent = new Agent({
|
|
|
47
47
|
|
|
48
48
|
In your `src/mastra/index.ts` file, register the agent:
|
|
49
49
|
|
|
50
|
-
```ts
|
|
50
|
+
```ts title="src/mastra/index.ts" {2, 5}
|
|
51
51
|
import { Mastra } from "@mastra/core";
|
|
52
52
|
import { stockAgent } from "./agents/stockAgent";
|
|
53
53
|
|
|
@@ -103,7 +103,7 @@ export const stockPrices = createTool({
|
|
|
103
103
|
|
|
104
104
|
Inside `src/mastra/agents/stockAgent.ts` import your newly created `stockPrices` tool and add it to the agent.
|
|
105
105
|
|
|
106
|
-
```ts
|
|
106
|
+
```ts title="src/mastra/agents/stockAgent.ts" {9-11}
|
|
107
107
|
import { Agent } from "@mastra/core/agent";
|
|
108
108
|
import { stockPrices } from "../tools/stockPrices";
|
|
109
109
|
|
|
@@ -133,7 +133,7 @@ Learn how to interact with your agent through Mastra's API.
|
|
|
133
133
|
|
|
134
134
|
You can run your agent as a service using the `mastra dev` command:
|
|
135
135
|
|
|
136
|
-
```bash
|
|
136
|
+
```bash
|
|
137
137
|
mastra dev
|
|
138
138
|
```
|
|
139
139
|
|
|
@@ -155,7 +155,7 @@ POST http://localhost:4111/api/agents/stockAgent/generate
|
|
|
155
155
|
|
|
156
156
|
You can interact with the agent using `curl` from the command line:
|
|
157
157
|
|
|
158
|
-
```bash
|
|
158
|
+
```bash
|
|
159
159
|
curl -X POST http://localhost:4111/api/agents/stockAgent/generate \
|
|
160
160
|
-H "Content-Type: application/json" \
|
|
161
161
|
-d '{
|
|
@@ -140,7 +140,7 @@ Setup the tool:
|
|
|
140
140
|
|
|
141
141
|
In your `src/mastra/index.ts` file, register the agent:
|
|
142
142
|
|
|
143
|
-
```ts
|
|
143
|
+
```ts title="src/mastra/index.ts" {2, 5}
|
|
144
144
|
import { Mastra } from "@mastra/core";
|
|
145
145
|
import { searchAgent } from "./agents/searchAgent";
|
|
146
146
|
|
|
@@ -155,7 +155,7 @@ export const mastra = new Mastra({
|
|
|
155
155
|
|
|
156
156
|
You can test your agent with [Studio](/docs/v1/getting-started/studio) using the `mastra dev` command:
|
|
157
157
|
|
|
158
|
-
```bash
|
|
158
|
+
```bash
|
|
159
159
|
mastra dev
|
|
160
160
|
```
|
|
161
161
|
|
|
@@ -175,7 +175,7 @@ For more control over search behavior, you can integrate external search APIs as
|
|
|
175
175
|
|
|
176
176
|
Install dependencies
|
|
177
177
|
|
|
178
|
-
```bash
|
|
178
|
+
```bash
|
|
179
179
|
npm install exa-js
|
|
180
180
|
```
|
|
181
181
|
|
|
@@ -185,7 +185,7 @@ npm install exa-js
|
|
|
185
185
|
|
|
186
186
|
Create a new file `src/mastra/agents/searchAgent.ts` and define your agent:
|
|
187
187
|
|
|
188
|
-
```ts
|
|
188
|
+
```ts title="src/mastra/agents/searchAgent.ts"
|
|
189
189
|
import { Agent } from "@mastra/core/agent";
|
|
190
190
|
|
|
191
191
|
export const searchAgent = new Agent({
|
|
@@ -203,7 +203,7 @@ export const searchAgent = new Agent({
|
|
|
203
203
|
|
|
204
204
|
Setup the tool
|
|
205
205
|
|
|
206
|
-
```ts
|
|
206
|
+
```ts title="src/mastra/tools/searchTool.ts"
|
|
207
207
|
import { createTool } from "@mastra/core/tools";
|
|
208
208
|
import z from "zod";
|
|
209
209
|
import Exa from "exa-js";
|
|
@@ -246,7 +246,7 @@ export const webSearch = createTool({
|
|
|
246
246
|
|
|
247
247
|
Add to your Agent
|
|
248
248
|
|
|
249
|
-
```ts
|
|
249
|
+
```ts title="src/mastra/agents/searchAgent.ts"
|
|
250
250
|
import { webSearch } from "./tools/searchTool";
|
|
251
251
|
|
|
252
252
|
export const searchAgent = new Agent({
|
|
@@ -267,7 +267,7 @@ export const searchAgent = new Agent({
|
|
|
267
267
|
|
|
268
268
|
In your `src/mastra/index.ts` file, register the agent:
|
|
269
269
|
|
|
270
|
-
```ts
|
|
270
|
+
```ts title="src/mastra/index.ts" {2, 5}
|
|
271
271
|
import { Mastra } from "@mastra/core";
|
|
272
272
|
import { searchAgent } from "./agents/searchAgent";
|
|
273
273
|
|
|
@@ -282,7 +282,7 @@ export const mastra = new Mastra({
|
|
|
282
282
|
|
|
283
283
|
You can test your agent with [Studio](/docs/v1/getting-started/studio) using the `mastra dev` command:
|
|
284
284
|
|
|
285
|
-
```bash
|
|
285
|
+
```bash
|
|
286
286
|
mastra dev
|
|
287
287
|
```
|
|
288
288
|
|
|
@@ -11,7 +11,7 @@ This guide demonstrates how to create a WhatsApp chat bot using Mastra agents an
|
|
|
11
11
|
|
|
12
12
|
This example requires a WhatsApp Business API setup and uses the `anthropic` model. Add these environment variables to your `.env` file:
|
|
13
13
|
|
|
14
|
-
```bash title=".env"
|
|
14
|
+
```bash title=".env"
|
|
15
15
|
ANTHROPIC_API_KEY=<your-anthropic-api-key>
|
|
16
16
|
WHATSAPP_VERIFY_TOKEN=<your-verify-token>
|
|
17
17
|
WHATSAPP_ACCESS_TOKEN=<your-whatsapp-access-token>
|
|
@@ -23,7 +23,7 @@ WHATSAPP_API_VERSION=v22.0
|
|
|
23
23
|
|
|
24
24
|
This client handles sending messages to users via the WhatsApp Business API.
|
|
25
25
|
|
|
26
|
-
```typescript title="src/whatsapp-client.ts"
|
|
26
|
+
```typescript title="src/whatsapp-client.ts"
|
|
27
27
|
// Simple WhatsApp Business API client for sending messages
|
|
28
28
|
|
|
29
29
|
interface SendMessageParams {
|
|
@@ -87,7 +87,7 @@ export async function sendWhatsAppMessage({ to, message }: SendMessageParams) {
|
|
|
87
87
|
|
|
88
88
|
This agent handles the main conversation logic with a friendly, conversational personality.
|
|
89
89
|
|
|
90
|
-
```typescript title="src/mastra/agents/chat-agent.ts"
|
|
90
|
+
```typescript title="src/mastra/agents/chat-agent.ts"
|
|
91
91
|
import { Agent } from "@mastra/core/agent";
|
|
92
92
|
import { Memory } from "@mastra/memory";
|
|
93
93
|
import { LibSQLStore } from "@mastra/libsql";
|
|
@@ -136,7 +136,7 @@ export const chatAgent = new Agent({
|
|
|
136
136
|
|
|
137
137
|
This agent converts longer responses into natural, bite-sized text messages suitable for WhatsApp.
|
|
138
138
|
|
|
139
|
-
```typescript title="src/mastra/agents/text-message-agent.ts"
|
|
139
|
+
```typescript title="src/mastra/agents/text-message-agent.ts"
|
|
140
140
|
import { Agent } from "@mastra/core/agent";
|
|
141
141
|
import { Memory } from "@mastra/memory";
|
|
142
142
|
import { LibSQLStore } from "@mastra/libsql";
|
|
@@ -174,7 +174,7 @@ export const textMessageAgent = new Agent({
|
|
|
174
174
|
|
|
175
175
|
This workflow orchestrates the entire chat process: generating a response, breaking it into messages, and sending them via WhatsApp.
|
|
176
176
|
|
|
177
|
-
```typescript title="src/mastra/workflows/chat-workflow.ts"
|
|
177
|
+
```typescript title="src/mastra/workflows/chat-workflow.ts"
|
|
178
178
|
import { createStep, createWorkflow } from "@mastra/core/workflows";
|
|
179
179
|
import { z } from "zod";
|
|
180
180
|
import { sendWhatsAppMessage } from "../../whatsapp-client";
|
|
@@ -300,7 +300,7 @@ chatWorkflow.commit();
|
|
|
300
300
|
|
|
301
301
|
Configure your Mastra instance with the agents, workflow, and WhatsApp webhook endpoints.
|
|
302
302
|
|
|
303
|
-
```typescript title="src/mastra/index.ts"
|
|
303
|
+
```typescript title="src/mastra/index.ts"
|
|
304
304
|
import { Mastra } from "@mastra/core";
|
|
305
305
|
import { registerApiRoute } from "@mastra/core/server";
|
|
306
306
|
import { PinoLogger } from "@mastra/loggers";
|
|
@@ -365,7 +365,7 @@ export const mastra = new Mastra({
|
|
|
365
365
|
|
|
366
366
|
You can test the chat bot locally by simulating a WhatsApp webhook payload.
|
|
367
367
|
|
|
368
|
-
```typescript title="src/test-whatsapp-bot.ts"
|
|
368
|
+
```typescript title="src/test-whatsapp-bot.ts"
|
|
369
369
|
import "dotenv/config";
|
|
370
370
|
|
|
371
371
|
import { mastra } from "./mastra";
|
|
@@ -45,7 +45,7 @@ When using tools with TypeScript in AI SDK v5, Mastra provides type inference he
|
|
|
45
45
|
|
|
46
46
|
The `InferUITool` type helper infers the input and output types of a single Mastra tool:
|
|
47
47
|
|
|
48
|
-
```typescript title="app/types.ts"
|
|
48
|
+
```typescript title="app/types.ts"
|
|
49
49
|
import { InferUITool, createTool } from "@mastra/core/tools";
|
|
50
50
|
import { z } from "zod";
|
|
51
51
|
|
|
@@ -80,7 +80,7 @@ type WeatherUITool = InferUITool<typeof weatherTool>;
|
|
|
80
80
|
|
|
81
81
|
The `InferUITools` type helper infers the input and output types of multiple tools:
|
|
82
82
|
|
|
83
|
-
```typescript title="app/mastra/tools.ts"
|
|
83
|
+
```typescript title="app/mastra/tools.ts"
|
|
84
84
|
import { InferUITools, createTool } from "@mastra/core/tools";
|
|
85
85
|
import { z } from "zod";
|
|
86
86
|
|
|
@@ -155,6 +155,23 @@ To migrate, use workflow streaming APIs instead of watch.
|
|
|
155
155
|
+ }
|
|
156
156
|
```
|
|
157
157
|
|
|
158
|
+
### Run-related methods cannot be called directly on workflow instance
|
|
159
|
+
|
|
160
|
+
Run-related methods cannot be called directly on workflow instance. You need to create a run instance first using `createRun()` method.
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
```diff
|
|
164
|
+
- const result = await workflow.start({ runId: '123', inputData: { ... } });
|
|
165
|
+
+ const run = await workflow.createRun({ runId: '123' });
|
|
166
|
+
+ const result = await run.start({ inputData: { ... } });
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
```diff
|
|
170
|
+
- const result = await workflow.stream({ runId: '123', inputData: { ... } });
|
|
171
|
+
+ const run = await workflow.createRun({ runId: '123' });
|
|
172
|
+
+ const stream = await run.stream({ inputData: { ... } });
|
|
173
|
+
```
|
|
174
|
+
|
|
158
175
|
### Deprecated stream endpoints
|
|
159
176
|
|
|
160
177
|
Some stream endpoints are deprecated and will be removed. The `/api/agents/:agentId/stream/vnext` endpoint returns 410 Gone, and `/api/agents/:agentId/stream/ui` is deprecated. This change consolidates on standard streaming endpoints.
|
|
@@ -5,6 +5,12 @@ description: "Overview of breaking changes when upgrading to Mastra v1."
|
|
|
5
5
|
|
|
6
6
|
# Upgrade to Mastra v1
|
|
7
7
|
|
|
8
|
+
:::info[First update to latest 0.x version]
|
|
9
|
+
Before upgrading to v1, make sure you've updated to the latest 0.x version of Mastra. Follow the [upgrade to latest 0.x guide](https://mastra.ai/guides/migrations/upgrade-to-latest-0x) first, then return here to complete the v1 migration.
|
|
10
|
+
:::
|
|
11
|
+
|
|
12
|
+
Mastra v1 is coming in January 2026. We recommend starting any new projects with the beta, or upgrading your existing project today to get ahead.
|
|
13
|
+
|
|
8
14
|
This guide provides a comprehensive overview of breaking changes when upgrading from Mastra 0.x to v1.0. The migration is organized by package and feature area to help you systematically update your codebase.
|
|
9
15
|
|
|
10
16
|
:::tip[Need help?]
|
|
@@ -153,7 +153,6 @@ Step `suspendPayload` is now validated for steps that have a `suspendSchema` def
|
|
|
153
153
|
- return suspend({ reason: "Suspension reason" }); // Missing otherReason
|
|
154
154
|
+ return suspend({ reason: "Suspension reason", otherReason: "Other reason" });
|
|
155
155
|
}
|
|
156
|
-
//... continue execution logic
|
|
157
156
|
},
|
|
158
157
|
});
|
|
159
158
|
```
|
|
@@ -334,7 +333,6 @@ createStep({
|
|
|
334
333
|
+ if (!context.resumeData) {
|
|
335
334
|
+ return context.suspend({})
|
|
336
335
|
+ }
|
|
337
|
-
+ //..continue execution logic
|
|
338
336
|
+ }
|
|
339
337
|
});
|
|
340
338
|
+
|