@mastra/mcp-docs-server 1.0.0-beta.1 → 1.0.0-beta.11
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%2Fchangeset-cli.md +1 -15
- package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +1 -7
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +201 -1
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +1 -55
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +276 -76
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fauth.md +6 -0
- 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 +200 -0
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +26 -0
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +89 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +392 -192
- 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 +200 -0
- package/.docs/organized/changelogs/%40mastra%2Fduckdb.md +42 -0
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Felasticsearch.md +61 -0
- 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 +263 -63
- 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 +154 -1
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +18 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +42 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +274 -74
- 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/agui.md +1 -0
- package/.docs/organized/code-examples/ai-elements.md +2 -2
- package/.docs/organized/code-examples/ai-sdk-useChat.md +2 -2
- package/.docs/organized/code-examples/ai-sdk-v5.md +3 -2
- package/.docs/organized/code-examples/assistant-ui.md +2 -2
- package/.docs/organized/code-examples/bird-checker-with-express.md +1 -1
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +2 -2
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +2 -2
- package/.docs/organized/code-examples/client-side-tools.md +1 -1
- package/.docs/organized/code-examples/crypto-chatbot.md +2 -2
- package/.docs/organized/code-examples/fireworks-r1.md +1 -1
- package/.docs/organized/code-examples/heads-up-game.md +1 -1
- package/.docs/organized/code-examples/mcp-configuration.md +0 -3
- package/.docs/organized/code-examples/mcp-server-adapters.md +720 -0
- package/.docs/organized/code-examples/memory-per-resource-example.md +1 -1
- package/.docs/organized/code-examples/memory-with-processors.md +1 -1
- package/.docs/organized/code-examples/openapi-spec-writer.md +1 -1
- package/.docs/organized/code-examples/processors-with-ai-sdk.md +14 -0
- package/.docs/organized/code-examples/quick-start.md +2 -2
- package/.docs/organized/code-examples/server-app-access.md +342 -0
- package/.docs/organized/code-examples/server-express-adapter.md +87 -0
- package/.docs/organized/code-examples/server-hono-adapter.md +85 -0
- package/.docs/organized/code-examples/stock-price-tool.md +1 -21
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +1 -1
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +1 -1
- package/.docs/organized/code-examples/workflow-with-memory.md +1 -1
- package/.docs/organized/code-examples/workflow-with-separate-steps.md +1 -1
- package/.docs/organized/code-examples/workflow-with-suspend-resume.md +1 -1
- package/.docs/raw/agents/adding-voice.mdx +56 -10
- package/.docs/raw/agents/agent-approval.mdx +189 -0
- package/.docs/raw/agents/agent-memory.mdx +1 -1
- package/.docs/raw/agents/guardrails.mdx +70 -30
- package/.docs/raw/agents/networks.mdx +3 -3
- package/.docs/raw/agents/overview.mdx +18 -167
- package/.docs/raw/agents/processors.mdx +430 -0
- package/.docs/raw/agents/structured-output.mdx +224 -0
- package/.docs/raw/agents/using-tools.mdx +14 -14
- package/.docs/raw/auth/auth0.mdx +1 -1
- package/.docs/raw/auth/clerk.mdx +1 -1
- package/.docs/raw/auth/firebase.mdx +1 -1
- package/.docs/raw/auth/index.mdx +1 -1
- package/.docs/raw/auth/jwt.mdx +1 -1
- package/.docs/raw/auth/supabase.mdx +1 -1
- package/.docs/raw/auth/workos.mdx +1 -1
- package/.docs/raw/community/contributing-templates.mdx +1 -1
- package/.docs/raw/community/discord.mdx +2 -2
- package/.docs/raw/community/licensing.mdx +1 -1
- 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/{server-deployment.mdx → building-mastra.mdx} +4 -4
- package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +2 -2
- package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +3 -3
- package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +2 -2
- package/.docs/raw/deployment/{serverless-platforms → cloud-providers}/cloudflare-deployer.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +2 -2
- package/.docs/raw/deployment/cloud-providers/index.mdx +26 -29
- package/.docs/raw/deployment/{serverless-platforms → cloud-providers}/netlify-deployer.mdx +45 -14
- package/.docs/raw/deployment/{serverless-platforms → cloud-providers}/vercel-deployer.mdx +1 -1
- package/.docs/raw/{mastra-cloud → deployment/mastra-cloud}/dashboard.mdx +3 -3
- package/.docs/raw/deployment/mastra-cloud/observability.mdx +53 -0
- package/.docs/raw/{mastra-cloud → deployment/mastra-cloud}/overview.mdx +3 -3
- package/.docs/raw/{mastra-cloud → deployment/mastra-cloud}/setting-up.mdx +4 -4
- package/.docs/raw/deployment/monorepo.mdx +3 -3
- package/.docs/raw/deployment/overview.mdx +7 -7
- package/.docs/raw/deployment/web-framework.mdx +6 -6
- package/.docs/raw/evals/{off-the-shelf-scorers.mdx → built-in-scorers.mdx} +17 -15
- package/.docs/raw/evals/custom-scorers.mdx +4 -6
- package/.docs/raw/evals/overview.mdx +5 -6
- package/.docs/raw/evals/running-in-ci.mdx +2 -4
- package/.docs/raw/getting-started/{installation.mdx → manual-install.mdx} +6 -80
- package/.docs/raw/getting-started/mcp-docs-server.mdx +63 -6
- package/.docs/raw/getting-started/project-structure.mdx +2 -2
- package/.docs/raw/getting-started/start.mdx +72 -0
- package/.docs/raw/getting-started/studio.mdx +32 -7
- package/.docs/raw/guides/agent-frameworks/ai-sdk.mdx +147 -0
- package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +627 -0
- package/.docs/raw/{frameworks/agentic-uis → guides/build-your-ui}/assistant-ui.mdx +71 -19
- package/.docs/raw/guides/build-your-ui/copilotkit.mdx +206 -0
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/astro.mdx +24 -26
- package/.docs/raw/{frameworks/servers → guides/getting-started}/express.mdx +4 -5
- package/.docs/raw/guides/{quickstarts/nextjs.mdx → getting-started/next-js.mdx} +26 -25
- package/.docs/raw/guides/getting-started/quickstart.mdx +97 -0
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/sveltekit.mdx +24 -26
- 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/guide/whatsapp-chat-bot.mdx +421 -0
- package/.docs/raw/guides/index.mdx +3 -35
- package/.docs/raw/guides/migrations/agentnetwork.mdx +4 -4
- package/.docs/raw/guides/migrations/ai-sdk-v4-to-v5.mdx +119 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +121 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/client.mdx +42 -2
- package/.docs/raw/guides/migrations/upgrade-to-v1/evals.mdx +31 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/mastra.mdx +27 -3
- package/.docs/raw/guides/migrations/upgrade-to-v1/mcp.mdx +1 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/memory.mdx +28 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/overview.mdx +25 -3
- package/.docs/raw/guides/migrations/upgrade-to-v1/storage.mdx +80 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/tools.mdx +68 -3
- package/.docs/raw/guides/migrations/upgrade-to-v1/vectors.mdx +25 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +174 -1
- package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +2 -2
- package/.docs/raw/index.mdx +3 -3
- package/.docs/raw/mcp/overview.mdx +358 -0
- package/.docs/raw/mcp/publishing-mcp-server.mdx +139 -0
- package/.docs/raw/memory/conversation-history.mdx +1 -1
- package/.docs/raw/memory/memory-processors.mdx +265 -80
- package/.docs/raw/memory/overview.mdx +2 -2
- package/.docs/raw/memory/semantic-recall.mdx +9 -9
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +3 -8
- package/.docs/raw/memory/storage/memory-with-mongodb.mdx +150 -0
- package/.docs/raw/memory/storage/memory-with-pg.mdx +3 -8
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +3 -8
- package/.docs/raw/memory/threads-and-resources.mdx +4 -4
- package/.docs/raw/memory/working-memory.mdx +16 -8
- package/.docs/raw/{logging.mdx → observability/logging.mdx} +7 -7
- package/.docs/raw/observability/overview.mdx +3 -4
- package/.docs/raw/observability/tracing/bridges/otel.mdx +200 -0
- package/.docs/raw/observability/tracing/exporters/arize.mdx +37 -1
- package/.docs/raw/observability/tracing/exporters/braintrust.mdx +20 -1
- package/.docs/raw/observability/tracing/exporters/cloud.mdx +2 -2
- package/.docs/raw/observability/tracing/exporters/default.mdx +1 -1
- package/.docs/raw/observability/tracing/exporters/langfuse.mdx +84 -1
- package/.docs/raw/observability/tracing/exporters/langsmith.mdx +13 -1
- package/.docs/raw/observability/tracing/exporters/otel.mdx +123 -25
- package/.docs/raw/observability/tracing/exporters/posthog.mdx +127 -0
- package/.docs/raw/observability/tracing/overview.mdx +80 -9
- package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +1 -2
- package/.docs/raw/rag/chunking-and-embedding.mdx +16 -17
- package/.docs/raw/rag/overview.mdx +4 -3
- package/.docs/raw/rag/retrieval.mdx +44 -39
- package/.docs/raw/rag/vector-databases.mdx +94 -3
- package/.docs/raw/reference/agents/agent.mdx +19 -16
- package/.docs/raw/reference/agents/generate.mdx +67 -99
- package/.docs/raw/reference/agents/generateLegacy.mdx +3 -3
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +1 -1
- package/.docs/raw/reference/agents/getDefaultOptions.mdx +1 -1
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +1 -1
- package/.docs/raw/reference/agents/getDescription.mdx +1 -1
- package/.docs/raw/reference/agents/getInstructions.mdx +1 -1
- package/.docs/raw/reference/agents/getLLM.mdx +2 -2
- package/.docs/raw/reference/agents/getMemory.mdx +1 -1
- package/.docs/raw/reference/agents/getModel.mdx +1 -1
- package/.docs/raw/reference/agents/getTools.mdx +69 -0
- package/.docs/raw/reference/agents/getVoice.mdx +1 -1
- package/.docs/raw/reference/agents/listAgents.mdx +1 -1
- package/.docs/raw/reference/agents/listScorers.mdx +1 -1
- package/.docs/raw/reference/agents/listTools.mdx +2 -2
- package/.docs/raw/reference/agents/listWorkflows.mdx +1 -1
- package/.docs/raw/reference/agents/network.mdx +33 -72
- package/.docs/raw/reference/ai-sdk/chat-route.mdx +127 -0
- package/.docs/raw/reference/ai-sdk/handle-chat-stream.mdx +117 -0
- package/.docs/raw/reference/ai-sdk/handle-network-stream.mdx +64 -0
- package/.docs/raw/reference/ai-sdk/handle-workflow-stream.mdx +116 -0
- package/.docs/raw/reference/ai-sdk/network-route.mdx +99 -0
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-stream.mdx +289 -0
- package/.docs/raw/reference/ai-sdk/with-mastra.mdx +119 -0
- package/.docs/raw/reference/ai-sdk/workflow-route.mdx +110 -0
- package/.docs/raw/reference/auth/auth0.mdx +1 -1
- package/.docs/raw/reference/auth/clerk.mdx +1 -1
- package/.docs/raw/reference/auth/firebase.mdx +1 -1
- package/.docs/raw/reference/auth/jwt.mdx +1 -1
- package/.docs/raw/reference/auth/supabase.mdx +1 -1
- package/.docs/raw/reference/auth/workos.mdx +1 -1
- package/.docs/raw/reference/cli/create-mastra.mdx +1 -1
- package/.docs/raw/reference/cli/mastra.mdx +19 -6
- package/.docs/raw/reference/client-js/agents.mdx +252 -68
- package/.docs/raw/reference/client-js/error-handling.mdx +1 -1
- package/.docs/raw/reference/client-js/logs.mdx +1 -1
- package/.docs/raw/reference/client-js/mastra-client.mdx +4 -4
- package/.docs/raw/reference/client-js/memory.mdx +48 -2
- package/.docs/raw/reference/client-js/observability.mdx +1 -1
- package/.docs/raw/reference/client-js/telemetry.mdx +1 -1
- package/.docs/raw/reference/client-js/tools.mdx +1 -1
- package/.docs/raw/reference/client-js/vectors.mdx +1 -1
- package/.docs/raw/reference/client-js/workflows.mdx +93 -64
- package/.docs/raw/reference/core/addGateway.mdx +59 -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/getGateway.mdx +59 -0
- package/.docs/raw/reference/core/getGatewayById.mdx +62 -0
- package/.docs/raw/reference/core/getLogger.mdx +2 -2
- package/.docs/raw/reference/core/getMCPServer.mdx +2 -2
- package/.docs/raw/reference/core/getMCPServerById.mdx +2 -2
- package/.docs/raw/reference/core/getMemory.mdx +73 -0
- package/.docs/raw/reference/core/getScorer.mdx +1 -1
- package/.docs/raw/reference/core/getScorerById.mdx +1 -1
- package/.docs/raw/reference/core/getServer.mdx +3 -3
- package/.docs/raw/reference/core/getStorage.mdx +1 -1
- package/.docs/raw/reference/core/getStoredAgentById.mdx +183 -0
- 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/listGateways.mdx +53 -0
- package/.docs/raw/reference/core/listLogs.mdx +2 -2
- package/.docs/raw/reference/core/listLogsByRunId.mdx +2 -2
- package/.docs/raw/reference/core/listMCPServers.mdx +2 -2
- package/.docs/raw/reference/core/listMemory.mdx +70 -0
- package/.docs/raw/reference/core/listScorers.mdx +1 -1
- package/.docs/raw/reference/core/listStoredAgents.mdx +151 -0
- package/.docs/raw/reference/core/listVectors.mdx +1 -1
- package/.docs/raw/reference/core/listWorkflows.mdx +1 -1
- package/.docs/raw/reference/core/mastra-class.mdx +17 -1
- package/.docs/raw/reference/core/mastra-model-gateway.mdx +227 -0
- package/.docs/raw/reference/core/setLogger.mdx +2 -2
- package/.docs/raw/reference/core/setStorage.mdx +1 -1
- package/.docs/raw/reference/core/setTelemetry.mdx +2 -2
- package/.docs/raw/reference/deployer/cloudflare.mdx +1 -1
- package/.docs/raw/reference/deployer/deployer.mdx +1 -1
- package/.docs/raw/reference/deployer/netlify.mdx +2 -3
- package/.docs/raw/reference/deployer/vercel.mdx +1 -1
- package/.docs/raw/reference/evals/answer-relevancy.mdx +29 -99
- package/.docs/raw/reference/evals/answer-similarity.mdx +13 -259
- package/.docs/raw/reference/evals/bias.mdx +30 -88
- package/.docs/raw/reference/evals/completeness.mdx +32 -91
- package/.docs/raw/reference/evals/content-similarity.mdx +29 -89
- package/.docs/raw/reference/evals/context-precision.mdx +29 -131
- package/.docs/raw/reference/evals/context-relevance.mdx +12 -12
- package/.docs/raw/reference/evals/create-scorer.mdx +1 -1
- package/.docs/raw/reference/evals/faithfulness.mdx +29 -102
- package/.docs/raw/reference/evals/hallucination.mdx +29 -104
- package/.docs/raw/reference/evals/keyword-coverage.mdx +29 -108
- package/.docs/raw/reference/evals/mastra-scorer.mdx +1 -1
- package/.docs/raw/reference/evals/noise-sensitivity.mdx +12 -12
- package/.docs/raw/reference/evals/prompt-alignment.mdx +16 -16
- package/.docs/raw/reference/evals/run-evals.mdx +1 -1
- package/.docs/raw/reference/evals/scorer-utils.mdx +362 -0
- package/.docs/raw/reference/evals/textual-difference.mdx +28 -101
- package/.docs/raw/reference/evals/tone-consistency.mdx +26 -99
- package/.docs/raw/reference/evals/tool-call-accuracy.mdx +8 -8
- package/.docs/raw/reference/evals/toxicity.mdx +30 -93
- package/.docs/raw/reference/index.mdx +1 -0
- package/.docs/raw/reference/logging/pino-logger.mdx +2 -2
- package/.docs/raw/reference/memory/createThread.mdx +1 -1
- package/.docs/raw/reference/memory/deleteMessages.mdx +1 -1
- package/.docs/raw/reference/memory/getThreadById.mdx +1 -1
- package/.docs/raw/reference/memory/listThreadsByResourceId.mdx +1 -1
- package/.docs/raw/reference/memory/memory-class.mdx +6 -8
- package/.docs/raw/reference/memory/query.mdx +1 -1
- package/.docs/raw/reference/memory/recall.mdx +1 -1
- package/.docs/raw/reference/observability/tracing/bridges/otel.mdx +177 -0
- package/.docs/raw/reference/observability/tracing/configuration.mdx +1 -5
- package/.docs/raw/reference/observability/tracing/exporters/arize.mdx +30 -1
- package/.docs/raw/reference/observability/tracing/exporters/braintrust.mdx +1 -1
- package/.docs/raw/reference/observability/tracing/exporters/cloud-exporter.mdx +1 -1
- package/.docs/raw/reference/observability/tracing/exporters/console-exporter.mdx +1 -1
- package/.docs/raw/reference/observability/tracing/exporters/default-exporter.mdx +1 -1
- package/.docs/raw/reference/observability/tracing/exporters/langfuse.mdx +44 -1
- package/.docs/raw/reference/observability/tracing/exporters/langsmith.mdx +18 -2
- package/.docs/raw/reference/observability/tracing/exporters/otel.mdx +34 -44
- package/.docs/raw/reference/observability/tracing/exporters/posthog.mdx +132 -0
- package/.docs/raw/reference/observability/tracing/instances.mdx +1 -5
- package/.docs/raw/reference/observability/tracing/interfaces.mdx +30 -5
- package/.docs/raw/reference/observability/tracing/processors/sensitive-data-filter.mdx +1 -1
- package/.docs/raw/reference/observability/tracing/spans.mdx +1 -5
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +2 -2
- package/.docs/raw/reference/processors/language-detector.mdx +11 -4
- package/.docs/raw/reference/processors/message-history-processor.mdx +131 -0
- package/.docs/raw/reference/processors/moderation-processor.mdx +13 -6
- package/.docs/raw/reference/processors/pii-detector.mdx +13 -6
- package/.docs/raw/reference/processors/processor-interface.mdx +803 -0
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +11 -4
- package/.docs/raw/reference/processors/semantic-recall-processor.mdx +197 -0
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +4 -5
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +3 -3
- package/.docs/raw/reference/processors/tool-call-filter.mdx +125 -0
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +2 -2
- package/.docs/raw/reference/processors/working-memory-processor.mdx +221 -0
- package/.docs/raw/reference/rag/chunk.mdx +1 -1
- package/.docs/raw/reference/rag/database-config.mdx +1 -1
- package/.docs/raw/reference/rag/document.mdx +1 -1
- package/.docs/raw/reference/rag/embeddings.mdx +6 -6
- package/.docs/raw/reference/rag/extract-params.mdx +1 -1
- package/.docs/raw/reference/rag/graph-rag.mdx +1 -1
- package/.docs/raw/reference/rag/metadata-filters.mdx +1 -1
- package/.docs/raw/reference/rag/rerank.mdx +2 -3
- package/.docs/raw/reference/rag/rerankWithScorer.mdx +1 -2
- package/.docs/raw/reference/server/create-route.mdx +328 -0
- package/.docs/raw/reference/server/express-adapter.mdx +260 -0
- package/.docs/raw/reference/server/hono-adapter.mdx +242 -0
- package/.docs/raw/reference/server/mastra-server.mdx +345 -0
- package/.docs/raw/reference/server/routes.mdx +250 -0
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +38 -1
- package/.docs/raw/reference/storage/cloudflare.mdx +1 -1
- package/.docs/raw/reference/storage/convex.mdx +164 -0
- package/.docs/raw/reference/storage/dynamodb.mdx +1 -1
- package/.docs/raw/reference/storage/lance.mdx +34 -1
- package/.docs/raw/reference/storage/libsql.mdx +38 -1
- package/.docs/raw/reference/storage/mongodb.mdx +40 -1
- package/.docs/raw/reference/storage/mssql.mdx +38 -1
- package/.docs/raw/reference/storage/postgresql.mdx +38 -1
- package/.docs/raw/reference/storage/upstash.mdx +1 -1
- package/.docs/raw/reference/streaming/ChunkType.mdx +25 -4
- package/.docs/raw/reference/streaming/agents/MastraModelOutput.mdx +1 -1
- package/.docs/raw/reference/streaming/agents/stream.mdx +84 -124
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +1 -1
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +8 -10
- package/.docs/raw/reference/streaming/workflows/{resumeStreamVNext.mdx → resumeStream.mdx} +51 -11
- package/.docs/raw/reference/streaming/workflows/stream.mdx +84 -25
- package/.docs/raw/reference/streaming/workflows/timeTravelStream.mdx +170 -0
- package/.docs/raw/reference/templates/overview.mdx +2 -5
- package/.docs/raw/reference/tools/client.mdx +2 -3
- package/.docs/raw/reference/tools/create-tool.mdx +135 -4
- package/.docs/raw/reference/tools/document-chunker-tool.mdx +1 -1
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +7 -7
- package/.docs/raw/reference/tools/mcp-client.mdx +131 -23
- package/.docs/raw/reference/tools/mcp-server.mdx +56 -8
- package/.docs/raw/reference/tools/vector-query-tool.mdx +16 -17
- package/.docs/raw/reference/vectors/astra.mdx +1 -1
- package/.docs/raw/reference/vectors/chroma.mdx +82 -2
- package/.docs/raw/reference/vectors/convex.mdx +429 -0
- package/.docs/raw/reference/vectors/couchbase.mdx +25 -18
- package/.docs/raw/reference/vectors/duckdb.mdx +462 -0
- package/.docs/raw/reference/vectors/elasticsearch.mdx +310 -0
- package/.docs/raw/reference/vectors/lance.mdx +39 -23
- package/.docs/raw/reference/vectors/libsql.mdx +36 -3
- package/.docs/raw/reference/vectors/mongodb.mdx +36 -3
- package/.docs/raw/reference/vectors/opensearch.mdx +38 -17
- package/.docs/raw/reference/vectors/pg.mdx +44 -37
- package/.docs/raw/reference/vectors/pinecone.mdx +70 -3
- package/.docs/raw/reference/vectors/qdrant.mdx +37 -2
- package/.docs/raw/reference/vectors/s3vectors.mdx +1 -1
- package/.docs/raw/reference/vectors/turbopuffer.mdx +75 -1
- package/.docs/raw/reference/vectors/upstash.mdx +1 -1
- package/.docs/raw/reference/vectors/vectorize.mdx +1 -1
- package/.docs/raw/reference/voice/azure.mdx +96 -81
- package/.docs/raw/reference/voice/cloudflare.mdx +1 -1
- package/.docs/raw/reference/voice/composite-voice.mdx +72 -29
- package/.docs/raw/reference/voice/deepgram.mdx +1 -1
- package/.docs/raw/reference/voice/elevenlabs.mdx +1 -1
- package/.docs/raw/reference/voice/google-gemini-live.mdx +1 -1
- package/.docs/raw/reference/voice/google.mdx +160 -21
- package/.docs/raw/reference/voice/mastra-voice.mdx +1 -1
- package/.docs/raw/reference/voice/murf.mdx +1 -1
- package/.docs/raw/reference/voice/openai-realtime.mdx +3 -3
- package/.docs/raw/reference/voice/openai.mdx +1 -1
- package/.docs/raw/reference/voice/playai.mdx +1 -1
- package/.docs/raw/reference/voice/sarvam.mdx +1 -1
- package/.docs/raw/reference/voice/speechify.mdx +1 -1
- package/.docs/raw/reference/voice/voice.addInstructions.mdx +3 -4
- package/.docs/raw/reference/voice/voice.addTools.mdx +2 -2
- package/.docs/raw/reference/voice/voice.answer.mdx +2 -2
- package/.docs/raw/reference/voice/voice.close.mdx +2 -2
- package/.docs/raw/reference/voice/voice.connect.mdx +2 -2
- package/.docs/raw/reference/voice/voice.events.mdx +1 -1
- package/.docs/raw/reference/voice/voice.getSpeakers.mdx +1 -1
- package/.docs/raw/reference/voice/voice.listen.mdx +87 -53
- package/.docs/raw/reference/voice/voice.off.mdx +2 -2
- package/.docs/raw/reference/voice/voice.on.mdx +2 -2
- package/.docs/raw/reference/voice/voice.send.mdx +2 -2
- package/.docs/raw/reference/voice/voice.speak.mdx +76 -41
- package/.docs/raw/reference/voice/voice.updateConfig.mdx +2 -2
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +1 -1
- package/.docs/raw/reference/workflows/run-methods/restart.mdx +142 -0
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +45 -1
- package/.docs/raw/reference/workflows/run-methods/start.mdx +48 -4
- package/.docs/raw/reference/workflows/run-methods/timeTravel.mdx +310 -0
- package/.docs/raw/reference/workflows/run.mdx +28 -6
- package/.docs/raw/reference/workflows/step.mdx +65 -1
- 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 +1 -1
- 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 +69 -4
- package/.docs/raw/reference/workflows/workflow-methods/map.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/parallel.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/sendEvent.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/sleep.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/then.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow.mdx +44 -2
- package/.docs/raw/server-db/custom-adapters.mdx +386 -0
- package/.docs/raw/server-db/custom-api-routes.mdx +6 -6
- package/.docs/raw/server-db/mastra-client.mdx +3 -4
- package/.docs/raw/server-db/{production-server.mdx → mastra-server.mdx} +22 -12
- package/.docs/raw/server-db/middleware.mdx +31 -31
- package/.docs/raw/server-db/request-context.mdx +3 -4
- package/.docs/raw/server-db/server-adapters.mdx +312 -0
- package/.docs/raw/server-db/storage.mdx +12 -1
- package/.docs/raw/streaming/events.mdx +1 -1
- package/.docs/raw/streaming/overview.mdx +27 -16
- package/.docs/raw/streaming/tool-streaming.mdx +58 -19
- package/.docs/raw/streaming/workflow-streaming.mdx +6 -12
- package/.docs/raw/tools-mcp/advanced-usage.mdx +2 -3
- package/.docs/raw/tools-mcp/mcp-overview.mdx +4 -6
- package/.docs/raw/tools-mcp/overview.mdx +1 -1
- package/.docs/raw/voice/overview.mdx +88 -41
- package/.docs/raw/voice/speech-to-speech.mdx +5 -5
- package/.docs/raw/voice/speech-to-text.mdx +2 -3
- package/.docs/raw/voice/text-to-speech.mdx +2 -3
- package/.docs/raw/workflows/agents-and-tools.mdx +43 -5
- package/.docs/raw/workflows/control-flow.mdx +534 -3
- package/.docs/raw/workflows/error-handling.mdx +5 -4
- package/.docs/raw/workflows/human-in-the-loop.mdx +160 -213
- package/.docs/raw/workflows/inngest-workflow.mdx +1 -1
- package/.docs/raw/workflows/input-data-mapping.mdx +1 -1
- package/.docs/raw/workflows/overview.mdx +67 -47
- package/.docs/raw/workflows/snapshots.mdx +5 -3
- package/.docs/raw/workflows/suspend-and-resume.mdx +121 -204
- package/.docs/raw/workflows/time-travel.mdx +313 -0
- package/.docs/raw/workflows/workflow-state.mdx +190 -0
- package/CHANGELOG.md +88 -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 +17 -19
- package/package.json +10 -14
- package/.docs/raw/deployment/serverless-platforms/index.mdx +0 -58
- package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +0 -688
- package/.docs/raw/frameworks/agentic-uis/cedar-os.mdx +0 -123
- package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +0 -382
- 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/templates.mdx +0 -73
- package/.docs/raw/mastra-cloud/observability.mdx +0 -51
- package/.docs/raw/reference/streaming/workflows/observeStreamVNext.mdx +0 -47
- package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +0 -153
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Request Context | Server & DB
|
|
2
|
+
title: "Request Context | Server & DB"
|
|
3
3
|
description: Learn how to use Mastra's RequestContext to provide dynamic, request-specific configuration to agents.
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -187,8 +187,7 @@ export const weatherTool = createTool({
|
|
|
187
187
|
|
|
188
188
|
## Related
|
|
189
189
|
|
|
190
|
-
- [Request Context Example](/examples/v1/agents/request-context)
|
|
191
190
|
- [Agent Request Context](/docs/v1/agents/overview#using-requestcontext)
|
|
192
191
|
- [Workflow Request Context](../workflows/overview#using-requestcontext)
|
|
193
|
-
- [Tool Request Context](../
|
|
194
|
-
- [Server Middleware
|
|
192
|
+
- [Tool Request Context](../mcp/overview#using-requestcontext)
|
|
193
|
+
- [Server Middleware](/docs/v1/server-db/middleware)
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Server Adapters | Server & DB"
|
|
3
|
+
description: "Manually configure a Mastra server using Hono or Express adapters."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import Tabs from "@theme/Tabs";
|
|
7
|
+
import TabItem from "@theme/TabItem";
|
|
8
|
+
|
|
9
|
+
# Server Adapters
|
|
10
|
+
|
|
11
|
+
Server adapters let you run Mastra with your own HTTP server instead of the Hono server generated by `mastra build`. They provide more control over the server setup, including custom middleware ordering, authentication, logging, and deployment configuration. You can still integrate Mastra into any Node.js application without changing how agents or workflows execute.
|
|
12
|
+
|
|
13
|
+
## When to use server adapters
|
|
14
|
+
|
|
15
|
+
- You want Mastra’s endpoints added automatically to an existing application
|
|
16
|
+
- You need direct access to the server instance for custom configuration
|
|
17
|
+
- Your team prefers using another server framework instead of the Hono server created by `mastra build`.
|
|
18
|
+
|
|
19
|
+
:::tip
|
|
20
|
+
|
|
21
|
+
For simple deployments without custom server requirements, use `mastra build` instead. It configures server setup, registers middleware, and applies deployment settings based on your project configuration. See [Server Configuration](/docs/v1/server-db/mastra-server).
|
|
22
|
+
|
|
23
|
+
:::
|
|
24
|
+
|
|
25
|
+
## Available adapters
|
|
26
|
+
|
|
27
|
+
Mastra currently provides two official server adapters:
|
|
28
|
+
|
|
29
|
+
- [@mastra/express](/reference/v1/server/express-adapter): Express framework adapter
|
|
30
|
+
- [@mastra/hono](/reference/v1/server/hono-adapter): Hono framework adapter
|
|
31
|
+
|
|
32
|
+
You can build your own adapter, read [Custom Adapters](/docs/v1/server-db/custom-adapters) for details.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
Install the adapter for the framework of your choice.
|
|
37
|
+
|
|
38
|
+
<Tabs>
|
|
39
|
+
<TabItem value="express" label="Express">
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install @mastra/express@beta
|
|
43
|
+
```
|
|
44
|
+
</TabItem>
|
|
45
|
+
<TabItem value="hono" label="Hono">
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install @mastra/hono@beta
|
|
49
|
+
```
|
|
50
|
+
</TabItem>
|
|
51
|
+
</Tabs>
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
Initialize your app as usual, then create a `MastraServer` by passing in the `app` and your main `mastra` instance from `src/mastra/index.ts`. Calling `init()` automatically registers Mastra middleware and all available endpoints. You can continue adding your own routes as normal, either before or after `init()`, and they’ll run alongside Mastra’s endpoints.
|
|
56
|
+
|
|
57
|
+
<Tabs>
|
|
58
|
+
<TabItem value="express" label="Express">
|
|
59
|
+
|
|
60
|
+
```typescript {8} title="src/express-server.ts"
|
|
61
|
+
import express from "express";
|
|
62
|
+
import { MastraServer } from "@mastra/express";
|
|
63
|
+
import { mastra } from "./mastra";
|
|
64
|
+
|
|
65
|
+
const app = express();
|
|
66
|
+
app.use(express.json());
|
|
67
|
+
|
|
68
|
+
const server = new MastraServer({ app, mastra });
|
|
69
|
+
|
|
70
|
+
await server.init();
|
|
71
|
+
|
|
72
|
+
app.listen(4111, () => {
|
|
73
|
+
console.log('Server running on port 4111');
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
</TabItem>
|
|
78
|
+
<TabItem value="hono" label="Hono">
|
|
79
|
+
|
|
80
|
+
```typescript {8} title="src/hono-server.ts"
|
|
81
|
+
import { Hono } from "hono";
|
|
82
|
+
import { serve } from "@hono/node-server";
|
|
83
|
+
import { HonoBindings, HonoVariables, MastraServer } from "@mastra/hono";
|
|
84
|
+
import { mastra } from "./mastra";
|
|
85
|
+
|
|
86
|
+
const app = new Hono<{ Bindings: HonoBindings; Variables: HonoVariables }>();
|
|
87
|
+
|
|
88
|
+
const server = new MastraServer({ app, mastra });
|
|
89
|
+
|
|
90
|
+
await server.init();
|
|
91
|
+
|
|
92
|
+
serve({ fetch: app.fetch, port: 4111 }, () => {
|
|
93
|
+
console.log('Server running on port 4111');
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
</TabItem>
|
|
98
|
+
</Tabs>
|
|
99
|
+
|
|
100
|
+
:::info
|
|
101
|
+
|
|
102
|
+
See the [Express Adapter](/reference/v1/server/express-adapter) or [Hono Adapter](/reference/v1/server/hono-adapter) docs for full configuration options.
|
|
103
|
+
|
|
104
|
+
:::
|
|
105
|
+
|
|
106
|
+
## Initialization flow
|
|
107
|
+
|
|
108
|
+
Calling `init()` runs three steps in order. Understanding this flow helps when you need to insert your own middleware at specific points.
|
|
109
|
+
|
|
110
|
+
1. `registerContextMiddleware()`: Attaches the Mastra instance, request context, tools, and abort signal to every request. This makes Mastra available to all subsequent middleware and route handlers.
|
|
111
|
+
2. `registerAuthMiddleware()`: Adds authentication and authorization middleware, but only if `server.auth` is configured in your Mastra instance. Skipped entirely if no auth is configured.
|
|
112
|
+
3. `registerRoutes()`: Registers all Mastra API routes for agents, workflows, and other features. Also registers MCP routes if MCP servers are configured.
|
|
113
|
+
|
|
114
|
+
### Manual initialization
|
|
115
|
+
|
|
116
|
+
For custom middleware ordering, call each method separately instead of `init()`. This is useful when you need middleware that runs before Mastra's context is set up, or when you need to insert logic between the initialization steps.
|
|
117
|
+
|
|
118
|
+
```typescript title="server.ts" copy
|
|
119
|
+
const server = new MastraServer({ app, mastra });
|
|
120
|
+
|
|
121
|
+
// Your middleware first
|
|
122
|
+
app.use(loggingMiddleware);
|
|
123
|
+
|
|
124
|
+
server.registerContextMiddleware();
|
|
125
|
+
|
|
126
|
+
// Middleware that needs Mastra context
|
|
127
|
+
app.use(customMiddleware);
|
|
128
|
+
|
|
129
|
+
server.registerAuthMiddleware();
|
|
130
|
+
await server.registerRoutes();
|
|
131
|
+
|
|
132
|
+
// Routes after Mastra
|
|
133
|
+
app.get('/health', ...);
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
:::tip
|
|
137
|
+
|
|
138
|
+
Use manual initialization when you need middleware that runs before Mastra's context is available, or when you need to insert middleware between the context and auth steps.
|
|
139
|
+
|
|
140
|
+
:::
|
|
141
|
+
|
|
142
|
+
## Adding custom routes
|
|
143
|
+
|
|
144
|
+
You can add your own routes to the app alongside Mastra's routes.
|
|
145
|
+
|
|
146
|
+
- Routes added **before** `init()` won't have Mastra context available.
|
|
147
|
+
- Routes added **after** `init()` have access to the Mastra context (the Mastra instance, request context, authenticated user, etc.).
|
|
148
|
+
|
|
149
|
+
:::info
|
|
150
|
+
|
|
151
|
+
Visit "Adding custom routes" for [Express](/reference/v1/server/express-adapter#adding-custom-routes) and [Hono](/reference/v1/server/hono-adapter#adding-custom-routes) for more information.
|
|
152
|
+
|
|
153
|
+
:::
|
|
154
|
+
|
|
155
|
+
## Route prefixes
|
|
156
|
+
|
|
157
|
+
By default, Mastra routes are registered at `/api/agents`, `/api/workflows`, etc. Use the `prefix` option to change this. This is useful for API versioning or when integrating with an existing app that has its own `/api` routes.
|
|
158
|
+
|
|
159
|
+
```typescript copy
|
|
160
|
+
const server = new MastraServer({
|
|
161
|
+
app,
|
|
162
|
+
mastra,
|
|
163
|
+
prefix: '/api/v2',
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
With this prefix, Mastra routes become `/api/v2/agents`, `/api/v2/workflows`, etc. Custom routes you add directly to the app are not affected by this prefix.
|
|
168
|
+
|
|
169
|
+
## OpenAPI spec
|
|
170
|
+
|
|
171
|
+
Mastra can generate an OpenAPI specification for all registered routes. This is useful for documentation, client generation, or integration with API tools. Enable it by setting the `openapiPath` option:
|
|
172
|
+
|
|
173
|
+
```typescript copy
|
|
174
|
+
const server = new MastraServer({
|
|
175
|
+
app,
|
|
176
|
+
mastra,
|
|
177
|
+
openapiPath: '/openapi.json',
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
The spec is generated from the Zod schemas defined on each route and served at the specified path. It includes all Mastra routes as well as any custom routes created with `createRoute()`.
|
|
182
|
+
|
|
183
|
+
## Stream data redaction
|
|
184
|
+
|
|
185
|
+
When streaming agent responses over HTTP, the HTTP streaming layer redacts sensitive information from stream chunks before sending them to clients. This prevents accidental exposure of:
|
|
186
|
+
|
|
187
|
+
- System prompts and agent instructions
|
|
188
|
+
- Tool definitions and their parameters
|
|
189
|
+
- API keys and other credentials in request bodies
|
|
190
|
+
- Internal configuration data
|
|
191
|
+
|
|
192
|
+
This redaction happens at the HTTP boundary, so internal callbacks like `onStepFinish` still have access to the full request data for debugging and observability purposes.
|
|
193
|
+
|
|
194
|
+
By default, redaction is enabled. Configure this behavior via `streamOptions`. Set `redact: false` only for internal services or debugging scenarios where you need access to the full request data in stream responses.
|
|
195
|
+
|
|
196
|
+
```typescript copy
|
|
197
|
+
const server = new MastraServer({
|
|
198
|
+
app,
|
|
199
|
+
mastra,
|
|
200
|
+
streamOptions: {
|
|
201
|
+
redact: true, // Default
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
:::info
|
|
207
|
+
|
|
208
|
+
See [MastraServer](/reference/v1/server/mastra-server) for full configuration options.
|
|
209
|
+
|
|
210
|
+
:::
|
|
211
|
+
|
|
212
|
+
## Per-route auth overrides
|
|
213
|
+
|
|
214
|
+
When authentication is configured on your Mastra instance, all routes require authentication by default. Sometimes you need exceptions: public health check endpoints, webhook receivers, or admin routes that need stricter controls.
|
|
215
|
+
|
|
216
|
+
Use `customRouteAuthConfig` to override authentication behavior for specific routes. Keys follow the format `METHOD:PATH` where method is `GET`, `POST`, `PUT`, `DELETE`, or `ALL`. Paths support wildcards (`*`) for matching multiple routes. Setting a value to `false` makes the route public, while `true` requires authentication.
|
|
217
|
+
|
|
218
|
+
```typescript copy
|
|
219
|
+
const server = new MastraServer({
|
|
220
|
+
app,
|
|
221
|
+
mastra,
|
|
222
|
+
customRouteAuthConfig: new Map([
|
|
223
|
+
// Public health check
|
|
224
|
+
['GET:/api/health', false],
|
|
225
|
+
// Public API spec
|
|
226
|
+
['GET:/api/openapi.json', false],
|
|
227
|
+
// Public webhook endpoints
|
|
228
|
+
['POST:/api/webhooks/*', false],
|
|
229
|
+
// Require auth even if globally disabled
|
|
230
|
+
['POST:/api/admin/reset', true],
|
|
231
|
+
// Protect all methods on internal routes
|
|
232
|
+
['ALL:/api/internal/*', true],
|
|
233
|
+
]),
|
|
234
|
+
});
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
:::info
|
|
238
|
+
|
|
239
|
+
See [MastraServer](/reference/v1/server/mastra-server) for full configuration options.
|
|
240
|
+
|
|
241
|
+
:::
|
|
242
|
+
|
|
243
|
+
## Accessing the app
|
|
244
|
+
|
|
245
|
+
After creating the adapter, you may still need access to the underlying framework app. This is useful when passing it to a platform’s `serve` function or when adding routes from another module.
|
|
246
|
+
|
|
247
|
+
```typescript copy
|
|
248
|
+
// Via the MastraServer instance
|
|
249
|
+
const app = server.getApp();
|
|
250
|
+
|
|
251
|
+
// Via the Mastra instance (available after adapter construction)
|
|
252
|
+
const app = mastra.getServerApp();
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Both methods return the same app instance. Use whichever is more convenient based on what's in scope.
|
|
256
|
+
|
|
257
|
+
## Server config vs adapter options
|
|
258
|
+
|
|
259
|
+
When using server adapters, configuration comes from two places: the Mastra `server` config (passed to the `Mastra` constructor) and the adapter constructor options. Understanding which options come from where helps avoid confusion when settings don't seem to take effect.
|
|
260
|
+
|
|
261
|
+
### Used by adapters
|
|
262
|
+
|
|
263
|
+
The adapter reads these settings from `mastra.getServer()`:
|
|
264
|
+
|
|
265
|
+
| Option | Description |
|
|
266
|
+
|--------|-------------|
|
|
267
|
+
| `auth` | Authentication config, used by `registerAuthMiddleware()`. |
|
|
268
|
+
| `bodySizeLimit` | Default body size limit in bytes. Can be overridden per-adapter via `bodyLimitOptions`. |
|
|
269
|
+
|
|
270
|
+
### Adapter constructor only
|
|
271
|
+
|
|
272
|
+
These options are passed directly to the adapter constructor and are not read from the Mastra config:
|
|
273
|
+
|
|
274
|
+
| Option | Description |
|
|
275
|
+
|--------|-------------|
|
|
276
|
+
| `prefix` | Route path prefix |
|
|
277
|
+
| `openapiPath` | OpenAPI spec endpoint |
|
|
278
|
+
| `bodyLimitOptions` | Body size limit with custom error handler |
|
|
279
|
+
| `streamOptions` | Stream redaction settings |
|
|
280
|
+
| `customRouteAuthConfig` | Per-route auth overrides |
|
|
281
|
+
|
|
282
|
+
### Not used by adapters
|
|
283
|
+
|
|
284
|
+
These `server` config options are only used by `mastra build` and have no effect when using adapters directly:
|
|
285
|
+
|
|
286
|
+
| Option | Used by |
|
|
287
|
+
|--------|---------|
|
|
288
|
+
| `port`, `host` | `mastra dev`, `mastra build` |
|
|
289
|
+
| `cors` | `mastra build` adds CORS middleware |
|
|
290
|
+
| `timeout` | `mastra build` |
|
|
291
|
+
| `apiRoutes` | `registerApiRoute()` for `mastra build` |
|
|
292
|
+
| `middleware` | Middleware config for `mastra build` |
|
|
293
|
+
|
|
294
|
+
When using adapters, configure these features directly with your framework. For example, add CORS middleware using Hono's or Express's built-in CORS packages, and set the port when calling your framework's listen function.
|
|
295
|
+
|
|
296
|
+
## MCP support
|
|
297
|
+
|
|
298
|
+
Server adapters register MCP (Model Context Protocol) routes during `registerRoutes()` when MCP servers are configured in your Mastra instance. MCP allows external tools and services to connect to your Mastra server and interact with your agents.
|
|
299
|
+
|
|
300
|
+
The adapter registers routes for both HTTP and SSE (Server-Sent Events) transports, enabling different client connection patterns.
|
|
301
|
+
|
|
302
|
+
See [MCP](/docs/v1/mcp/overview) for configuration details and how to set up MCP servers.
|
|
303
|
+
|
|
304
|
+
## Related
|
|
305
|
+
|
|
306
|
+
- [Hono Adapter](/reference/v1/server/hono-adapter) - Hono-specific setup
|
|
307
|
+
- [Express Adapter](/reference/v1/server/express-adapter) - Express-specific setup
|
|
308
|
+
- [Custom Adapters](/docs/v1/server-db/custom-adapters) - Building adapters for other frameworks
|
|
309
|
+
- [Server Configuration](/docs/v1/server-db/mastra-server) - Using `mastra build` instead
|
|
310
|
+
- [Authentication](/docs/v1/auth) - Configuring auth for your server
|
|
311
|
+
- [MastraServer Reference](/reference/v1/server/mastra-server) - Full API reference
|
|
312
|
+
- [createRoute() Reference](/reference/v1/server/create-route) - Creating type-safe custom routes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "MastraStorage | Server & DB
|
|
2
|
+
title: "MastraStorage | Server & DB"
|
|
3
3
|
description: Overview of Mastra's storage system and data persistence capabilities.
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -489,12 +489,23 @@ console.log(result.messages); // MastraDBMessage[]
|
|
|
489
489
|
console.log(result.total); // Total count
|
|
490
490
|
console.log(result.hasMore); // Whether more pages exist
|
|
491
491
|
|
|
492
|
+
// Get messages from multiple threads at once
|
|
493
|
+
const multiThreadResult = await mastra
|
|
494
|
+
.getStorage()
|
|
495
|
+
.listMessages({
|
|
496
|
+
threadId: ["thread-1", "thread-2", "thread-3"],
|
|
497
|
+
page: 0,
|
|
498
|
+
perPage: 100
|
|
499
|
+
});
|
|
500
|
+
|
|
492
501
|
// Get messages by their IDs
|
|
493
502
|
const messages = await mastra
|
|
494
503
|
.getStorage()
|
|
495
504
|
.listMessagesById({ messageIds: messageIdArr });
|
|
496
505
|
```
|
|
497
506
|
|
|
507
|
+
The `threadId` parameter accepts either a single thread ID string or an array of thread IDs to query messages from multiple threads in a single request.
|
|
508
|
+
|
|
498
509
|
All message queries return `MastraDBMessage[]` format. If you need to convert messages to AI SDK formats for UI rendering, use the conversion utilities from `@mastra/ai-sdk/ui`:
|
|
499
510
|
|
|
500
511
|
```typescript copy
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Streaming Events | Streaming
|
|
2
|
+
title: "Streaming Events | Streaming"
|
|
3
3
|
description: "Learn about the different types of streaming events in Mastra, including text deltas, tool calls, step events, and how to handle them in your applications."
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Streaming Overview | Streaming
|
|
2
|
+
title: "Streaming Overview | Streaming"
|
|
3
3
|
description: "Streaming in Mastra enables real-time, incremental responses from both agents and workflows, providing immediate feedback as AI-generated content is produced."
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -60,19 +60,30 @@ An agent stream provides access to various response properties:
|
|
|
60
60
|
|
|
61
61
|
AI SDK v5 uses `LanguageModelV2` for the model providers. If you are getting an error that you are using an AI SDK v4 model you will need to upgrade your model package to the next major version.
|
|
62
62
|
|
|
63
|
-
For integration with AI SDK v5, use `
|
|
63
|
+
For integration with AI SDK v5, use the `toAISdkV5Stream()` utility from `@mastra/ai-sdk` to convert Mastra streams to AI SDK-compatible format:
|
|
64
|
+
|
|
65
|
+
```typescript {2,9-12} showLineNumbers copy
|
|
66
|
+
import { toAISdkV5Stream } from "@mastra/ai-sdk";
|
|
64
67
|
|
|
65
|
-
```typescript {5} showLineNumbers copy
|
|
66
68
|
const testAgent = mastra.getAgent("testAgent");
|
|
67
69
|
|
|
68
|
-
const stream = await testAgent.stream(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
);
|
|
70
|
+
const stream = await testAgent.stream([
|
|
71
|
+
{ role: "user", content: "Help me organize my day" },
|
|
72
|
+
]);
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
// Convert to AI SDK v5 compatible stream
|
|
75
|
+
const aiSDKStream = toAISdkV5Stream(stream, { from: "agent" });
|
|
76
|
+
|
|
77
|
+
// Use with AI SDK v5 methods
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
For converting messages to AI SDK v5 format, use the `toAISdkV5Messages()` utility from `@mastra/ai-sdk/ui`:
|
|
81
|
+
|
|
82
|
+
```typescript {1,4} showLineNumbers copy
|
|
83
|
+
import { toAISdkV5Messages } from "@mastra/ai-sdk/ui";
|
|
84
|
+
|
|
85
|
+
const messages = [{ role: "user", content: "Hello" }];
|
|
86
|
+
const aiSDKMessages = toAISdkV5Messages(messages);
|
|
76
87
|
```
|
|
77
88
|
|
|
78
89
|
### Using `Agent.network()`
|
|
@@ -121,14 +132,14 @@ console.log("Token usage:", await networkStream.usage);
|
|
|
121
132
|
|
|
122
133
|
Streaming from a workflow returns a sequence of structured events describing the run lifecycle, rather than incremental text chunks. This event-based format makes it possible to track and respond to workflow progress in real time once a run is created using `.createRun()`.
|
|
123
134
|
|
|
124
|
-
### Using `Run.
|
|
135
|
+
### Using `Run.stream()`
|
|
125
136
|
|
|
126
|
-
|
|
137
|
+
The `stream()` method returns a `ReadableStream` of events directly.
|
|
127
138
|
|
|
128
139
|
```typescript {3,9} showLineNumbers copy
|
|
129
140
|
const run = await testWorkflow.createRun();
|
|
130
141
|
|
|
131
|
-
const stream = await run.
|
|
142
|
+
const stream = await run.stream({
|
|
132
143
|
inputData: {
|
|
133
144
|
value: "initial data",
|
|
134
145
|
},
|
|
@@ -139,16 +150,16 @@ for await (const chunk of stream) {
|
|
|
139
150
|
}
|
|
140
151
|
```
|
|
141
152
|
|
|
142
|
-
> See Run.
|
|
153
|
+
> See [Run.stream()](/reference/v1/streaming/workflows/stream) method documentation for more information.
|
|
143
154
|
|
|
144
155
|
### Output from `Run.stream()`
|
|
145
156
|
|
|
146
|
-
The
|
|
157
|
+
The event structure includes `runId` and `from` at the top level, making it easier to identify and track workflow runs without digging into the payload.
|
|
147
158
|
|
|
148
159
|
```typescript
|
|
149
160
|
// ...
|
|
150
161
|
{
|
|
151
|
-
type: '
|
|
162
|
+
type: 'workflow-start',
|
|
152
163
|
runId: '1eeaf01a-d2bf-4e3f-8d1b-027795ccd3df',
|
|
153
164
|
from: 'WORKFLOW',
|
|
154
165
|
payload: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Tool streaming | Streaming
|
|
2
|
+
title: "Tool streaming | Streaming"
|
|
3
3
|
description: "Learn how to use tool streaming in Mastra, including handling tool calls, tool results, and tool execution events during streaming."
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -18,47 +18,44 @@ By combining writable tool streams with agent streaming, you gain fine grained c
|
|
|
18
18
|
|
|
19
19
|
Agent streaming can be combined with tool calls, allowing tool outputs to be written directly into the agent’s streaming response. This makes it possible to surface tool activity as part of the overall interaction.
|
|
20
20
|
|
|
21
|
-
```typescript {
|
|
22
|
-
import { openai } from "@ai-sdk/openai";
|
|
21
|
+
```typescript {2,9} showLineNumbers copy
|
|
23
22
|
import { Agent } from "@mastra/core/agent";
|
|
24
|
-
|
|
25
23
|
import { testTool } from "../tools/test-tool";
|
|
26
24
|
|
|
27
25
|
export const testAgent = new Agent({
|
|
28
26
|
id: "test-agent",
|
|
29
27
|
name: "Test Agent",
|
|
30
28
|
instructions: "You are a weather agent.",
|
|
31
|
-
model: openai
|
|
29
|
+
model: "openai/gpt-5.1",
|
|
32
30
|
tools: { testTool },
|
|
33
31
|
});
|
|
34
32
|
```
|
|
35
33
|
|
|
36
34
|
### Using `context.writer`
|
|
37
35
|
|
|
38
|
-
The `context.writer` object is available in a tool's `execute` function and can be used to emit custom events, data, or values into the active stream. This enables tools to provide intermediate results or status updates while execution is still in progress.
|
|
36
|
+
The `context.writer` object is available in a tool's `execute()` function and can be used to emit custom events, data, or values into the active stream. This enables tools to provide intermediate results or status updates while execution is still in progress.
|
|
39
37
|
|
|
40
38
|
:::warning
|
|
41
39
|
|
|
42
|
-
You must `await` the call to `writer.write(
|
|
40
|
+
You must `await` the call to `writer.write()` or else you will lock the stream and get a `WritableStream is locked` error.
|
|
43
41
|
|
|
44
42
|
:::
|
|
45
43
|
|
|
46
|
-
```typescript {
|
|
44
|
+
```typescript {4,7,14} showLineNumbers copy
|
|
47
45
|
import { createTool } from "@mastra/core/tools";
|
|
48
46
|
|
|
49
47
|
export const testTool = createTool({
|
|
50
|
-
// ...
|
|
51
48
|
execute: async (inputData, context) => {
|
|
52
49
|
const { value } = inputData;
|
|
53
50
|
|
|
54
|
-
|
|
51
|
+
await context?.writer?.write({
|
|
55
52
|
type: "custom-event",
|
|
56
53
|
status: "pending"
|
|
57
54
|
});
|
|
58
55
|
|
|
59
56
|
const response = await fetch(...);
|
|
60
57
|
|
|
61
|
-
|
|
58
|
+
await context?.writer?.write({
|
|
62
59
|
type: "custom-event",
|
|
63
60
|
status: "success"
|
|
64
61
|
});
|
|
@@ -70,14 +67,13 @@ export const testTool = createTool({
|
|
|
70
67
|
});
|
|
71
68
|
```
|
|
72
69
|
|
|
73
|
-
You can also use `writer.custom` if you want to emit top level stream chunks, This useful and relevant when
|
|
70
|
+
You can also use `writer.custom()` if you want to emit top level stream chunks, This useful and relevant when
|
|
74
71
|
integrating with UI Frameworks
|
|
75
72
|
|
|
76
|
-
```typescript {
|
|
73
|
+
```typescript {4,7,14} showLineNumbers copy
|
|
77
74
|
import { createTool } from "@mastra/core/tools";
|
|
78
75
|
|
|
79
76
|
export const testTool = createTool({
|
|
80
|
-
// ...
|
|
81
77
|
execute: async (inputData, context) => {
|
|
82
78
|
const { value } = inputData;
|
|
83
79
|
|
|
@@ -117,23 +113,66 @@ for await (const chunk of stream) {
|
|
|
117
113
|
}
|
|
118
114
|
```
|
|
119
115
|
|
|
116
|
+
## Tool Lifecycle Hooks
|
|
117
|
+
|
|
118
|
+
Tools support lifecycle hooks that allow you to monitor different stages of tool execution during streaming. These hooks are particularly useful for logging or analytics.
|
|
119
|
+
|
|
120
|
+
### Example: Using onInputAvailable and onOutput
|
|
121
|
+
|
|
122
|
+
```typescript showLineNumbers copy
|
|
123
|
+
import { createTool } from "@mastra/core/tools";
|
|
124
|
+
import { z } from "zod";
|
|
125
|
+
|
|
126
|
+
export const weatherTool = createTool({
|
|
127
|
+
id: "weather-tool",
|
|
128
|
+
description: "Get weather information",
|
|
129
|
+
inputSchema: z.object({
|
|
130
|
+
city: z.string(),
|
|
131
|
+
}),
|
|
132
|
+
outputSchema: z.object({
|
|
133
|
+
temperature: z.number(),
|
|
134
|
+
conditions: z.string(),
|
|
135
|
+
}),
|
|
136
|
+
// Called when the complete input is available
|
|
137
|
+
onInputAvailable: ({ input, toolCallId }) => {
|
|
138
|
+
console.log(`Weather requested for: ${input.city}`);
|
|
139
|
+
},
|
|
140
|
+
execute: async (input) => {
|
|
141
|
+
const weather = await fetchWeather(input.city);
|
|
142
|
+
return weather;
|
|
143
|
+
},
|
|
144
|
+
// Called after successful execution
|
|
145
|
+
onOutput: ({ output, toolName }) => {
|
|
146
|
+
console.log(`${toolName} result: ${output.temperature}°F, ${output.conditions}`);
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Available Hooks
|
|
152
|
+
|
|
153
|
+
- **onInputStart**: Called when tool call input streaming begins
|
|
154
|
+
- **onInputDelta**: Called for each chunk of input as it streams in
|
|
155
|
+
- **onInputAvailable**: Called when complete input is parsed and validated
|
|
156
|
+
- **onOutput**: Called after the tool successfully executes with the output
|
|
157
|
+
|
|
158
|
+
For detailed documentation on all lifecycle hooks, see the [createTool() reference](/reference/v1/tools/create-tool#tool-lifecycle-hooks).
|
|
159
|
+
|
|
120
160
|
## Tool using an agent
|
|
121
161
|
|
|
122
|
-
Pipe an agent
|
|
162
|
+
Pipe an agent's `fullStream` to the tool's `writer`. This streams partial output, and Mastra automatically aggregates the agent's usage into the tool run.
|
|
123
163
|
|
|
124
164
|
```typescript showLineNumbers copy
|
|
125
165
|
import { createTool } from "@mastra/core/tools";
|
|
126
166
|
import { z } from "zod";
|
|
127
167
|
|
|
128
168
|
export const testTool = createTool({
|
|
129
|
-
// ...
|
|
130
169
|
execute: async (inputData, context) => {
|
|
131
170
|
const { city } = inputData;
|
|
132
171
|
|
|
133
|
-
const
|
|
134
|
-
const stream = await
|
|
172
|
+
const agent = context?.mastra?.getAgent("testAgent");
|
|
173
|
+
const stream = await agent?.stream(`What is the weather in ${city}?`);
|
|
135
174
|
|
|
136
|
-
await stream!.
|
|
175
|
+
await stream!.fullStream.pipeTo(context?.writer!);
|
|
137
176
|
|
|
138
177
|
return {
|
|
139
178
|
value: await stream!.text,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Workflow streaming | Streaming
|
|
2
|
+
title: "Workflow streaming | Streaming"
|
|
3
3
|
description: "Learn how to use workflow streaming in Mastra, including handling workflow execution events, step streaming, and workflow integration with agents and tools."
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -16,12 +16,6 @@ By combining writable workflow streams with agent streaming, you gain fine-grain
|
|
|
16
16
|
|
|
17
17
|
### Using the `writer` argument
|
|
18
18
|
|
|
19
|
-
:::warning
|
|
20
|
-
|
|
21
|
-
The writer is only available when using `streamVNext`.
|
|
22
|
-
|
|
23
|
-
:::
|
|
24
|
-
|
|
25
19
|
The `writer` argument is passed to a workflow step's `execute` function and can be used to emit custom events, data, or values into the active stream. This enables workflow steps to provide intermediate results or status updates while execution is still in progress.
|
|
26
20
|
|
|
27
21
|
:::warning
|
|
@@ -66,7 +60,7 @@ const testWorkflow = mastra.getWorkflow("testWorkflow");
|
|
|
66
60
|
|
|
67
61
|
const run = await testWorkflow.createRun();
|
|
68
62
|
|
|
69
|
-
const stream = await run.
|
|
63
|
+
const stream = await run.stream({
|
|
70
64
|
inputData: {
|
|
71
65
|
value: "initial data",
|
|
72
66
|
},
|
|
@@ -77,8 +71,8 @@ for await (const chunk of stream) {
|
|
|
77
71
|
}
|
|
78
72
|
|
|
79
73
|
if (result!.status === "suspended") {
|
|
80
|
-
// if the workflow is suspended, we can resume it with the
|
|
81
|
-
const resumedStream = await run.
|
|
74
|
+
// if the workflow is suspended, we can resume it with the resumeStream method
|
|
75
|
+
const resumedStream = await run.resumeStream({
|
|
82
76
|
resumeData: { value: "resume data" },
|
|
83
77
|
});
|
|
84
78
|
|
|
@@ -90,10 +84,10 @@ if (result!.status === "suspended") {
|
|
|
90
84
|
|
|
91
85
|
### Resuming an interrupted workflow stream
|
|
92
86
|
|
|
93
|
-
If a workflow stream is closed or interrupted for any reason, you can resume it with the `
|
|
87
|
+
If a workflow stream is closed or interrupted for any reason, you can resume it with the `resumeStream` method. This will return a new `ReadableStream` that you can use to observe the workflow events.
|
|
94
88
|
|
|
95
89
|
```typescript showLineNumbers copy
|
|
96
|
-
const newStream = await run.
|
|
90
|
+
const newStream = await run.resumeStream();
|
|
97
91
|
|
|
98
92
|
for await (const chunk of newStream) {
|
|
99
93
|
console.log(chunk);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Advanced Tool Usage | Tools & MCP
|
|
2
|
+
title: "Advanced Tool Usage | Tools & MCP"
|
|
3
3
|
description: This page covers advanced features for Mastra tools, including abort signals and compatibility with the Vercel AI SDK tool format.
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -110,7 +110,6 @@ You can then add this tool to your Mastra agent just like any other tool:
|
|
|
110
110
|
|
|
111
111
|
```typescript title="src/mastra/agents/mixedToolsAgent.ts"
|
|
112
112
|
import { Agent } from "@mastra/core/agent";
|
|
113
|
-
import { openai } from "@ai-sdk/openai";
|
|
114
113
|
import { vercelWeatherTool } from "../tools/vercelWeatherTool"; // Vercel AI SDK tool
|
|
115
114
|
import { mastraTool } from "../tools/mastraTool"; // Mastra createTool tool
|
|
116
115
|
|
|
@@ -118,7 +117,7 @@ export const mixedToolsAgent = new Agent({
|
|
|
118
117
|
id: "mixed-tools-agent",
|
|
119
118
|
name: "Mixed Tools Agent",
|
|
120
119
|
instructions: "You can use tools defined in different formats.",
|
|
121
|
-
model: openai
|
|
120
|
+
model: "openai/gpt-5.1",
|
|
122
121
|
tools: {
|
|
123
122
|
weatherVercel: vercelWeatherTool,
|
|
124
123
|
someMastraTool: mastraTool,
|