@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,6 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "MastraAuthFirebase Class | Auth"
|
|
3
3
|
description: "Documentation for the MastraAuthFirebase class, which authenticates Mastra applications using Firebase Authentication."
|
|
4
|
+
packages:
|
|
5
|
+
- "@mastra/auth-firebase"
|
|
6
|
+
- "@mastra/client-js"
|
|
7
|
+
- "@mastra/core"
|
|
4
8
|
---
|
|
5
9
|
|
|
6
10
|
import Tabs from "@theme/Tabs";
|
|
@@ -19,20 +23,24 @@ This example uses Firebase Authentication. Make sure to:
|
|
|
19
23
|
3. Generate a service account key from Project Settings > Service Accounts
|
|
20
24
|
4. Download the service account JSON file
|
|
21
25
|
|
|
22
|
-
```env title=".env"
|
|
26
|
+
```env title=".env"
|
|
23
27
|
FIREBASE_SERVICE_ACCOUNT=/path/to/your/service-account-key.json
|
|
24
28
|
FIRESTORE_DATABASE_ID=(default)
|
|
25
29
|
# Alternative environment variable names:
|
|
26
30
|
# FIREBASE_DATABASE_ID=(default)
|
|
27
31
|
```
|
|
28
32
|
|
|
29
|
-
|
|
33
|
+
:::note
|
|
34
|
+
|
|
35
|
+
Store your service account JSON file securely and never commit it to version control.
|
|
36
|
+
|
|
37
|
+
:::
|
|
30
38
|
|
|
31
39
|
## Installation
|
|
32
40
|
|
|
33
41
|
Before you can use the `MastraAuthFirebase` class you have to install the `@mastra/auth-firebase` package.
|
|
34
42
|
|
|
35
|
-
```bash
|
|
43
|
+
```bash
|
|
36
44
|
npm install @mastra/auth-firebase@beta
|
|
37
45
|
```
|
|
38
46
|
|
|
@@ -42,13 +50,12 @@ npm install @mastra/auth-firebase@beta
|
|
|
42
50
|
|
|
43
51
|
If you set the required environment variables (`FIREBASE_SERVICE_ACCOUNT` and `FIRESTORE_DATABASE_ID`), you can initialize `MastraAuthFirebase` without any constructor arguments. The class will automatically read these environment variables as configuration:
|
|
44
52
|
|
|
45
|
-
```typescript {2,7} title="src/mastra/index.ts"
|
|
53
|
+
```typescript {2,7} title="src/mastra/index.ts"
|
|
46
54
|
import { Mastra } from "@mastra/core";
|
|
47
55
|
import { MastraAuthFirebase } from "@mastra/auth-firebase";
|
|
48
56
|
|
|
49
57
|
// Automatically uses FIREBASE_SERVICE_ACCOUNT and FIRESTORE_DATABASE_ID env vars
|
|
50
58
|
export const mastra = new Mastra({
|
|
51
|
-
// ..
|
|
52
59
|
server: {
|
|
53
60
|
auth: new MastraAuthFirebase(),
|
|
54
61
|
},
|
|
@@ -57,12 +64,11 @@ export const mastra = new Mastra({
|
|
|
57
64
|
|
|
58
65
|
### Custom configuration
|
|
59
66
|
|
|
60
|
-
```typescript {2,
|
|
67
|
+
```typescript {2,6-9} title="src/mastra/index.ts"
|
|
61
68
|
import { Mastra } from "@mastra/core";
|
|
62
69
|
import { MastraAuthFirebase } from "@mastra/auth-firebase";
|
|
63
70
|
|
|
64
71
|
export const mastra = new Mastra({
|
|
65
|
-
// ..
|
|
66
72
|
server: {
|
|
67
73
|
auth: new MastraAuthFirebase({
|
|
68
74
|
serviceAccount: "/path/to/service-account.json",
|
|
@@ -81,13 +87,17 @@ The `MastraAuthFirebase` class can be configured through constructor options or
|
|
|
81
87
|
- `FIREBASE_SERVICE_ACCOUNT`: Path to Firebase service account JSON file
|
|
82
88
|
- `FIRESTORE_DATABASE_ID` or `FIREBASE_DATABASE_ID`: Firestore database ID
|
|
83
89
|
|
|
84
|
-
|
|
90
|
+
:::note
|
|
91
|
+
|
|
92
|
+
When constructor options are not provided, the class automatically reads these environment variables. This means you can simply call `new MastraAuthFirebase()` without any arguments if your environment variables are properly configured.
|
|
93
|
+
|
|
94
|
+
:::
|
|
85
95
|
|
|
86
96
|
### User Authorization
|
|
87
97
|
|
|
88
98
|
By default, `MastraAuthFirebase` uses Firestore to manage user access. It expects a collection named `user_access` with documents keyed by user UIDs. The presence of a document in this collection determines whether a user is authorized.
|
|
89
99
|
|
|
90
|
-
```typescript title="firestore-structure.txt"
|
|
100
|
+
```typescript title="firestore-structure.txt"
|
|
91
101
|
user_access/
|
|
92
102
|
{user_uid_1}/ // Document exists = user authorized
|
|
93
103
|
{user_uid_2}/ // Document exists = user authorized
|
|
@@ -95,7 +105,7 @@ user_access/
|
|
|
95
105
|
|
|
96
106
|
To customize user authorization, provide a custom `authorizeUser` function:
|
|
97
107
|
|
|
98
|
-
```typescript title="src/mastra/auth.ts"
|
|
108
|
+
```typescript title="src/mastra/auth.ts"
|
|
99
109
|
import { MastraAuthFirebase } from "@mastra/auth-firebase";
|
|
100
110
|
|
|
101
111
|
const firebaseAuth = new MastraAuthFirebase({
|
|
@@ -106,7 +116,11 @@ const firebaseAuth = new MastraAuthFirebase({
|
|
|
106
116
|
});
|
|
107
117
|
```
|
|
108
118
|
|
|
109
|
-
|
|
119
|
+
:::info
|
|
120
|
+
|
|
121
|
+
Visit [MastraAuthFirebase](/reference/v1/auth/firebase) for all available configuration options.
|
|
122
|
+
|
|
123
|
+
:::
|
|
110
124
|
|
|
111
125
|
## Client-side setup
|
|
112
126
|
|
|
@@ -116,7 +130,7 @@ When using Firebase auth, you'll need to initialize Firebase on the client side,
|
|
|
116
130
|
|
|
117
131
|
First, initialize Firebase in your client application:
|
|
118
132
|
|
|
119
|
-
```typescript title="lib/firebase.ts"
|
|
133
|
+
```typescript title="lib/firebase.ts"
|
|
120
134
|
import { initializeApp } from "firebase/app";
|
|
121
135
|
import { getAuth, GoogleAuthProvider } from "firebase/auth";
|
|
122
136
|
|
|
@@ -135,7 +149,7 @@ export const googleProvider = new GoogleAuthProvider();
|
|
|
135
149
|
|
|
136
150
|
Use Firebase authentication to sign in users and retrieve their ID tokens:
|
|
137
151
|
|
|
138
|
-
```typescript title="lib/auth.ts"
|
|
152
|
+
```typescript title="lib/auth.ts"
|
|
139
153
|
import { signInWithPopup, signOut, User } from "firebase/auth";
|
|
140
154
|
import { auth, googleProvider } from "./firebase";
|
|
141
155
|
|
|
@@ -169,13 +183,17 @@ export const signOutUser = async () => {
|
|
|
169
183
|
};
|
|
170
184
|
```
|
|
171
185
|
|
|
172
|
-
|
|
186
|
+
:::note
|
|
187
|
+
|
|
188
|
+
Refer to the [Firebase documentation](https://firebase.google.com/docs/auth) for other authentication methods like email/password, phone authentication, and more.
|
|
189
|
+
|
|
190
|
+
:::
|
|
173
191
|
|
|
174
192
|
## Configuring `MastraClient`
|
|
175
193
|
|
|
176
194
|
When `auth` is enabled, all requests made with `MastraClient` must include a valid Firebase ID token in the `Authorization` header:
|
|
177
195
|
|
|
178
|
-
```typescript {6} title="lib/mastra/mastra-client.ts"
|
|
196
|
+
```typescript {6} title="lib/mastra/mastra-client.ts"
|
|
179
197
|
import { MastraClient } from "@mastra/client-js";
|
|
180
198
|
|
|
181
199
|
export const createMastraClient = (idToken: string) => {
|
|
@@ -188,9 +206,13 @@ export const createMastraClient = (idToken: string) => {
|
|
|
188
206
|
};
|
|
189
207
|
```
|
|
190
208
|
|
|
191
|
-
|
|
209
|
+
:::info
|
|
192
210
|
|
|
193
|
-
|
|
211
|
+
The ID token must be prefixed with `Bearer` in the Authorization header.
|
|
212
|
+
|
|
213
|
+
Visit [Mastra Client SDK](/docs/v1/server/mastra-client) for more configuration options.
|
|
214
|
+
|
|
215
|
+
:::
|
|
194
216
|
|
|
195
217
|
### Making authenticated requests
|
|
196
218
|
|
|
@@ -198,7 +220,8 @@ Once `MastraClient` is configured with the Firebase ID token, you can send authe
|
|
|
198
220
|
|
|
199
221
|
<Tabs>
|
|
200
222
|
<TabItem value="react" label="React">
|
|
201
|
-
|
|
223
|
+
|
|
224
|
+
```tsx title="src/components/test-agent.tsx" copy
|
|
202
225
|
"use client";
|
|
203
226
|
|
|
204
227
|
import { useAuthState } from 'react-firebase-hooks/auth';
|
|
@@ -216,9 +239,7 @@ Once `MastraClient` is configured with the Firebase ID token, you can send authe
|
|
|
216
239
|
const client = createMastraClient(token);
|
|
217
240
|
|
|
218
241
|
const weatherAgent = client.getAgent("weatherAgent");
|
|
219
|
-
const response = await weatherAgent.generate(
|
|
220
|
-
messages: "What's the weather like in New York",
|
|
221
|
-
});
|
|
242
|
+
const response = await weatherAgent.generate("What's the weather like in New York");
|
|
222
243
|
|
|
223
244
|
console.log({ response });
|
|
224
245
|
}
|
|
@@ -233,7 +254,8 @@ Once `MastraClient` is configured with the Firebase ID token, you can send authe
|
|
|
233
254
|
|
|
234
255
|
</TabItem>
|
|
235
256
|
<TabItem value="nodejs" label="Node.js">
|
|
236
|
-
|
|
257
|
+
|
|
258
|
+
```typescript title="server.js" copy
|
|
237
259
|
const express = require('express');
|
|
238
260
|
const admin = require('firebase-admin');
|
|
239
261
|
const { MastraClient } = require('@mastra/client-js');
|
|
@@ -263,9 +285,7 @@ Once `MastraClient` is configured with the Firebase ID token, you can send authe
|
|
|
263
285
|
});
|
|
264
286
|
|
|
265
287
|
const weatherAgent = mastra.getAgent("weatherAgent");
|
|
266
|
-
const response = await weatherAgent.generate(
|
|
267
|
-
messages: "What's the weather like in Nairobi"
|
|
268
|
-
});
|
|
288
|
+
const response = await weatherAgent.generate("What's the weather like in Nairobi");
|
|
269
289
|
|
|
270
290
|
res.json({ response: response.text });
|
|
271
291
|
} catch (error) {
|
|
@@ -276,6 +296,7 @@ Once `MastraClient` is configured with the Firebase ID token, you can send authe
|
|
|
276
296
|
|
|
277
297
|
</TabItem>
|
|
278
298
|
<TabItem value="curl" label="cURL">
|
|
299
|
+
|
|
279
300
|
```bash copy
|
|
280
301
|
curl -X POST http://localhost:4111/api/agents/weatherAgent/generate \
|
|
281
302
|
-H "Content-Type: application/json" \
|
|
@@ -284,5 +305,6 @@ Once `MastraClient` is configured with the Firebase ID token, you can send authe
|
|
|
284
305
|
"messages": "Weather in London"
|
|
285
306
|
}'
|
|
286
307
|
```
|
|
308
|
+
|
|
287
309
|
</TabItem>
|
|
288
310
|
</Tabs>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Auth Overview | Auth"
|
|
3
3
|
description: Learn about different Auth options for your Mastra applications
|
|
4
|
+
packages:
|
|
5
|
+
- "@mastra/auth"
|
|
4
6
|
---
|
|
5
7
|
|
|
6
8
|
# Auth Overview
|
|
@@ -11,9 +13,9 @@ You can start with simple shared secret JWT authentication and switch to provide
|
|
|
11
13
|
|
|
12
14
|
## Available providers
|
|
13
15
|
|
|
14
|
-
- [JSON Web Token (JWT)](/docs/v1/auth/jwt)
|
|
15
|
-
- [Clerk](/docs/v1/auth/clerk)
|
|
16
|
-
- [Supabase](/docs/v1/auth/supabase)
|
|
17
|
-
- [Firebase](/docs/v1/auth/firebase)
|
|
18
|
-
- [WorkOS](/docs/v1/auth/workos)
|
|
19
|
-
- [Auth0](/docs/v1/auth/auth0)
|
|
16
|
+
- [JSON Web Token (JWT)](/docs/v1/server/auth/jwt)
|
|
17
|
+
- [Clerk](/docs/v1/server/auth/clerk)
|
|
18
|
+
- [Supabase](/docs/v1/server/auth/supabase)
|
|
19
|
+
- [Firebase](/docs/v1/server/auth/firebase)
|
|
20
|
+
- [WorkOS](/docs/v1/server/auth/workos)
|
|
21
|
+
- [Auth0](/docs/v1/server/auth/auth0)
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "MastraJwtAuth Class | Auth"
|
|
3
3
|
description: "Documentation for the MastraJwtAuth class, which authenticates Mastra applications using JSON Web Tokens."
|
|
4
|
+
packages:
|
|
5
|
+
- "@mastra/auth"
|
|
6
|
+
- "@mastra/client-js"
|
|
7
|
+
- "@mastra/core"
|
|
4
8
|
---
|
|
5
9
|
|
|
6
10
|
import Tabs from "@theme/Tabs";
|
|
@@ -14,18 +18,17 @@ The `MastraJwtAuth` class provides a lightweight authentication mechanism for Ma
|
|
|
14
18
|
|
|
15
19
|
Before you can use the `MastraJwtAuth` class you have to install the `@mastra/auth` package.
|
|
16
20
|
|
|
17
|
-
```bash
|
|
21
|
+
```bash
|
|
18
22
|
npm install @mastra/auth@beta
|
|
19
23
|
```
|
|
20
24
|
|
|
21
25
|
## Usage example
|
|
22
26
|
|
|
23
|
-
```typescript {2,
|
|
27
|
+
```typescript {2,6-8} title="src/mastra/index.ts"
|
|
24
28
|
import { Mastra } from "@mastra/core";
|
|
25
29
|
import { MastraJwtAuth } from "@mastra/auth";
|
|
26
30
|
|
|
27
31
|
export const mastra = new Mastra({
|
|
28
|
-
// ..
|
|
29
32
|
server: {
|
|
30
33
|
auth: new MastraJwtAuth({
|
|
31
34
|
secret: process.env.MASTRA_JWT_SECRET,
|
|
@@ -34,13 +37,17 @@ export const mastra = new Mastra({
|
|
|
34
37
|
});
|
|
35
38
|
```
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
:::info
|
|
41
|
+
|
|
42
|
+
Visit [MastraJwtAuth](/reference/v1/auth/jwt) for all available configuration options.
|
|
43
|
+
|
|
44
|
+
:::
|
|
38
45
|
|
|
39
46
|
## Configuring `MastraClient`
|
|
40
47
|
|
|
41
48
|
When `auth` is enabled, all requests made with `MastraClient` must include a valid JWT in the `Authorization` header:
|
|
42
49
|
|
|
43
|
-
```typescript {6} title="lib/mastra/mastra-client.ts"
|
|
50
|
+
```typescript {6} title="lib/mastra/mastra-client.ts"
|
|
44
51
|
import { MastraClient } from "@mastra/client-js";
|
|
45
52
|
|
|
46
53
|
export const mastraClient = new MastraClient({
|
|
@@ -51,7 +58,11 @@ export const mastraClient = new MastraClient({
|
|
|
51
58
|
});
|
|
52
59
|
```
|
|
53
60
|
|
|
54
|
-
|
|
61
|
+
:::info
|
|
62
|
+
|
|
63
|
+
Visit [Mastra Client SDK](/docs/v1/server/mastra-client) for more configuration options.
|
|
64
|
+
|
|
65
|
+
:::
|
|
55
66
|
|
|
56
67
|
### Making authenticated requests
|
|
57
68
|
|
|
@@ -59,16 +70,15 @@ Once `MastraClient` is configured, you can send authenticated requests from your
|
|
|
59
70
|
|
|
60
71
|
<Tabs>
|
|
61
72
|
<TabItem value="react" label="React">
|
|
62
|
-
|
|
73
|
+
|
|
74
|
+
```tsx title="src/components/test-agent.tsx" copy
|
|
63
75
|
import { mastraClient } from "../../lib/mastra-client";
|
|
64
76
|
|
|
65
77
|
export const TestAgent = () => {
|
|
66
78
|
async function handleClick() {
|
|
67
79
|
const agent = mastraClient.getAgent("weatherAgent");
|
|
68
80
|
|
|
69
|
-
const response = await agent.generate(
|
|
70
|
-
messages: "Weather in London"
|
|
71
|
-
});
|
|
81
|
+
const response = await agent.generate("Weather in London");
|
|
72
82
|
|
|
73
83
|
console.log(response);
|
|
74
84
|
}
|
|
@@ -79,6 +89,7 @@ Once `MastraClient` is configured, you can send authenticated requests from your
|
|
|
79
89
|
|
|
80
90
|
</TabItem>
|
|
81
91
|
<TabItem value="curl" label="cURL">
|
|
92
|
+
|
|
82
93
|
```bash copy
|
|
83
94
|
curl -X POST http://localhost:4111/api/agents/weatherAgent/generate \
|
|
84
95
|
-H "Content-Type: application/json" \
|
|
@@ -87,6 +98,7 @@ Once `MastraClient` is configured, you can send authenticated requests from your
|
|
|
87
98
|
"messages": "Weather in London"
|
|
88
99
|
}'
|
|
89
100
|
```
|
|
101
|
+
|
|
90
102
|
</TabItem>
|
|
91
103
|
</Tabs>
|
|
92
104
|
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "MastraAuthSupabase Class | Auth"
|
|
3
3
|
description: "Documentation for the MastraAuthSupabase class, which authenticates Mastra applications using Supabase Auth."
|
|
4
|
+
packages:
|
|
5
|
+
- "@mastra/auth-supabase"
|
|
6
|
+
- "@mastra/client-js"
|
|
7
|
+
- "@mastra/core"
|
|
4
8
|
---
|
|
5
9
|
|
|
6
10
|
import Tabs from "@theme/Tabs";
|
|
@@ -14,29 +18,32 @@ The `MastraAuthSupabase` class provides authentication for Mastra using Supabase
|
|
|
14
18
|
|
|
15
19
|
This example uses Supabase Auth. Make sure to add your Supabase credentials to your `.env` file and ensure your Supabase project is properly configured.
|
|
16
20
|
|
|
17
|
-
```env title=".env"
|
|
21
|
+
```env title=".env"
|
|
18
22
|
SUPABASE_URL=https://your-project.supabase.co
|
|
19
23
|
SUPABASE_ANON_KEY=your-anon-key
|
|
20
24
|
```
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
:::note
|
|
27
|
+
|
|
28
|
+
Review your Supabase Row Level Security (RLS) settings to ensure proper data access controls.
|
|
29
|
+
|
|
30
|
+
:::
|
|
23
31
|
|
|
24
32
|
## Installation
|
|
25
33
|
|
|
26
34
|
Before you can use the `MastraAuthSupabase` class you have to install the `@mastra/auth-supabase` package.
|
|
27
35
|
|
|
28
|
-
```bash
|
|
36
|
+
```bash
|
|
29
37
|
npm install @mastra/auth-supabase@beta
|
|
30
38
|
```
|
|
31
39
|
|
|
32
40
|
## Usage example
|
|
33
41
|
|
|
34
|
-
```typescript {2,
|
|
42
|
+
```typescript {2,6-9} title="src/mastra/index.ts"
|
|
35
43
|
import { Mastra } from "@mastra/core";
|
|
36
44
|
import { MastraAuthSupabase } from "@mastra/auth-supabase";
|
|
37
45
|
|
|
38
46
|
export const mastra = new Mastra({
|
|
39
|
-
// ..
|
|
40
47
|
server: {
|
|
41
48
|
auth: new MastraAuthSupabase({
|
|
42
49
|
url: process.env.SUPABASE_URL,
|
|
@@ -46,9 +53,13 @@ export const mastra = new Mastra({
|
|
|
46
53
|
});
|
|
47
54
|
```
|
|
48
55
|
|
|
49
|
-
|
|
56
|
+
:::info
|
|
57
|
+
|
|
58
|
+
The default `authorizeUser` method checks the `isAdmin` column in the `users` table in the `public` schema. To customize user authorization, provide a custom `authorizeUser` function when constructing the provider.
|
|
50
59
|
|
|
51
|
-
|
|
60
|
+
Visit [MastraAuthSupabase](/reference/v1/auth/supabase) for all available configuration options.
|
|
61
|
+
|
|
62
|
+
:::
|
|
52
63
|
|
|
53
64
|
## Client-side setup
|
|
54
65
|
|
|
@@ -58,7 +69,7 @@ When using Supabase auth, you'll need to retrieve the access token from Supabase
|
|
|
58
69
|
|
|
59
70
|
Use the Supabase client to authenticate users and retrieve their access token:
|
|
60
71
|
|
|
61
|
-
```typescript title="lib/auth.ts"
|
|
72
|
+
```typescript title="lib/auth.ts"
|
|
62
73
|
import { createClient } from "@supabase/supabase-js";
|
|
63
74
|
|
|
64
75
|
const supabase = createClient("<supabase-url>", "<supabase-key>");
|
|
@@ -71,13 +82,17 @@ const authTokenResponse = await supabase.auth.signInWithPassword({
|
|
|
71
82
|
const accessToken = authTokenResponse.data?.session?.access_token;
|
|
72
83
|
```
|
|
73
84
|
|
|
74
|
-
|
|
85
|
+
:::note
|
|
86
|
+
|
|
87
|
+
Refer to the [Supabase documentation](https://supabase.com/docs/guides/auth) for other authentication methods like OAuth, magic links, and more.
|
|
88
|
+
|
|
89
|
+
:::
|
|
75
90
|
|
|
76
91
|
## Configuring `MastraClient`
|
|
77
92
|
|
|
78
93
|
When `auth` is enabled, all requests made with `MastraClient` must include a valid Supabase access token in the `Authorization` header:
|
|
79
94
|
|
|
80
|
-
```typescript {6} title="lib/mastra/mastra-client.ts"
|
|
95
|
+
```typescript {6} title="lib/mastra/mastra-client.ts"
|
|
81
96
|
import { MastraClient } from "@mastra/client-js";
|
|
82
97
|
|
|
83
98
|
export const mastraClient = new MastraClient({
|
|
@@ -88,9 +103,13 @@ export const mastraClient = new MastraClient({
|
|
|
88
103
|
});
|
|
89
104
|
```
|
|
90
105
|
|
|
91
|
-
|
|
106
|
+
:::info
|
|
92
107
|
|
|
93
|
-
|
|
108
|
+
The access token must be prefixed with `Bearer` in the Authorization header.
|
|
109
|
+
|
|
110
|
+
Visit [Mastra Client SDK](/docs/v1/server/mastra-client) for more configuration options.
|
|
111
|
+
|
|
112
|
+
:::
|
|
94
113
|
|
|
95
114
|
### Making authenticated requests
|
|
96
115
|
|
|
@@ -98,26 +117,26 @@ Once `MastraClient` is configured with the Supabase access token, you can send a
|
|
|
98
117
|
|
|
99
118
|
<Tabs>
|
|
100
119
|
<TabItem value="react" label="React">
|
|
101
|
-
```tsx title="src/components/test-agent.tsx" showLineNumbers copy
|
|
102
|
-
import { mastraClient } from "../../lib/mastra-client";
|
|
103
120
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const agent = mastraClient.getAgent("weatherAgent");
|
|
121
|
+
```tsx title="src/components/test-agent.tsx" copy
|
|
122
|
+
import { mastraClient } from "../../lib/mastra-client";
|
|
107
123
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
124
|
+
export const TestAgent = () => {
|
|
125
|
+
async function handleClick() {
|
|
126
|
+
const agent = mastraClient.getAgent("weatherAgent");
|
|
111
127
|
|
|
112
|
-
|
|
113
|
-
}
|
|
128
|
+
const response = await agent.generate("What's the weather like in New York");
|
|
114
129
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
130
|
+
console.log(response);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return <button onClick={handleClick}>Test Agent</button>;
|
|
134
|
+
};
|
|
135
|
+
```
|
|
118
136
|
|
|
119
137
|
</TabItem>
|
|
120
138
|
<TabItem value="curl" label="cURL">
|
|
139
|
+
|
|
121
140
|
```bash copy
|
|
122
141
|
curl -X POST http://localhost:4111/api/agents/weatherAgent/generate \
|
|
123
142
|
-H "Content-Type: application/json" \
|
|
@@ -126,5 +145,6 @@ Once `MastraClient` is configured with the Supabase access token, you can send a
|
|
|
126
145
|
"messages": "Weather in London"
|
|
127
146
|
}'
|
|
128
147
|
```
|
|
148
|
+
|
|
129
149
|
</TabItem>
|
|
130
150
|
</Tabs>
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "MastraAuthWorkos Class | Auth"
|
|
3
3
|
description: "Documentation for the MastraAuthWorkos class, which authenticates Mastra applications using WorkOS authentication."
|
|
4
|
+
packages:
|
|
5
|
+
- "@mastra/auth-workos"
|
|
6
|
+
- "@mastra/client-js"
|
|
7
|
+
- "@mastra/core"
|
|
4
8
|
---
|
|
5
9
|
|
|
6
10
|
import Tabs from "@theme/Tabs";
|
|
@@ -19,20 +23,24 @@ This example uses WorkOS authentication. Make sure to:
|
|
|
19
23
|
3. Configure your redirect URIs and allowed origins
|
|
20
24
|
4. Set up Organizations and configure user roles as needed
|
|
21
25
|
|
|
22
|
-
```env title=".env"
|
|
26
|
+
```env title=".env"
|
|
23
27
|
WORKOS_API_KEY=sk_live_...
|
|
24
28
|
WORKOS_CLIENT_ID=client_...
|
|
25
29
|
```
|
|
26
30
|
|
|
27
|
-
|
|
31
|
+
:::note
|
|
28
32
|
|
|
29
|
-
|
|
33
|
+
You can find your API key and Client ID in the WorkOS Dashboard under API Keys and Applications respectively.
|
|
34
|
+
|
|
35
|
+
For detailed setup instructions, refer to the [WorkOS documentation](https://workos.com/docs) for your specific platform.
|
|
36
|
+
|
|
37
|
+
:::
|
|
30
38
|
|
|
31
39
|
## Installation
|
|
32
40
|
|
|
33
41
|
Before you can use the `MastraAuthWorkos` class you have to install the `@mastra/auth-workos` package.
|
|
34
42
|
|
|
35
|
-
```bash
|
|
43
|
+
```bash
|
|
36
44
|
npm install @mastra/auth-workos@beta
|
|
37
45
|
```
|
|
38
46
|
|
|
@@ -40,12 +48,11 @@ npm install @mastra/auth-workos@beta
|
|
|
40
48
|
|
|
41
49
|
### Basic usage with environment variables
|
|
42
50
|
|
|
43
|
-
```typescript {2,
|
|
51
|
+
```typescript {2,6} title="src/mastra/index.ts"
|
|
44
52
|
import { Mastra } from "@mastra/core";
|
|
45
53
|
import { MastraAuthWorkos } from "@mastra/auth-workos";
|
|
46
54
|
|
|
47
55
|
export const mastra = new Mastra({
|
|
48
|
-
// ..
|
|
49
56
|
server: {
|
|
50
57
|
auth: new MastraAuthWorkos(),
|
|
51
58
|
},
|
|
@@ -54,12 +61,11 @@ export const mastra = new Mastra({
|
|
|
54
61
|
|
|
55
62
|
### Custom configuration
|
|
56
63
|
|
|
57
|
-
```typescript {2,
|
|
64
|
+
```typescript {2,6-9} title="src/mastra/index.ts"
|
|
58
65
|
import { Mastra } from "@mastra/core";
|
|
59
66
|
import { MastraAuthWorkos } from "@mastra/auth-workos";
|
|
60
67
|
|
|
61
68
|
export const mastra = new Mastra({
|
|
62
|
-
// ..
|
|
63
69
|
server: {
|
|
64
70
|
auth: new MastraAuthWorkos({
|
|
65
71
|
apiKey: process.env.WORKOS_API_KEY,
|
|
@@ -82,7 +88,7 @@ By default, `MastraAuthWorkos` checks whether the authenticated user has an 'adm
|
|
|
82
88
|
|
|
83
89
|
To customize user authorization, provide a custom `authorizeUser` function:
|
|
84
90
|
|
|
85
|
-
```typescript title="src/mastra/auth.ts"
|
|
91
|
+
```typescript title="src/mastra/auth.ts"
|
|
86
92
|
import { MastraAuthWorkos } from "@mastra/auth-workos";
|
|
87
93
|
|
|
88
94
|
const workosAuth = new MastraAuthWorkos({
|
|
@@ -94,7 +100,11 @@ const workosAuth = new MastraAuthWorkos({
|
|
|
94
100
|
});
|
|
95
101
|
```
|
|
96
102
|
|
|
97
|
-
|
|
103
|
+
:::info
|
|
104
|
+
|
|
105
|
+
Visit [MastraAuthWorkos](/reference/v1/auth/workos) for all available configuration options.
|
|
106
|
+
|
|
107
|
+
:::
|
|
98
108
|
|
|
99
109
|
## Client-side setup
|
|
100
110
|
|
|
@@ -104,7 +114,7 @@ When using WorkOS auth, you'll need to implement the WorkOS authentication flow
|
|
|
104
114
|
|
|
105
115
|
First, install the WorkOS SDK in your application:
|
|
106
116
|
|
|
107
|
-
```bash
|
|
117
|
+
```bash
|
|
108
118
|
npm install @workos-inc/node
|
|
109
119
|
```
|
|
110
120
|
|
|
@@ -112,7 +122,7 @@ npm install @workos-inc/node
|
|
|
112
122
|
|
|
113
123
|
After users complete the WorkOS authentication flow and return with an authorization code, exchange it for an access token:
|
|
114
124
|
|
|
115
|
-
```typescript title="lib/auth.ts"
|
|
125
|
+
```typescript title="lib/auth.ts"
|
|
116
126
|
import { WorkOS } from "@workos-inc/node";
|
|
117
127
|
|
|
118
128
|
const workos = new WorkOS(process.env.WORKOS_API_KEY);
|
|
@@ -131,13 +141,17 @@ export const authenticateWithWorkos = async (
|
|
|
131
141
|
};
|
|
132
142
|
```
|
|
133
143
|
|
|
134
|
-
|
|
144
|
+
:::note
|
|
145
|
+
|
|
146
|
+
Refer to the [WorkOS User Management documentation](https://workos.com/docs/authkit/vanilla/nodejs) for more authentication methods and configuration options.
|
|
147
|
+
|
|
148
|
+
:::
|
|
135
149
|
|
|
136
150
|
## Configuring `MastraClient`
|
|
137
151
|
|
|
138
152
|
When `auth` is enabled, all requests made with `MastraClient` must include a valid WorkOS access token in the `Authorization` header:
|
|
139
153
|
|
|
140
|
-
```typescript title="lib/mastra/mastra-client.ts"
|
|
154
|
+
```typescript title="lib/mastra/mastra-client.ts"
|
|
141
155
|
import { MastraClient } from "@mastra/client-js";
|
|
142
156
|
|
|
143
157
|
export const createMastraClient = (accessToken: string) => {
|
|
@@ -150,9 +164,13 @@ export const createMastraClient = (accessToken: string) => {
|
|
|
150
164
|
};
|
|
151
165
|
```
|
|
152
166
|
|
|
153
|
-
|
|
167
|
+
:::info
|
|
154
168
|
|
|
155
|
-
|
|
169
|
+
The access token must be prefixed with `Bearer` in the Authorization header.
|
|
170
|
+
|
|
171
|
+
Visit [Mastra Client SDK](/docs/v1/server/mastra-client) for more configuration options.
|
|
172
|
+
|
|
173
|
+
:::
|
|
156
174
|
|
|
157
175
|
### Making authenticated requests
|
|
158
176
|
|
|
@@ -160,7 +178,8 @@ Once `MastraClient` is configured with the WorkOS access token, you can send aut
|
|
|
160
178
|
|
|
161
179
|
<Tabs>
|
|
162
180
|
<TabItem value="react" label="React">
|
|
163
|
-
|
|
181
|
+
|
|
182
|
+
```typescript title="src/api/agents.ts" copy
|
|
164
183
|
import { WorkOS } from '@workos-inc/node';
|
|
165
184
|
import { MastraClient } from '@mastra/client-js';
|
|
166
185
|
|
|
@@ -182,9 +201,7 @@ Once `MastraClient` is configured with the WorkOS access token, you can send aut
|
|
|
182
201
|
});
|
|
183
202
|
|
|
184
203
|
const weatherAgent = mastra.getAgent("weatherAgent");
|
|
185
|
-
const response = await weatherAgent.generate(
|
|
186
|
-
messages: "What's the weather like in Nairobi",
|
|
187
|
-
});
|
|
204
|
+
const response = await weatherAgent.generate("What's the weather like in Nairobi");
|
|
188
205
|
|
|
189
206
|
return response.text;
|
|
190
207
|
};
|
|
@@ -192,6 +209,7 @@ Once `MastraClient` is configured with the WorkOS access token, you can send aut
|
|
|
192
209
|
|
|
193
210
|
</TabItem>
|
|
194
211
|
<TabItem value="curl" label="cURL">
|
|
212
|
+
|
|
195
213
|
```bash copy
|
|
196
214
|
curl -X POST http://localhost:4111/api/agents/weatherAgent/generate \
|
|
197
215
|
-H "Content-Type: application/json" \
|
|
@@ -200,5 +218,6 @@ Once `MastraClient` is configured with the WorkOS access token, you can send aut
|
|
|
200
218
|
"messages": "Weather in London"
|
|
201
219
|
}'
|
|
202
220
|
```
|
|
221
|
+
|
|
203
222
|
</TabItem>
|
|
204
223
|
</Tabs>
|