@mastra/mcp-docs-server 1.0.0-beta.8 → 1.0.0
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 -13
- package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +1 -5
- package/.docs/organized/changelogs/%40internal%2Fplayground.md +40 -0
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +8 -8
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +1 -53
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +287 -287
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +315 -315
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +53 -53
- package/.docs/organized/changelogs/%40mastra%2Fauth.md +38 -0
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +66 -66
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +522 -212
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +658 -196
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +439 -234
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +450 -211
- package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +208 -0
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +448 -22
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +3341 -271
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +60 -60
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +289 -289
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +90 -90
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +74 -74
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +70 -70
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +247 -220
- package/.docs/organized/changelogs/%40mastra%2Fduckdb.md +70 -0
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +403 -225
- package/.docs/organized/changelogs/%40mastra%2Felasticsearch.md +72 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +145 -145
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +54 -0
- package/.docs/organized/changelogs/%40mastra%2Flance.md +456 -226
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +604 -208
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +71 -71
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +247 -247
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +28 -28
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +285 -285
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +354 -156
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +545 -212
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +481 -202
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +194 -194
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +759 -213
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +198 -198
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +636 -229
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +163 -163
- package/.docs/organized/changelogs/%40mastra%2Frag.md +310 -310
- package/.docs/organized/changelogs/%40mastra%2Freact.md +328 -230
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +64 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +160 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +829 -218
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +479 -232
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +53 -53
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +47 -47
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +110 -110
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +15 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +98 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +54 -54
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +46 -46
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +93 -93
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +47 -47
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +45 -45
- package/.docs/organized/changelogs/create-mastra.md +227 -227
- package/.docs/organized/changelogs/mastra.md +277 -277
- package/.docs/organized/code-examples/a2a.md +2 -2
- package/.docs/organized/code-examples/agent-v6.md +221 -0
- package/.docs/organized/code-examples/agui.md +4 -4
- package/.docs/organized/code-examples/ai-elements.md +3 -3
- package/.docs/organized/code-examples/ai-sdk-useChat.md +2 -2
- package/.docs/organized/code-examples/ai-sdk-v5.md +3 -3
- package/.docs/organized/code-examples/assistant-ui.md +5 -5
- 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 +3 -3
- package/.docs/organized/code-examples/client-side-tools.md +4 -4
- package/.docs/organized/code-examples/crypto-chatbot.md +5 -5
- package/.docs/organized/code-examples/experimental-auth-weather-agent.md +1 -1
- package/.docs/organized/code-examples/fireworks-r1.md +2 -2
- package/.docs/organized/code-examples/heads-up-game.md +7 -7
- package/.docs/organized/code-examples/inngest.md +1075 -0
- package/.docs/organized/code-examples/mcp-configuration.md +1 -1
- package/.docs/organized/code-examples/mcp-server-adapters.md +3 -4
- package/.docs/organized/code-examples/memory-per-resource-example.md +3 -3
- package/.docs/organized/code-examples/memory-todo-agent.md +1 -1
- package/.docs/organized/code-examples/memory-with-context.md +1 -1
- package/.docs/organized/code-examples/memory-with-processors.md +1 -1
- package/.docs/organized/code-examples/openapi-spec-writer.md +3 -3
- package/.docs/organized/code-examples/processors-with-ai-sdk.md +14 -0
- package/.docs/organized/code-examples/quick-start.md +1 -5
- package/.docs/organized/code-examples/server-app-access.md +3 -3
- package/.docs/organized/code-examples/server-express-adapter.md +1 -1
- package/.docs/organized/code-examples/server-fastify-adapter.md +83 -0
- package/.docs/organized/code-examples/server-hono-adapter.md +3 -3
- package/.docs/organized/code-examples/server-koa-adapter.md +94 -0
- package/.docs/organized/code-examples/stock-price-tool.md +21 -2
- 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 +24 -6
- package/.docs/raw/agents/agent-approval.mdx +209 -12
- package/.docs/raw/agents/agent-memory.mdx +36 -32
- package/.docs/raw/agents/guardrails.mdx +105 -56
- package/.docs/raw/agents/network-approval.mdx +281 -0
- package/.docs/raw/agents/networks.mdx +69 -13
- package/.docs/raw/agents/overview.mdx +43 -25
- package/.docs/raw/agents/processors.mdx +234 -17
- package/.docs/raw/agents/structured-output.mdx +78 -8
- package/.docs/raw/agents/using-tools.mdx +67 -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 +3 -3
- package/.docs/raw/course/03-agent-memory/04-creating-basic-memory-agent.md +1 -2
- package/.docs/raw/course/03-agent-memory/07-understanding-memory-threads.md +35 -0
- package/.docs/raw/course/03-agent-memory/08-configuring-conversation-history.md +1 -2
- package/.docs/raw/course/03-agent-memory/13-vector-store-configuration.md +1 -1
- package/.docs/raw/course/03-agent-memory/16-configuring-semantic-recall.md +4 -5
- package/.docs/raw/course/03-agent-memory/18-advanced-configuration-semantic-recall.md +1 -1
- package/.docs/raw/course/03-agent-memory/21-configuring-working-memory.md +3 -4
- package/.docs/raw/course/03-agent-memory/22-custom-working-memory-templates.md +3 -4
- package/.docs/raw/course/03-agent-memory/25-combining-memory-features.md +3 -4
- package/.docs/raw/course/03-agent-memory/27-creating-learning-assistant.md +3 -4
- package/.docs/raw/course/04-workflows/11-creating-an-ai-agent.md +2 -3
- package/.docs/raw/deployment/cloud-providers.mdx +22 -0
- package/.docs/raw/deployment/mastra-server.mdx +140 -0
- package/.docs/raw/deployment/monorepo.mdx +106 -42
- package/.docs/raw/deployment/overview.mdx +35 -48
- package/.docs/raw/deployment/web-framework.mdx +17 -19
- package/.docs/raw/deployment/workflow-runners.mdx +16 -0
- package/.docs/raw/evals/built-in-scorers.mdx +2 -0
- package/.docs/raw/evals/custom-scorers.mdx +60 -12
- package/.docs/raw/evals/overview.mdx +6 -6
- package/.docs/raw/evals/running-in-ci.mdx +4 -2
- package/.docs/raw/getting-started/manual-install.mdx +20 -20
- package/.docs/raw/getting-started/mcp-docs-server.mdx +59 -2
- package/.docs/raw/getting-started/project-structure.mdx +2 -2
- package/.docs/raw/getting-started/start.mdx +17 -1
- package/.docs/raw/getting-started/studio.mdx +10 -37
- package/.docs/raw/guides/agent-frameworks/ai-sdk.mdx +151 -0
- package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +1034 -80
- package/.docs/raw/guides/build-your-ui/assistant-ui.mdx +8 -8
- package/.docs/raw/guides/build-your-ui/copilotkit.mdx +32 -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 +18 -23
- package/.docs/raw/guides/deployment/index.mdx +32 -0
- package/.docs/raw/guides/deployment/inngest.mdx +673 -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 +173 -61
- package/.docs/raw/guides/getting-started/nuxt.mdx +505 -0
- package/.docs/raw/guides/getting-started/quickstart.mdx +5 -5
- 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 +20 -20
- package/.docs/raw/guides/guide/stock-agent.mdx +5 -5
- package/.docs/raw/guides/guide/web-search.mdx +38 -38
- package/.docs/raw/guides/guide/whatsapp-chat-bot.mdx +7 -7
- package/.docs/raw/guides/index.mdx +0 -1
- package/.docs/raw/guides/migrations/ai-sdk-v4-to-v5.mdx +2 -2
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +105 -4
- package/.docs/raw/guides/migrations/upgrade-to-v1/cli.mdx +15 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/client.mdx +170 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/deployment.mdx +42 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/mastra.mdx +0 -35
- package/.docs/raw/guides/migrations/upgrade-to-v1/memory.mdx +40 -3
- package/.docs/raw/guides/migrations/upgrade-to-v1/overview.mdx +17 -2
- package/.docs/raw/guides/migrations/upgrade-to-v1/processors.mdx +11 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/rag.mdx +47 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/storage.mdx +271 -25
- package/.docs/raw/guides/migrations/upgrade-to-v1/tools.mdx +3 -3
- package/.docs/raw/guides/migrations/upgrade-to-v1/tracing.mdx +72 -17
- package/.docs/raw/guides/migrations/upgrade-to-v1/vectors.mdx +46 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +50 -7
- package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +21 -23
- package/.docs/raw/index.mdx +2 -2
- package/.docs/raw/mastra-cloud/deployment.mdx +86 -0
- package/.docs/raw/mastra-cloud/observability.mdx +43 -0
- package/.docs/raw/mastra-cloud/overview.mdx +31 -0
- package/.docs/raw/mastra-cloud/setup.mdx +64 -0
- package/.docs/raw/mastra-cloud/studio.mdx +35 -0
- package/.docs/raw/mcp/overview.mdx +60 -25
- package/.docs/raw/mcp/publishing-mcp-server.mdx +7 -4
- package/.docs/raw/memory/memory-processors.mdx +17 -12
- package/.docs/raw/memory/message-history.mdx +72 -0
- package/.docs/raw/memory/overview.mdx +38 -76
- package/.docs/raw/memory/semantic-recall.mdx +65 -52
- package/.docs/raw/memory/storage.mdx +248 -0
- package/.docs/raw/memory/working-memory.mdx +24 -13
- package/.docs/raw/observability/logging.mdx +16 -15
- package/.docs/raw/observability/overview.mdx +27 -7
- package/.docs/raw/observability/tracing/bridges/otel.mdx +7 -4
- package/.docs/raw/observability/tracing/exporters/arize.mdx +61 -24
- package/.docs/raw/observability/tracing/exporters/braintrust.mdx +32 -22
- package/.docs/raw/observability/tracing/exporters/cloud.mdx +24 -5
- package/.docs/raw/observability/tracing/exporters/datadog.mdx +175 -0
- package/.docs/raw/observability/tracing/exporters/default.mdx +28 -7
- package/.docs/raw/observability/tracing/exporters/laminar.mdx +89 -0
- package/.docs/raw/observability/tracing/exporters/langfuse.mdx +31 -22
- package/.docs/raw/observability/tracing/exporters/langsmith.mdx +33 -3
- package/.docs/raw/observability/tracing/exporters/otel.mdx +194 -22
- package/.docs/raw/observability/tracing/exporters/posthog.mdx +32 -22
- package/.docs/raw/observability/tracing/exporters/sentry.mdx +198 -0
- package/.docs/raw/observability/tracing/overview.mdx +388 -108
- package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +27 -7
- package/.docs/raw/rag/chunking-and-embedding.mdx +22 -33
- package/.docs/raw/rag/graph-rag.mdx +223 -0
- package/.docs/raw/rag/overview.mdx +6 -3
- package/.docs/raw/rag/retrieval.mdx +53 -57
- package/.docs/raw/rag/vector-databases.mdx +55 -31
- package/.docs/raw/reference/agents/agent.mdx +17 -14
- package/.docs/raw/reference/agents/generate.mdx +172 -44
- package/.docs/raw/reference/agents/generateLegacy.mdx +5 -3
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +5 -3
- package/.docs/raw/reference/agents/getDefaultOptions.mdx +5 -3
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +5 -3
- package/.docs/raw/reference/agents/getDescription.mdx +3 -1
- package/.docs/raw/reference/agents/getInstructions.mdx +5 -3
- package/.docs/raw/reference/agents/getLLM.mdx +5 -3
- package/.docs/raw/reference/agents/getMemory.mdx +5 -3
- package/.docs/raw/reference/agents/getModel.mdx +5 -3
- package/.docs/raw/reference/agents/getTools.mdx +4 -2
- package/.docs/raw/reference/agents/getVoice.mdx +4 -2
- package/.docs/raw/reference/agents/listAgents.mdx +4 -2
- package/.docs/raw/reference/agents/listScorers.mdx +5 -3
- package/.docs/raw/reference/agents/listTools.mdx +4 -2
- package/.docs/raw/reference/agents/listWorkflows.mdx +4 -2
- package/.docs/raw/reference/agents/network.mdx +113 -1
- package/.docs/raw/reference/ai-sdk/chat-route.mdx +6 -3
- package/.docs/raw/reference/ai-sdk/handle-chat-stream.mdx +4 -2
- package/.docs/raw/reference/ai-sdk/handle-network-stream.mdx +4 -2
- package/.docs/raw/reference/ai-sdk/handle-workflow-stream.mdx +5 -3
- package/.docs/raw/reference/ai-sdk/network-route.mdx +6 -3
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-stream.mdx +10 -6
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v4-messages.mdx +130 -0
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v5-messages.mdx +110 -0
- package/.docs/raw/reference/ai-sdk/with-mastra.mdx +122 -0
- package/.docs/raw/reference/ai-sdk/workflow-route.mdx +7 -4
- package/.docs/raw/reference/auth/auth0.mdx +5 -3
- package/.docs/raw/reference/auth/clerk.mdx +5 -3
- package/.docs/raw/reference/auth/firebase.mdx +6 -5
- package/.docs/raw/reference/auth/jwt.mdx +5 -3
- package/.docs/raw/reference/auth/supabase.mdx +5 -3
- package/.docs/raw/reference/auth/workos.mdx +5 -3
- package/.docs/raw/reference/cli/create-mastra.mdx +12 -10
- package/.docs/raw/reference/cli/mastra.mdx +63 -15
- package/.docs/raw/reference/client-js/agents.mdx +311 -85
- package/.docs/raw/reference/client-js/error-handling.mdx +3 -3
- package/.docs/raw/reference/client-js/logs.mdx +2 -0
- package/.docs/raw/reference/client-js/mastra-client.mdx +6 -4
- package/.docs/raw/reference/client-js/memory.mdx +47 -2
- package/.docs/raw/reference/client-js/observability.mdx +2 -0
- package/.docs/raw/reference/client-js/telemetry.mdx +2 -0
- package/.docs/raw/reference/client-js/tools.mdx +2 -0
- package/.docs/raw/reference/client-js/vectors.mdx +2 -0
- package/.docs/raw/reference/client-js/workflows.mdx +47 -3
- package/.docs/raw/reference/configuration.mdx +761 -0
- package/.docs/raw/reference/core/addGateway.mdx +2 -0
- package/.docs/raw/reference/core/getAgent.mdx +3 -1
- package/.docs/raw/reference/core/getAgentById.mdx +3 -1
- package/.docs/raw/reference/core/getDeployer.mdx +3 -1
- package/.docs/raw/reference/core/getGateway.mdx +2 -0
- package/.docs/raw/reference/core/getGatewayById.mdx +2 -0
- package/.docs/raw/reference/core/getLogger.mdx +3 -1
- package/.docs/raw/reference/core/getMCPServer.mdx +3 -1
- package/.docs/raw/reference/core/getMCPServerById.mdx +3 -1
- package/.docs/raw/reference/core/getMemory.mdx +77 -0
- package/.docs/raw/reference/core/getScorer.mdx +2 -0
- package/.docs/raw/reference/core/getScorerById.mdx +2 -0
- package/.docs/raw/reference/core/getServer.mdx +6 -4
- package/.docs/raw/reference/core/getStorage.mdx +5 -3
- package/.docs/raw/reference/core/getStoredAgentById.mdx +185 -0
- package/.docs/raw/reference/core/getTelemetry.mdx +3 -1
- package/.docs/raw/reference/core/getVector.mdx +3 -1
- package/.docs/raw/reference/core/getWorkflow.mdx +3 -1
- package/.docs/raw/reference/core/listAgents.mdx +3 -1
- package/.docs/raw/reference/core/listGateways.mdx +2 -0
- package/.docs/raw/reference/core/listLogs.mdx +3 -1
- package/.docs/raw/reference/core/listLogsByRunId.mdx +3 -1
- package/.docs/raw/reference/core/listMCPServers.mdx +3 -1
- package/.docs/raw/reference/core/listMemory.mdx +74 -0
- package/.docs/raw/reference/core/listScorers.mdx +2 -0
- package/.docs/raw/reference/core/listStoredAgents.mdx +153 -0
- package/.docs/raw/reference/core/listVectors.mdx +3 -1
- package/.docs/raw/reference/core/listWorkflows.mdx +3 -1
- package/.docs/raw/reference/core/mastra-class.mdx +35 -20
- package/.docs/raw/reference/core/mastra-model-gateway.mdx +2 -0
- package/.docs/raw/reference/core/setLogger.mdx +3 -1
- package/.docs/raw/reference/core/setStorage.mdx +6 -4
- package/.docs/raw/reference/deployer/cloudflare.mdx +22 -53
- package/.docs/raw/reference/deployer/deployer.mdx +2 -1
- package/.docs/raw/reference/deployer/netlify.mdx +4 -1
- package/.docs/raw/reference/deployer/vercel.mdx +5 -4
- package/.docs/raw/reference/evals/answer-relevancy.mdx +4 -1
- package/.docs/raw/reference/evals/answer-similarity.mdx +4 -1
- package/.docs/raw/reference/evals/bias.mdx +4 -1
- package/.docs/raw/reference/evals/completeness.mdx +4 -1
- package/.docs/raw/reference/evals/content-similarity.mdx +4 -1
- package/.docs/raw/reference/evals/context-precision.mdx +4 -1
- package/.docs/raw/reference/evals/context-relevance.mdx +2 -0
- package/.docs/raw/reference/evals/create-scorer.mdx +11 -3
- package/.docs/raw/reference/evals/faithfulness.mdx +4 -1
- package/.docs/raw/reference/evals/hallucination.mdx +4 -1
- package/.docs/raw/reference/evals/keyword-coverage.mdx +4 -1
- package/.docs/raw/reference/evals/mastra-scorer.mdx +2 -0
- package/.docs/raw/reference/evals/noise-sensitivity.mdx +2 -0
- package/.docs/raw/reference/evals/prompt-alignment.mdx +9 -7
- package/.docs/raw/reference/evals/run-evals.mdx +3 -1
- package/.docs/raw/reference/evals/scorer-utils.mdx +3 -0
- package/.docs/raw/reference/evals/textual-difference.mdx +4 -1
- package/.docs/raw/reference/evals/tone-consistency.mdx +4 -1
- package/.docs/raw/reference/evals/tool-call-accuracy.mdx +25 -23
- package/.docs/raw/reference/evals/toxicity.mdx +4 -1
- package/.docs/raw/reference/index.mdx +2 -1
- package/.docs/raw/reference/logging/pino-logger.mdx +10 -8
- package/.docs/raw/reference/memory/clone-utilities.mdx +345 -0
- package/.docs/raw/reference/memory/cloneThread.mdx +237 -0
- package/.docs/raw/reference/memory/createThread.mdx +6 -4
- package/.docs/raw/reference/memory/deleteMessages.mdx +4 -2
- package/.docs/raw/reference/memory/getThreadById.mdx +3 -1
- package/.docs/raw/reference/memory/listThreads.mdx +187 -0
- package/.docs/raw/reference/memory/memory-class.mdx +27 -20
- package/.docs/raw/reference/memory/recall.mdx +6 -4
- package/.docs/raw/reference/observability/tracing/bridges/otel.mdx +6 -2
- package/.docs/raw/reference/observability/tracing/configuration.mdx +51 -0
- package/.docs/raw/reference/observability/tracing/exporters/arize.mdx +25 -6
- package/.docs/raw/reference/observability/tracing/exporters/braintrust.mdx +23 -2
- package/.docs/raw/reference/observability/tracing/exporters/cloud-exporter.mdx +10 -0
- package/.docs/raw/reference/observability/tracing/exporters/console-exporter.mdx +3 -0
- package/.docs/raw/reference/observability/tracing/exporters/datadog.mdx +172 -0
- package/.docs/raw/reference/observability/tracing/exporters/default-exporter.mdx +10 -0
- package/.docs/raw/reference/observability/tracing/exporters/laminar.mdx +139 -0
- package/.docs/raw/reference/observability/tracing/exporters/langfuse.mdx +26 -4
- package/.docs/raw/reference/observability/tracing/exporters/langsmith.mdx +10 -0
- package/.docs/raw/reference/observability/tracing/exporters/otel.mdx +51 -34
- package/.docs/raw/reference/observability/tracing/exporters/posthog.mdx +25 -4
- package/.docs/raw/reference/observability/tracing/exporters/sentry.mdx +224 -0
- package/.docs/raw/reference/observability/tracing/instances.mdx +2 -0
- package/.docs/raw/reference/observability/tracing/interfaces.mdx +20 -0
- package/.docs/raw/reference/observability/tracing/processors/sensitive-data-filter.mdx +2 -0
- package/.docs/raw/reference/observability/tracing/spans.mdx +2 -0
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +4 -2
- package/.docs/raw/reference/processors/language-detector.mdx +6 -3
- package/.docs/raw/reference/processors/message-history-processor.mdx +5 -2
- package/.docs/raw/reference/processors/moderation-processor.mdx +6 -4
- package/.docs/raw/reference/processors/pii-detector.mdx +6 -4
- package/.docs/raw/reference/processors/processor-interface.mdx +326 -23
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +5 -3
- package/.docs/raw/reference/processors/semantic-recall-processor.mdx +7 -2
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +5 -3
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +62 -19
- package/.docs/raw/reference/processors/tool-call-filter.mdx +5 -3
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +6 -3
- package/.docs/raw/reference/processors/working-memory-processor.mdx +6 -3
- package/.docs/raw/reference/rag/chunk.mdx +7 -6
- package/.docs/raw/reference/rag/database-config.mdx +8 -6
- package/.docs/raw/reference/rag/document.mdx +2 -0
- package/.docs/raw/reference/rag/embeddings.mdx +2 -0
- package/.docs/raw/reference/rag/extract-params.mdx +57 -3
- package/.docs/raw/reference/rag/graph-rag.mdx +2 -0
- package/.docs/raw/reference/rag/metadata-filters.mdx +27 -7
- package/.docs/raw/reference/rag/rerank.mdx +2 -0
- package/.docs/raw/reference/rag/rerankWithScorer.mdx +2 -0
- package/.docs/raw/reference/server/create-route.mdx +34 -18
- package/.docs/raw/reference/server/express-adapter.mdx +78 -50
- package/.docs/raw/reference/server/fastify-adapter.mdx +130 -0
- package/.docs/raw/reference/server/hono-adapter.mdx +78 -48
- package/.docs/raw/reference/server/koa-adapter.mdx +129 -0
- package/.docs/raw/reference/server/mastra-server.mdx +52 -34
- package/.docs/raw/reference/server/routes.mdx +73 -10
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +10 -5
- package/.docs/raw/reference/storage/cloudflare.mdx +12 -2
- package/.docs/raw/reference/storage/composite.mdx +245 -0
- package/.docs/raw/reference/storage/convex.mdx +8 -6
- package/.docs/raw/reference/storage/dynamodb.mdx +134 -8
- package/.docs/raw/reference/storage/lance.mdx +9 -5
- package/.docs/raw/reference/storage/libsql.mdx +76 -54
- package/.docs/raw/reference/storage/mongodb.mdx +115 -16
- package/.docs/raw/reference/storage/mssql.mdx +11 -6
- package/.docs/raw/{server-db/storage.mdx → reference/storage/overview.mdx} +15 -111
- package/.docs/raw/reference/storage/postgresql.mdx +228 -83
- package/.docs/raw/reference/storage/upstash.mdx +78 -2
- package/.docs/raw/reference/streaming/ChunkType.mdx +31 -3
- package/.docs/raw/reference/streaming/agents/MastraModelOutput.mdx +67 -6
- package/.docs/raw/reference/streaming/agents/stream.mdx +48 -51
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +5 -3
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +3 -1
- package/.docs/raw/reference/streaming/workflows/resumeStream.mdx +3 -1
- package/.docs/raw/reference/streaming/workflows/stream.mdx +37 -22
- package/.docs/raw/reference/streaming/workflows/timeTravelStream.mdx +6 -4
- package/.docs/raw/reference/templates/overview.mdx +3 -2
- package/.docs/raw/reference/tools/client.mdx +3 -0
- package/.docs/raw/reference/tools/create-tool.mdx +127 -5
- package/.docs/raw/reference/tools/document-chunker-tool.mdx +2 -0
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +40 -3
- package/.docs/raw/reference/tools/mcp-client.mdx +110 -1
- package/.docs/raw/reference/tools/mcp-server.mdx +278 -24
- package/.docs/raw/reference/tools/vector-query-tool.mdx +68 -4
- package/.docs/raw/reference/vectors/astra.mdx +5 -3
- package/.docs/raw/reference/vectors/chroma.mdx +5 -3
- package/.docs/raw/reference/vectors/convex.mdx +14 -12
- package/.docs/raw/reference/vectors/couchbase.mdx +7 -5
- package/.docs/raw/reference/vectors/duckdb.mdx +12 -10
- package/.docs/raw/reference/vectors/elasticsearch.mdx +12 -4
- package/.docs/raw/reference/vectors/lance.mdx +6 -4
- package/.docs/raw/reference/vectors/libsql.mdx +66 -13
- package/.docs/raw/reference/vectors/mongodb.mdx +90 -10
- package/.docs/raw/reference/vectors/opensearch.mdx +30 -3
- package/.docs/raw/reference/vectors/pg.mdx +58 -6
- package/.docs/raw/reference/vectors/pinecone.mdx +23 -8
- package/.docs/raw/reference/vectors/qdrant.mdx +148 -4
- package/.docs/raw/reference/vectors/s3vectors.mdx +8 -6
- package/.docs/raw/reference/vectors/turbopuffer.mdx +6 -4
- package/.docs/raw/reference/vectors/upstash.mdx +60 -6
- package/.docs/raw/reference/vectors/vectorize.mdx +5 -3
- package/.docs/raw/reference/voice/azure.mdx +2 -0
- package/.docs/raw/reference/voice/cloudflare.mdx +2 -0
- package/.docs/raw/reference/voice/composite-voice.mdx +4 -0
- package/.docs/raw/reference/voice/deepgram.mdx +2 -0
- package/.docs/raw/reference/voice/elevenlabs.mdx +2 -0
- package/.docs/raw/reference/voice/google-gemini-live.mdx +3 -0
- package/.docs/raw/reference/voice/google.mdx +2 -0
- package/.docs/raw/reference/voice/mastra-voice.mdx +2 -0
- package/.docs/raw/reference/voice/murf.mdx +2 -0
- package/.docs/raw/reference/voice/openai-realtime.mdx +3 -0
- package/.docs/raw/reference/voice/openai.mdx +2 -0
- package/.docs/raw/reference/voice/playai.mdx +2 -0
- package/.docs/raw/reference/voice/sarvam.mdx +2 -0
- package/.docs/raw/reference/voice/speechify.mdx +2 -0
- package/.docs/raw/reference/voice/voice.addInstructions.mdx +3 -0
- package/.docs/raw/reference/voice/voice.addTools.mdx +3 -0
- package/.docs/raw/reference/voice/voice.answer.mdx +4 -0
- package/.docs/raw/reference/voice/voice.close.mdx +3 -0
- package/.docs/raw/reference/voice/voice.connect.mdx +5 -1
- package/.docs/raw/reference/voice/voice.events.mdx +2 -0
- package/.docs/raw/reference/voice/voice.getSpeakers.mdx +3 -0
- package/.docs/raw/reference/voice/voice.listen.mdx +6 -0
- package/.docs/raw/reference/voice/voice.off.mdx +2 -0
- package/.docs/raw/reference/voice/voice.on.mdx +5 -1
- package/.docs/raw/reference/voice/voice.send.mdx +4 -0
- package/.docs/raw/reference/voice/voice.speak.mdx +6 -0
- package/.docs/raw/reference/voice/voice.updateConfig.mdx +2 -0
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +55 -5
- package/.docs/raw/reference/workflows/run-methods/restart.mdx +3 -3
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +6 -4
- package/.docs/raw/reference/workflows/run-methods/start.mdx +7 -5
- package/.docs/raw/reference/workflows/run-methods/startAsync.mdx +145 -0
- package/.docs/raw/reference/workflows/run-methods/timeTravel.mdx +10 -8
- package/.docs/raw/reference/workflows/run.mdx +11 -3
- package/.docs/raw/reference/workflows/step.mdx +56 -3
- package/.docs/raw/reference/workflows/workflow-methods/branch.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/commit.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/create-run.mdx +39 -2
- package/.docs/raw/reference/workflows/workflow-methods/dountil.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/dowhile.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +71 -4
- package/.docs/raw/reference/workflows/workflow-methods/map.mdx +9 -7
- package/.docs/raw/reference/workflows/workflow-methods/parallel.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/sleep.mdx +4 -6
- package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +4 -6
- package/.docs/raw/reference/workflows/workflow-methods/then.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow.mdx +193 -2
- package/.docs/raw/{auth → server/auth}/auth0.mdx +40 -21
- package/.docs/raw/{auth → server/auth}/clerk.mdx +37 -16
- package/.docs/raw/{auth → server/auth}/firebase.mdx +47 -25
- package/.docs/raw/{auth → server/auth}/index.mdx +8 -6
- package/.docs/raw/{auth → server/auth}/jwt.mdx +22 -10
- package/.docs/raw/{auth → server/auth}/supabase.mdx +45 -25
- package/.docs/raw/{auth → server/auth}/workos.mdx +39 -20
- package/.docs/raw/{server-db → server}/custom-adapters.mdx +40 -24
- package/.docs/raw/{server-db → server}/custom-api-routes.mdx +6 -6
- package/.docs/raw/{server-db → server}/mastra-client.mdx +35 -38
- package/.docs/raw/server/mastra-server.mdx +86 -0
- package/.docs/raw/{server-db → server}/middleware.mdx +11 -9
- package/.docs/raw/{server-db → server}/request-context.mdx +85 -43
- package/.docs/raw/server/server-adapters.mdx +410 -0
- package/.docs/raw/streaming/events.mdx +16 -7
- package/.docs/raw/streaming/overview.mdx +30 -17
- package/.docs/raw/streaming/tool-streaming.mdx +15 -17
- package/.docs/raw/streaming/workflow-streaming.mdx +8 -8
- package/.docs/raw/tools-mcp/advanced-usage.mdx +4 -2
- package/.docs/raw/tools-mcp/mcp-overview.mdx +46 -12
- package/.docs/raw/tools-mcp/overview.mdx +14 -13
- package/.docs/raw/voice/overview.mdx +17 -2
- package/.docs/raw/voice/speech-to-speech.mdx +5 -0
- package/.docs/raw/voice/speech-to-text.mdx +4 -0
- package/.docs/raw/voice/text-to-speech.mdx +3 -0
- package/.docs/raw/workflows/agents-and-tools.mdx +70 -21
- package/.docs/raw/workflows/control-flow.mdx +369 -34
- package/.docs/raw/workflows/error-handling.mdx +192 -18
- package/.docs/raw/workflows/human-in-the-loop.mdx +8 -7
- package/.docs/raw/workflows/input-data-mapping.mdx +9 -7
- package/.docs/raw/workflows/overview.mdx +80 -34
- package/.docs/raw/workflows/snapshots.mdx +19 -45
- package/.docs/raw/workflows/suspend-and-resume.mdx +14 -14
- package/.docs/raw/workflows/time-travel.mdx +25 -21
- package/.docs/raw/workflows/workflow-state.mdx +7 -8
- package/CHANGELOG.md +254 -0
- package/README.md +36 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/stdio.js +746 -49
- package/dist/tools/course.d.ts.map +1 -1
- package/dist/tools/embedded-docs.d.ts +276 -0
- package/dist/tools/embedded-docs.d.ts.map +1 -0
- package/package.json +9 -8
- package/.docs/organized/changelogs/%40internal%2Fai-sdk-v4.md +0 -1
- package/.docs/raw/deployment/building-mastra.mdx +0 -73
- package/.docs/raw/deployment/cloud-providers/index.mdx +0 -55
- package/.docs/raw/deployment/mastra-cloud/dashboard.mdx +0 -100
- package/.docs/raw/deployment/mastra-cloud/observability.mdx +0 -53
- package/.docs/raw/deployment/mastra-cloud/overview.mdx +0 -65
- package/.docs/raw/deployment/mastra-cloud/setting-up.mdx +0 -105
- 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
- package/.docs/raw/reference/core/setTelemetry.mdx +0 -36
- package/.docs/raw/reference/memory/listThreadsByResourceId.mdx +0 -110
- package/.docs/raw/reference/memory/query.mdx +0 -189
- package/.docs/raw/reference/workflows/workflow-methods/sendEvent.mdx +0 -70
- package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +0 -66
- package/.docs/raw/server-db/mastra-server.mdx +0 -97
- package/.docs/raw/server-db/server-adapters.mdx +0 -286
- package/.docs/raw/workflows/inngest-workflow.mdx +0 -363
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Server Adapters | Server & DB"
|
|
3
|
-
description: "Manually configure a Mastra server using Hono or Express adapters."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
import PropertiesTable from "@site/src/components/PropertiesTable";
|
|
7
|
-
import Tabs from "@theme/Tabs";
|
|
8
|
-
import TabItem from "@theme/TabItem";
|
|
9
|
-
|
|
10
|
-
# Server Adapters
|
|
11
|
-
|
|
12
|
-
Server adapters let you run Mastra with your own HTTP server instead of using `mastra build`. While `mastra build` generates a standalone server for you, adapters give you full control over the server setup, letting you integrate Mastra into any Node.js application.
|
|
13
|
-
|
|
14
|
-
Use adapters when you need to:
|
|
15
|
-
|
|
16
|
-
- **Integrate Mastra into an existing application** - Add Mastra endpoints to an Express or Hono app you already have running
|
|
17
|
-
- **Control middleware ordering** - Insert your own middleware before or after Mastra's authentication and routing
|
|
18
|
-
- **Deploy to platforms requiring specific server setup** - Some platforms like Cloudflare Workers or custom Docker setups need direct access to the server instance
|
|
19
|
-
- **Use Express instead of Hono** - `mastra build` uses Hono internally, but you may prefer Express for its ecosystem or team familiarity
|
|
20
|
-
|
|
21
|
-
:::info
|
|
22
|
-
|
|
23
|
-
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).
|
|
24
|
-
|
|
25
|
-
:::
|
|
26
|
-
|
|
27
|
-
## Available adapters
|
|
28
|
-
|
|
29
|
-
- **[@mastra/hono](/reference/v1/server/hono-adapter)** - Hono framework adapter
|
|
30
|
-
- **[@mastra/express](/reference/v1/server/express-adapter)** - Express framework adapter
|
|
31
|
-
|
|
32
|
-
## Basic setup
|
|
33
|
-
|
|
34
|
-
Both adapters follow the same pattern. The adapter wraps your framework's app instance and registers Mastra's routes and middleware onto it.
|
|
35
|
-
|
|
36
|
-
1. **Create your framework's app instance** - Initialize Hono or Express as you normally would
|
|
37
|
-
2. **Create a `MastraServer`** - Pass your app and Mastra instance to the adapter
|
|
38
|
-
3. **Call `init()`** - This registers context middleware, authentication, and all API routes
|
|
39
|
-
|
|
40
|
-
After `init()`, your app has all the Mastra endpoints (`/api/agents`, `/api/workflows`, etc.) and you can add your own routes before or after.
|
|
41
|
-
|
|
42
|
-
See the [Hono Adapter](/reference/v1/server/hono-adapter) or [Express Adapter](/reference/v1/server/express-adapter) docs for framework-specific setup and code examples.
|
|
43
|
-
|
|
44
|
-
## Constructor options
|
|
45
|
-
|
|
46
|
-
Both adapters accept the same options:
|
|
47
|
-
|
|
48
|
-
<PropertiesTable
|
|
49
|
-
content={[
|
|
50
|
-
{
|
|
51
|
-
name: "app",
|
|
52
|
-
type: "Hono | Application",
|
|
53
|
-
description: "Framework app instance",
|
|
54
|
-
isOptional: false,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: "mastra",
|
|
58
|
-
type: "Mastra",
|
|
59
|
-
description: "Mastra instance",
|
|
60
|
-
isOptional: false,
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: "prefix",
|
|
64
|
-
type: "string",
|
|
65
|
-
description: "Route path prefix (e.g., `/api/v2`)",
|
|
66
|
-
isOptional: true,
|
|
67
|
-
defaultValue: "''",
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: "openapiPath",
|
|
71
|
-
type: "string",
|
|
72
|
-
description: "Path to serve OpenAPI spec (e.g., `/openapi.json`)",
|
|
73
|
-
isOptional: true,
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
name: "bodyLimitOptions",
|
|
77
|
-
type: "{ maxSize: number, onError: (err) => unknown }",
|
|
78
|
-
description: "Request body size limits",
|
|
79
|
-
isOptional: true,
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
name: "streamOptions",
|
|
83
|
-
type: "{ redact?: boolean }",
|
|
84
|
-
description: "Stream redaction config. When true, redacts sensitive data from streams.",
|
|
85
|
-
isOptional: true,
|
|
86
|
-
defaultValue: "{ redact: true }",
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: "customRouteAuthConfig",
|
|
90
|
-
type: "Map<string, boolean>",
|
|
91
|
-
description: "Per-route auth overrides. Keys are `METHOD:PATH` (e.g., `GET:/api/health`). Value `false` makes route public, `true` requires auth.",
|
|
92
|
-
isOptional: true,
|
|
93
|
-
},
|
|
94
|
-
]}
|
|
95
|
-
/>
|
|
96
|
-
|
|
97
|
-
## Initialization flow
|
|
98
|
-
|
|
99
|
-
Calling `init()` runs three steps in order. Understanding this flow helps when you need to insert your own middleware at specific points.
|
|
100
|
-
|
|
101
|
-
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.
|
|
102
|
-
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.
|
|
103
|
-
3. **`registerRoutes()`** - Registers all Mastra API routes for agents, workflows, and other features. Also registers MCP routes if MCP servers are configured.
|
|
104
|
-
|
|
105
|
-
### Manual initialization
|
|
106
|
-
|
|
107
|
-
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.
|
|
108
|
-
|
|
109
|
-
```typescript title="server.ts" copy showLineNumbers
|
|
110
|
-
const server = new MastraServer({ app, mastra });
|
|
111
|
-
|
|
112
|
-
// Your middleware first
|
|
113
|
-
app.use(loggingMiddleware);
|
|
114
|
-
|
|
115
|
-
server.registerContextMiddleware();
|
|
116
|
-
|
|
117
|
-
// Middleware that needs Mastra context
|
|
118
|
-
app.use(customMiddleware);
|
|
119
|
-
|
|
120
|
-
server.registerAuthMiddleware();
|
|
121
|
-
await server.registerRoutes();
|
|
122
|
-
|
|
123
|
-
// Routes after Mastra
|
|
124
|
-
app.get('/health', ...);
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
:::tip
|
|
128
|
-
|
|
129
|
-
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.
|
|
130
|
-
|
|
131
|
-
:::
|
|
132
|
-
|
|
133
|
-
## Adding custom routes
|
|
134
|
-
|
|
135
|
-
You can add your own routes to the app alongside Mastra's routes. Routes added after `init()` have access to the Mastra context (the Mastra instance, request context, authenticated user, etc.) through framework-specific mechanisms.
|
|
136
|
-
|
|
137
|
-
The timing matters: routes added before `init()` won't have Mastra context available, while routes added after `init()` will. See the framework-specific docs for syntax and examples:
|
|
138
|
-
|
|
139
|
-
- [Hono: Adding custom routes](/reference/v1/server/hono-adapter#adding-custom-routes)
|
|
140
|
-
- [Express: Adding custom routes](/reference/v1/server/express-adapter#adding-custom-routes)
|
|
141
|
-
|
|
142
|
-
## Route prefixes
|
|
143
|
-
|
|
144
|
-
By default, Mastra routes are registered at `/api/agents`, `/api/workflows`, etc. Use the `prefix` option to change this, which is useful for API versioning or when integrating with an existing app that has its own `/api` routes.
|
|
145
|
-
|
|
146
|
-
```typescript copy showLineNumbers
|
|
147
|
-
const server = new MastraServer({
|
|
148
|
-
app,
|
|
149
|
-
mastra,
|
|
150
|
-
prefix: '/api/v2',
|
|
151
|
-
});
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
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.
|
|
155
|
-
|
|
156
|
-
## OpenAPI spec
|
|
157
|
-
|
|
158
|
-
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:
|
|
159
|
-
|
|
160
|
-
```typescript copy showLineNumbers
|
|
161
|
-
const server = new MastraServer({
|
|
162
|
-
app,
|
|
163
|
-
mastra,
|
|
164
|
-
openapiPath: '/openapi.json',
|
|
165
|
-
});
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
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()`.
|
|
169
|
-
|
|
170
|
-
## Stream data redaction
|
|
171
|
-
|
|
172
|
-
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:
|
|
173
|
-
|
|
174
|
-
- System prompts and agent instructions
|
|
175
|
-
- Tool definitions and their parameters
|
|
176
|
-
- API keys and other credentials in request bodies
|
|
177
|
-
- Internal configuration data
|
|
178
|
-
|
|
179
|
-
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.
|
|
180
|
-
|
|
181
|
-
By default, redaction is enabled. Configure this behavior via `streamOptions`:
|
|
182
|
-
|
|
183
|
-
```typescript copy showLineNumbers
|
|
184
|
-
const server = new MastraServer({
|
|
185
|
-
app,
|
|
186
|
-
mastra,
|
|
187
|
-
streamOptions: {
|
|
188
|
-
redact: true, // Default
|
|
189
|
-
},
|
|
190
|
-
});
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
Set `redact: false` only for internal services or debugging scenarios where you need access to the full request data in stream responses.
|
|
194
|
-
|
|
195
|
-
## Per-route auth overrides
|
|
196
|
-
|
|
197
|
-
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.
|
|
198
|
-
|
|
199
|
-
Use `customRouteAuthConfig` to override authentication behavior for specific routes:
|
|
200
|
-
|
|
201
|
-
```typescript copy showLineNumbers
|
|
202
|
-
const server = new MastraServer({
|
|
203
|
-
app,
|
|
204
|
-
mastra,
|
|
205
|
-
customRouteAuthConfig: new Map([
|
|
206
|
-
['GET:/api/health', false], // Public health check
|
|
207
|
-
['GET:/api/openapi.json', false], // Public API spec
|
|
208
|
-
['POST:/api/webhooks/*', false], // Public webhook endpoints
|
|
209
|
-
['POST:/api/admin/reset', true], // Require auth even if globally disabled
|
|
210
|
-
['ALL:/api/internal/*', true], // Protect all methods on internal routes
|
|
211
|
-
]),
|
|
212
|
-
});
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
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.
|
|
216
|
-
|
|
217
|
-
## Accessing the app
|
|
218
|
-
|
|
219
|
-
After creating the adapter, you may need to access the underlying framework app instance—for example, to pass it to a platform's serve function or to add routes programmatically from another module.
|
|
220
|
-
|
|
221
|
-
```typescript copy showLineNumbers
|
|
222
|
-
// Via the MastraServer instance
|
|
223
|
-
const app = server.getApp();
|
|
224
|
-
|
|
225
|
-
// Via the Mastra instance (available after adapter construction)
|
|
226
|
-
const app = mastra.getServerApp();
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
Both methods return the same app instance. Use whichever is more convenient based on what's in scope.
|
|
230
|
-
|
|
231
|
-
## Server config vs adapter options
|
|
232
|
-
|
|
233
|
-
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.
|
|
234
|
-
|
|
235
|
-
### Used by adapters
|
|
236
|
-
|
|
237
|
-
The adapter reads these settings from `mastra.getServer()`:
|
|
238
|
-
|
|
239
|
-
| Option | Description |
|
|
240
|
-
|--------|-------------|
|
|
241
|
-
| `auth` | Authentication config, used by `registerAuthMiddleware()`. |
|
|
242
|
-
| `bodySizeLimit` | Default body size limit in bytes. Can be overridden per-adapter via `bodyLimitOptions`. |
|
|
243
|
-
|
|
244
|
-
### Adapter constructor only
|
|
245
|
-
|
|
246
|
-
These options are passed directly to the adapter constructor and are not read from the Mastra config:
|
|
247
|
-
|
|
248
|
-
| Option | Description |
|
|
249
|
-
|--------|-------------|
|
|
250
|
-
| `prefix` | Route path prefix |
|
|
251
|
-
| `openapiPath` | OpenAPI spec endpoint |
|
|
252
|
-
| `bodyLimitOptions` | Body size limit with custom error handler |
|
|
253
|
-
| `streamOptions` | Stream redaction settings |
|
|
254
|
-
| `customRouteAuthConfig` | Per-route auth overrides |
|
|
255
|
-
|
|
256
|
-
### Not used by adapters
|
|
257
|
-
|
|
258
|
-
These `server` config options are only used by `mastra build` and have no effect when using adapters directly:
|
|
259
|
-
|
|
260
|
-
| Option | Used by |
|
|
261
|
-
|--------|---------|
|
|
262
|
-
| `port`, `host` | `mastra dev`, `mastra build` |
|
|
263
|
-
| `cors` | `mastra build` adds CORS middleware |
|
|
264
|
-
| `timeout` | `mastra build` |
|
|
265
|
-
| `apiRoutes` | `registerApiRoute()` for `mastra build` |
|
|
266
|
-
| `middleware` | Middleware config for `mastra build` |
|
|
267
|
-
|
|
268
|
-
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.
|
|
269
|
-
|
|
270
|
-
## MCP support
|
|
271
|
-
|
|
272
|
-
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.
|
|
273
|
-
|
|
274
|
-
The adapter registers routes for both HTTP and SSE (Server-Sent Events) transports, enabling different client connection patterns.
|
|
275
|
-
|
|
276
|
-
See [MCP](/docs/v1/mcp/overview) for configuration details and how to set up MCP servers.
|
|
277
|
-
|
|
278
|
-
## Related
|
|
279
|
-
|
|
280
|
-
- [Hono Adapter](/reference/v1/server/hono-adapter) - Hono-specific setup
|
|
281
|
-
- [Express Adapter](/reference/v1/server/express-adapter) - Express-specific setup
|
|
282
|
-
- [Custom Adapters](/docs/v1/server-db/custom-adapters) - Building adapters for other frameworks
|
|
283
|
-
- [Server Configuration](/docs/v1/server-db/mastra-server) - Using `mastra build` instead
|
|
284
|
-
- [Authentication](/docs/v1/auth) - Configuring auth for your server
|
|
285
|
-
- [MastraServer Reference](/reference/v1/server/mastra-server) - Full API reference
|
|
286
|
-
- [createRoute() Reference](/reference/v1/server/create-route) - Creating type-safe custom routes
|
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Inngest Workflow | Workflows"
|
|
3
|
-
description: "Inngest workflow allows you to run Mastra workflows with Inngest"
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Inngest Workflow
|
|
7
|
-
|
|
8
|
-
[Inngest](https://www.inngest.com/docs) is a developer platform for building and running background workflows, without managing infrastructure.
|
|
9
|
-
|
|
10
|
-
## How Inngest Works with Mastra
|
|
11
|
-
|
|
12
|
-
Inngest and Mastra integrate by aligning their workflow models: Inngest organizes logic into functions composed of steps, and Mastra workflows defined using `createWorkflow` and `createStep` map directly onto this paradigm. Each Mastra workflow becomes an Inngest function with a unique identifier, and each step within the workflow maps to an Inngest step.
|
|
13
|
-
|
|
14
|
-
The `serve` function bridges the two systems by registering Mastra workflows as Inngest functions and setting up the necessary event handlers for execution and monitoring.
|
|
15
|
-
|
|
16
|
-
When an event triggers a workflow, Inngest executes it step by step, memoizing each step’s result. This means if a workflow is retried or resumed, completed steps are skipped, ensuring efficient and reliable execution. Control flow primitives in Mastra, such as loops, conditionals, and nested workflows are seamlessly translated into the same Inngest’s function/step model, preserving advanced workflow features like composition, branching, and suspension.
|
|
17
|
-
|
|
18
|
-
Real-time monitoring, suspend/resume, and step-level observability are enabled via Inngest’s publish-subscribe system and dashboard. As each step executes, its state and output are tracked using Mastra storage and can be resumed as needed.
|
|
19
|
-
|
|
20
|
-
## Setup
|
|
21
|
-
|
|
22
|
-
```sh
|
|
23
|
-
npm install @mastra/inngest@beta @mastra/core@beta @mastra/deployer@beta
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Building an Inngest Workflow
|
|
27
|
-
|
|
28
|
-
This guide walks through creating a workflow with Inngest and Mastra, demonstrating a counter application that increments a value until it reaches 10.
|
|
29
|
-
|
|
30
|
-
### Inngest Initialization
|
|
31
|
-
|
|
32
|
-
Initialize the Inngest integration to obtain Mastra-compatible workflow helpers. The createWorkflow and createStep functions are used to create workflow and step objects that are compatible with Mastra and inngest.
|
|
33
|
-
|
|
34
|
-
In development
|
|
35
|
-
|
|
36
|
-
```ts showLineNumbers copy title="src/mastra/inngest/index.ts"
|
|
37
|
-
import { Inngest } from "inngest";
|
|
38
|
-
import { realtimeMiddleware } from "@inngest/realtime/middleware";
|
|
39
|
-
|
|
40
|
-
export const inngest = new Inngest({
|
|
41
|
-
id: "mastra",
|
|
42
|
-
baseUrl: "http://localhost:8288",
|
|
43
|
-
isDev: true,
|
|
44
|
-
middleware: [realtimeMiddleware()],
|
|
45
|
-
});
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
In production
|
|
49
|
-
|
|
50
|
-
```ts showLineNumbers copy title="src/mastra/inngest/index.ts"
|
|
51
|
-
import { Inngest } from "inngest";
|
|
52
|
-
import { realtimeMiddleware } from "@inngest/realtime/middleware";
|
|
53
|
-
|
|
54
|
-
export const inngest = new Inngest({
|
|
55
|
-
id: "mastra",
|
|
56
|
-
middleware: [realtimeMiddleware()],
|
|
57
|
-
});
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Creating Steps
|
|
61
|
-
|
|
62
|
-
Define the individual steps that will compose your workflow:
|
|
63
|
-
|
|
64
|
-
```ts showLineNumbers copy title="src/mastra/workflows/index.ts"
|
|
65
|
-
import { z } from "zod";
|
|
66
|
-
import { inngest } from "../inngest";
|
|
67
|
-
import { init } from "@mastra/inngest";
|
|
68
|
-
|
|
69
|
-
// Initialize Inngest with Mastra, pointing to your local Inngest server
|
|
70
|
-
const { createWorkflow, createStep } = init(inngest);
|
|
71
|
-
|
|
72
|
-
// Step: Increment the counter value
|
|
73
|
-
const incrementStep = createStep({
|
|
74
|
-
id: "increment",
|
|
75
|
-
inputSchema: z.object({
|
|
76
|
-
value: z.number(),
|
|
77
|
-
}),
|
|
78
|
-
outputSchema: z.object({
|
|
79
|
-
value: z.number(),
|
|
80
|
-
}),
|
|
81
|
-
execute: async ({ inputData }) => {
|
|
82
|
-
return { value: inputData.value + 1 };
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Creating the Workflow
|
|
88
|
-
|
|
89
|
-
Compose the steps into a workflow using the `dountil` loop pattern. The createWorkflow function creates a function on inngest server that is invocable.
|
|
90
|
-
|
|
91
|
-
```ts showLineNumbers copy title="src/mastra/workflows/index.ts"
|
|
92
|
-
// workflow that is registered as a function on inngest server
|
|
93
|
-
const workflow = createWorkflow({
|
|
94
|
-
id: "increment-workflow",
|
|
95
|
-
inputSchema: z.object({
|
|
96
|
-
value: z.number(),
|
|
97
|
-
}),
|
|
98
|
-
outputSchema: z.object({
|
|
99
|
-
value: z.number(),
|
|
100
|
-
}),
|
|
101
|
-
}).then(incrementStep);
|
|
102
|
-
|
|
103
|
-
workflow.commit();
|
|
104
|
-
|
|
105
|
-
export { workflow as incrementWorkflow };
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
### Configuring the Mastra Instance and Executing the Workflow
|
|
109
|
-
|
|
110
|
-
Register the workflow with Mastra and configure the Inngest API endpoint:
|
|
111
|
-
|
|
112
|
-
```ts showLineNumbers copy title="src/mastra/index.ts"
|
|
113
|
-
import { Mastra } from "@mastra/core";
|
|
114
|
-
import { serve as inngestServe } from "@mastra/inngest";
|
|
115
|
-
import { incrementWorkflow } from "./workflows";
|
|
116
|
-
import { inngest } from "./inngest";
|
|
117
|
-
import { PinoLogger } from "@mastra/loggers";
|
|
118
|
-
|
|
119
|
-
// Configure Mastra with the workflow and Inngest API endpoint
|
|
120
|
-
export const mastra = new Mastra({
|
|
121
|
-
workflows: {
|
|
122
|
-
incrementWorkflow,
|
|
123
|
-
},
|
|
124
|
-
server: {
|
|
125
|
-
// The server configuration is required to allow local docker container can connect to the mastra server
|
|
126
|
-
host: "0.0.0.0",
|
|
127
|
-
apiRoutes: [
|
|
128
|
-
// This API route is used to register the Mastra workflow (inngest function) on the inngest server
|
|
129
|
-
{
|
|
130
|
-
path: "/api/inngest",
|
|
131
|
-
method: "ALL",
|
|
132
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
133
|
-
// The inngestServe function integrates Mastra workflows with Inngest by:
|
|
134
|
-
// 1. Creating Inngest functions for each workflow with unique IDs (workflow.${workflowId})
|
|
135
|
-
// 2. Setting up event handlers that:
|
|
136
|
-
// - Generate unique run IDs for each workflow execution
|
|
137
|
-
// - Create an InngestExecutionEngine to manage step execution
|
|
138
|
-
// - Handle workflow state persistence and real-time updates
|
|
139
|
-
// 3. Establishing a publish-subscribe system for real-time monitoring
|
|
140
|
-
// through the workflow:${workflowId}:${runId} channel
|
|
141
|
-
//
|
|
142
|
-
// Optional: You can also pass additional Inngest functions to serve alongside workflows:
|
|
143
|
-
// createHandler: async ({ mastra }) => inngestServe({
|
|
144
|
-
// mastra,
|
|
145
|
-
// inngest,
|
|
146
|
-
// functions: [customFunction1, customFunction2] // User-defined Inngest functions
|
|
147
|
-
// }),
|
|
148
|
-
},
|
|
149
|
-
],
|
|
150
|
-
},
|
|
151
|
-
logger: new PinoLogger({
|
|
152
|
-
name: "Mastra",
|
|
153
|
-
level: "info",
|
|
154
|
-
}),
|
|
155
|
-
});
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### Running the Workflow locally
|
|
159
|
-
|
|
160
|
-
> **Prerequisites:**
|
|
161
|
-
>
|
|
162
|
-
> - Docker installed and running
|
|
163
|
-
> - Mastra project set up
|
|
164
|
-
> - Dependencies installed (`npm install`)
|
|
165
|
-
|
|
166
|
-
1. Run `npx mastra dev` to start the Mastra server on local to serve the server on port 4111.
|
|
167
|
-
2. Start the Inngest Dev Server (via Docker)
|
|
168
|
-
In a new terminal, run:
|
|
169
|
-
|
|
170
|
-
```sh
|
|
171
|
-
docker run --rm -p 8288:8288 \
|
|
172
|
-
inngest/inngest \
|
|
173
|
-
inngest dev -u http://host.docker.internal:4111/api/inngest
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
> **Note:** The URL after `-u` tells the Inngest dev server where to find your Mastra `/api/inngest` endpoint.
|
|
177
|
-
|
|
178
|
-
3. Open the Inngest Dashboard
|
|
179
|
-
|
|
180
|
-
- Visit [http://localhost:8288](http://localhost:8288) in your browser.
|
|
181
|
-
- Go to the **Apps** section in the sidebar.
|
|
182
|
-
- You should see your Mastra workflow registered.
|
|
183
|
-

|
|
184
|
-
|
|
185
|
-
4. Invoke the Workflow
|
|
186
|
-
|
|
187
|
-
- Go to the **Functions** section in the sidebar.
|
|
188
|
-
- Select your Mastra workflow.
|
|
189
|
-
- Click **Invoke** and use the following input:
|
|
190
|
-
|
|
191
|
-
```json
|
|
192
|
-
{
|
|
193
|
-
"data": {
|
|
194
|
-
"inputData": {
|
|
195
|
-
"value": 5
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-

|
|
202
|
-
|
|
203
|
-
5. **Monitor the Workflow Execution**
|
|
204
|
-
|
|
205
|
-
- Go to the **Runs** tab in the sidebar.
|
|
206
|
-
- Click on the latest run to see step-by-step execution progress.
|
|
207
|
-

|
|
208
|
-
|
|
209
|
-
### Running the Workflow in Production
|
|
210
|
-
|
|
211
|
-
> **Prerequisites:**
|
|
212
|
-
>
|
|
213
|
-
> - Vercel account and Vercel CLI installed (`npm i -g vercel`)
|
|
214
|
-
> - Inngest account
|
|
215
|
-
> - Vercel token (recommended: set as environment variable)
|
|
216
|
-
|
|
217
|
-
1. Add Vercel Deployer to Mastra instance
|
|
218
|
-
|
|
219
|
-
```ts showLineNumbers copy title="src/mastra/index.ts"
|
|
220
|
-
import { VercelDeployer } from "@mastra/deployer-vercel";
|
|
221
|
-
|
|
222
|
-
export const mastra = new Mastra({
|
|
223
|
-
// ...other config
|
|
224
|
-
deployer: new VercelDeployer({
|
|
225
|
-
teamSlug: "your_team_slug",
|
|
226
|
-
projectName: "your_project_name",
|
|
227
|
-
// you can get your vercel token from the vercel dashboard by clicking on the user icon in the top right corner
|
|
228
|
-
// and then clicking on "Account Settings" and then clicking on "Tokens" on the left sidebar.
|
|
229
|
-
token: "your_vercel_token",
|
|
230
|
-
}),
|
|
231
|
-
});
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
> **Note:** Set your Vercel token in your environment:
|
|
235
|
-
>
|
|
236
|
-
> ```sh
|
|
237
|
-
> export VERCEL_TOKEN=your_vercel_token
|
|
238
|
-
> ```
|
|
239
|
-
|
|
240
|
-
2. Build the mastra instance
|
|
241
|
-
|
|
242
|
-
```sh
|
|
243
|
-
npx mastra build
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
3. Deploy to Vercel
|
|
247
|
-
|
|
248
|
-
```sh
|
|
249
|
-
cd .mastra/output
|
|
250
|
-
vercel --prod
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
> **Tip:** If you haven't already, log in to Vercel CLI with `vercel login`.
|
|
254
|
-
|
|
255
|
-
4. Sync with Inngest Dashboard
|
|
256
|
-
|
|
257
|
-
- Go to the [Inngest dashboard](https://app.inngest.com/env/production/apps).
|
|
258
|
-
- Click **Sync new app with Vercel** and follow the instructions.
|
|
259
|
-
- You should see your Mastra workflow registered as an app.
|
|
260
|
-

|
|
261
|
-
|
|
262
|
-
5. Invoke the Workflow
|
|
263
|
-
|
|
264
|
-
- In the **Functions** section, select `workflow.increment-workflow`.
|
|
265
|
-
- Click **All actions** (top right) > **Invoke**.
|
|
266
|
-
- Provide the following input:
|
|
267
|
-
|
|
268
|
-
```json
|
|
269
|
-
{
|
|
270
|
-
"data": {
|
|
271
|
-
"inputData": {
|
|
272
|
-
"value": 5
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-

|
|
279
|
-
|
|
280
|
-
6. Monitor Execution
|
|
281
|
-
|
|
282
|
-
- Go to the **Runs** tab.
|
|
283
|
-
- Click the latest run to see step-by-step execution progress.
|
|
284
|
-

|
|
285
|
-
|
|
286
|
-
## Advanced Usage: Adding Custom Inngest Functions
|
|
287
|
-
|
|
288
|
-
You can serve additional Inngest functions alongside your Mastra workflows by using the optional `functions` parameter in `inngestServe`.
|
|
289
|
-
|
|
290
|
-
### Creating Custom Functions
|
|
291
|
-
|
|
292
|
-
First, create your custom Inngest functions:
|
|
293
|
-
|
|
294
|
-
```ts showLineNumbers copy title="src/inngest/custom-functions.ts"
|
|
295
|
-
import { inngest } from "./inngest";
|
|
296
|
-
|
|
297
|
-
// Define custom Inngest functions
|
|
298
|
-
export const customEmailFunction = inngest.createFunction(
|
|
299
|
-
{ id: "send-welcome-email" },
|
|
300
|
-
{ event: "user/registered" },
|
|
301
|
-
async ({ event }) => {
|
|
302
|
-
// Custom email logic here
|
|
303
|
-
console.log(`Sending welcome email to ${event.data.email}`);
|
|
304
|
-
return { status: "email_sent" };
|
|
305
|
-
},
|
|
306
|
-
);
|
|
307
|
-
|
|
308
|
-
export const customWebhookFunction = inngest.createFunction(
|
|
309
|
-
{ id: "process-webhook" },
|
|
310
|
-
{ event: "webhook/received" },
|
|
311
|
-
async ({ event }) => {
|
|
312
|
-
// Custom webhook processing
|
|
313
|
-
console.log(`Processing webhook: ${event.data.type}`);
|
|
314
|
-
return { processed: true };
|
|
315
|
-
},
|
|
316
|
-
);
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
### Serving Custom Functions with Workflows
|
|
320
|
-
|
|
321
|
-
Update your Mastra configuration to include the custom functions:
|
|
322
|
-
|
|
323
|
-
```ts showLineNumbers copy title="src/mastra/index.ts"
|
|
324
|
-
import { Mastra } from "@mastra/core";
|
|
325
|
-
import { serve as inngestServe } from "@mastra/inngest";
|
|
326
|
-
import { incrementWorkflow } from "./workflows";
|
|
327
|
-
import { inngest } from "./inngest";
|
|
328
|
-
import {
|
|
329
|
-
customEmailFunction,
|
|
330
|
-
customWebhookFunction,
|
|
331
|
-
} from "./inngest/custom-functions";
|
|
332
|
-
|
|
333
|
-
export const mastra = new Mastra({
|
|
334
|
-
workflows: {
|
|
335
|
-
incrementWorkflow,
|
|
336
|
-
},
|
|
337
|
-
server: {
|
|
338
|
-
host: "0.0.0.0",
|
|
339
|
-
apiRoutes: [
|
|
340
|
-
{
|
|
341
|
-
path: "/api/inngest",
|
|
342
|
-
method: "ALL",
|
|
343
|
-
createHandler: async ({ mastra }) =>
|
|
344
|
-
inngestServe({
|
|
345
|
-
mastra,
|
|
346
|
-
inngest,
|
|
347
|
-
functions: [customEmailFunction, customWebhookFunction], // Add your custom functions
|
|
348
|
-
}),
|
|
349
|
-
},
|
|
350
|
-
],
|
|
351
|
-
},
|
|
352
|
-
});
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
### Function Registration
|
|
356
|
-
|
|
357
|
-
When you include custom functions:
|
|
358
|
-
|
|
359
|
-
1. **Mastra workflows** are automatically converted to Inngest functions with IDs like `workflow.${workflowId}`
|
|
360
|
-
2. **Custom functions** retain their specified IDs (e.g., `send-welcome-email`, `process-webhook`)
|
|
361
|
-
3. **All functions** are served together on the same `/api/inngest` endpoint
|
|
362
|
-
|
|
363
|
-
This allows you to combine Mastra's workflow orchestration with your existing Inngest functions seamlessly.
|