@mastra/mcp-docs-server 1.1.4 → 1.1.5-alpha.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/CHANGELOG.md +7 -0
- package/package.json +3 -3
- package/.docs/docs/agents/adding-voice.md +0 -353
- package/.docs/docs/agents/agent-approval.md +0 -377
- package/.docs/docs/agents/agent-memory.md +0 -212
- package/.docs/docs/agents/guardrails.md +0 -382
- package/.docs/docs/agents/network-approval.md +0 -275
- package/.docs/docs/agents/networks.md +0 -290
- package/.docs/docs/agents/overview.md +0 -309
- package/.docs/docs/agents/processors.md +0 -632
- package/.docs/docs/agents/structured-output.md +0 -271
- package/.docs/docs/agents/using-tools.md +0 -214
- package/.docs/docs/build-with-ai/mcp-docs-server.md +0 -241
- package/.docs/docs/build-with-ai/skills.md +0 -35
- package/.docs/docs/community/contributing-templates.md +0 -3
- package/.docs/docs/community/discord.md +0 -9
- package/.docs/docs/community/licensing.md +0 -66
- package/.docs/docs/deployment/cloud-providers.md +0 -15
- package/.docs/docs/deployment/mastra-server.md +0 -122
- package/.docs/docs/deployment/monorepo.md +0 -142
- package/.docs/docs/deployment/overview.md +0 -62
- package/.docs/docs/deployment/studio.md +0 -234
- package/.docs/docs/deployment/web-framework.md +0 -52
- package/.docs/docs/deployment/workflow-runners.md +0 -9
- package/.docs/docs/evals/built-in-scorers.md +0 -47
- package/.docs/docs/evals/custom-scorers.md +0 -519
- package/.docs/docs/evals/overview.md +0 -146
- package/.docs/docs/evals/running-in-ci.md +0 -106
- package/.docs/docs/getting-started/build-with-ai.md +0 -68
- package/.docs/docs/getting-started/manual-install.md +0 -226
- package/.docs/docs/getting-started/project-structure.md +0 -60
- package/.docs/docs/getting-started/start.md +0 -28
- package/.docs/docs/getting-started/studio.md +0 -101
- package/.docs/docs/index.md +0 -43
- package/.docs/docs/mastra-cloud/deployment.md +0 -77
- package/.docs/docs/mastra-cloud/observability.md +0 -38
- package/.docs/docs/mastra-cloud/overview.md +0 -23
- package/.docs/docs/mastra-cloud/setup.md +0 -42
- package/.docs/docs/mastra-cloud/studio.md +0 -24
- package/.docs/docs/mcp/overview.md +0 -370
- package/.docs/docs/mcp/publishing-mcp-server.md +0 -95
- package/.docs/docs/memory/memory-processors.md +0 -316
- package/.docs/docs/memory/message-history.md +0 -260
- package/.docs/docs/memory/observational-memory.md +0 -246
- package/.docs/docs/memory/overview.md +0 -45
- package/.docs/docs/memory/semantic-recall.md +0 -272
- package/.docs/docs/memory/storage.md +0 -261
- package/.docs/docs/memory/working-memory.md +0 -400
- package/.docs/docs/observability/datasets/overview.md +0 -188
- package/.docs/docs/observability/datasets/running-experiments.md +0 -266
- package/.docs/docs/observability/logging.md +0 -99
- package/.docs/docs/observability/overview.md +0 -70
- package/.docs/docs/observability/tracing/bridges/otel.md +0 -209
- package/.docs/docs/observability/tracing/exporters/arize.md +0 -274
- package/.docs/docs/observability/tracing/exporters/braintrust.md +0 -111
- package/.docs/docs/observability/tracing/exporters/cloud.md +0 -129
- package/.docs/docs/observability/tracing/exporters/datadog.md +0 -187
- package/.docs/docs/observability/tracing/exporters/default.md +0 -211
- package/.docs/docs/observability/tracing/exporters/laminar.md +0 -100
- package/.docs/docs/observability/tracing/exporters/langfuse.md +0 -217
- package/.docs/docs/observability/tracing/exporters/langsmith.md +0 -202
- package/.docs/docs/observability/tracing/exporters/otel.md +0 -479
- package/.docs/docs/observability/tracing/exporters/posthog.md +0 -148
- package/.docs/docs/observability/tracing/exporters/sentry.md +0 -208
- package/.docs/docs/observability/tracing/overview.md +0 -1114
- package/.docs/docs/observability/tracing/processors/sensitive-data-filter.md +0 -303
- package/.docs/docs/rag/chunking-and-embedding.md +0 -183
- package/.docs/docs/rag/graph-rag.md +0 -215
- package/.docs/docs/rag/overview.md +0 -72
- package/.docs/docs/rag/retrieval.md +0 -521
- package/.docs/docs/rag/vector-databases.md +0 -648
- package/.docs/docs/server/auth/auth0.md +0 -222
- package/.docs/docs/server/auth/better-auth.md +0 -203
- package/.docs/docs/server/auth/clerk.md +0 -132
- package/.docs/docs/server/auth/composite-auth.md +0 -234
- package/.docs/docs/server/auth/custom-auth-provider.md +0 -513
- package/.docs/docs/server/auth/firebase.md +0 -272
- package/.docs/docs/server/auth/jwt.md +0 -110
- package/.docs/docs/server/auth/simple-auth.md +0 -178
- package/.docs/docs/server/auth/supabase.md +0 -117
- package/.docs/docs/server/auth/workos.md +0 -190
- package/.docs/docs/server/auth.md +0 -38
- package/.docs/docs/server/custom-adapters.md +0 -374
- package/.docs/docs/server/custom-api-routes.md +0 -267
- package/.docs/docs/server/mastra-client.md +0 -243
- package/.docs/docs/server/mastra-server.md +0 -71
- package/.docs/docs/server/middleware.md +0 -228
- package/.docs/docs/server/request-context.md +0 -478
- package/.docs/docs/server/server-adapters.md +0 -547
- package/.docs/docs/streaming/events.md +0 -247
- package/.docs/docs/streaming/overview.md +0 -181
- package/.docs/docs/streaming/tool-streaming.md +0 -178
- package/.docs/docs/streaming/workflow-streaming.md +0 -109
- package/.docs/docs/voice/overview.md +0 -979
- package/.docs/docs/voice/speech-to-speech.md +0 -103
- package/.docs/docs/voice/speech-to-text.md +0 -80
- package/.docs/docs/voice/text-to-speech.md +0 -84
- package/.docs/docs/workflows/agents-and-tools.md +0 -170
- package/.docs/docs/workflows/control-flow.md +0 -823
- package/.docs/docs/workflows/error-handling.md +0 -360
- package/.docs/docs/workflows/human-in-the-loop.md +0 -213
- package/.docs/docs/workflows/overview.md +0 -372
- package/.docs/docs/workflows/snapshots.md +0 -238
- package/.docs/docs/workflows/suspend-and-resume.md +0 -205
- package/.docs/docs/workflows/time-travel.md +0 -309
- package/.docs/docs/workflows/workflow-state.md +0 -181
- package/.docs/docs/workspace/filesystem.md +0 -162
- package/.docs/docs/workspace/overview.md +0 -239
- package/.docs/docs/workspace/sandbox.md +0 -63
- package/.docs/docs/workspace/search.md +0 -219
- package/.docs/docs/workspace/skills.md +0 -126
- package/.docs/guides/agent-frameworks/ai-sdk.md +0 -140
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +0 -1463
- package/.docs/guides/build-your-ui/assistant-ui.md +0 -156
- package/.docs/guides/build-your-ui/copilotkit.md +0 -292
- package/.docs/guides/deployment/amazon-ec2.md +0 -130
- package/.docs/guides/deployment/aws-lambda.md +0 -248
- package/.docs/guides/deployment/azure-app-services.md +0 -114
- package/.docs/guides/deployment/cloudflare.md +0 -99
- package/.docs/guides/deployment/digital-ocean.md +0 -168
- package/.docs/guides/deployment/inngest.md +0 -685
- package/.docs/guides/deployment/netlify.md +0 -77
- package/.docs/guides/deployment/vercel.md +0 -101
- package/.docs/guides/getting-started/astro.md +0 -408
- package/.docs/guides/getting-started/electron.md +0 -504
- package/.docs/guides/getting-started/express.md +0 -251
- package/.docs/guides/getting-started/hono.md +0 -191
- package/.docs/guides/getting-started/next-js.md +0 -355
- package/.docs/guides/getting-started/nuxt.md +0 -476
- package/.docs/guides/getting-started/quickstart.md +0 -67
- package/.docs/guides/getting-started/sveltekit.md +0 -300
- package/.docs/guides/getting-started/vite-react.md +0 -439
- package/.docs/guides/guide/ai-recruiter.md +0 -227
- package/.docs/guides/guide/chef-michel.md +0 -215
- package/.docs/guides/guide/code-review-bot.md +0 -221
- package/.docs/guides/guide/dev-assistant.md +0 -304
- package/.docs/guides/guide/docs-manager.md +0 -238
- package/.docs/guides/guide/github-actions-pr-description.md +0 -236
- package/.docs/guides/guide/notes-mcp-server.md +0 -425
- package/.docs/guides/guide/research-assistant.md +0 -349
- package/.docs/guides/guide/stock-agent.md +0 -134
- package/.docs/guides/guide/web-search.md +0 -326
- package/.docs/guides/guide/whatsapp-chat-bot.md +0 -416
- package/.docs/guides/index.md +0 -3
- package/.docs/guides/migrations/agentnetwork.md +0 -101
- package/.docs/guides/migrations/ai-sdk-v4-to-v5.md +0 -112
- package/.docs/guides/migrations/upgrade-to-v1/agent.md +0 -404
- package/.docs/guides/migrations/upgrade-to-v1/cli.md +0 -57
- package/.docs/guides/migrations/upgrade-to-v1/client.md +0 -337
- package/.docs/guides/migrations/upgrade-to-v1/deployment.md +0 -37
- package/.docs/guides/migrations/upgrade-to-v1/evals.md +0 -239
- package/.docs/guides/migrations/upgrade-to-v1/mastra.md +0 -143
- package/.docs/guides/migrations/upgrade-to-v1/mcp.md +0 -97
- package/.docs/guides/migrations/upgrade-to-v1/memory.md +0 -285
- package/.docs/guides/migrations/upgrade-to-v1/overview.md +0 -119
- package/.docs/guides/migrations/upgrade-to-v1/processors.md +0 -68
- package/.docs/guides/migrations/upgrade-to-v1/rag.md +0 -42
- package/.docs/guides/migrations/upgrade-to-v1/storage.md +0 -553
- package/.docs/guides/migrations/upgrade-to-v1/tools.md +0 -180
- package/.docs/guides/migrations/upgrade-to-v1/tracing.md +0 -417
- package/.docs/guides/migrations/upgrade-to-v1/vectors.md +0 -87
- package/.docs/guides/migrations/upgrade-to-v1/voice.md +0 -30
- package/.docs/guides/migrations/upgrade-to-v1/workflows.md +0 -341
- package/.docs/guides/migrations/vnext-to-standard-apis.md +0 -364
- package/.docs/models/embeddings.md +0 -161
- package/.docs/models/gateways/azure-openai.md +0 -128
- package/.docs/models/gateways/custom-gateways.md +0 -545
- package/.docs/models/gateways/netlify.md +0 -88
- package/.docs/models/gateways/openrouter.md +0 -219
- package/.docs/models/gateways/vercel.md +0 -225
- package/.docs/models/gateways.md +0 -14
- package/.docs/models/index.md +0 -286
- package/.docs/models/providers/302ai.md +0 -134
- package/.docs/models/providers/abacus.md +0 -125
- package/.docs/models/providers/agentrouter.md +0 -90
- package/.docs/models/providers/aihubmix.md +0 -107
- package/.docs/models/providers/alibaba-cn.md +0 -135
- package/.docs/models/providers/alibaba.md +0 -111
- package/.docs/models/providers/amazon-bedrock.md +0 -33
- package/.docs/models/providers/anthropic.md +0 -153
- package/.docs/models/providers/azure.md +0 -33
- package/.docs/models/providers/bailing.md +0 -72
- package/.docs/models/providers/baseten.md +0 -77
- package/.docs/models/providers/berget.md +0 -78
- package/.docs/models/providers/cerebras.md +0 -101
- package/.docs/models/providers/chutes.md +0 -136
- package/.docs/models/providers/cloudflare-ai-gateway.md +0 -33
- package/.docs/models/providers/cloudflare-workers-ai.md +0 -109
- package/.docs/models/providers/cohere.md +0 -33
- package/.docs/models/providers/cortecs.md +0 -91
- package/.docs/models/providers/deepinfra.md +0 -112
- package/.docs/models/providers/deepseek.md +0 -88
- package/.docs/models/providers/fastrouter.md +0 -84
- package/.docs/models/providers/fireworks-ai.md +0 -89
- package/.docs/models/providers/firmware.md +0 -85
- package/.docs/models/providers/friendli.md +0 -78
- package/.docs/models/providers/github-models.md +0 -125
- package/.docs/models/providers/google-vertex.md +0 -33
- package/.docs/models/providers/google.md +0 -159
- package/.docs/models/providers/groq.md +0 -107
- package/.docs/models/providers/helicone.md +0 -161
- package/.docs/models/providers/huggingface.md +0 -90
- package/.docs/models/providers/iflowcn.md +0 -84
- package/.docs/models/providers/inception.md +0 -72
- package/.docs/models/providers/inference.md +0 -79
- package/.docs/models/providers/io-intelligence.md +0 -87
- package/.docs/models/providers/io-net.md +0 -87
- package/.docs/models/providers/jiekou.md +0 -131
- package/.docs/models/providers/kilo.md +0 -333
- package/.docs/models/providers/kimi-for-coding.md +0 -100
- package/.docs/models/providers/kuae-cloud-coding-plan.md +0 -71
- package/.docs/models/providers/llama.md +0 -77
- package/.docs/models/providers/lmstudio.md +0 -73
- package/.docs/models/providers/lucidquery.md +0 -72
- package/.docs/models/providers/minimax-cn-coding-plan.md +0 -102
- package/.docs/models/providers/minimax-cn.md +0 -102
- package/.docs/models/providers/minimax-coding-plan.md +0 -102
- package/.docs/models/providers/minimax.md +0 -104
- package/.docs/models/providers/mistral.md +0 -124
- package/.docs/models/providers/moark.md +0 -72
- package/.docs/models/providers/modelscope.md +0 -77
- package/.docs/models/providers/moonshotai-cn.md +0 -76
- package/.docs/models/providers/moonshotai.md +0 -76
- package/.docs/models/providers/morph.md +0 -73
- package/.docs/models/providers/nano-gpt.md +0 -103
- package/.docs/models/providers/nebius.md +0 -116
- package/.docs/models/providers/nova.md +0 -72
- package/.docs/models/providers/novita-ai.md +0 -154
- package/.docs/models/providers/nvidia.md +0 -141
- package/.docs/models/providers/ollama-cloud.md +0 -103
- package/.docs/models/providers/ollama.md +0 -33
- package/.docs/models/providers/openai.md +0 -193
- package/.docs/models/providers/opencode.md +0 -100
- package/.docs/models/providers/ovhcloud.md +0 -83
- package/.docs/models/providers/perplexity.md +0 -100
- package/.docs/models/providers/poe.md +0 -183
- package/.docs/models/providers/privatemode-ai.md +0 -75
- package/.docs/models/providers/requesty.md +0 -90
- package/.docs/models/providers/scaleway.md +0 -84
- package/.docs/models/providers/siliconflow-cn.md +0 -138
- package/.docs/models/providers/siliconflow.md +0 -140
- package/.docs/models/providers/stackit.md +0 -78
- package/.docs/models/providers/stepfun.md +0 -73
- package/.docs/models/providers/submodel.md +0 -79
- package/.docs/models/providers/synthetic.md +0 -96
- package/.docs/models/providers/togetherai.md +0 -115
- package/.docs/models/providers/upstage.md +0 -73
- package/.docs/models/providers/venice.md +0 -95
- package/.docs/models/providers/vivgrid.md +0 -106
- package/.docs/models/providers/vultr.md +0 -75
- package/.docs/models/providers/wandb.md +0 -80
- package/.docs/models/providers/xai.md +0 -141
- package/.docs/models/providers/xiaomi.md +0 -71
- package/.docs/models/providers/zai-coding-plan.md +0 -80
- package/.docs/models/providers/zai.md +0 -79
- package/.docs/models/providers/zenmux.md +0 -161
- package/.docs/models/providers/zhipuai-coding-plan.md +0 -79
- package/.docs/models/providers/zhipuai.md +0 -79
- package/.docs/models/providers.md +0 -81
- package/.docs/reference/agents/agent.md +0 -142
- package/.docs/reference/agents/generate.md +0 -174
- package/.docs/reference/agents/generateLegacy.md +0 -176
- package/.docs/reference/agents/getDefaultGenerateOptions.md +0 -36
- package/.docs/reference/agents/getDefaultOptions.md +0 -34
- package/.docs/reference/agents/getDefaultStreamOptions.md +0 -36
- package/.docs/reference/agents/getDescription.md +0 -21
- package/.docs/reference/agents/getInstructions.md +0 -34
- package/.docs/reference/agents/getLLM.md +0 -37
- package/.docs/reference/agents/getMemory.md +0 -34
- package/.docs/reference/agents/getModel.md +0 -34
- package/.docs/reference/agents/getTools.md +0 -29
- package/.docs/reference/agents/getVoice.md +0 -34
- package/.docs/reference/agents/listAgents.md +0 -35
- package/.docs/reference/agents/listScorers.md +0 -34
- package/.docs/reference/agents/listTools.md +0 -34
- package/.docs/reference/agents/listWorkflows.md +0 -34
- package/.docs/reference/agents/network.md +0 -134
- package/.docs/reference/ai-sdk/chat-route.md +0 -82
- package/.docs/reference/ai-sdk/handle-chat-stream.md +0 -53
- package/.docs/reference/ai-sdk/handle-network-stream.md +0 -37
- package/.docs/reference/ai-sdk/handle-workflow-stream.md +0 -55
- package/.docs/reference/ai-sdk/network-route.md +0 -74
- package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +0 -232
- package/.docs/reference/ai-sdk/to-ai-sdk-v4-messages.md +0 -79
- package/.docs/reference/ai-sdk/to-ai-sdk-v5-messages.md +0 -73
- package/.docs/reference/ai-sdk/with-mastra.md +0 -59
- package/.docs/reference/ai-sdk/workflow-route.md +0 -79
- package/.docs/reference/auth/auth0.md +0 -73
- package/.docs/reference/auth/better-auth.md +0 -71
- package/.docs/reference/auth/clerk.md +0 -36
- package/.docs/reference/auth/firebase.md +0 -80
- package/.docs/reference/auth/jwt.md +0 -26
- package/.docs/reference/auth/supabase.md +0 -33
- package/.docs/reference/auth/workos.md +0 -84
- package/.docs/reference/cli/create-mastra.md +0 -137
- package/.docs/reference/cli/mastra.md +0 -336
- package/.docs/reference/client-js/agents.md +0 -438
- package/.docs/reference/client-js/error-handling.md +0 -16
- package/.docs/reference/client-js/logs.md +0 -24
- package/.docs/reference/client-js/mastra-client.md +0 -63
- package/.docs/reference/client-js/memory.md +0 -225
- package/.docs/reference/client-js/observability.md +0 -72
- package/.docs/reference/client-js/telemetry.md +0 -20
- package/.docs/reference/client-js/tools.md +0 -44
- package/.docs/reference/client-js/vectors.md +0 -79
- package/.docs/reference/client-js/workflows.md +0 -199
- package/.docs/reference/configuration.md +0 -749
- package/.docs/reference/core/addGateway.md +0 -42
- package/.docs/reference/core/getAgent.md +0 -21
- package/.docs/reference/core/getAgentById.md +0 -21
- package/.docs/reference/core/getDeployer.md +0 -22
- package/.docs/reference/core/getGateway.md +0 -38
- package/.docs/reference/core/getGatewayById.md +0 -41
- package/.docs/reference/core/getLogger.md +0 -22
- package/.docs/reference/core/getMCPServer.md +0 -45
- package/.docs/reference/core/getMCPServerById.md +0 -53
- package/.docs/reference/core/getMemory.md +0 -50
- package/.docs/reference/core/getScorer.md +0 -54
- package/.docs/reference/core/getScorerById.md +0 -54
- package/.docs/reference/core/getServer.md +0 -22
- package/.docs/reference/core/getStorage.md +0 -22
- package/.docs/reference/core/getStoredAgentById.md +0 -89
- package/.docs/reference/core/getTelemetry.md +0 -22
- package/.docs/reference/core/getVector.md +0 -22
- package/.docs/reference/core/getWorkflow.md +0 -40
- package/.docs/reference/core/listAgents.md +0 -21
- package/.docs/reference/core/listGateways.md +0 -40
- package/.docs/reference/core/listLogs.md +0 -38
- package/.docs/reference/core/listLogsByRunId.md +0 -36
- package/.docs/reference/core/listMCPServers.md +0 -51
- package/.docs/reference/core/listMemory.md +0 -56
- package/.docs/reference/core/listScorers.md +0 -29
- package/.docs/reference/core/listStoredAgents.md +0 -93
- package/.docs/reference/core/listVectors.md +0 -22
- package/.docs/reference/core/listWorkflows.md +0 -21
- package/.docs/reference/core/mastra-class.md +0 -66
- package/.docs/reference/core/mastra-model-gateway.md +0 -153
- package/.docs/reference/core/setLogger.md +0 -26
- package/.docs/reference/core/setStorage.md +0 -27
- package/.docs/reference/datasets/addItem.md +0 -35
- package/.docs/reference/datasets/addItems.md +0 -33
- package/.docs/reference/datasets/compareExperiments.md +0 -48
- package/.docs/reference/datasets/create.md +0 -49
- package/.docs/reference/datasets/dataset.md +0 -78
- package/.docs/reference/datasets/datasets-manager.md +0 -84
- package/.docs/reference/datasets/delete.md +0 -23
- package/.docs/reference/datasets/deleteExperiment.md +0 -25
- package/.docs/reference/datasets/deleteItem.md +0 -25
- package/.docs/reference/datasets/deleteItems.md +0 -27
- package/.docs/reference/datasets/get.md +0 -29
- package/.docs/reference/datasets/getDetails.md +0 -45
- package/.docs/reference/datasets/getExperiment.md +0 -28
- package/.docs/reference/datasets/getItem.md +0 -31
- package/.docs/reference/datasets/getItemHistory.md +0 -29
- package/.docs/reference/datasets/list.md +0 -29
- package/.docs/reference/datasets/listExperimentResults.md +0 -37
- package/.docs/reference/datasets/listExperiments.md +0 -31
- package/.docs/reference/datasets/listItems.md +0 -44
- package/.docs/reference/datasets/listVersions.md +0 -31
- package/.docs/reference/datasets/startExperiment.md +0 -60
- package/.docs/reference/datasets/startExperimentAsync.md +0 -41
- package/.docs/reference/datasets/update.md +0 -46
- package/.docs/reference/datasets/updateItem.md +0 -36
- package/.docs/reference/deployer/cloudflare.md +0 -79
- package/.docs/reference/deployer/netlify.md +0 -82
- package/.docs/reference/deployer/vercel.md +0 -91
- package/.docs/reference/deployer.md +0 -100
- package/.docs/reference/evals/answer-relevancy.md +0 -105
- package/.docs/reference/evals/answer-similarity.md +0 -99
- package/.docs/reference/evals/bias.md +0 -120
- package/.docs/reference/evals/completeness.md +0 -137
- package/.docs/reference/evals/content-similarity.md +0 -101
- package/.docs/reference/evals/context-precision.md +0 -196
- package/.docs/reference/evals/context-relevance.md +0 -536
- package/.docs/reference/evals/create-scorer.md +0 -270
- package/.docs/reference/evals/faithfulness.md +0 -114
- package/.docs/reference/evals/hallucination.md +0 -220
- package/.docs/reference/evals/keyword-coverage.md +0 -128
- package/.docs/reference/evals/mastra-scorer.md +0 -123
- package/.docs/reference/evals/noise-sensitivity.md +0 -685
- package/.docs/reference/evals/prompt-alignment.md +0 -619
- package/.docs/reference/evals/run-evals.md +0 -138
- package/.docs/reference/evals/scorer-utils.md +0 -330
- package/.docs/reference/evals/textual-difference.md +0 -113
- package/.docs/reference/evals/tone-consistency.md +0 -119
- package/.docs/reference/evals/tool-call-accuracy.md +0 -533
- package/.docs/reference/evals/toxicity.md +0 -123
- package/.docs/reference/harness/harness-class.md +0 -645
- package/.docs/reference/index.md +0 -276
- package/.docs/reference/logging/pino-logger.md +0 -117
- package/.docs/reference/memory/clone-utilities.md +0 -199
- package/.docs/reference/memory/cloneThread.md +0 -130
- package/.docs/reference/memory/createThread.md +0 -68
- package/.docs/reference/memory/deleteMessages.md +0 -40
- package/.docs/reference/memory/getThreadById.md +0 -24
- package/.docs/reference/memory/listThreads.md +0 -145
- package/.docs/reference/memory/memory-class.md +0 -147
- package/.docs/reference/memory/observational-memory.md +0 -565
- package/.docs/reference/memory/recall.md +0 -91
- package/.docs/reference/observability/tracing/bridges/otel.md +0 -131
- package/.docs/reference/observability/tracing/configuration.md +0 -178
- package/.docs/reference/observability/tracing/exporters/arize.md +0 -141
- package/.docs/reference/observability/tracing/exporters/braintrust.md +0 -93
- package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +0 -163
- package/.docs/reference/observability/tracing/exporters/console-exporter.md +0 -138
- package/.docs/reference/observability/tracing/exporters/datadog.md +0 -116
- package/.docs/reference/observability/tracing/exporters/default-exporter.md +0 -174
- package/.docs/reference/observability/tracing/exporters/laminar.md +0 -78
- package/.docs/reference/observability/tracing/exporters/langfuse.md +0 -134
- package/.docs/reference/observability/tracing/exporters/langsmith.md +0 -110
- package/.docs/reference/observability/tracing/exporters/otel.md +0 -199
- package/.docs/reference/observability/tracing/exporters/posthog.md +0 -92
- package/.docs/reference/observability/tracing/exporters/sentry.md +0 -184
- package/.docs/reference/observability/tracing/instances.md +0 -109
- package/.docs/reference/observability/tracing/interfaces.md +0 -749
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +0 -144
- package/.docs/reference/observability/tracing/spans.md +0 -224
- package/.docs/reference/processors/batch-parts-processor.md +0 -61
- package/.docs/reference/processors/language-detector.md +0 -81
- package/.docs/reference/processors/message-history-processor.md +0 -85
- package/.docs/reference/processors/moderation-processor.md +0 -104
- package/.docs/reference/processors/pii-detector.md +0 -107
- package/.docs/reference/processors/processor-interface.md +0 -525
- package/.docs/reference/processors/prompt-injection-detector.md +0 -71
- package/.docs/reference/processors/semantic-recall-processor.md +0 -123
- package/.docs/reference/processors/system-prompt-scrubber.md +0 -80
- package/.docs/reference/processors/token-limiter-processor.md +0 -113
- package/.docs/reference/processors/tool-call-filter.md +0 -85
- package/.docs/reference/processors/tool-search-processor.md +0 -113
- package/.docs/reference/processors/unicode-normalizer.md +0 -62
- package/.docs/reference/processors/working-memory-processor.md +0 -154
- package/.docs/reference/rag/chunk.md +0 -221
- package/.docs/reference/rag/database-config.md +0 -264
- package/.docs/reference/rag/document.md +0 -114
- package/.docs/reference/rag/embeddings.md +0 -92
- package/.docs/reference/rag/extract-params.md +0 -168
- package/.docs/reference/rag/graph-rag.md +0 -111
- package/.docs/reference/rag/metadata-filters.md +0 -216
- package/.docs/reference/rag/rerank.md +0 -80
- package/.docs/reference/rag/rerankWithScorer.md +0 -80
- package/.docs/reference/server/create-route.md +0 -260
- package/.docs/reference/server/express-adapter.md +0 -176
- package/.docs/reference/server/fastify-adapter.md +0 -90
- package/.docs/reference/server/hono-adapter.md +0 -162
- package/.docs/reference/server/koa-adapter.md +0 -127
- package/.docs/reference/server/mastra-server.md +0 -298
- package/.docs/reference/server/register-api-route.md +0 -249
- package/.docs/reference/server/routes.md +0 -306
- package/.docs/reference/storage/cloudflare-d1.md +0 -218
- package/.docs/reference/storage/cloudflare.md +0 -88
- package/.docs/reference/storage/composite.md +0 -235
- package/.docs/reference/storage/convex.md +0 -161
- package/.docs/reference/storage/dynamodb.md +0 -282
- package/.docs/reference/storage/lance.md +0 -131
- package/.docs/reference/storage/libsql.md +0 -135
- package/.docs/reference/storage/mongodb.md +0 -262
- package/.docs/reference/storage/mssql.md +0 -155
- package/.docs/reference/storage/overview.md +0 -121
- package/.docs/reference/storage/postgresql.md +0 -529
- package/.docs/reference/storage/upstash.md +0 -160
- package/.docs/reference/streaming/ChunkType.md +0 -292
- package/.docs/reference/streaming/agents/MastraModelOutput.md +0 -182
- package/.docs/reference/streaming/agents/stream.md +0 -212
- package/.docs/reference/streaming/agents/streamLegacy.md +0 -142
- package/.docs/reference/streaming/workflows/observeStream.md +0 -42
- package/.docs/reference/streaming/workflows/resumeStream.md +0 -61
- package/.docs/reference/streaming/workflows/stream.md +0 -88
- package/.docs/reference/streaming/workflows/timeTravelStream.md +0 -142
- package/.docs/reference/templates/overview.md +0 -194
- package/.docs/reference/tools/create-tool.md +0 -237
- package/.docs/reference/tools/document-chunker-tool.md +0 -89
- package/.docs/reference/tools/graph-rag-tool.md +0 -185
- package/.docs/reference/tools/mcp-client.md +0 -962
- package/.docs/reference/tools/mcp-server.md +0 -1275
- package/.docs/reference/tools/vector-query-tool.md +0 -459
- package/.docs/reference/vectors/astra.md +0 -121
- package/.docs/reference/vectors/chroma.md +0 -267
- package/.docs/reference/vectors/convex.md +0 -303
- package/.docs/reference/vectors/couchbase.md +0 -226
- package/.docs/reference/vectors/duckdb.md +0 -318
- package/.docs/reference/vectors/elasticsearch.md +0 -189
- package/.docs/reference/vectors/lance.md +0 -220
- package/.docs/reference/vectors/libsql.md +0 -305
- package/.docs/reference/vectors/mongodb.md +0 -295
- package/.docs/reference/vectors/opensearch.md +0 -99
- package/.docs/reference/vectors/pg.md +0 -408
- package/.docs/reference/vectors/pinecone.md +0 -168
- package/.docs/reference/vectors/qdrant.md +0 -222
- package/.docs/reference/vectors/s3vectors.md +0 -277
- package/.docs/reference/vectors/turbopuffer.md +0 -157
- package/.docs/reference/vectors/upstash.md +0 -294
- package/.docs/reference/vectors/vectorize.md +0 -147
- package/.docs/reference/voice/azure.md +0 -148
- package/.docs/reference/voice/cloudflare.md +0 -83
- package/.docs/reference/voice/composite-voice.md +0 -121
- package/.docs/reference/voice/deepgram.md +0 -79
- package/.docs/reference/voice/elevenlabs.md +0 -98
- package/.docs/reference/voice/google-gemini-live.md +0 -378
- package/.docs/reference/voice/google.md +0 -228
- package/.docs/reference/voice/mastra-voice.md +0 -313
- package/.docs/reference/voice/murf.md +0 -122
- package/.docs/reference/voice/openai-realtime.md +0 -203
- package/.docs/reference/voice/openai.md +0 -88
- package/.docs/reference/voice/playai.md +0 -80
- package/.docs/reference/voice/sarvam.md +0 -126
- package/.docs/reference/voice/speechify.md +0 -75
- package/.docs/reference/voice/voice.addInstructions.md +0 -56
- package/.docs/reference/voice/voice.addTools.md +0 -67
- package/.docs/reference/voice/voice.answer.md +0 -54
- package/.docs/reference/voice/voice.close.md +0 -51
- package/.docs/reference/voice/voice.connect.md +0 -94
- package/.docs/reference/voice/voice.events.md +0 -37
- package/.docs/reference/voice/voice.getSpeakers.md +0 -129
- package/.docs/reference/voice/voice.listen.md +0 -164
- package/.docs/reference/voice/voice.off.md +0 -54
- package/.docs/reference/voice/voice.on.md +0 -111
- package/.docs/reference/voice/voice.send.md +0 -65
- package/.docs/reference/voice/voice.speak.md +0 -157
- package/.docs/reference/voice/voice.updateConfig.md +0 -60
- package/.docs/reference/workflows/run-methods/cancel.md +0 -86
- package/.docs/reference/workflows/run-methods/restart.md +0 -33
- package/.docs/reference/workflows/run-methods/resume.md +0 -59
- package/.docs/reference/workflows/run-methods/start.md +0 -58
- package/.docs/reference/workflows/run-methods/startAsync.md +0 -67
- package/.docs/reference/workflows/run-methods/timeTravel.md +0 -142
- package/.docs/reference/workflows/run.md +0 -59
- package/.docs/reference/workflows/step.md +0 -119
- package/.docs/reference/workflows/workflow-methods/branch.md +0 -25
- package/.docs/reference/workflows/workflow-methods/commit.md +0 -17
- package/.docs/reference/workflows/workflow-methods/create-run.md +0 -63
- package/.docs/reference/workflows/workflow-methods/dountil.md +0 -25
- package/.docs/reference/workflows/workflow-methods/dowhile.md +0 -25
- package/.docs/reference/workflows/workflow-methods/foreach.md +0 -118
- package/.docs/reference/workflows/workflow-methods/map.md +0 -93
- package/.docs/reference/workflows/workflow-methods/parallel.md +0 -21
- package/.docs/reference/workflows/workflow-methods/sleep.md +0 -35
- package/.docs/reference/workflows/workflow-methods/sleepUntil.md +0 -35
- package/.docs/reference/workflows/workflow-methods/then.md +0 -21
- package/.docs/reference/workflows/workflow.md +0 -157
- package/.docs/reference/workspace/e2b-sandbox.md +0 -288
- package/.docs/reference/workspace/filesystem.md +0 -202
- package/.docs/reference/workspace/gcs-filesystem.md +0 -170
- package/.docs/reference/workspace/local-filesystem.md +0 -327
- package/.docs/reference/workspace/local-sandbox.md +0 -285
- package/.docs/reference/workspace/s3-filesystem.md +0 -169
- package/.docs/reference/workspace/sandbox.md +0 -81
- package/.docs/reference/workspace/workspace-class.md +0 -226
|
@@ -1,439 +0,0 @@
|
|
|
1
|
-
# Integrate Mastra in your React + Vite project
|
|
2
|
-
|
|
3
|
-
In this guide, you'll build a tool-calling AI agent using Mastra, then connect it to React by calling the agent directly from Mastra's standalone server.
|
|
4
|
-
|
|
5
|
-
You'll use [AI SDK UI](https://ai-sdk.dev/docs/ai-sdk-ui/overview) and [AI Elements](https://ai-sdk.dev/elements) to create a beautiful, interactive chat experience.
|
|
6
|
-
|
|
7
|
-
## Before you begin
|
|
8
|
-
|
|
9
|
-
- You'll need an API key from a supported [model provider](https://mastra.ai/models). If you don't have a preference, use [OpenAI](https://mastra.ai/models/providers/openai).
|
|
10
|
-
- Install Node.js `v22.13.0` or later
|
|
11
|
-
|
|
12
|
-
## Create a new React + Vite app (optional)
|
|
13
|
-
|
|
14
|
-
If you already have a React + Vite app using Tailwind, skip to the next step.
|
|
15
|
-
|
|
16
|
-
### Project scaffold
|
|
17
|
-
|
|
18
|
-
Run the following command to [create a new React + Vite app](https://vite.dev/guide/#scaffolding-your-first-vite-project):
|
|
19
|
-
|
|
20
|
-
**npm**:
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
npm create vite@latest mastra-react -- --template react-ts
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
**pnpm**:
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
pnpm create vite mastra-react --template react-ts
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
**Yarn**:
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
yarn create vite mastra-react --template react-ts
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
**Bun**:
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
bunx create-vite mastra-react --template react-ts
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
This creates a project called `mastra-react`, but you can replace it with any name you want.
|
|
45
|
-
|
|
46
|
-
Navigate to your project directory:
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
cd mastra-react
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Tailwind
|
|
53
|
-
|
|
54
|
-
Next, install Tailwind:
|
|
55
|
-
|
|
56
|
-
**npm**:
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
npm install tailwindcss @tailwindcss/vite
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
**pnpm**:
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
pnpm add tailwindcss @tailwindcss/vite
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
**Yarn**:
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
yarn add tailwindcss @tailwindcss/vite
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
**Bun**:
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
bun add tailwindcss @tailwindcss/vite
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Configure the Vite plugins:
|
|
81
|
-
|
|
82
|
-
```typescript
|
|
83
|
-
import { defineConfig } from 'vite'
|
|
84
|
-
import react from '@vitejs/plugin-react'
|
|
85
|
-
import path from "path"
|
|
86
|
-
import tailwindcss from '@tailwindcss/vite'
|
|
87
|
-
|
|
88
|
-
export default defineConfig({
|
|
89
|
-
plugins: [react(), tailwindcss()],
|
|
90
|
-
resolve: {
|
|
91
|
-
alias: {
|
|
92
|
-
"@": path.resolve(__dirname, "./src"),
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
})
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
Replace everything in `src/index.css` with the following:
|
|
99
|
-
|
|
100
|
-
```css
|
|
101
|
-
@import "tailwindcss";
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
Add these `compilerOptions` to `tsconfig.json`:
|
|
105
|
-
|
|
106
|
-
```ts
|
|
107
|
-
{
|
|
108
|
-
// ...
|
|
109
|
-
"compilerOptions": {
|
|
110
|
-
"baseUrl": ".",
|
|
111
|
-
"paths": {
|
|
112
|
-
"@/*": ["./src/*"]
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
Edit `tsconfig.app.json` to resolve paths:
|
|
119
|
-
|
|
120
|
-
```ts
|
|
121
|
-
{
|
|
122
|
-
"compilerOptions": {
|
|
123
|
-
// ...
|
|
124
|
-
"baseUrl": ".",
|
|
125
|
-
"paths": {
|
|
126
|
-
"@/*": [
|
|
127
|
-
"./src/*"
|
|
128
|
-
]
|
|
129
|
-
}
|
|
130
|
-
// ...
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
## Initialize Mastra
|
|
136
|
-
|
|
137
|
-
Run [`mastra init`](https://mastra.ai/reference/cli/mastra). When prompted, choose a provider (e.g. OpenAI) and enter your key:
|
|
138
|
-
|
|
139
|
-
**npm**:
|
|
140
|
-
|
|
141
|
-
```bash
|
|
142
|
-
npx mastra@latest init
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
**pnpm**:
|
|
146
|
-
|
|
147
|
-
```bash
|
|
148
|
-
pnpm dlx mastra@latest init
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
**Yarn**:
|
|
152
|
-
|
|
153
|
-
```bash
|
|
154
|
-
yarn dlx mastra@latest init
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
**Bun**:
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
bun x mastra@latest init
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
This creates a `src/mastra` folder with an example weather agent and the following files:
|
|
164
|
-
|
|
165
|
-
- `index.ts` - Mastra config, including memory
|
|
166
|
-
- `tools/weather-tool.ts` - a tool to fetch weather for a given location
|
|
167
|
-
- `agents/weather-agent.ts`- a weather agent with a prompt that uses the tool
|
|
168
|
-
|
|
169
|
-
You'll call `weather-agent.ts` from your chat UI in the next steps.
|
|
170
|
-
|
|
171
|
-
## Install AI SDK UI & AI Elements
|
|
172
|
-
|
|
173
|
-
Install AI SDK UI along with the Mastra adapter:
|
|
174
|
-
|
|
175
|
-
**npm**:
|
|
176
|
-
|
|
177
|
-
```bash
|
|
178
|
-
npm install @mastra/ai-sdk@latest @ai-sdk/react ai
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
**pnpm**:
|
|
182
|
-
|
|
183
|
-
```bash
|
|
184
|
-
pnpm add @mastra/ai-sdk@latest @ai-sdk/react ai
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
**Yarn**:
|
|
188
|
-
|
|
189
|
-
```bash
|
|
190
|
-
yarn add @mastra/ai-sdk@latest @ai-sdk/react ai
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
**Bun**:
|
|
194
|
-
|
|
195
|
-
```bash
|
|
196
|
-
bun add @mastra/ai-sdk@latest @ai-sdk/react ai
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
Next, initialize AI Elements. When prompted, choose the default options:
|
|
200
|
-
|
|
201
|
-
**npm**:
|
|
202
|
-
|
|
203
|
-
```bash
|
|
204
|
-
npx ai-elements@latest
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
**pnpm**:
|
|
208
|
-
|
|
209
|
-
```bash
|
|
210
|
-
pnpm dlx ai-elements@latest
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
**Yarn**:
|
|
214
|
-
|
|
215
|
-
```bash
|
|
216
|
-
yarn dlx ai-elements@latest
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
**Bun**:
|
|
220
|
-
|
|
221
|
-
```bash
|
|
222
|
-
bun x ai-elements@latest
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
This downloads the entire AI Elements UI component library into a `@/components/ai-elements` folder.
|
|
226
|
-
|
|
227
|
-
## Create a chat route
|
|
228
|
-
|
|
229
|
-
Open `src/mastra/index.ts` and add a [chatRoute()](https://mastra.ai/reference/ai-sdk/chat-route) to your config. This creates an API route your React frontend can call for AI SDK-compatible chat responses, which you’ll use with useChat() next.
|
|
230
|
-
|
|
231
|
-
```ts
|
|
232
|
-
import { Mastra } from '@mastra/core/mastra';
|
|
233
|
-
// Existing imports...
|
|
234
|
-
import { chatRoute } from "@mastra/ai-sdk"
|
|
235
|
-
|
|
236
|
-
export const mastra = new Mastra({
|
|
237
|
-
// Existing config...
|
|
238
|
-
server: {
|
|
239
|
-
apiRoutes: [
|
|
240
|
-
chatRoute({
|
|
241
|
-
path: '/chat/:agentId'
|
|
242
|
-
})
|
|
243
|
-
]
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
## Add the chat UI
|
|
249
|
-
|
|
250
|
-
Replace the `src/App.tsx` file to create a chat interface:
|
|
251
|
-
|
|
252
|
-
```tsx
|
|
253
|
-
import * as React from 'react';
|
|
254
|
-
import { DefaultChatTransport, type ToolUIPart } from 'ai';
|
|
255
|
-
import { useChat } from '@ai-sdk/react';
|
|
256
|
-
|
|
257
|
-
import {
|
|
258
|
-
PromptInput,
|
|
259
|
-
PromptInputBody,
|
|
260
|
-
PromptInputTextarea,
|
|
261
|
-
} from '@/components/ai-elements/prompt-input';
|
|
262
|
-
|
|
263
|
-
import {
|
|
264
|
-
Conversation,
|
|
265
|
-
ConversationContent,
|
|
266
|
-
ConversationScrollButton,
|
|
267
|
-
} from '@/components/ai-elements/conversation';
|
|
268
|
-
|
|
269
|
-
import {
|
|
270
|
-
Message,
|
|
271
|
-
MessageContent,
|
|
272
|
-
MessageResponse
|
|
273
|
-
} from '@/components/ai-elements/message';
|
|
274
|
-
|
|
275
|
-
import {
|
|
276
|
-
Tool,
|
|
277
|
-
ToolHeader,
|
|
278
|
-
ToolContent,
|
|
279
|
-
ToolInput,
|
|
280
|
-
ToolOutput,
|
|
281
|
-
} from '@/components/ai-elements/tool';
|
|
282
|
-
|
|
283
|
-
export default function App() {
|
|
284
|
-
const [input, setInput] = React.useState<string>('');
|
|
285
|
-
|
|
286
|
-
const { messages, sendMessage, status } = useChat({
|
|
287
|
-
transport: new DefaultChatTransport({
|
|
288
|
-
api: 'http://localhost:4111/chat/weather-agent',
|
|
289
|
-
}),
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
const handleSubmit = async () => {
|
|
293
|
-
if (!input.trim()) return;
|
|
294
|
-
|
|
295
|
-
sendMessage({ text: input });
|
|
296
|
-
setInput('');
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
return (
|
|
300
|
-
<div className="max-w-4xl mx-auto p-6 relative size-full h-screen">
|
|
301
|
-
<div className="flex flex-col h-full">
|
|
302
|
-
<Conversation className="h-full">
|
|
303
|
-
<ConversationContent>
|
|
304
|
-
{messages.map((message) => (
|
|
305
|
-
<div key={message.id}>
|
|
306
|
-
{message.parts?.map((part, i) => {
|
|
307
|
-
if (part.type === 'text') {
|
|
308
|
-
return (
|
|
309
|
-
<Message
|
|
310
|
-
key={`${message.id}-${i}`}
|
|
311
|
-
from={message.role}>
|
|
312
|
-
<MessageContent>
|
|
313
|
-
<MessageResponse>{part.text}</MessageResponse>
|
|
314
|
-
</MessageContent>
|
|
315
|
-
</Message>
|
|
316
|
-
);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
if (part.type?.startsWith('tool-')) {
|
|
320
|
-
return (
|
|
321
|
-
<Tool key={`${message.id}-${i}`}>
|
|
322
|
-
<ToolHeader
|
|
323
|
-
type={(part as ToolUIPart).type}
|
|
324
|
-
state={(part as ToolUIPart).state || 'output-available'}
|
|
325
|
-
className="cursor-pointer"
|
|
326
|
-
/>
|
|
327
|
-
<ToolContent>
|
|
328
|
-
<ToolInput input={(part as ToolUIPart).input || {}} />
|
|
329
|
-
<ToolOutput
|
|
330
|
-
output={(part as ToolUIPart).output}
|
|
331
|
-
errorText={(part as ToolUIPart).errorText}
|
|
332
|
-
/>
|
|
333
|
-
</ToolContent>
|
|
334
|
-
</Tool>
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
return null;
|
|
339
|
-
})}
|
|
340
|
-
</div>
|
|
341
|
-
))}
|
|
342
|
-
<ConversationScrollButton />
|
|
343
|
-
</ConversationContent>
|
|
344
|
-
</Conversation>
|
|
345
|
-
<PromptInput onSubmit={handleSubmit} className="mt-20">
|
|
346
|
-
<PromptInputBody>
|
|
347
|
-
<PromptInputTextarea
|
|
348
|
-
onChange={(e) => setInput(e.target.value)}
|
|
349
|
-
className="md:leading-10"
|
|
350
|
-
value={input}
|
|
351
|
-
placeholder="Ask about the weather..."
|
|
352
|
-
disabled={status !== 'ready'}
|
|
353
|
-
/>
|
|
354
|
-
</PromptInputBody>
|
|
355
|
-
</PromptInput>
|
|
356
|
-
</div>
|
|
357
|
-
</div>
|
|
358
|
-
);
|
|
359
|
-
}
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
This component connects [`useChat()`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat) to the `chat/weather-agent` endpoint, sending prompts there and streaming the response back in chunks.
|
|
363
|
-
|
|
364
|
-
It renders the response text using the [`<MessageResponse>`](https://ai-sdk.dev/elements/components/message#messageresponse-) component, and shows any tool invocations with the [`<Tool>`](https://ai-sdk.dev/elements/components/tool) component.
|
|
365
|
-
|
|
366
|
-
## Test your agent
|
|
367
|
-
|
|
368
|
-
In order to test your agent with the chat interface, you need to run both the Mastra server and the Vite development server.
|
|
369
|
-
|
|
370
|
-
1. Start the Mastra development server:
|
|
371
|
-
|
|
372
|
-
**npm**:
|
|
373
|
-
|
|
374
|
-
```bash
|
|
375
|
-
npx mastra dev
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
**pnpm**:
|
|
379
|
-
|
|
380
|
-
```bash
|
|
381
|
-
pnpm dlx mastra dev
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
**Yarn**:
|
|
385
|
-
|
|
386
|
-
```bash
|
|
387
|
-
yarn dlx mastra dev
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
**Bun**:
|
|
391
|
-
|
|
392
|
-
```bash
|
|
393
|
-
bun x mastra dev
|
|
394
|
-
```
|
|
395
|
-
|
|
396
|
-
2. In a separate terminal window, start the Vite development server:
|
|
397
|
-
|
|
398
|
-
**npm**:
|
|
399
|
-
|
|
400
|
-
```bash
|
|
401
|
-
npm run dev
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
**pnpm**:
|
|
405
|
-
|
|
406
|
-
```bash
|
|
407
|
-
pnpm run dev
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
**Yarn**:
|
|
411
|
-
|
|
412
|
-
```bash
|
|
413
|
-
yarn dev
|
|
414
|
-
```
|
|
415
|
-
|
|
416
|
-
**Bun**:
|
|
417
|
-
|
|
418
|
-
```bash
|
|
419
|
-
bun run dev
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
3. Open your application at <http://localhost:5173>
|
|
423
|
-
|
|
424
|
-
4. Try asking about the weather. If your API key is set up correctly, you'll get a response
|
|
425
|
-
|
|
426
|
-
## Next steps
|
|
427
|
-
|
|
428
|
-
Congratulations on building your Mastra agent with React! 🎉
|
|
429
|
-
|
|
430
|
-
From here, you can extend the project with your own tools and logic:
|
|
431
|
-
|
|
432
|
-
- Learn more about [agents](https://mastra.ai/docs/agents/overview)
|
|
433
|
-
- Give your agent its own [tools](https://mastra.ai/docs/agents/using-tools)
|
|
434
|
-
- Add human-like [memory](https://mastra.ai/docs/agents/agent-memory) to your agent
|
|
435
|
-
|
|
436
|
-
When you're ready, read more about how Mastra integrates with AI SDK UI and React, and how to deploy your agent anywhere:
|
|
437
|
-
|
|
438
|
-
- Integrate Mastra with [AI SDK UI](https://mastra.ai/guides/build-your-ui/ai-sdk-ui)
|
|
439
|
-
- Deploy your agent [anywhere](https://mastra.ai/docs/deployment/overview)
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
# Building an AI Recruiter
|
|
2
|
-
|
|
3
|
-
In this guide, you'll learn how Mastra helps you build workflows with LLMs.
|
|
4
|
-
|
|
5
|
-
You'll create a workflow that gathers information from a candidate's resume, then branches to either a technical or behavioral question based on the candidate's profile. Along the way, you'll see how to structure workflow steps, handle branching, and integrate LLM calls.
|
|
6
|
-
|
|
7
|
-
## Prerequisites
|
|
8
|
-
|
|
9
|
-
- Node.js `v22.13.0` or later installed
|
|
10
|
-
- An API key from a supported [Model Provider](https://mastra.ai/models)
|
|
11
|
-
- An existing Mastra project (Follow the [installation guide](https://mastra.ai/guides/getting-started/quickstart) to set up a new project)
|
|
12
|
-
|
|
13
|
-
## Building the Workflow
|
|
14
|
-
|
|
15
|
-
Set up the Workflow, define steps to extract and classify candidate data, and then ask suitable follow-up questions.
|
|
16
|
-
|
|
17
|
-
1. Create a new file `src/mastra/workflows/candidate-workflow.ts` and define your workflow:
|
|
18
|
-
|
|
19
|
-
```ts
|
|
20
|
-
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
21
|
-
import { z } from "zod";
|
|
22
|
-
|
|
23
|
-
export const candidateWorkflow = createWorkflow({
|
|
24
|
-
id: "candidate-workflow",
|
|
25
|
-
inputSchema: z.object({
|
|
26
|
-
resumeText: z.string(),
|
|
27
|
-
}),
|
|
28
|
-
outputSchema: z.object({
|
|
29
|
-
askAboutSpecialty: z.object({
|
|
30
|
-
question: z.string(),
|
|
31
|
-
}),
|
|
32
|
-
askAboutRole: z.object({
|
|
33
|
-
question: z.string(),
|
|
34
|
-
}),
|
|
35
|
-
}),
|
|
36
|
-
}).commit();
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
2. You want to extract candidate details from the resume text and classify the person as "technical" or "non-technical". This step calls an LLM to parse the resume and returns structured JSON, including the name, technical status, specialty, and the original resume text. Defined through the `inputSchema` you get access to the `resumeText` inside `execute()`. Use it to prompt an LLM and return the organized fields.
|
|
40
|
-
|
|
41
|
-
To the existing `src/mastra/workflows/candidate-workflow.ts` file add the following:
|
|
42
|
-
|
|
43
|
-
```ts
|
|
44
|
-
import { Agent } from "@mastra/core/agent";
|
|
45
|
-
|
|
46
|
-
const recruiter = new Agent({
|
|
47
|
-
id: "recruiter-agent",
|
|
48
|
-
name: "Recruiter Agent",
|
|
49
|
-
instructions: `You are a recruiter.`,
|
|
50
|
-
model: "openai/gpt-5.1",
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const gatherCandidateInfo = createStep({
|
|
54
|
-
id: "gatherCandidateInfo",
|
|
55
|
-
inputSchema: z.object({
|
|
56
|
-
resumeText: z.string(),
|
|
57
|
-
}),
|
|
58
|
-
outputSchema: z.object({
|
|
59
|
-
candidateName: z.string(),
|
|
60
|
-
isTechnical: z.boolean(),
|
|
61
|
-
specialty: z.string(),
|
|
62
|
-
resumeText: z.string(),
|
|
63
|
-
}),
|
|
64
|
-
execute: async ({ inputData }) => {
|
|
65
|
-
const resumeText = inputData?.resumeText;
|
|
66
|
-
|
|
67
|
-
const prompt = `Extract details from the resume text:
|
|
68
|
-
"${resumeText}"`;
|
|
69
|
-
|
|
70
|
-
const res = await recruiter.generate(prompt, {
|
|
71
|
-
structuredOutput: {
|
|
72
|
-
schema: z.object({
|
|
73
|
-
candidateName: z.string(),
|
|
74
|
-
isTechnical: z.boolean(),
|
|
75
|
-
specialty: z.string(),
|
|
76
|
-
resumeText: z.string(),
|
|
77
|
-
}),
|
|
78
|
-
},
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
return res.object;
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
Since you're using a Recruiter agent inside `execute()` you need to define it above the step and add the necessary imports.
|
|
87
|
-
|
|
88
|
-
3. This step prompts a candidate who is identified as "technical" for more information about how they got into their specialty. It uses the entire resume text so the LLM can craft a relevant follow-up question.
|
|
89
|
-
|
|
90
|
-
To the existing `src/mastra/workflows/candidate-workflow.ts` file add the following:
|
|
91
|
-
|
|
92
|
-
```ts
|
|
93
|
-
const askAboutSpecialty = createStep({
|
|
94
|
-
id: "askAboutSpecialty",
|
|
95
|
-
inputSchema: z.object({
|
|
96
|
-
candidateName: z.string(),
|
|
97
|
-
isTechnical: z.boolean(),
|
|
98
|
-
specialty: z.string(),
|
|
99
|
-
resumeText: z.string(),
|
|
100
|
-
}),
|
|
101
|
-
outputSchema: z.object({
|
|
102
|
-
question: z.string(),
|
|
103
|
-
}),
|
|
104
|
-
execute: async ({ inputData: candidateInfo }) => {
|
|
105
|
-
const prompt = `You are a recruiter. Given the resume below, craft a short question
|
|
106
|
-
for ${candidateInfo?.candidateName} about how they got into "${candidateInfo?.specialty}".
|
|
107
|
-
Resume: ${candidateInfo?.resumeText}`;
|
|
108
|
-
const res = await recruiter.generate(prompt);
|
|
109
|
-
|
|
110
|
-
return { question: res?.text?.trim() || "" };
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
4. If the candidate is "non-technical", you want a different follow-up question. This step asks what interests them most about the role, again referencing their complete resume text. The `execute()` function solicits a role-focused query from the LLM.
|
|
116
|
-
|
|
117
|
-
To the existing `src/mastra/workflows/candidate-workflow.ts` file add the following:
|
|
118
|
-
|
|
119
|
-
```ts
|
|
120
|
-
const askAboutRole = createStep({
|
|
121
|
-
id: "askAboutRole",
|
|
122
|
-
inputSchema: z.object({
|
|
123
|
-
candidateName: z.string(),
|
|
124
|
-
isTechnical: z.boolean(),
|
|
125
|
-
specialty: z.string(),
|
|
126
|
-
resumeText: z.string(),
|
|
127
|
-
}),
|
|
128
|
-
outputSchema: z.object({
|
|
129
|
-
question: z.string(),
|
|
130
|
-
}),
|
|
131
|
-
execute: async ({ inputData: candidateInfo }) => {
|
|
132
|
-
const prompt = `You are a recruiter. Given the resume below, craft a short question
|
|
133
|
-
for ${candidateInfo?.candidateName} asking what interests them most about this role.
|
|
134
|
-
Resume: ${candidateInfo?.resumeText}`;
|
|
135
|
-
const res = await recruiter.generate(prompt);
|
|
136
|
-
return { question: res?.text?.trim() || "" };
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
5. You now combine the steps to implement branching logic based on the candidate's technical status. The workflow first gathers candidate data, then either asks about their specialty or about their role, depending on `isTechnical`. This is done by chaining `gatherCandidateInfo` with `askAboutSpecialty` and `askAboutRole`.
|
|
142
|
-
|
|
143
|
-
To the existing `src/mastra/workflows/candidate-workflow.ts` file change the `candidateWorkflow` like so:
|
|
144
|
-
|
|
145
|
-
```ts
|
|
146
|
-
export const candidateWorkflow = createWorkflow({
|
|
147
|
-
id: "candidate-workflow",
|
|
148
|
-
inputSchema: z.object({
|
|
149
|
-
resumeText: z.string(),
|
|
150
|
-
}),
|
|
151
|
-
outputSchema: z.object({
|
|
152
|
-
askAboutSpecialty: z.object({
|
|
153
|
-
question: z.string(),
|
|
154
|
-
}),
|
|
155
|
-
askAboutRole: z.object({
|
|
156
|
-
question: z.string(),
|
|
157
|
-
}),
|
|
158
|
-
}),
|
|
159
|
-
})
|
|
160
|
-
.then(gatherCandidateInfo)
|
|
161
|
-
.branch([
|
|
162
|
-
[async ({ inputData: { isTechnical } }) => isTechnical, askAboutSpecialty],
|
|
163
|
-
[async ({ inputData: { isTechnical } }) => !isTechnical, askAboutRole],
|
|
164
|
-
])
|
|
165
|
-
.commit();
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
6. In your `src/mastra/index.ts` file, register the workflow:
|
|
169
|
-
|
|
170
|
-
```ts
|
|
171
|
-
import { Mastra } from "@mastra/core";
|
|
172
|
-
import { candidateWorkflow } from "./workflows/candidate-workflow";
|
|
173
|
-
|
|
174
|
-
export const mastra = new Mastra({
|
|
175
|
-
workflows: { candidateWorkflow },
|
|
176
|
-
});
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
## Testing the Workflow
|
|
180
|
-
|
|
181
|
-
You can test your workflow inside [Studio](https://mastra.ai/docs/getting-started/studio) by starting the development server:
|
|
182
|
-
|
|
183
|
-
```bash
|
|
184
|
-
mastra dev
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
In the sidebar, navigate to **Workflows** and select **candidate-workflow**. In the middle you'll see a graph view of your workflow and on the right sidebar the **Run** tab is selected by default. Inside this tab you can enter a resume text, for example:
|
|
188
|
-
|
|
189
|
-
```text
|
|
190
|
-
Knowledgeable Software Engineer with more than 10 years of experience in software development. Proven expertise in the design and development of software databases and optimization of user interfaces.
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
After entering the resume text, press the **Run** button. You should now see two status boxes (`GatherCandidateInfo` and `AskAboutSpecialty`) which contain the output of the workflow steps.
|
|
194
|
-
|
|
195
|
-
You can also test the workflow programmatically by calling [`.createRun()`](https://mastra.ai/reference/workflows/workflow-methods/create-run) and [`.start()`](https://mastra.ai/reference/workflows/run-methods/start). Create a new file `src/test-workflow.ts` and add the following:
|
|
196
|
-
|
|
197
|
-
```ts
|
|
198
|
-
import { mastra } from "./mastra";
|
|
199
|
-
|
|
200
|
-
const run = await mastra.getWorkflow("candidateWorkflow").createRun();
|
|
201
|
-
|
|
202
|
-
const res = await run.start({
|
|
203
|
-
inputData: {
|
|
204
|
-
resumeText:
|
|
205
|
-
"Knowledgeable Software Engineer with more than 10 years of experience in software development. Proven expertise in the design and development of software databases and optimization of user interfaces.",
|
|
206
|
-
},
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
// Dump the complete workflow result (includes status, steps and result)
|
|
210
|
-
console.log(JSON.stringify(res, null, 2));
|
|
211
|
-
|
|
212
|
-
// Get the workflow output value
|
|
213
|
-
if (res.status === "success") {
|
|
214
|
-
const question =
|
|
215
|
-
res.result.askAboutRole?.question ?? res.result.askAboutSpecialty?.question;
|
|
216
|
-
|
|
217
|
-
console.log(`Output value: ${question}`);
|
|
218
|
-
}
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
Now, run the workflow and get output in your terminal:
|
|
222
|
-
|
|
223
|
-
```bash
|
|
224
|
-
npx tsx src/test-workflow.ts
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
You've just built a workflow to parse a resume and decide which question to ask based on the candidate's technical abilities. Congrats and happy hacking!
|