@mastra/mcp-docs-server 0.13.37 → 0.13.38
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 +2 -0
- package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +2 -0
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +8 -8
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +23 -23
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +69 -69
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +15 -15
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +27 -27
- package/.docs/organized/changelogs/%40mastra%2Freact.md +15 -15
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +23 -23
- package/.docs/organized/changelogs/create-mastra.md +5 -5
- package/.docs/organized/changelogs/mastra.md +17 -17
- package/.docs/raw/agents/adding-voice.mdx +20 -9
- package/.docs/raw/agents/agent-memory.mdx +55 -39
- package/.docs/raw/agents/guardrails.mdx +68 -61
- package/.docs/raw/agents/networks.mdx +50 -46
- package/.docs/raw/agents/overview.mdx +125 -88
- package/.docs/raw/agents/using-tools.mdx +14 -15
- package/.docs/raw/auth/auth0.mdx +28 -27
- package/.docs/raw/auth/clerk.mdx +22 -20
- package/.docs/raw/auth/firebase.mdx +42 -39
- package/.docs/raw/auth/index.mdx +1 -1
- package/.docs/raw/auth/jwt.mdx +18 -16
- package/.docs/raw/auth/supabase.mdx +20 -18
- package/.docs/raw/auth/workos.mdx +32 -26
- package/.docs/raw/community/contributing-templates.mdx +7 -7
- package/.docs/raw/community/discord.mdx +2 -2
- package/.docs/raw/community/licensing.mdx +1 -1
- package/.docs/raw/course/03-agent-memory/26-updating-mastra-export-comprehensive.md +0 -32
- package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +41 -22
- package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +48 -29
- package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +52 -24
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +86 -55
- package/.docs/raw/deployment/cloud-providers/index.mdx +16 -13
- package/.docs/raw/deployment/monorepo.mdx +32 -42
- package/.docs/raw/deployment/overview.mdx +15 -15
- package/.docs/raw/deployment/server-deployment.mdx +18 -23
- package/.docs/raw/deployment/serverless-platforms/cloudflare-deployer.mdx +16 -17
- package/.docs/raw/deployment/serverless-platforms/index.mdx +15 -12
- package/.docs/raw/deployment/serverless-platforms/netlify-deployer.mdx +14 -23
- package/.docs/raw/deployment/serverless-platforms/vercel-deployer.mdx +16 -23
- package/.docs/raw/deployment/web-framework.mdx +14 -14
- package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +138 -145
- package/.docs/raw/frameworks/agentic-uis/assistant-ui.mdx +54 -43
- package/.docs/raw/frameworks/agentic-uis/cedar-os.mdx +51 -36
- package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +161 -120
- package/.docs/raw/frameworks/agentic-uis/openrouter.mdx +59 -48
- package/.docs/raw/frameworks/servers/express.mdx +45 -44
- package/.docs/raw/frameworks/web-frameworks/astro.mdx +245 -162
- package/.docs/raw/frameworks/web-frameworks/next-js.mdx +112 -69
- package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +189 -164
- package/.docs/raw/frameworks/web-frameworks/vite-react.mdx +94 -81
- package/.docs/raw/getting-started/installation.mdx +164 -133
- package/.docs/raw/getting-started/mcp-docs-server.mdx +36 -39
- package/.docs/raw/getting-started/project-structure.mdx +34 -42
- package/.docs/raw/getting-started/studio.mdx +40 -58
- package/.docs/raw/getting-started/templates.mdx +22 -27
- package/.docs/raw/index.mdx +9 -9
- package/.docs/raw/mastra-cloud/dashboard.mdx +10 -10
- package/.docs/raw/mastra-cloud/observability.mdx +7 -8
- package/.docs/raw/mastra-cloud/overview.mdx +16 -22
- package/.docs/raw/mastra-cloud/setting-up.mdx +33 -20
- package/.docs/raw/memory/conversation-history.mdx +2 -2
- package/.docs/raw/memory/overview.mdx +21 -23
- package/.docs/raw/memory/semantic-recall.mdx +14 -13
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +27 -28
- package/.docs/raw/memory/storage/memory-with-pg.mdx +26 -26
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +26 -27
- package/.docs/raw/memory/threads-and-resources.mdx +23 -20
- package/.docs/raw/memory/working-memory.mdx +27 -38
- package/.docs/raw/observability/ai-tracing/exporters/arize.mdx +30 -29
- package/.docs/raw/observability/ai-tracing/exporters/braintrust.mdx +8 -9
- package/.docs/raw/observability/ai-tracing/exporters/cloud.mdx +17 -16
- package/.docs/raw/observability/ai-tracing/exporters/default.mdx +31 -32
- package/.docs/raw/observability/ai-tracing/exporters/langfuse.mdx +18 -17
- package/.docs/raw/observability/ai-tracing/exporters/langsmith.mdx +14 -14
- package/.docs/raw/observability/ai-tracing/exporters/otel.mdx +56 -46
- package/.docs/raw/observability/ai-tracing/overview.mdx +145 -122
- package/.docs/raw/observability/ai-tracing/processors/sensitive-data-filter.mdx +57 -36
- package/.docs/raw/observability/logging.mdx +14 -17
- package/.docs/raw/observability/nextjs-tracing.mdx +5 -5
- package/.docs/raw/observability/otel-tracing.mdx +17 -18
- package/.docs/raw/observability/overview.mdx +14 -10
- package/.docs/raw/rag/chunking-and-embedding.mdx +10 -8
- package/.docs/raw/rag/overview.mdx +5 -5
- package/.docs/raw/rag/retrieval.mdx +125 -107
- package/.docs/raw/rag/vector-databases.mdx +232 -223
- package/.docs/raw/reference/agents/agent.mdx +54 -41
- package/.docs/raw/reference/agents/generate.mdx +367 -261
- package/.docs/raw/reference/agents/generateLegacy.mdx +260 -178
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +7 -5
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +7 -5
- package/.docs/raw/reference/agents/getDescription.mdx +3 -2
- package/.docs/raw/reference/agents/getInstructions.mdx +7 -5
- package/.docs/raw/reference/agents/getLLM.mdx +11 -7
- package/.docs/raw/reference/agents/getMemory.mdx +7 -5
- package/.docs/raw/reference/agents/getModel.mdx +7 -5
- package/.docs/raw/reference/agents/getScorers.mdx +7 -5
- package/.docs/raw/reference/agents/getTools.mdx +7 -5
- package/.docs/raw/reference/agents/getVoice.mdx +7 -5
- package/.docs/raw/reference/agents/getWorkflows.mdx +7 -5
- package/.docs/raw/reference/agents/listAgents.mdx +6 -4
- package/.docs/raw/reference/agents/network.mdx +171 -116
- package/.docs/raw/reference/auth/auth0.mdx +18 -14
- package/.docs/raw/reference/auth/clerk.mdx +15 -12
- package/.docs/raw/reference/auth/firebase.mdx +23 -16
- package/.docs/raw/reference/auth/jwt.mdx +7 -6
- package/.docs/raw/reference/auth/supabase.mdx +13 -10
- package/.docs/raw/reference/auth/workos.mdx +17 -13
- package/.docs/raw/reference/cli/create-mastra.mdx +61 -44
- package/.docs/raw/reference/cli/mastra.mdx +11 -11
- package/.docs/raw/reference/client-js/agents.mdx +40 -43
- package/.docs/raw/reference/client-js/error-handling.mdx +1 -1
- package/.docs/raw/reference/client-js/logs.mdx +1 -1
- package/.docs/raw/reference/client-js/mastra-client.mdx +21 -13
- package/.docs/raw/reference/client-js/memory.mdx +6 -2
- package/.docs/raw/reference/client-js/observability.mdx +10 -9
- package/.docs/raw/reference/client-js/telemetry.mdx +1 -1
- package/.docs/raw/reference/client-js/tools.mdx +1 -1
- package/.docs/raw/reference/client-js/vectors.mdx +1 -1
- package/.docs/raw/reference/client-js/workflows-legacy.mdx +1 -1
- package/.docs/raw/reference/client-js/workflows.mdx +7 -7
- package/.docs/raw/reference/core/getAgent.mdx +6 -5
- package/.docs/raw/reference/core/getAgentById.mdx +5 -4
- package/.docs/raw/reference/core/getAgents.mdx +3 -3
- package/.docs/raw/reference/core/getDeployer.mdx +4 -3
- package/.docs/raw/reference/core/getLogger.mdx +4 -3
- package/.docs/raw/reference/core/getLogs.mdx +10 -6
- package/.docs/raw/reference/core/getLogsByRunId.mdx +8 -5
- package/.docs/raw/reference/core/getMCPServer.mdx +8 -5
- package/.docs/raw/reference/core/getMCPServers.mdx +4 -3
- package/.docs/raw/reference/core/getMemory.mdx +4 -3
- package/.docs/raw/reference/core/getScorer.mdx +15 -12
- package/.docs/raw/reference/core/getScorerByName.mdx +12 -9
- package/.docs/raw/reference/core/getScorers.mdx +3 -2
- package/.docs/raw/reference/core/getServer.mdx +4 -3
- package/.docs/raw/reference/core/getStorage.mdx +4 -3
- package/.docs/raw/reference/core/getTelemetry.mdx +4 -3
- package/.docs/raw/reference/core/getVector.mdx +6 -4
- package/.docs/raw/reference/core/getVectors.mdx +4 -3
- package/.docs/raw/reference/core/getWorkflow.mdx +7 -4
- package/.docs/raw/reference/core/getWorkflows.mdx +5 -3
- package/.docs/raw/reference/core/mastra-class.mdx +16 -16
- package/.docs/raw/reference/core/setLogger.mdx +6 -4
- package/.docs/raw/reference/core/setStorage.mdx +4 -4
- package/.docs/raw/reference/core/setTelemetry.mdx +4 -3
- package/.docs/raw/reference/deployer/cloudflare.mdx +11 -7
- package/.docs/raw/reference/deployer/deployer.mdx +2 -1
- package/.docs/raw/reference/deployer/netlify.mdx +4 -4
- package/.docs/raw/reference/deployer/vercel.mdx +6 -6
- package/.docs/raw/reference/evals/answer-relevancy.mdx +4 -5
- package/.docs/raw/reference/evals/bias.mdx +4 -5
- package/.docs/raw/reference/evals/completeness.mdx +4 -5
- package/.docs/raw/reference/evals/content-similarity.mdx +4 -5
- package/.docs/raw/reference/evals/context-position.mdx +4 -5
- package/.docs/raw/reference/evals/context-precision.mdx +4 -5
- package/.docs/raw/reference/evals/context-relevancy.mdx +4 -5
- package/.docs/raw/reference/evals/contextual-recall.mdx +4 -5
- package/.docs/raw/reference/evals/faithfulness.mdx +4 -5
- package/.docs/raw/reference/evals/hallucination.mdx +4 -6
- package/.docs/raw/reference/evals/keyword-coverage.mdx +4 -5
- package/.docs/raw/reference/evals/prompt-alignment.mdx +4 -6
- package/.docs/raw/reference/evals/summarization.mdx +4 -6
- package/.docs/raw/reference/evals/textual-difference.mdx +4 -5
- package/.docs/raw/reference/evals/tone-consistency.mdx +4 -7
- package/.docs/raw/reference/evals/toxicity.mdx +4 -5
- package/.docs/raw/reference/index.mdx +3 -3
- package/.docs/raw/reference/legacyWorkflows/after.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/afterEvent.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/commit.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/createRun.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/else.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/events.mdx +7 -7
- package/.docs/raw/reference/legacyWorkflows/execute.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/if.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/resume.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/resumeWithEvent.mdx +6 -6
- package/.docs/raw/reference/legacyWorkflows/snapshots.mdx +6 -6
- package/.docs/raw/reference/legacyWorkflows/start.mdx +6 -6
- package/.docs/raw/reference/legacyWorkflows/step-class.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/step-condition.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/step-function.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/step-options.mdx +6 -6
- package/.docs/raw/reference/legacyWorkflows/step-retries.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/suspend.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/then.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/until.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/watch.mdx +3 -3
- package/.docs/raw/reference/legacyWorkflows/while.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/workflow.mdx +7 -7
- package/.docs/raw/reference/memory/createThread.mdx +10 -10
- package/.docs/raw/reference/memory/deleteMessages.mdx +7 -5
- package/.docs/raw/reference/memory/getThreadById.mdx +6 -5
- package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +11 -10
- package/.docs/raw/reference/memory/getThreadsByResourceIdPaginated.mdx +10 -9
- package/.docs/raw/reference/memory/{Memory.mdx → memory-class.mdx} +53 -46
- package/.docs/raw/reference/memory/query.mdx +39 -25
- package/.docs/raw/reference/observability/ai-tracing/ai-tracing.mdx +9 -5
- package/.docs/raw/reference/observability/ai-tracing/configuration.mdx +26 -22
- package/.docs/raw/reference/observability/ai-tracing/exporters/arize.mdx +16 -12
- package/.docs/raw/reference/observability/ai-tracing/exporters/braintrust.mdx +14 -14
- package/.docs/raw/reference/observability/ai-tracing/exporters/cloud-exporter.mdx +16 -11
- package/.docs/raw/reference/observability/ai-tracing/exporters/console-exporter.mdx +10 -6
- package/.docs/raw/reference/observability/ai-tracing/exporters/default-exporter.mdx +23 -15
- package/.docs/raw/reference/observability/ai-tracing/exporters/langfuse.mdx +6 -6
- package/.docs/raw/reference/observability/ai-tracing/exporters/langsmith.mdx +13 -13
- package/.docs/raw/reference/observability/ai-tracing/exporters/otel.mdx +44 -36
- package/.docs/raw/reference/observability/ai-tracing/interfaces.mdx +115 -106
- package/.docs/raw/reference/observability/ai-tracing/processors/sensitive-data-filter.mdx +37 -32
- package/.docs/raw/reference/observability/ai-tracing/span.mdx +29 -26
- package/.docs/raw/reference/observability/logging/pino-logger.mdx +13 -15
- package/.docs/raw/reference/observability/otel-tracing/otel-config.mdx +2 -2
- package/.docs/raw/reference/observability/otel-tracing/providers/arize-ax.mdx +3 -3
- package/.docs/raw/reference/observability/otel-tracing/providers/arize-phoenix.mdx +2 -1
- package/.docs/raw/reference/observability/otel-tracing/providers/dash0.mdx +1 -1
- package/.docs/raw/reference/observability/otel-tracing/providers/index.mdx +12 -14
- package/.docs/raw/reference/observability/otel-tracing/providers/keywordsai.mdx +3 -3
- package/.docs/raw/reference/observability/otel-tracing/providers/laminar.mdx +1 -1
- package/.docs/raw/reference/observability/otel-tracing/providers/langfuse.mdx +4 -4
- package/.docs/raw/reference/observability/otel-tracing/providers/langsmith.mdx +1 -1
- package/.docs/raw/reference/observability/otel-tracing/providers/langwatch.mdx +2 -2
- package/.docs/raw/reference/observability/otel-tracing/providers/new-relic.mdx +1 -1
- package/.docs/raw/reference/observability/otel-tracing/providers/signoz.mdx +1 -1
- package/.docs/raw/reference/observability/otel-tracing/providers/traceloop.mdx +1 -1
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +13 -10
- package/.docs/raw/reference/processors/language-detector.mdx +27 -17
- package/.docs/raw/reference/processors/moderation-processor.mdx +26 -17
- package/.docs/raw/reference/processors/pii-detector.mdx +28 -18
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +25 -17
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +26 -17
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +22 -15
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +13 -12
- package/.docs/raw/reference/rag/chunk.mdx +41 -23
- package/.docs/raw/reference/rag/database-config.mdx +56 -38
- package/.docs/raw/reference/rag/document.mdx +1 -1
- package/.docs/raw/reference/rag/embeddings.mdx +1 -1
- package/.docs/raw/reference/rag/extract-params.mdx +1 -1
- package/.docs/raw/reference/rag/graph-rag.mdx +1 -1
- package/.docs/raw/reference/rag/metadata-filters.mdx +23 -26
- package/.docs/raw/reference/rag/rerank.mdx +1 -1
- package/.docs/raw/reference/rag/rerankWithScorer.mdx +2 -2
- package/.docs/raw/reference/scorers/answer-relevancy.mdx +35 -17
- package/.docs/raw/reference/scorers/answer-similarity.mdx +84 -68
- package/.docs/raw/reference/scorers/bias.mdx +22 -19
- package/.docs/raw/reference/scorers/completeness.mdx +21 -16
- package/.docs/raw/reference/scorers/content-similarity.mdx +12 -10
- package/.docs/raw/reference/scorers/context-precision.mdx +73 -64
- package/.docs/raw/reference/scorers/context-relevance.mdx +142 -126
- package/.docs/raw/reference/scorers/create-scorer.mdx +93 -61
- package/.docs/raw/reference/scorers/faithfulness.mdx +21 -13
- package/.docs/raw/reference/scorers/hallucination.mdx +17 -12
- package/.docs/raw/reference/scorers/keyword-coverage.mdx +32 -27
- package/.docs/raw/reference/scorers/mastra-scorer.mdx +39 -33
- package/.docs/raw/reference/scorers/noise-sensitivity.mdx +203 -152
- package/.docs/raw/reference/scorers/prompt-alignment.mdx +186 -132
- package/.docs/raw/reference/scorers/run-experiment.mdx +40 -31
- package/.docs/raw/reference/scorers/textual-difference.mdx +25 -26
- package/.docs/raw/reference/scorers/tone-consistency.mdx +29 -26
- package/.docs/raw/reference/scorers/tool-call-accuracy.mdx +180 -176
- package/.docs/raw/reference/scorers/toxicity.mdx +35 -31
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +1 -1
- package/.docs/raw/reference/storage/cloudflare.mdx +1 -1
- package/.docs/raw/reference/storage/dynamodb.mdx +1 -1
- package/.docs/raw/reference/storage/lance.mdx +1 -1
- package/.docs/raw/reference/storage/libsql.mdx +2 -2
- package/.docs/raw/reference/storage/mongodb.mdx +4 -5
- package/.docs/raw/reference/storage/mssql.mdx +5 -4
- package/.docs/raw/reference/storage/postgresql.mdx +35 -33
- package/.docs/raw/reference/storage/upstash.mdx +6 -5
- package/.docs/raw/reference/streaming/ChunkType.mdx +788 -314
- package/.docs/raw/reference/streaming/agents/MastraModelOutput.mdx +265 -109
- package/.docs/raw/reference/streaming/agents/stream.mdx +375 -266
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +233 -162
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +4 -4
- package/.docs/raw/reference/streaming/workflows/observeStreamVNext.mdx +5 -5
- package/.docs/raw/reference/streaming/workflows/resumeStreamVNext.mdx +24 -20
- package/.docs/raw/reference/streaming/workflows/stream.mdx +35 -26
- package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +36 -27
- package/.docs/raw/reference/templates/overview.mdx +16 -39
- package/.docs/raw/reference/tools/client.mdx +1 -1
- package/.docs/raw/reference/tools/create-tool.mdx +45 -35
- package/.docs/raw/reference/tools/document-chunker-tool.mdx +2 -2
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +12 -12
- package/.docs/raw/reference/tools/mcp-client.mdx +70 -64
- package/.docs/raw/reference/tools/mcp-server.mdx +91 -78
- package/.docs/raw/reference/tools/vector-query-tool.mdx +48 -38
- package/.docs/raw/reference/vectors/astra.mdx +1 -1
- package/.docs/raw/reference/vectors/chroma.mdx +25 -19
- package/.docs/raw/reference/vectors/couchbase.mdx +4 -4
- package/.docs/raw/reference/vectors/lance.mdx +5 -6
- package/.docs/raw/reference/vectors/libsql.mdx +1 -1
- package/.docs/raw/reference/vectors/mongodb.mdx +1 -1
- package/.docs/raw/reference/vectors/opensearch.mdx +1 -1
- package/.docs/raw/reference/vectors/pg.mdx +8 -4
- package/.docs/raw/reference/vectors/pinecone.mdx +1 -1
- package/.docs/raw/reference/vectors/qdrant.mdx +1 -1
- package/.docs/raw/reference/vectors/s3vectors.mdx +35 -27
- package/.docs/raw/reference/vectors/turbopuffer.mdx +1 -1
- package/.docs/raw/reference/vectors/upstash.mdx +33 -25
- package/.docs/raw/reference/vectors/vectorize.mdx +1 -1
- package/.docs/raw/reference/voice/azure.mdx +1 -1
- package/.docs/raw/reference/voice/cloudflare.mdx +1 -1
- package/.docs/raw/reference/voice/composite-voice.mdx +1 -1
- package/.docs/raw/reference/voice/deepgram.mdx +1 -1
- package/.docs/raw/reference/voice/elevenlabs.mdx +1 -1
- package/.docs/raw/reference/voice/google-gemini-live.mdx +6 -4
- package/.docs/raw/reference/voice/google.mdx +1 -1
- package/.docs/raw/reference/voice/mastra-voice.mdx +1 -1
- package/.docs/raw/reference/voice/murf.mdx +1 -1
- package/.docs/raw/reference/voice/openai-realtime.mdx +1 -1
- package/.docs/raw/reference/voice/openai.mdx +1 -1
- package/.docs/raw/reference/voice/playai.mdx +1 -1
- package/.docs/raw/reference/voice/sarvam.mdx +1 -1
- package/.docs/raw/reference/voice/speechify.mdx +1 -1
- package/.docs/raw/reference/voice/voice.addInstructions.mdx +1 -1
- package/.docs/raw/reference/voice/voice.addTools.mdx +1 -1
- package/.docs/raw/reference/voice/voice.answer.mdx +1 -1
- package/.docs/raw/reference/voice/voice.close.mdx +1 -1
- package/.docs/raw/reference/voice/voice.connect.mdx +1 -1
- package/.docs/raw/reference/voice/voice.events.mdx +1 -1
- package/.docs/raw/reference/voice/voice.getSpeakers.mdx +23 -30
- package/.docs/raw/reference/voice/voice.listen.mdx +1 -1
- package/.docs/raw/reference/voice/voice.off.mdx +1 -1
- package/.docs/raw/reference/voice/voice.on.mdx +1 -1
- package/.docs/raw/reference/voice/voice.send.mdx +1 -1
- package/.docs/raw/reference/voice/voice.speak.mdx +1 -1
- package/.docs/raw/reference/voice/voice.updateConfig.mdx +1 -1
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +4 -3
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +49 -34
- package/.docs/raw/reference/workflows/run-methods/start.mdx +43 -31
- package/.docs/raw/reference/workflows/run-methods/watch.mdx +7 -8
- package/.docs/raw/reference/workflows/run.mdx +7 -10
- package/.docs/raw/reference/workflows/step.mdx +15 -12
- package/.docs/raw/reference/workflows/workflow-methods/branch.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/commit.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/create-run.mdx +7 -7
- package/.docs/raw/reference/workflows/workflow-methods/dountil.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/dowhile.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/map.mdx +3 -2
- package/.docs/raw/reference/workflows/workflow-methods/parallel.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/sendEvent.mdx +5 -5
- package/.docs/raw/reference/workflows/workflow-methods/sleep.mdx +3 -2
- package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +3 -2
- package/.docs/raw/reference/workflows/workflow-methods/then.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +3 -3
- package/.docs/raw/reference/workflows/workflow.mdx +13 -10
- package/.docs/raw/scorers/custom-scorers.mdx +58 -48
- package/.docs/raw/scorers/evals-old-api/custom-eval.mdx +6 -8
- package/.docs/raw/scorers/evals-old-api/overview.mdx +8 -8
- package/.docs/raw/scorers/evals-old-api/running-in-ci.mdx +9 -9
- package/.docs/raw/scorers/evals-old-api/textual-evals.mdx +5 -5
- package/.docs/raw/scorers/off-the-shelf-scorers.mdx +3 -1
- package/.docs/raw/scorers/overview.mdx +20 -19
- package/.docs/raw/server-db/custom-api-routes.mdx +8 -8
- package/.docs/raw/server-db/mastra-client.mdx +56 -54
- package/.docs/raw/server-db/middleware.mdx +11 -7
- package/.docs/raw/server-db/production-server.mdx +5 -7
- package/.docs/raw/server-db/runtime-context.mdx +41 -38
- package/.docs/raw/server-db/storage.mdx +82 -87
- package/.docs/raw/streaming/events.mdx +24 -16
- package/.docs/raw/streaming/overview.mdx +17 -18
- package/.docs/raw/streaming/tool-streaming.mdx +9 -10
- package/.docs/raw/streaming/workflow-streaming.mdx +14 -12
- package/.docs/raw/tools-mcp/advanced-usage.mdx +2 -2
- package/.docs/raw/tools-mcp/mcp-overview.mdx +92 -102
- package/.docs/raw/tools-mcp/overview.mdx +9 -14
- package/.docs/raw/voice/overview.mdx +273 -250
- package/.docs/raw/voice/speech-to-speech.mdx +14 -12
- package/.docs/raw/voice/speech-to-text.mdx +2 -2
- package/.docs/raw/voice/text-to-speech.mdx +2 -2
- package/.docs/raw/workflows/agents-and-tools.mdx +29 -28
- package/.docs/raw/workflows/control-flow.mdx +24 -24
- package/.docs/raw/workflows/error-handling.mdx +15 -17
- package/.docs/raw/workflows/human-in-the-loop.mdx +39 -39
- package/.docs/raw/workflows/inngest-workflow.mdx +33 -29
- package/.docs/raw/workflows/input-data-mapping.mdx +9 -9
- package/.docs/raw/workflows/overview.mdx +60 -60
- package/.docs/raw/workflows/snapshots.mdx +54 -36
- package/.docs/raw/workflows/suspend-and-resume.mdx +52 -57
- package/.docs/raw/workflows-legacy/control-flow.mdx +15 -17
- package/.docs/raw/workflows-legacy/dynamic-workflows.mdx +3 -1
- package/.docs/raw/workflows-legacy/error-handling.mdx +8 -6
- package/.docs/raw/workflows-legacy/nested-workflows.mdx +6 -0
- package/.docs/raw/workflows-legacy/overview.mdx +28 -26
- package/.docs/raw/workflows-legacy/runtime-variables.mdx +4 -2
- package/.docs/raw/workflows-legacy/steps.mdx +5 -3
- package/.docs/raw/workflows-legacy/suspend-and-resume.mdx +10 -8
- package/.docs/raw/workflows-legacy/variables.mdx +10 -8
- package/CHANGELOG.md +14 -0
- package/package.json +5 -5
- package/.docs/raw/memory/storage/memory-with-mongodb.mdx +0 -148
package/.docs/raw/auth/auth0.mdx
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "MastraAuthAuth0 Class"
|
|
2
|
+
title: "MastraAuthAuth0 Class | Auth | Mastra Docs"
|
|
3
3
|
description: "Documentation for the MastraAuthAuth0 class, which authenticates Mastra applications using Auth0 authentication."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import Tabs from "@theme/Tabs";
|
|
7
|
+
import TabItem from "@theme/TabItem";
|
|
7
8
|
|
|
8
9
|
# MastraAuthAuth0 Class
|
|
9
10
|
|
|
@@ -18,7 +19,7 @@ This example uses Auth0 authentication. Make sure to:
|
|
|
18
19
|
3. Configure an API in your Auth0 Dashboard with an identifier (audience)
|
|
19
20
|
4. Configure your application's allowed callback URLs, web origins, and logout URLs
|
|
20
21
|
|
|
21
|
-
```env
|
|
22
|
+
```env title=".env" copy
|
|
22
23
|
AUTH0_DOMAIN=your-tenant.auth0.com
|
|
23
24
|
AUTH0_AUDIENCE=your-api-identifier
|
|
24
25
|
```
|
|
@@ -39,9 +40,9 @@ npm install @mastra/auth-auth0@latest
|
|
|
39
40
|
|
|
40
41
|
### Basic usage with environment variables
|
|
41
42
|
|
|
42
|
-
```typescript {2,7}
|
|
43
|
+
```typescript {2,7} title="src/mastra/index.ts" showLineNumbers copy
|
|
43
44
|
import { Mastra } from "@mastra/core/mastra";
|
|
44
|
-
import { MastraAuthAuth0 } from
|
|
45
|
+
import { MastraAuthAuth0 } from "@mastra/auth-auth0";
|
|
45
46
|
|
|
46
47
|
export const mastra = new Mastra({
|
|
47
48
|
// ..
|
|
@@ -53,16 +54,16 @@ export const mastra = new Mastra({
|
|
|
53
54
|
|
|
54
55
|
### Custom configuration
|
|
55
56
|
|
|
56
|
-
```typescript {2,7-10}
|
|
57
|
+
```typescript {2,7-10} title="src/mastra/index.ts" showLineNumbers copy
|
|
57
58
|
import { Mastra } from "@mastra/core/mastra";
|
|
58
|
-
import { MastraAuthAuth0 } from
|
|
59
|
+
import { MastraAuthAuth0 } from "@mastra/auth-auth0";
|
|
59
60
|
|
|
60
61
|
export const mastra = new Mastra({
|
|
61
62
|
// ..
|
|
62
63
|
server: {
|
|
63
64
|
experimental_auth: new MastraAuthAuth0({
|
|
64
65
|
domain: process.env.AUTH0_DOMAIN,
|
|
65
|
-
audience: process.env.AUTH0_AUDIENCE
|
|
66
|
+
audience: process.env.AUTH0_AUDIENCE,
|
|
66
67
|
}),
|
|
67
68
|
},
|
|
68
69
|
});
|
|
@@ -81,18 +82,18 @@ By default, `MastraAuthAuth0` allows all authenticated users who have valid Auth
|
|
|
81
82
|
|
|
82
83
|
To customize user authorization, provide a custom `authorizeUser` function:
|
|
83
84
|
|
|
84
|
-
```typescript
|
|
85
|
-
import { MastraAuthAuth0 } from
|
|
85
|
+
```typescript title="src/mastra/auth.ts" showLineNumbers copy
|
|
86
|
+
import { MastraAuthAuth0 } from "@mastra/auth-auth0";
|
|
86
87
|
|
|
87
88
|
const auth0Provider = new MastraAuthAuth0({
|
|
88
89
|
authorizeUser: async (user) => {
|
|
89
90
|
// Custom authorization logic
|
|
90
|
-
return user.email?.endsWith(
|
|
91
|
-
}
|
|
91
|
+
return user.email?.endsWith("@yourcompany.com") || false;
|
|
92
|
+
},
|
|
92
93
|
});
|
|
93
94
|
```
|
|
94
95
|
|
|
95
|
-
> See the [MastraAuthAuth0](/reference/auth/auth0
|
|
96
|
+
> See the [MastraAuthAuth0](/reference/auth/auth0) API reference for all available configuration options.
|
|
96
97
|
|
|
97
98
|
## Client-side setup
|
|
98
99
|
|
|
@@ -106,7 +107,7 @@ First, install and configure the Auth0 React SDK in your application:
|
|
|
106
107
|
npm install @auth0/auth0-react
|
|
107
108
|
```
|
|
108
109
|
|
|
109
|
-
```typescript
|
|
110
|
+
```typescript title="src/auth0-provider.tsx" showLineNumbers copy
|
|
110
111
|
import React from 'react';
|
|
111
112
|
import { Auth0Provider } from '@auth0/auth0-react';
|
|
112
113
|
|
|
@@ -133,8 +134,8 @@ export default Auth0ProviderWithHistory;
|
|
|
133
134
|
|
|
134
135
|
Use the Auth0 React SDK to authenticate users and retrieve their access tokens:
|
|
135
136
|
|
|
136
|
-
```typescript
|
|
137
|
-
import { useAuth0 } from
|
|
137
|
+
```typescript title="lib/auth.ts" showLineNumbers copy
|
|
138
|
+
import { useAuth0 } from "@auth0/auth0-react";
|
|
138
139
|
|
|
139
140
|
export const useAuth0Token = () => {
|
|
140
141
|
const { getAccessTokenSilently } = useAuth0();
|
|
@@ -154,30 +155,30 @@ export const useAuth0Token = () => {
|
|
|
154
155
|
|
|
155
156
|
When `experimental_auth` is enabled, all requests made with `MastraClient` must include a valid Auth0 access token in the `Authorization` header:
|
|
156
157
|
|
|
157
|
-
```typescript
|
|
158
|
+
```typescript title="lib/mastra/mastra-client.ts" showLineNumbers copy
|
|
158
159
|
import { MastraClient } from "@mastra/client-js";
|
|
159
160
|
|
|
160
161
|
export const createMastraClient = (accessToken: string) => {
|
|
161
162
|
return new MastraClient({
|
|
162
163
|
baseUrl: "https://<mastra-api-url>",
|
|
163
164
|
headers: {
|
|
164
|
-
Authorization: `Bearer ${accessToken}
|
|
165
|
-
}
|
|
165
|
+
Authorization: `Bearer ${accessToken}`,
|
|
166
|
+
},
|
|
166
167
|
});
|
|
167
168
|
};
|
|
168
169
|
```
|
|
169
170
|
|
|
170
171
|
> **Note:** The access token must be prefixed with `Bearer` in the Authorization header.
|
|
171
172
|
|
|
172
|
-
> See [Mastra Client SDK](/docs/server-db/mastra-client
|
|
173
|
+
> See [Mastra Client SDK](/docs/server-db/mastra-client) for more configuration options.
|
|
173
174
|
|
|
174
175
|
### Making authenticated requests
|
|
175
176
|
|
|
176
177
|
Once `MastraClient` is configured with the Auth0 access token, you can send authenticated requests:
|
|
177
178
|
|
|
178
|
-
<Tabs
|
|
179
|
-
<
|
|
180
|
-
```tsx
|
|
179
|
+
<Tabs>
|
|
180
|
+
<TabItem value="react" label="React">
|
|
181
|
+
```tsx title="src/components/mastra-api-test.tsx" showLineNumbers copy
|
|
181
182
|
import React, { useState } from 'react';
|
|
182
183
|
import { useAuth0 } from '@auth0/auth0-react';
|
|
183
184
|
import { MastraClient } from '@mastra/client-js';
|
|
@@ -220,8 +221,9 @@ Once `MastraClient` is configured with the Auth0 access token, you can send auth
|
|
|
220
221
|
);
|
|
221
222
|
};
|
|
222
223
|
```
|
|
223
|
-
|
|
224
|
-
|
|
224
|
+
|
|
225
|
+
</TabItem>
|
|
226
|
+
<TabItem value="curl" label="cURL">
|
|
225
227
|
```bash copy
|
|
226
228
|
curl -X POST http://localhost:4111/api/agents/weatherAgent/generate \
|
|
227
229
|
-H "Content-Type: application/json" \
|
|
@@ -230,6 +232,5 @@ Once `MastraClient` is configured with the Auth0 access token, you can send auth
|
|
|
230
232
|
"messages": "Weather in London"
|
|
231
233
|
}'
|
|
232
234
|
```
|
|
233
|
-
</
|
|
235
|
+
</TabItem>
|
|
234
236
|
</Tabs>
|
|
235
|
-
|
package/.docs/raw/auth/clerk.mdx
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "MastraAuthClerk Class"
|
|
2
|
+
title: "MastraAuthClerk Class | Auth | Mastra Docs"
|
|
3
3
|
description: "Documentation for the MastraAuthClerk class, which authenticates Mastra applications using Clerk authentication."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import Tabs from "@theme/Tabs";
|
|
7
|
+
import TabItem from "@theme/TabItem";
|
|
7
8
|
|
|
8
9
|
# MastraAuthClerk Class
|
|
9
10
|
|
|
@@ -13,7 +14,7 @@ The `MastraAuthClerk` class provides authentication for Mastra using Clerk. It v
|
|
|
13
14
|
|
|
14
15
|
This example uses Clerk authentication. Make sure to add your Clerk credentials to your `.env` file and ensure your Clerk project is properly configured.
|
|
15
16
|
|
|
16
|
-
```env
|
|
17
|
+
```env title=".env" copy
|
|
17
18
|
CLERK_PUBLISHABLE_KEY=pk_test_...
|
|
18
19
|
CLERK_SECRET_KEY=sk_test_...
|
|
19
20
|
CLERK_JWKS_URI=https://your-clerk-domain.clerk.accounts.dev/.well-known/jwks.json
|
|
@@ -31,9 +32,9 @@ npm install @mastra/auth-clerk@latest
|
|
|
31
32
|
|
|
32
33
|
## Usage example
|
|
33
34
|
|
|
34
|
-
```typescript {2,7-11}
|
|
35
|
+
```typescript {2,7-11} title="src/mastra/index.ts" showLineNumbers copy
|
|
35
36
|
import { Mastra } from "@mastra/core/mastra";
|
|
36
|
-
import { MastraAuthClerk } from
|
|
37
|
+
import { MastraAuthClerk } from "@mastra/auth-clerk";
|
|
37
38
|
|
|
38
39
|
export const mastra = new Mastra({
|
|
39
40
|
// ..
|
|
@@ -41,7 +42,7 @@ export const mastra = new Mastra({
|
|
|
41
42
|
experimental_auth: new MastraAuthClerk({
|
|
42
43
|
publishableKey: process.env.CLERK_PUBLISHABLE_KEY,
|
|
43
44
|
secretKey: process.env.CLERK_SECRET_KEY,
|
|
44
|
-
jwksUri: process.env.CLERK_JWKS_URI
|
|
45
|
+
jwksUri: process.env.CLERK_JWKS_URI,
|
|
45
46
|
}),
|
|
46
47
|
},
|
|
47
48
|
});
|
|
@@ -49,7 +50,7 @@ export const mastra = new Mastra({
|
|
|
49
50
|
|
|
50
51
|
> **Note:** The default `authorizeUser` method allows all authenticated users. To customize user authorization, provide a custom `authorizeUser` function when constructing the provider.
|
|
51
52
|
|
|
52
|
-
> See the [MastraAuthClerk](/reference/auth/clerk
|
|
53
|
+
> See the [MastraAuthClerk](/reference/auth/clerk) API reference for all available configuration options.
|
|
53
54
|
|
|
54
55
|
## Client-side setup
|
|
55
56
|
|
|
@@ -59,17 +60,17 @@ When using Clerk auth, you'll need to retrieve the access token from Clerk on th
|
|
|
59
60
|
|
|
60
61
|
Use the Clerk React hooks to authenticate users and retrieve their access token:
|
|
61
62
|
|
|
62
|
-
```typescript
|
|
63
|
+
```typescript title="lib/auth.ts" showLineNumbers copy
|
|
63
64
|
import { useAuth } from "@clerk/nextjs";
|
|
64
65
|
|
|
65
66
|
export const useClerkAuth = () => {
|
|
66
67
|
const { getToken } = useAuth();
|
|
67
|
-
|
|
68
|
+
|
|
68
69
|
const getAccessToken = async () => {
|
|
69
70
|
const token = await getToken();
|
|
70
71
|
return token;
|
|
71
72
|
};
|
|
72
|
-
|
|
73
|
+
|
|
73
74
|
return { getAccessToken };
|
|
74
75
|
};
|
|
75
76
|
```
|
|
@@ -80,27 +81,27 @@ export const useClerkAuth = () => {
|
|
|
80
81
|
|
|
81
82
|
When `experimental_auth` is enabled, all requests made with `MastraClient` must include a valid Clerk access token in the `Authorization` header:
|
|
82
83
|
|
|
83
|
-
```typescript {6}
|
|
84
|
+
```typescript {6} title="lib/mastra/mastra-client.ts" showLineNumbers copy
|
|
84
85
|
import { MastraClient } from "@mastra/client-js";
|
|
85
86
|
|
|
86
87
|
export const mastraClient = new MastraClient({
|
|
87
88
|
baseUrl: "https://<mastra-api-url>",
|
|
88
89
|
headers: {
|
|
89
|
-
Authorization: `Bearer ${accessToken}
|
|
90
|
-
}
|
|
90
|
+
Authorization: `Bearer ${accessToken}`,
|
|
91
|
+
},
|
|
91
92
|
});
|
|
92
93
|
```
|
|
93
94
|
|
|
94
95
|
> **Note:** The access token must be prefixed with `Bearer` in the Authorization header.
|
|
95
|
-
> See [Mastra Client SDK](/docs/server-db/mastra-client
|
|
96
|
+
> See [Mastra Client SDK](/docs/server-db/mastra-client) for more configuration options.
|
|
96
97
|
|
|
97
98
|
### Making authenticated requests
|
|
98
99
|
|
|
99
100
|
Once `MastraClient` is configured with the Clerk access token, you can send authenticated requests:
|
|
100
101
|
|
|
101
|
-
<Tabs
|
|
102
|
-
<
|
|
103
|
-
```tsx
|
|
102
|
+
<Tabs>
|
|
103
|
+
<TabItem value="react" label="React">
|
|
104
|
+
```tsx title="src/components/test-agent.tsx" showLineNumbers copy
|
|
104
105
|
"use client";
|
|
105
106
|
|
|
106
107
|
import { useAuth } from "@clerk/nextjs";
|
|
@@ -128,8 +129,9 @@ Once `MastraClient` is configured with the Clerk access token, you can send auth
|
|
|
128
129
|
return <button onClick={handleClick}>Test Agent</button>;
|
|
129
130
|
};
|
|
130
131
|
```
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
|
|
133
|
+
</TabItem>
|
|
134
|
+
<TabItem value="curl" label="cURL">
|
|
133
135
|
```bash copy
|
|
134
136
|
curl -X POST http://localhost:4111/api/agents/weatherAgent/generate \
|
|
135
137
|
-H "Content-Type: application/json" \
|
|
@@ -138,5 +140,5 @@ Once `MastraClient` is configured with the Clerk access token, you can send auth
|
|
|
138
140
|
"messages": "Weather in London"
|
|
139
141
|
}'
|
|
140
142
|
```
|
|
141
|
-
</
|
|
143
|
+
</TabItem>
|
|
142
144
|
</Tabs>
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "MastraAuthFirebase Class"
|
|
2
|
+
title: "MastraAuthFirebase Class | Auth | Mastra Docs"
|
|
3
3
|
description: "Documentation for the MastraAuthFirebase class, which authenticates Mastra applications using Firebase Authentication."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import Tabs from "@theme/Tabs";
|
|
7
|
+
import TabItem from "@theme/TabItem";
|
|
7
8
|
|
|
8
9
|
# MastraAuthFirebase Class
|
|
9
10
|
|
|
@@ -18,7 +19,7 @@ This example uses Firebase Authentication. Make sure to:
|
|
|
18
19
|
3. Generate a service account key from Project Settings > Service Accounts
|
|
19
20
|
4. Download the service account JSON file
|
|
20
21
|
|
|
21
|
-
```env
|
|
22
|
+
```env title=".env" copy
|
|
22
23
|
FIREBASE_SERVICE_ACCOUNT=/path/to/your/service-account-key.json
|
|
23
24
|
FIRESTORE_DATABASE_ID=(default)
|
|
24
25
|
# Alternative environment variable names:
|
|
@@ -41,9 +42,9 @@ npm install @mastra/auth-firebase@latest
|
|
|
41
42
|
|
|
42
43
|
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:
|
|
43
44
|
|
|
44
|
-
```typescript {2,7}
|
|
45
|
+
```typescript {2,7} title="src/mastra/index.ts" showLineNumbers copy
|
|
45
46
|
import { Mastra } from "@mastra/core/mastra";
|
|
46
|
-
import { MastraAuthFirebase } from
|
|
47
|
+
import { MastraAuthFirebase } from "@mastra/auth-firebase";
|
|
47
48
|
|
|
48
49
|
// Automatically uses FIREBASE_SERVICE_ACCOUNT and FIRESTORE_DATABASE_ID env vars
|
|
49
50
|
export const mastra = new Mastra({
|
|
@@ -56,16 +57,16 @@ export const mastra = new Mastra({
|
|
|
56
57
|
|
|
57
58
|
### Custom configuration
|
|
58
59
|
|
|
59
|
-
```typescript {2,7-10}
|
|
60
|
+
```typescript {2,7-10} title="src/mastra/index.ts" showLineNumbers copy
|
|
60
61
|
import { Mastra } from "@mastra/core/mastra";
|
|
61
|
-
import { MastraAuthFirebase } from
|
|
62
|
+
import { MastraAuthFirebase } from "@mastra/auth-firebase";
|
|
62
63
|
|
|
63
64
|
export const mastra = new Mastra({
|
|
64
65
|
// ..
|
|
65
66
|
server: {
|
|
66
67
|
experimental_auth: new MastraAuthFirebase({
|
|
67
|
-
serviceAccount:
|
|
68
|
-
databaseId:
|
|
68
|
+
serviceAccount: "/path/to/service-account.json",
|
|
69
|
+
databaseId: "your-database-id",
|
|
69
70
|
}),
|
|
70
71
|
},
|
|
71
72
|
});
|
|
@@ -86,7 +87,7 @@ The `MastraAuthFirebase` class can be configured through constructor options or
|
|
|
86
87
|
|
|
87
88
|
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.
|
|
88
89
|
|
|
89
|
-
```typescript
|
|
90
|
+
```typescript title="firestore-structure.txt" copy
|
|
90
91
|
user_access/
|
|
91
92
|
{user_uid_1}/ // Document exists = user authorized
|
|
92
93
|
{user_uid_2}/ // Document exists = user authorized
|
|
@@ -94,18 +95,18 @@ user_access/
|
|
|
94
95
|
|
|
95
96
|
To customize user authorization, provide a custom `authorizeUser` function:
|
|
96
97
|
|
|
97
|
-
```typescript
|
|
98
|
-
import { MastraAuthFirebase } from
|
|
98
|
+
```typescript title="src/mastra/auth.ts" showLineNumbers copy
|
|
99
|
+
import { MastraAuthFirebase } from "@mastra/auth-firebase";
|
|
99
100
|
|
|
100
101
|
const firebaseAuth = new MastraAuthFirebase({
|
|
101
102
|
authorizeUser: async (user) => {
|
|
102
103
|
// Custom authorization logic
|
|
103
|
-
return user.email?.endsWith(
|
|
104
|
-
}
|
|
104
|
+
return user.email?.endsWith("@yourcompany.com") || false;
|
|
105
|
+
},
|
|
105
106
|
});
|
|
106
107
|
```
|
|
107
108
|
|
|
108
|
-
> See the [MastraAuthFirebase](/reference/auth/firebase
|
|
109
|
+
> See the [MastraAuthFirebase](/reference/auth/firebase) API reference for all available configuration options.
|
|
109
110
|
|
|
110
111
|
## Client-side setup
|
|
111
112
|
|
|
@@ -115,9 +116,9 @@ When using Firebase auth, you'll need to initialize Firebase on the client side,
|
|
|
115
116
|
|
|
116
117
|
First, initialize Firebase in your client application:
|
|
117
118
|
|
|
118
|
-
```typescript
|
|
119
|
-
import { initializeApp } from
|
|
120
|
-
import { getAuth, GoogleAuthProvider } from
|
|
119
|
+
```typescript title="lib/firebase.ts" showLineNumbers copy
|
|
120
|
+
import { initializeApp } from "firebase/app";
|
|
121
|
+
import { getAuth, GoogleAuthProvider } from "firebase/auth";
|
|
121
122
|
|
|
122
123
|
const firebaseConfig = {
|
|
123
124
|
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
|
|
@@ -134,16 +135,16 @@ export const googleProvider = new GoogleAuthProvider();
|
|
|
134
135
|
|
|
135
136
|
Use Firebase authentication to sign in users and retrieve their ID tokens:
|
|
136
137
|
|
|
137
|
-
```typescript
|
|
138
|
-
import { signInWithPopup, signOut, User } from
|
|
139
|
-
import { auth, googleProvider } from
|
|
138
|
+
```typescript title="lib/auth.ts" showLineNumbers copy
|
|
139
|
+
import { signInWithPopup, signOut, User } from "firebase/auth";
|
|
140
|
+
import { auth, googleProvider } from "./firebase";
|
|
140
141
|
|
|
141
142
|
export const signInWithGoogle = async () => {
|
|
142
143
|
try {
|
|
143
144
|
const result = await signInWithPopup(auth, googleProvider);
|
|
144
145
|
return result.user;
|
|
145
146
|
} catch (error) {
|
|
146
|
-
console.error(
|
|
147
|
+
console.error("Error signing in:", error);
|
|
147
148
|
throw error;
|
|
148
149
|
}
|
|
149
150
|
};
|
|
@@ -153,7 +154,7 @@ export const getIdToken = async (user: User) => {
|
|
|
153
154
|
const idToken = await user.getIdToken();
|
|
154
155
|
return idToken;
|
|
155
156
|
} catch (error) {
|
|
156
|
-
console.error(
|
|
157
|
+
console.error("Error getting ID token:", error);
|
|
157
158
|
throw error;
|
|
158
159
|
}
|
|
159
160
|
};
|
|
@@ -162,7 +163,7 @@ export const signOutUser = async () => {
|
|
|
162
163
|
try {
|
|
163
164
|
await signOut(auth);
|
|
164
165
|
} catch (error) {
|
|
165
|
-
console.error(
|
|
166
|
+
console.error("Error signing out:", error);
|
|
166
167
|
throw error;
|
|
167
168
|
}
|
|
168
169
|
};
|
|
@@ -174,30 +175,30 @@ export const signOutUser = async () => {
|
|
|
174
175
|
|
|
175
176
|
When `experimental_auth` is enabled, all requests made with `MastraClient` must include a valid Firebase ID token in the `Authorization` header:
|
|
176
177
|
|
|
177
|
-
```typescript {6}
|
|
178
|
+
```typescript {6} title="lib/mastra/mastra-client.ts" showLineNumbers copy
|
|
178
179
|
import { MastraClient } from "@mastra/client-js";
|
|
179
180
|
|
|
180
181
|
export const createMastraClient = (idToken: string) => {
|
|
181
182
|
return new MastraClient({
|
|
182
183
|
baseUrl: "https://<mastra-api-url>",
|
|
183
184
|
headers: {
|
|
184
|
-
Authorization: `Bearer ${idToken}
|
|
185
|
-
}
|
|
185
|
+
Authorization: `Bearer ${idToken}`,
|
|
186
|
+
},
|
|
186
187
|
});
|
|
187
188
|
};
|
|
188
189
|
```
|
|
189
190
|
|
|
190
191
|
> **Note:** The ID token must be prefixed with `Bearer` in the Authorization header.
|
|
191
192
|
|
|
192
|
-
> See [Mastra Client SDK](/docs/server-db/mastra-client
|
|
193
|
+
> See [Mastra Client SDK](/docs/server-db/mastra-client) for more configuration options.
|
|
193
194
|
|
|
194
195
|
### Making authenticated requests
|
|
195
196
|
|
|
196
197
|
Once `MastraClient` is configured with the Firebase ID token, you can send authenticated requests:
|
|
197
198
|
|
|
198
|
-
<Tabs
|
|
199
|
-
<
|
|
200
|
-
```tsx
|
|
199
|
+
<Tabs>
|
|
200
|
+
<TabItem value="react" label="React">
|
|
201
|
+
```tsx title="src/components/test-agent.tsx" showLineNumbers copy
|
|
201
202
|
"use client";
|
|
202
203
|
|
|
203
204
|
import { useAuthState } from 'react-firebase-hooks/auth';
|
|
@@ -229,9 +230,10 @@ Once `MastraClient` is configured with the Firebase ID token, you can send authe
|
|
|
229
230
|
);
|
|
230
231
|
};
|
|
231
232
|
```
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
|
|
234
|
+
</TabItem>
|
|
235
|
+
<TabItem value="nodejs" label="Node.js">
|
|
236
|
+
```typescript title="server.js" showLineNumbers copy
|
|
235
237
|
const express = require('express');
|
|
236
238
|
const admin = require('firebase-admin');
|
|
237
239
|
const { MastraClient } = require('@mastra/client-js');
|
|
@@ -249,7 +251,7 @@ Once `MastraClient` is configured with the Firebase ID token, you can send authe
|
|
|
249
251
|
app.post('/generate', async (req, res) => {
|
|
250
252
|
try {
|
|
251
253
|
const { idToken } = req.body;
|
|
252
|
-
|
|
254
|
+
|
|
253
255
|
// Verify the token
|
|
254
256
|
await admin.auth().verifyIdToken(idToken);
|
|
255
257
|
|
|
@@ -271,8 +273,9 @@ Once `MastraClient` is configured with the Firebase ID token, you can send authe
|
|
|
271
273
|
}
|
|
272
274
|
});
|
|
273
275
|
```
|
|
274
|
-
|
|
275
|
-
|
|
276
|
+
|
|
277
|
+
</TabItem>
|
|
278
|
+
<TabItem value="curl" label="cURL">
|
|
276
279
|
```bash copy
|
|
277
280
|
curl -X POST http://localhost:4111/api/agents/weatherAgent/generate \
|
|
278
281
|
-H "Content-Type: application/json" \
|
|
@@ -281,5 +284,5 @@ Once `MastraClient` is configured with the Firebase ID token, you can send authe
|
|
|
281
284
|
"messages": "Weather in London"
|
|
282
285
|
}'
|
|
283
286
|
```
|
|
284
|
-
</
|
|
285
|
-
</Tabs>
|
|
287
|
+
</TabItem>
|
|
288
|
+
</Tabs>
|
package/.docs/raw/auth/index.mdx
CHANGED
package/.docs/raw/auth/jwt.mdx
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "MastraJwtAuth Class"
|
|
2
|
+
title: "MastraJwtAuth Class | Auth | Mastra Docs"
|
|
3
3
|
description: "Documentation for the MastraJwtAuth class, which authenticates Mastra applications using JSON Web Tokens."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import Tabs from "@theme/Tabs";
|
|
7
|
+
import TabItem from "@theme/TabItem";
|
|
7
8
|
|
|
8
9
|
# MastraJwtAuth Class
|
|
9
10
|
|
|
@@ -19,46 +20,46 @@ npm install @mastra/auth@latest
|
|
|
19
20
|
|
|
20
21
|
## Usage example
|
|
21
22
|
|
|
22
|
-
```typescript {2,7-9}
|
|
23
|
+
```typescript {2,7-9} title="src/mastra/index.ts" showLineNumbers copy
|
|
23
24
|
import { Mastra } from "@mastra/core/mastra";
|
|
24
|
-
import { MastraJwtAuth } from
|
|
25
|
+
import { MastraJwtAuth } from "@mastra/auth";
|
|
25
26
|
|
|
26
27
|
export const mastra = new Mastra({
|
|
27
28
|
// ..
|
|
28
29
|
server: {
|
|
29
30
|
experimental_auth: new MastraJwtAuth({
|
|
30
|
-
|
|
31
|
+
secret: process.env.MASTRA_JWT_SECRET,
|
|
31
32
|
}),
|
|
32
33
|
},
|
|
33
34
|
});
|
|
34
35
|
```
|
|
35
36
|
|
|
36
|
-
> See the [MastraJwtAuth](/reference/auth/jwt
|
|
37
|
+
> See the [MastraJwtAuth](/reference/auth/jwt) API reference for all available configuration options.
|
|
37
38
|
|
|
38
39
|
## Configuring `MastraClient`
|
|
39
40
|
|
|
40
41
|
When `experimental_auth` is enabled, all requests made with `MastraClient` must include a valid JWT in the `Authorization` header:
|
|
41
42
|
|
|
42
|
-
```typescript {6}
|
|
43
|
+
```typescript {6} title="lib/mastra/mastra-client.ts" showLineNumbers copy
|
|
43
44
|
import { MastraClient } from "@mastra/client-js";
|
|
44
45
|
|
|
45
46
|
export const mastraClient = new MastraClient({
|
|
46
47
|
baseUrl: "https://<mastra-api-url>",
|
|
47
48
|
headers: {
|
|
48
|
-
Authorization: `Bearer ${process.env.MASTRA_JWT_TOKEN}
|
|
49
|
-
}
|
|
49
|
+
Authorization: `Bearer ${process.env.MASTRA_JWT_TOKEN}`,
|
|
50
|
+
},
|
|
50
51
|
});
|
|
51
52
|
```
|
|
52
53
|
|
|
53
|
-
> See [Mastra Client SDK](/docs/server-db/mastra-client
|
|
54
|
+
> See [Mastra Client SDK](/docs/server-db/mastra-client) for more configuration options.
|
|
54
55
|
|
|
55
56
|
### Making authenticated requests
|
|
56
57
|
|
|
57
58
|
Once `MastraClient` is configured, you can send authenticated requests from your frontend application, or use `curl` for quick local testing:
|
|
58
59
|
|
|
59
|
-
<Tabs
|
|
60
|
-
<
|
|
61
|
-
```tsx
|
|
60
|
+
<Tabs>
|
|
61
|
+
<TabItem value="curl" label="cURL">
|
|
62
|
+
```tsx title="src/components/test-agent.tsx" showLineNumbers copy
|
|
62
63
|
import { mastraClient } from "../../lib/mastra-client";
|
|
63
64
|
|
|
64
65
|
export const TestAgent = () => {
|
|
@@ -75,8 +76,9 @@ Once `MastraClient` is configured, you can send authenticated requests from your
|
|
|
75
76
|
return <button onClick={handleClick}>Test Agent</button>;
|
|
76
77
|
};
|
|
77
78
|
```
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
|
|
80
|
+
</TabItem>
|
|
81
|
+
<TabItem value="react" label="React">
|
|
80
82
|
```bash copy
|
|
81
83
|
curl -X POST http://localhost:4111/api/agents/weatherAgent/generate \
|
|
82
84
|
-H "Content-Type: application/json" \
|
|
@@ -85,7 +87,7 @@ Once `MastraClient` is configured, you can send authenticated requests from your
|
|
|
85
87
|
"messages": "Weather in London"
|
|
86
88
|
}'
|
|
87
89
|
```
|
|
88
|
-
</
|
|
90
|
+
</TabItem>
|
|
89
91
|
</Tabs>
|
|
90
92
|
|
|
91
93
|
## Creating a JWT
|