@mastra/mcp-docs-server 1.1.5 → 1.1.6
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/docs/agents/adding-voice.md +349 -0
- package/.docs/docs/agents/agent-approval.md +558 -0
- package/.docs/docs/agents/agent-memory.md +209 -0
- package/.docs/docs/agents/guardrails.md +374 -0
- package/.docs/docs/agents/network-approval.md +275 -0
- package/.docs/docs/agents/networks.md +299 -0
- package/.docs/docs/agents/overview.md +304 -0
- package/.docs/docs/agents/processors.md +622 -0
- package/.docs/docs/agents/structured-output.md +273 -0
- package/.docs/docs/agents/supervisor-agents.md +304 -0
- package/.docs/docs/agents/using-tools.md +214 -0
- package/.docs/docs/build-with-ai/mcp-docs-server.md +238 -0
- package/.docs/docs/build-with-ai/skills.md +35 -0
- package/.docs/docs/community/contributing-templates.md +3 -0
- package/.docs/docs/community/discord.md +9 -0
- package/.docs/docs/community/licensing.md +66 -0
- package/.docs/docs/deployment/cloud-providers.md +15 -0
- package/.docs/docs/deployment/mastra-server.md +122 -0
- package/.docs/docs/deployment/monorepo.md +142 -0
- package/.docs/docs/deployment/overview.md +62 -0
- package/.docs/docs/deployment/studio.md +239 -0
- package/.docs/docs/deployment/web-framework.md +52 -0
- package/.docs/docs/deployment/workflow-runners.md +9 -0
- package/.docs/docs/evals/built-in-scorers.md +47 -0
- package/.docs/docs/evals/custom-scorers.md +519 -0
- package/.docs/docs/evals/overview.md +141 -0
- package/.docs/docs/evals/running-in-ci.md +124 -0
- package/.docs/docs/getting-started/build-with-ai.md +68 -0
- package/.docs/docs/getting-started/manual-install.md +226 -0
- package/.docs/docs/getting-started/project-structure.md +60 -0
- package/.docs/docs/getting-started/start.md +28 -0
- package/.docs/docs/getting-started/studio.md +101 -0
- package/.docs/docs/index.md +43 -0
- package/.docs/docs/mastra-cloud/deployment.md +77 -0
- package/.docs/docs/mastra-cloud/observability.md +38 -0
- package/.docs/docs/mastra-cloud/overview.md +23 -0
- package/.docs/docs/mastra-cloud/setup.md +42 -0
- package/.docs/docs/mastra-cloud/studio.md +24 -0
- package/.docs/docs/mastra-code/configuration.md +299 -0
- package/.docs/docs/mastra-code/customization.md +228 -0
- package/.docs/docs/mastra-code/modes.md +104 -0
- package/.docs/docs/mastra-code/overview.md +135 -0
- package/.docs/docs/mastra-code/tools.md +229 -0
- package/.docs/docs/mcp/overview.md +373 -0
- package/.docs/docs/mcp/publishing-mcp-server.md +95 -0
- package/.docs/docs/memory/memory-processors.md +314 -0
- package/.docs/docs/memory/message-history.md +260 -0
- package/.docs/docs/memory/observational-memory.md +248 -0
- package/.docs/docs/memory/overview.md +45 -0
- package/.docs/docs/memory/semantic-recall.md +272 -0
- package/.docs/docs/memory/storage.md +261 -0
- package/.docs/docs/memory/working-memory.md +400 -0
- package/.docs/docs/observability/datasets/overview.md +198 -0
- package/.docs/docs/observability/datasets/running-experiments.md +274 -0
- package/.docs/docs/observability/logging.md +99 -0
- package/.docs/docs/observability/overview.md +70 -0
- package/.docs/docs/observability/tracing/bridges/otel.md +209 -0
- package/.docs/docs/observability/tracing/exporters/arize.md +272 -0
- package/.docs/docs/observability/tracing/exporters/braintrust.md +111 -0
- package/.docs/docs/observability/tracing/exporters/cloud.md +127 -0
- package/.docs/docs/observability/tracing/exporters/datadog.md +187 -0
- package/.docs/docs/observability/tracing/exporters/default.md +209 -0
- package/.docs/docs/observability/tracing/exporters/laminar.md +100 -0
- package/.docs/docs/observability/tracing/exporters/langfuse.md +213 -0
- package/.docs/docs/observability/tracing/exporters/langsmith.md +198 -0
- package/.docs/docs/observability/tracing/exporters/otel.md +476 -0
- package/.docs/docs/observability/tracing/exporters/posthog.md +148 -0
- package/.docs/docs/observability/tracing/exporters/sentry.md +208 -0
- package/.docs/docs/observability/tracing/overview.md +1112 -0
- package/.docs/docs/observability/tracing/processors/sensitive-data-filter.md +300 -0
- package/.docs/docs/rag/chunking-and-embedding.md +183 -0
- package/.docs/docs/rag/graph-rag.md +215 -0
- package/.docs/docs/rag/overview.md +72 -0
- package/.docs/docs/rag/retrieval.md +515 -0
- package/.docs/docs/rag/vector-databases.md +645 -0
- package/.docs/docs/server/auth/auth0.md +220 -0
- package/.docs/docs/server/auth/better-auth.md +203 -0
- package/.docs/docs/server/auth/clerk.md +132 -0
- package/.docs/docs/server/auth/composite-auth.md +234 -0
- package/.docs/docs/server/auth/custom-auth-provider.md +513 -0
- package/.docs/docs/server/auth/firebase.md +272 -0
- package/.docs/docs/server/auth/jwt.md +110 -0
- package/.docs/docs/server/auth/simple-auth.md +180 -0
- package/.docs/docs/server/auth/supabase.md +117 -0
- package/.docs/docs/server/auth/workos.md +186 -0
- package/.docs/docs/server/auth.md +38 -0
- package/.docs/docs/server/custom-adapters.md +378 -0
- package/.docs/docs/server/custom-api-routes.md +267 -0
- package/.docs/docs/server/mastra-client.md +243 -0
- package/.docs/docs/server/mastra-server.md +71 -0
- package/.docs/docs/server/middleware.md +225 -0
- package/.docs/docs/server/request-context.md +471 -0
- package/.docs/docs/server/server-adapters.md +547 -0
- package/.docs/docs/streaming/events.md +237 -0
- package/.docs/docs/streaming/overview.md +175 -0
- package/.docs/docs/streaming/tool-streaming.md +175 -0
- package/.docs/docs/streaming/workflow-streaming.md +109 -0
- package/.docs/docs/voice/overview.md +959 -0
- package/.docs/docs/voice/speech-to-speech.md +102 -0
- package/.docs/docs/voice/speech-to-text.md +79 -0
- package/.docs/docs/voice/text-to-speech.md +83 -0
- package/.docs/docs/workflows/agents-and-tools.md +166 -0
- package/.docs/docs/workflows/control-flow.md +822 -0
- package/.docs/docs/workflows/error-handling.md +360 -0
- package/.docs/docs/workflows/human-in-the-loop.md +215 -0
- package/.docs/docs/workflows/overview.md +370 -0
- package/.docs/docs/workflows/snapshots.md +238 -0
- package/.docs/docs/workflows/suspend-and-resume.md +205 -0
- package/.docs/docs/workflows/time-travel.md +309 -0
- package/.docs/docs/workflows/workflow-state.md +181 -0
- package/.docs/docs/workspace/filesystem.md +164 -0
- package/.docs/docs/workspace/overview.md +239 -0
- package/.docs/docs/workspace/sandbox.md +63 -0
- package/.docs/docs/workspace/search.md +243 -0
- package/.docs/docs/workspace/skills.md +169 -0
- package/.docs/guides/agent-frameworks/ai-sdk.md +140 -0
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +1499 -0
- package/.docs/guides/build-your-ui/assistant-ui.md +156 -0
- package/.docs/guides/build-your-ui/copilotkit.md +289 -0
- package/.docs/guides/deployment/amazon-ec2.md +130 -0
- package/.docs/guides/deployment/aws-lambda.md +248 -0
- package/.docs/guides/deployment/azure-app-services.md +114 -0
- package/.docs/guides/deployment/cloudflare.md +99 -0
- package/.docs/guides/deployment/digital-ocean.md +168 -0
- package/.docs/guides/deployment/inngest.md +682 -0
- package/.docs/guides/deployment/netlify.md +77 -0
- package/.docs/guides/deployment/vercel.md +101 -0
- package/.docs/guides/getting-started/astro.md +398 -0
- package/.docs/guides/getting-started/electron.md +504 -0
- package/.docs/guides/getting-started/express.md +251 -0
- package/.docs/guides/getting-started/hono.md +190 -0
- package/.docs/guides/getting-started/next-js.md +347 -0
- package/.docs/guides/getting-started/nuxt.md +497 -0
- package/.docs/guides/getting-started/quickstart.md +67 -0
- package/.docs/guides/getting-started/sveltekit.md +296 -0
- package/.docs/guides/getting-started/vite-react.md +425 -0
- package/.docs/guides/guide/ai-recruiter.md +226 -0
- package/.docs/guides/guide/chef-michel.md +211 -0
- package/.docs/guides/guide/code-review-bot.md +226 -0
- package/.docs/guides/guide/dev-assistant.md +307 -0
- package/.docs/guides/guide/docs-manager.md +238 -0
- package/.docs/guides/guide/github-actions-pr-description.md +236 -0
- package/.docs/guides/guide/notes-mcp-server.md +416 -0
- package/.docs/guides/guide/research-assistant.md +348 -0
- package/.docs/guides/guide/research-coordinator.md +416 -0
- package/.docs/guides/guide/stock-agent.md +132 -0
- package/.docs/guides/guide/web-search.md +320 -0
- package/.docs/guides/guide/whatsapp-chat-bot.md +405 -0
- package/.docs/guides/index.md +3 -0
- package/.docs/guides/migrations/agentnetwork.md +97 -0
- package/.docs/guides/migrations/ai-sdk-v4-to-v5.md +112 -0
- package/.docs/guides/migrations/network-to-supervisor.md +261 -0
- package/.docs/guides/migrations/upgrade-to-v1/agent.md +404 -0
- package/.docs/guides/migrations/upgrade-to-v1/cli.md +57 -0
- package/.docs/guides/migrations/upgrade-to-v1/client.md +337 -0
- package/.docs/guides/migrations/upgrade-to-v1/deployment.md +37 -0
- package/.docs/guides/migrations/upgrade-to-v1/evals.md +239 -0
- package/.docs/guides/migrations/upgrade-to-v1/mastra.md +143 -0
- package/.docs/guides/migrations/upgrade-to-v1/mcp.md +97 -0
- package/.docs/guides/migrations/upgrade-to-v1/memory.md +285 -0
- package/.docs/guides/migrations/upgrade-to-v1/overview.md +119 -0
- package/.docs/guides/migrations/upgrade-to-v1/processors.md +68 -0
- package/.docs/guides/migrations/upgrade-to-v1/rag.md +42 -0
- package/.docs/guides/migrations/upgrade-to-v1/storage.md +553 -0
- package/.docs/guides/migrations/upgrade-to-v1/tools.md +180 -0
- package/.docs/guides/migrations/upgrade-to-v1/tracing.md +412 -0
- package/.docs/guides/migrations/upgrade-to-v1/vectors.md +87 -0
- package/.docs/guides/migrations/upgrade-to-v1/voice.md +30 -0
- package/.docs/guides/migrations/upgrade-to-v1/workflows.md +341 -0
- package/.docs/guides/migrations/vnext-to-standard-apis.md +362 -0
- package/.docs/models/embeddings.md +161 -0
- package/.docs/models/gateways/azure-openai.md +128 -0
- package/.docs/models/gateways/custom-gateways.md +545 -0
- package/.docs/models/gateways/netlify.md +88 -0
- package/.docs/models/gateways/openrouter.md +219 -0
- package/.docs/models/gateways/vercel.md +225 -0
- package/.docs/models/gateways.md +14 -0
- package/.docs/models/index.md +286 -0
- package/.docs/models/providers/302ai.md +134 -0
- package/.docs/models/providers/abacus.md +125 -0
- package/.docs/models/providers/agentrouter.md +90 -0
- package/.docs/models/providers/aihubmix.md +107 -0
- package/.docs/models/providers/alibaba-cn.md +135 -0
- package/.docs/models/providers/alibaba.md +111 -0
- package/.docs/models/providers/amazon-bedrock.md +33 -0
- package/.docs/models/providers/anthropic.md +153 -0
- package/.docs/models/providers/azure.md +33 -0
- package/.docs/models/providers/bailing.md +72 -0
- package/.docs/models/providers/baseten.md +77 -0
- package/.docs/models/providers/berget.md +78 -0
- package/.docs/models/providers/cerebras.md +101 -0
- package/.docs/models/providers/chutes.md +136 -0
- package/.docs/models/providers/cloudflare-ai-gateway.md +33 -0
- package/.docs/models/providers/cloudflare-workers-ai.md +109 -0
- package/.docs/models/providers/cohere.md +33 -0
- package/.docs/models/providers/cortecs.md +91 -0
- package/.docs/models/providers/deepinfra.md +112 -0
- package/.docs/models/providers/deepseek.md +88 -0
- package/.docs/models/providers/fastrouter.md +84 -0
- package/.docs/models/providers/fireworks-ai.md +89 -0
- package/.docs/models/providers/firmware.md +85 -0
- package/.docs/models/providers/friendli.md +78 -0
- package/.docs/models/providers/github-models.md +125 -0
- package/.docs/models/providers/google-vertex.md +33 -0
- package/.docs/models/providers/google.md +159 -0
- package/.docs/models/providers/groq.md +107 -0
- package/.docs/models/providers/helicone.md +161 -0
- package/.docs/models/providers/huggingface.md +90 -0
- package/.docs/models/providers/iflowcn.md +84 -0
- package/.docs/models/providers/inception.md +72 -0
- package/.docs/models/providers/inference.md +79 -0
- package/.docs/models/providers/io-intelligence.md +87 -0
- package/.docs/models/providers/io-net.md +87 -0
- package/.docs/models/providers/jiekou.md +131 -0
- package/.docs/models/providers/kilo.md +333 -0
- package/.docs/models/providers/kimi-for-coding.md +100 -0
- package/.docs/models/providers/kuae-cloud-coding-plan.md +71 -0
- package/.docs/models/providers/llama.md +77 -0
- package/.docs/models/providers/lmstudio.md +73 -0
- package/.docs/models/providers/lucidquery.md +72 -0
- package/.docs/models/providers/minimax-cn-coding-plan.md +102 -0
- package/.docs/models/providers/minimax-cn.md +102 -0
- package/.docs/models/providers/minimax-coding-plan.md +102 -0
- package/.docs/models/providers/minimax.md +104 -0
- package/.docs/models/providers/mistral.md +124 -0
- package/.docs/models/providers/moark.md +72 -0
- package/.docs/models/providers/modelscope.md +77 -0
- package/.docs/models/providers/moonshotai-cn.md +76 -0
- package/.docs/models/providers/moonshotai.md +76 -0
- package/.docs/models/providers/morph.md +73 -0
- package/.docs/models/providers/nano-gpt.md +103 -0
- package/.docs/models/providers/nebius.md +116 -0
- package/.docs/models/providers/nova.md +72 -0
- package/.docs/models/providers/novita-ai.md +154 -0
- package/.docs/models/providers/nvidia.md +141 -0
- package/.docs/models/providers/ollama-cloud.md +103 -0
- package/.docs/models/providers/ollama.md +33 -0
- package/.docs/models/providers/openai.md +193 -0
- package/.docs/models/providers/opencode.md +100 -0
- package/.docs/models/providers/ovhcloud.md +83 -0
- package/.docs/models/providers/perplexity.md +100 -0
- package/.docs/models/providers/poe.md +183 -0
- package/.docs/models/providers/privatemode-ai.md +75 -0
- package/.docs/models/providers/requesty.md +90 -0
- package/.docs/models/providers/scaleway.md +84 -0
- package/.docs/models/providers/siliconflow-cn.md +138 -0
- package/.docs/models/providers/siliconflow.md +140 -0
- package/.docs/models/providers/stackit.md +78 -0
- package/.docs/models/providers/stepfun.md +73 -0
- package/.docs/models/providers/submodel.md +79 -0
- package/.docs/models/providers/synthetic.md +96 -0
- package/.docs/models/providers/togetherai.md +115 -0
- package/.docs/models/providers/upstage.md +73 -0
- package/.docs/models/providers/venice.md +95 -0
- package/.docs/models/providers/vivgrid.md +106 -0
- package/.docs/models/providers/vultr.md +75 -0
- package/.docs/models/providers/wandb.md +80 -0
- package/.docs/models/providers/xai.md +141 -0
- package/.docs/models/providers/xiaomi.md +71 -0
- package/.docs/models/providers/zai-coding-plan.md +80 -0
- package/.docs/models/providers/zai.md +79 -0
- package/.docs/models/providers/zenmux.md +161 -0
- package/.docs/models/providers/zhipuai-coding-plan.md +79 -0
- package/.docs/models/providers/zhipuai.md +79 -0
- package/.docs/models/providers.md +81 -0
- package/.docs/reference/agents/agent.md +141 -0
- package/.docs/reference/agents/generate.md +186 -0
- package/.docs/reference/agents/generateLegacy.md +173 -0
- package/.docs/reference/agents/getDefaultGenerateOptions.md +36 -0
- package/.docs/reference/agents/getDefaultOptions.md +34 -0
- package/.docs/reference/agents/getDefaultStreamOptions.md +36 -0
- package/.docs/reference/agents/getDescription.md +21 -0
- package/.docs/reference/agents/getInstructions.md +34 -0
- package/.docs/reference/agents/getLLM.md +37 -0
- package/.docs/reference/agents/getMemory.md +34 -0
- package/.docs/reference/agents/getModel.md +34 -0
- package/.docs/reference/agents/getTools.md +29 -0
- package/.docs/reference/agents/getVoice.md +34 -0
- package/.docs/reference/agents/listAgents.md +35 -0
- package/.docs/reference/agents/listScorers.md +34 -0
- package/.docs/reference/agents/listTools.md +34 -0
- package/.docs/reference/agents/listWorkflows.md +34 -0
- package/.docs/reference/agents/network.md +133 -0
- package/.docs/reference/ai-sdk/chat-route.md +82 -0
- package/.docs/reference/ai-sdk/handle-chat-stream.md +53 -0
- package/.docs/reference/ai-sdk/handle-network-stream.md +37 -0
- package/.docs/reference/ai-sdk/handle-workflow-stream.md +55 -0
- package/.docs/reference/ai-sdk/network-route.md +74 -0
- package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +231 -0
- package/.docs/reference/ai-sdk/to-ai-sdk-v4-messages.md +79 -0
- package/.docs/reference/ai-sdk/to-ai-sdk-v5-messages.md +76 -0
- package/.docs/reference/ai-sdk/with-mastra.md +59 -0
- package/.docs/reference/ai-sdk/workflow-route.md +79 -0
- package/.docs/reference/auth/auth0.md +73 -0
- package/.docs/reference/auth/better-auth.md +71 -0
- package/.docs/reference/auth/clerk.md +36 -0
- package/.docs/reference/auth/firebase.md +80 -0
- package/.docs/reference/auth/jwt.md +26 -0
- package/.docs/reference/auth/supabase.md +33 -0
- package/.docs/reference/auth/workos.md +84 -0
- package/.docs/reference/cli/create-mastra.md +137 -0
- package/.docs/reference/cli/mastra.md +336 -0
- package/.docs/reference/client-js/agents.md +437 -0
- package/.docs/reference/client-js/error-handling.md +16 -0
- package/.docs/reference/client-js/logs.md +24 -0
- package/.docs/reference/client-js/mastra-client.md +63 -0
- package/.docs/reference/client-js/memory.md +221 -0
- package/.docs/reference/client-js/observability.md +72 -0
- package/.docs/reference/client-js/telemetry.md +20 -0
- package/.docs/reference/client-js/tools.md +44 -0
- package/.docs/reference/client-js/vectors.md +79 -0
- package/.docs/reference/client-js/workflows.md +199 -0
- package/.docs/reference/configuration.md +752 -0
- package/.docs/reference/core/addGateway.md +42 -0
- package/.docs/reference/core/getAgent.md +21 -0
- package/.docs/reference/core/getAgentById.md +21 -0
- package/.docs/reference/core/getDeployer.md +22 -0
- package/.docs/reference/core/getGateway.md +38 -0
- package/.docs/reference/core/getGatewayById.md +41 -0
- package/.docs/reference/core/getLogger.md +22 -0
- package/.docs/reference/core/getMCPServer.md +47 -0
- package/.docs/reference/core/getMCPServerById.md +55 -0
- package/.docs/reference/core/getMemory.md +50 -0
- package/.docs/reference/core/getScorer.md +54 -0
- package/.docs/reference/core/getScorerById.md +54 -0
- package/.docs/reference/core/getServer.md +22 -0
- package/.docs/reference/core/getStorage.md +22 -0
- package/.docs/reference/core/getStoredAgentById.md +89 -0
- package/.docs/reference/core/getTelemetry.md +22 -0
- package/.docs/reference/core/getVector.md +22 -0
- package/.docs/reference/core/getWorkflow.md +42 -0
- package/.docs/reference/core/listAgents.md +21 -0
- package/.docs/reference/core/listGateways.md +40 -0
- package/.docs/reference/core/listLogs.md +38 -0
- package/.docs/reference/core/listLogsByRunId.md +36 -0
- package/.docs/reference/core/listMCPServers.md +55 -0
- package/.docs/reference/core/listMemory.md +56 -0
- package/.docs/reference/core/listScorers.md +29 -0
- package/.docs/reference/core/listStoredAgents.md +93 -0
- package/.docs/reference/core/listVectors.md +22 -0
- package/.docs/reference/core/listWorkflows.md +21 -0
- package/.docs/reference/core/mastra-class.md +66 -0
- package/.docs/reference/core/mastra-model-gateway.md +153 -0
- package/.docs/reference/core/setLogger.md +26 -0
- package/.docs/reference/core/setStorage.md +27 -0
- package/.docs/reference/datasets/addItem.md +37 -0
- package/.docs/reference/datasets/addItems.md +35 -0
- package/.docs/reference/datasets/compareExperiments.md +52 -0
- package/.docs/reference/datasets/create.md +51 -0
- package/.docs/reference/datasets/dataset.md +82 -0
- package/.docs/reference/datasets/datasets-manager.md +94 -0
- package/.docs/reference/datasets/delete.md +25 -0
- package/.docs/reference/datasets/deleteExperiment.md +27 -0
- package/.docs/reference/datasets/deleteItem.md +27 -0
- package/.docs/reference/datasets/deleteItems.md +29 -0
- package/.docs/reference/datasets/get.md +31 -0
- package/.docs/reference/datasets/getDetails.md +47 -0
- package/.docs/reference/datasets/getExperiment.md +30 -0
- package/.docs/reference/datasets/getItem.md +33 -0
- package/.docs/reference/datasets/getItemHistory.md +31 -0
- package/.docs/reference/datasets/list.md +31 -0
- package/.docs/reference/datasets/listExperimentResults.md +39 -0
- package/.docs/reference/datasets/listExperiments.md +33 -0
- package/.docs/reference/datasets/listItems.md +46 -0
- package/.docs/reference/datasets/listVersions.md +33 -0
- package/.docs/reference/datasets/startExperiment.md +62 -0
- package/.docs/reference/datasets/startExperimentAsync.md +43 -0
- package/.docs/reference/datasets/update.md +48 -0
- package/.docs/reference/datasets/updateItem.md +38 -0
- package/.docs/reference/deployer/cloudflare.md +79 -0
- package/.docs/reference/deployer/netlify.md +80 -0
- package/.docs/reference/deployer/vercel.md +91 -0
- package/.docs/reference/deployer.md +100 -0
- package/.docs/reference/evals/answer-relevancy.md +105 -0
- package/.docs/reference/evals/answer-similarity.md +99 -0
- package/.docs/reference/evals/bias.md +120 -0
- package/.docs/reference/evals/completeness.md +136 -0
- package/.docs/reference/evals/content-similarity.md +101 -0
- package/.docs/reference/evals/context-precision.md +196 -0
- package/.docs/reference/evals/context-relevance.md +531 -0
- package/.docs/reference/evals/create-scorer.md +270 -0
- package/.docs/reference/evals/faithfulness.md +114 -0
- package/.docs/reference/evals/hallucination.md +213 -0
- package/.docs/reference/evals/keyword-coverage.md +128 -0
- package/.docs/reference/evals/mastra-scorer.md +123 -0
- package/.docs/reference/evals/noise-sensitivity.md +675 -0
- package/.docs/reference/evals/prompt-alignment.md +614 -0
- package/.docs/reference/evals/run-evals.md +179 -0
- package/.docs/reference/evals/scorer-utils.md +326 -0
- package/.docs/reference/evals/textual-difference.md +113 -0
- package/.docs/reference/evals/tone-consistency.md +119 -0
- package/.docs/reference/evals/tool-call-accuracy.md +533 -0
- package/.docs/reference/evals/toxicity.md +123 -0
- package/.docs/reference/harness/harness-class.md +708 -0
- package/.docs/reference/index.md +277 -0
- package/.docs/reference/logging/pino-logger.md +117 -0
- package/.docs/reference/mastra-code/createMastraCode.md +108 -0
- package/.docs/reference/memory/clone-utilities.md +199 -0
- package/.docs/reference/memory/cloneThread.md +130 -0
- package/.docs/reference/memory/createThread.md +68 -0
- package/.docs/reference/memory/deleteMessages.md +38 -0
- package/.docs/reference/memory/getThreadById.md +24 -0
- package/.docs/reference/memory/listThreads.md +145 -0
- package/.docs/reference/memory/memory-class.md +147 -0
- package/.docs/reference/memory/observational-memory.md +565 -0
- package/.docs/reference/memory/recall.md +91 -0
- package/.docs/reference/observability/tracing/bridges/otel.md +131 -0
- package/.docs/reference/observability/tracing/configuration.md +178 -0
- package/.docs/reference/observability/tracing/exporters/arize.md +141 -0
- package/.docs/reference/observability/tracing/exporters/braintrust.md +93 -0
- package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +163 -0
- package/.docs/reference/observability/tracing/exporters/console-exporter.md +138 -0
- package/.docs/reference/observability/tracing/exporters/datadog.md +116 -0
- package/.docs/reference/observability/tracing/exporters/default-exporter.md +174 -0
- package/.docs/reference/observability/tracing/exporters/laminar.md +78 -0
- package/.docs/reference/observability/tracing/exporters/langfuse.md +134 -0
- package/.docs/reference/observability/tracing/exporters/langsmith.md +108 -0
- package/.docs/reference/observability/tracing/exporters/otel.md +199 -0
- package/.docs/reference/observability/tracing/exporters/posthog.md +92 -0
- package/.docs/reference/observability/tracing/exporters/sentry.md +184 -0
- package/.docs/reference/observability/tracing/instances.md +107 -0
- package/.docs/reference/observability/tracing/interfaces.md +743 -0
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +144 -0
- package/.docs/reference/observability/tracing/spans.md +224 -0
- package/.docs/reference/processors/batch-parts-processor.md +61 -0
- package/.docs/reference/processors/language-detector.md +82 -0
- package/.docs/reference/processors/message-history-processor.md +85 -0
- package/.docs/reference/processors/moderation-processor.md +104 -0
- package/.docs/reference/processors/pii-detector.md +108 -0
- package/.docs/reference/processors/processor-interface.md +521 -0
- package/.docs/reference/processors/prompt-injection-detector.md +72 -0
- package/.docs/reference/processors/semantic-recall-processor.md +117 -0
- package/.docs/reference/processors/system-prompt-scrubber.md +80 -0
- package/.docs/reference/processors/token-limiter-processor.md +115 -0
- package/.docs/reference/processors/tool-call-filter.md +85 -0
- package/.docs/reference/processors/tool-search-processor.md +111 -0
- package/.docs/reference/processors/unicode-normalizer.md +62 -0
- package/.docs/reference/processors/working-memory-processor.md +152 -0
- package/.docs/reference/rag/chunk.md +221 -0
- package/.docs/reference/rag/database-config.md +261 -0
- package/.docs/reference/rag/document.md +114 -0
- package/.docs/reference/rag/embeddings.md +92 -0
- package/.docs/reference/rag/extract-params.md +168 -0
- package/.docs/reference/rag/graph-rag.md +111 -0
- package/.docs/reference/rag/metadata-filters.md +216 -0
- package/.docs/reference/rag/rerank.md +75 -0
- package/.docs/reference/rag/rerankWithScorer.md +80 -0
- package/.docs/reference/server/create-route.md +262 -0
- package/.docs/reference/server/express-adapter.md +176 -0
- package/.docs/reference/server/fastify-adapter.md +90 -0
- package/.docs/reference/server/hono-adapter.md +162 -0
- package/.docs/reference/server/koa-adapter.md +127 -0
- package/.docs/reference/server/mastra-server.md +298 -0
- package/.docs/reference/server/register-api-route.md +249 -0
- package/.docs/reference/server/routes.md +306 -0
- package/.docs/reference/storage/cloudflare-d1.md +218 -0
- package/.docs/reference/storage/cloudflare.md +88 -0
- package/.docs/reference/storage/composite.md +235 -0
- package/.docs/reference/storage/convex.md +161 -0
- package/.docs/reference/storage/dynamodb.md +282 -0
- package/.docs/reference/storage/lance.md +131 -0
- package/.docs/reference/storage/libsql.md +135 -0
- package/.docs/reference/storage/mongodb.md +262 -0
- package/.docs/reference/storage/mssql.md +157 -0
- package/.docs/reference/storage/overview.md +121 -0
- package/.docs/reference/storage/postgresql.md +526 -0
- package/.docs/reference/storage/upstash.md +160 -0
- package/.docs/reference/streaming/ChunkType.md +292 -0
- package/.docs/reference/streaming/agents/MastraModelOutput.md +182 -0
- package/.docs/reference/streaming/agents/stream.md +221 -0
- package/.docs/reference/streaming/agents/streamLegacy.md +142 -0
- package/.docs/reference/streaming/workflows/observeStream.md +42 -0
- package/.docs/reference/streaming/workflows/resumeStream.md +61 -0
- package/.docs/reference/streaming/workflows/stream.md +88 -0
- package/.docs/reference/streaming/workflows/timeTravelStream.md +142 -0
- package/.docs/reference/templates/overview.md +194 -0
- package/.docs/reference/tools/create-tool.md +237 -0
- package/.docs/reference/tools/document-chunker-tool.md +89 -0
- package/.docs/reference/tools/graph-rag-tool.md +182 -0
- package/.docs/reference/tools/mcp-client.md +954 -0
- package/.docs/reference/tools/mcp-server.md +1271 -0
- package/.docs/reference/tools/vector-query-tool.md +459 -0
- package/.docs/reference/vectors/astra.md +121 -0
- package/.docs/reference/vectors/chroma.md +264 -0
- package/.docs/reference/vectors/convex.md +300 -0
- package/.docs/reference/vectors/couchbase.md +226 -0
- package/.docs/reference/vectors/duckdb.md +318 -0
- package/.docs/reference/vectors/elasticsearch.md +189 -0
- package/.docs/reference/vectors/lance.md +220 -0
- package/.docs/reference/vectors/libsql.md +305 -0
- package/.docs/reference/vectors/mongodb.md +295 -0
- package/.docs/reference/vectors/opensearch.md +99 -0
- package/.docs/reference/vectors/pg.md +408 -0
- package/.docs/reference/vectors/pinecone.md +168 -0
- package/.docs/reference/vectors/qdrant.md +222 -0
- package/.docs/reference/vectors/s3vectors.md +277 -0
- package/.docs/reference/vectors/turbopuffer.md +157 -0
- package/.docs/reference/vectors/upstash.md +294 -0
- package/.docs/reference/vectors/vectorize.md +147 -0
- package/.docs/reference/voice/azure.md +148 -0
- package/.docs/reference/voice/cloudflare.md +83 -0
- package/.docs/reference/voice/composite-voice.md +121 -0
- package/.docs/reference/voice/deepgram.md +79 -0
- package/.docs/reference/voice/elevenlabs.md +98 -0
- package/.docs/reference/voice/google-gemini-live.md +378 -0
- package/.docs/reference/voice/google.md +228 -0
- package/.docs/reference/voice/mastra-voice.md +311 -0
- package/.docs/reference/voice/murf.md +122 -0
- package/.docs/reference/voice/openai-realtime.md +203 -0
- package/.docs/reference/voice/openai.md +88 -0
- package/.docs/reference/voice/playai.md +80 -0
- package/.docs/reference/voice/sarvam.md +126 -0
- package/.docs/reference/voice/speechify.md +75 -0
- package/.docs/reference/voice/voice.addInstructions.md +55 -0
- package/.docs/reference/voice/voice.addTools.md +67 -0
- package/.docs/reference/voice/voice.answer.md +54 -0
- package/.docs/reference/voice/voice.close.md +51 -0
- package/.docs/reference/voice/voice.connect.md +94 -0
- package/.docs/reference/voice/voice.events.md +37 -0
- package/.docs/reference/voice/voice.getSpeakers.md +129 -0
- package/.docs/reference/voice/voice.listen.md +164 -0
- package/.docs/reference/voice/voice.off.md +54 -0
- package/.docs/reference/voice/voice.on.md +111 -0
- package/.docs/reference/voice/voice.send.md +65 -0
- package/.docs/reference/voice/voice.speak.md +157 -0
- package/.docs/reference/voice/voice.updateConfig.md +60 -0
- package/.docs/reference/workflows/run-methods/cancel.md +86 -0
- package/.docs/reference/workflows/run-methods/restart.md +33 -0
- package/.docs/reference/workflows/run-methods/resume.md +59 -0
- package/.docs/reference/workflows/run-methods/start.md +58 -0
- package/.docs/reference/workflows/run-methods/startAsync.md +67 -0
- package/.docs/reference/workflows/run-methods/timeTravel.md +142 -0
- package/.docs/reference/workflows/run.md +59 -0
- package/.docs/reference/workflows/step.md +119 -0
- package/.docs/reference/workflows/workflow-methods/branch.md +25 -0
- package/.docs/reference/workflows/workflow-methods/commit.md +17 -0
- package/.docs/reference/workflows/workflow-methods/create-run.md +63 -0
- package/.docs/reference/workflows/workflow-methods/dountil.md +25 -0
- package/.docs/reference/workflows/workflow-methods/dowhile.md +25 -0
- package/.docs/reference/workflows/workflow-methods/foreach.md +118 -0
- package/.docs/reference/workflows/workflow-methods/map.md +93 -0
- package/.docs/reference/workflows/workflow-methods/parallel.md +21 -0
- package/.docs/reference/workflows/workflow-methods/sleep.md +35 -0
- package/.docs/reference/workflows/workflow-methods/sleepUntil.md +35 -0
- package/.docs/reference/workflows/workflow-methods/then.md +21 -0
- package/.docs/reference/workflows/workflow.md +157 -0
- package/.docs/reference/workspace/e2b-sandbox.md +289 -0
- package/.docs/reference/workspace/filesystem.md +255 -0
- package/.docs/reference/workspace/gcs-filesystem.md +174 -0
- package/.docs/reference/workspace/local-filesystem.md +343 -0
- package/.docs/reference/workspace/local-sandbox.md +301 -0
- package/.docs/reference/workspace/s3-filesystem.md +175 -0
- package/.docs/reference/workspace/sandbox.md +87 -0
- package/.docs/reference/workspace/workspace-class.md +244 -0
- package/CHANGELOG.md +16 -0
- package/package.json +6 -6
|
@@ -0,0 +1,226 @@
|
|
|
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 = res.result.askAboutRole?.question ?? res.result.askAboutSpecialty?.question
|
|
215
|
+
|
|
216
|
+
console.log(`Output value: ${question}`)
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Now, run the workflow and get output in your terminal:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
npx tsx src/test-workflow.ts
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
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!
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# Building an AI Chef Assistant
|
|
2
|
+
|
|
3
|
+
In this guide, you'll create a "Chef Assistant" agent that helps users cook meals with available ingredients.
|
|
4
|
+
|
|
5
|
+
You'll learn how to create the agent and register it with Mastra. Next, you'll interact with the agent through your terminal and get to know different response formats. Lastly, you'll access the agent through Mastra's local API endpoints.
|
|
6
|
+
|
|
7
|
+
[YouTube video player](https://www.youtube-nocookie.com/embed/_tZhOqHCrF0)
|
|
8
|
+
|
|
9
|
+
## Prerequisites
|
|
10
|
+
|
|
11
|
+
- Node.js `v22.13.0` or later installed
|
|
12
|
+
- An API key from a supported [Model Provider](https://mastra.ai/models)
|
|
13
|
+
- An existing Mastra project (Follow the [installation guide](https://mastra.ai/guides/getting-started/quickstart) to set up a new project)
|
|
14
|
+
|
|
15
|
+
## Creating the Agent
|
|
16
|
+
|
|
17
|
+
To create an agent in Mastra use the `Agent` class to define it and then register it with Mastra.
|
|
18
|
+
|
|
19
|
+
1. Create a new file `src/mastra/agents/chefAgent.ts` and define your agent:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { Agent } from '@mastra/core/agent'
|
|
23
|
+
|
|
24
|
+
export const chefAgent = new Agent({
|
|
25
|
+
id: 'chef-agent',
|
|
26
|
+
name: 'chef-agent',
|
|
27
|
+
instructions:
|
|
28
|
+
'You are Michel, a practical and experienced home chef' +
|
|
29
|
+
'You help people cook with whatever ingredients they have available.',
|
|
30
|
+
model: 'openai/gpt-5.1',
|
|
31
|
+
})
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
2. In your `src/mastra/index.ts` file, register the agent:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { Mastra } from '@mastra/core'
|
|
38
|
+
import { chefAgent } from './agents/chefAgent'
|
|
39
|
+
|
|
40
|
+
export const mastra = new Mastra({
|
|
41
|
+
agents: { chefAgent },
|
|
42
|
+
})
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Interacting with the Agent
|
|
46
|
+
|
|
47
|
+
Depending on your requirements you can interact and get responses from the agent in different formats. In the following steps you'll learn how to generate, stream, and get structured output.
|
|
48
|
+
|
|
49
|
+
1. Create a new file `src/index.ts` and add a `main()` function to it. Inside, craft a query to ask the agent and log its response.
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { chefAgent } from './mastra/agents/chefAgent'
|
|
53
|
+
|
|
54
|
+
async function main() {
|
|
55
|
+
const query =
|
|
56
|
+
'In my kitchen I have: pasta, canned tomatoes, garlic, olive oil, and some dried herbs (basil and oregano). What can I make?'
|
|
57
|
+
console.log(`Query: ${query}`)
|
|
58
|
+
|
|
59
|
+
const response = await chefAgent.generate([{ role: 'user', content: query }])
|
|
60
|
+
console.log('\n👨🍳 Chef Michel:', response.text)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
main()
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Afterwards, run the script:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx bun src/index.ts
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
You should get an output similar to this:
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
Query: In my kitchen I have: pasta, canned tomatoes, garlic, olive oil, and some dried herbs (basil and oregano). What can I make?
|
|
76
|
+
|
|
77
|
+
👨🍳 Chef Michel: You can make a delicious pasta al pomodoro! Here's how...
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
2. In the previous example you might have waited a bit for the response without any sign of progress. To show the agent's output as it creates it you should instead stream its response to the terminal.
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { chefAgent } from './mastra/agents/chefAgent'
|
|
84
|
+
|
|
85
|
+
async function main() {
|
|
86
|
+
const query =
|
|
87
|
+
"Now I'm over at my friend's house, and they have: chicken thighs, coconut milk, sweet potatoes, and some curry powder."
|
|
88
|
+
console.log(`Query: ${query}`)
|
|
89
|
+
|
|
90
|
+
const stream = await chefAgent.stream([{ role: 'user', content: query }])
|
|
91
|
+
|
|
92
|
+
console.log('\n Chef Michel: ')
|
|
93
|
+
|
|
94
|
+
for await (const chunk of stream.textStream) {
|
|
95
|
+
process.stdout.write(chunk)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
console.log('\n\n✅ Recipe complete!')
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
main()
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Afterwards, run the script again:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npx bun src/index.ts
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
You should get an output similar to the one below. This time though you can read it line by line instead of one large block.
|
|
111
|
+
|
|
112
|
+
```text
|
|
113
|
+
Query: Now I'm over at my friend's house, and they have: chicken thighs, coconut milk, sweet potatoes, and some curry powder.
|
|
114
|
+
|
|
115
|
+
👨🍳 Chef Michel:
|
|
116
|
+
Great! You can make a comforting chicken curry...
|
|
117
|
+
|
|
118
|
+
✅ Recipe complete!
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
3. Instead of showing the agent's response to a human you might want to pass it along to another part of your code. For these instances your agent should return [structured output](https://mastra.ai/docs/agents/overview).
|
|
122
|
+
|
|
123
|
+
Change your `src/index.ts` to the following:
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
import { chefAgent } from './mastra/agents/chefAgent'
|
|
127
|
+
import { z } from 'zod'
|
|
128
|
+
|
|
129
|
+
async function main() {
|
|
130
|
+
const query = 'I want to make lasagna, can you generate a lasagna recipe for me?'
|
|
131
|
+
console.log(`Query: ${query}`)
|
|
132
|
+
|
|
133
|
+
// Define the Zod schema
|
|
134
|
+
const schema = z.object({
|
|
135
|
+
ingredients: z.array(
|
|
136
|
+
z.object({
|
|
137
|
+
name: z.string(),
|
|
138
|
+
amount: z.string(),
|
|
139
|
+
}),
|
|
140
|
+
),
|
|
141
|
+
steps: z.array(z.string()),
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
const response = await chefAgent.generate([{ role: 'user', content: query }], {
|
|
145
|
+
structuredOutput: {
|
|
146
|
+
schema,
|
|
147
|
+
},
|
|
148
|
+
})
|
|
149
|
+
console.log('\n👨🍳 Chef Michel:', response.object)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
main()
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
After running the script again you should get an output similar to this:
|
|
156
|
+
|
|
157
|
+
```text
|
|
158
|
+
Query: I want to make lasagna, can you generate a lasagna recipe for me?
|
|
159
|
+
|
|
160
|
+
👨🍳 Chef Michel: {
|
|
161
|
+
ingredients: [
|
|
162
|
+
{ name: "Lasagna noodles", amount: "12 sheets" },
|
|
163
|
+
{ name: "Ground beef", amount: "1 pound" },
|
|
164
|
+
],
|
|
165
|
+
steps: [
|
|
166
|
+
"Preheat oven to 375°F (190°C).",
|
|
167
|
+
"Cook the lasagna noodles according to package instructions.",
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Running the Agent Server
|
|
173
|
+
|
|
174
|
+
Learn how to interact with your agent through Mastra's API.
|
|
175
|
+
|
|
176
|
+
1. You can run your agent as a service using the `mastra dev` command:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
mastra dev
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
This will start a server exposing endpoints to interact with your registered agents. Within [Studio](https://mastra.ai/docs/getting-started/studio) you can test your agent through a UI.
|
|
183
|
+
|
|
184
|
+
2. By default, `mastra dev` runs on `http://localhost:4111`. Your Chef Assistant agent will be available at:
|
|
185
|
+
|
|
186
|
+
```text
|
|
187
|
+
POST http://localhost:4111/api/agents/chefAgent/generate
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
3. You can interact with the agent using `curl` from the command line:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
curl -X POST http://localhost:4111/api/agents/chefAgent/generate \
|
|
194
|
+
-H "Content-Type: application/json" \
|
|
195
|
+
-d '{
|
|
196
|
+
"messages": [
|
|
197
|
+
{
|
|
198
|
+
"role": "user",
|
|
199
|
+
"content": "I have eggs, flour, and milk. What can I make?"
|
|
200
|
+
}
|
|
201
|
+
]
|
|
202
|
+
}'
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**Sample Response:**
|
|
206
|
+
|
|
207
|
+
```json
|
|
208
|
+
{
|
|
209
|
+
"text": "You can make delicious pancakes! Here's a simple recipe..."
|
|
210
|
+
}
|
|
211
|
+
```
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# Building a Code Review Bot
|
|
2
|
+
|
|
3
|
+
In this guide, you'll build a code review bot that automatically reviews pull requests using workspace skills. The bot loads coding standards from skill files and provides structured feedback. You'll learn how to create a workspace with a skills directory, define an [Agent Skill](https://agentskills.io) with review instructions and reference files, and connect it to an agent that performs automated reviews.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Node.js `v22.13.0` or later installed
|
|
8
|
+
- An API key from a supported [Model Provider](https://mastra.ai/models)
|
|
9
|
+
- An existing Mastra project (Follow the [installation guide](https://mastra.ai/guides/getting-started/quickstart) to set up a new project)
|
|
10
|
+
|
|
11
|
+
## Create the workspace
|
|
12
|
+
|
|
13
|
+
In your `src/mastra/index.ts` file, import the [`Workspace`](https://mastra.ai/reference/workspace/workspace-class) and [`LocalFilesystem`](https://mastra.ai/reference/workspace/local-filesystem) classes. On the `Workspace` instance, configure the `skills` option to point to a skills directory. The `skills` directory will live inside the filesystem's `basePath`.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Mastra } from '@mastra/core'
|
|
17
|
+
import { resolve } from 'node:path'
|
|
18
|
+
import { Workspace, LocalFilesystem } from '@mastra/core/workspace'
|
|
19
|
+
|
|
20
|
+
const workspace = new Workspace({
|
|
21
|
+
filesystem: new LocalFilesystem({
|
|
22
|
+
basePath: resolve(import.meta.dirname, '../../workspace'),
|
|
23
|
+
}),
|
|
24
|
+
skills: ['/skills'],
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
export const mastra = new Mastra({
|
|
28
|
+
workspace,
|
|
29
|
+
})
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
At the root of your project, create a new folder called `workspace`. Inside that, create a `skills` folder. This is where you'll define the code standards skill in the next step.
|
|
33
|
+
|
|
34
|
+
## Create the code standards skill
|
|
35
|
+
|
|
36
|
+
Skills are structured directories containing a `SKILL.md` file with instructions for the agent. The code standards skill defines the review process and references a style guide.
|
|
37
|
+
|
|
38
|
+
Inside `workspace/skills`, create a new folder called `code-standards`. Create a file called `SKILL.md` and add the review instructions.
|
|
39
|
+
|
|
40
|
+
```markdown
|
|
41
|
+
---
|
|
42
|
+
name: code-standards
|
|
43
|
+
description: Automated code review standards and checks
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
# Code Review Standards
|
|
47
|
+
|
|
48
|
+
Review code systematically using these steps:
|
|
49
|
+
|
|
50
|
+
1. **Critical Issues**: Security vulnerabilities, memory leaks, logic bugs, missing error handling
|
|
51
|
+
2. **Code Quality**: Functions over 50 lines, code duplication, confusing names, missing types
|
|
52
|
+
3. **Style Guide**: Check references/style-guide.md for naming and organization
|
|
53
|
+
4. **Linting**: Flag common issues like use of `var`, leftover `console.log` statements, and `debugger` statements
|
|
54
|
+
|
|
55
|
+
Provide feedback in this format:
|
|
56
|
+
|
|
57
|
+
**Summary**: One sentence overview
|
|
58
|
+
|
|
59
|
+
**Critical Issues**: List with line numbers
|
|
60
|
+
|
|
61
|
+
**Suggestions**: Improvements that would help
|
|
62
|
+
|
|
63
|
+
**Positive Notes**: What the code does well
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Inside `workspace/skills/code-standards`, create a `references` folder to hold reference materials for the skill. Author a style guide file that outlines the project's coding conventions with the file name `style-guide.md`.
|
|
67
|
+
|
|
68
|
+
````markdown
|
|
69
|
+
# Style Guide
|
|
70
|
+
|
|
71
|
+
## Naming
|
|
72
|
+
|
|
73
|
+
- Variables/Functions: `camelCase`
|
|
74
|
+
- Constants: `UPPER_SNAKE_CASE`
|
|
75
|
+
- Files: `kebab-case.ts`
|
|
76
|
+
- Booleans: Start with `is`, `has`, `should`
|
|
77
|
+
|
|
78
|
+
## Code Organization
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
// 1. Imports
|
|
82
|
+
import { foo } from 'bar'
|
|
83
|
+
|
|
84
|
+
// 2. Constants
|
|
85
|
+
const MAX_SIZE = 100
|
|
86
|
+
|
|
87
|
+
// 3. Types
|
|
88
|
+
interface User {
|
|
89
|
+
id: string
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 4. Functions
|
|
93
|
+
function doSomething() {}
|
|
94
|
+
|
|
95
|
+
// 5. Exports
|
|
96
|
+
export { doSomething }
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Error Handling
|
|
100
|
+
|
|
101
|
+
Always handle errors explicitly - never silently catch.
|
|
102
|
+
|
|
103
|
+
## Comments
|
|
104
|
+
|
|
105
|
+
Write "why" not "what".
|
|
106
|
+
````
|
|
107
|
+
|
|
108
|
+
## Create the review agent
|
|
109
|
+
|
|
110
|
+
Now it's time to create the code review bot agent that uses the code-standards skill. Create a new file at `src/mastra/agents/code-reviewer.ts` and define the agent:
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { Agent } from '@mastra/core/agent'
|
|
114
|
+
|
|
115
|
+
export const codeReviewer = new Agent({
|
|
116
|
+
id: 'code-reviewer',
|
|
117
|
+
name: 'Code Review Bot',
|
|
118
|
+
instructions: `You are an automated code reviewer.
|
|
119
|
+
|
|
120
|
+
When asked to review code:
|
|
121
|
+
1. Activate the 'code-standards' skill
|
|
122
|
+
2. Follow the review process from the skill
|
|
123
|
+
3. Check against the style guide in skill references
|
|
124
|
+
4. Be constructive and specific with line numbers`,
|
|
125
|
+
model: 'openai/gpt-4o',
|
|
126
|
+
})
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Define the agent by importing it inside `src/mastra/index.ts` and registering it with the `Mastra` instance:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
import { Mastra } from '@mastra/core'
|
|
133
|
+
import { resolve } from 'node:path'
|
|
134
|
+
import { Workspace, LocalFilesystem } from '@mastra/core/workspace'
|
|
135
|
+
import { codeReviewer } from './agents/code-reviewer'
|
|
136
|
+
|
|
137
|
+
const workspace = new Workspace({
|
|
138
|
+
filesystem: new LocalFilesystem({
|
|
139
|
+
basePath: resolve(import.meta.dirname, '../../workspace'),
|
|
140
|
+
}),
|
|
141
|
+
skills: ['/skills'],
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
export const mastra = new Mastra({
|
|
145
|
+
workspace,
|
|
146
|
+
agents: { codeReviewer },
|
|
147
|
+
})
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Test the bot
|
|
151
|
+
|
|
152
|
+
Start Mastra Studio and interact with the code review bot to see it in action.
|
|
153
|
+
|
|
154
|
+
**npm**:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
npm run dev
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**pnpm**:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
pnpm run dev
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Yarn**:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
yarn dev
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Bun**:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
bun run dev
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Open [localhost:4111](http://localhost:4111) and navigate to the code reviewer agent.
|
|
179
|
+
|
|
180
|
+
Inside the chat input, provide a code snippet for review, such as:
|
|
181
|
+
|
|
182
|
+
```text
|
|
183
|
+
Review this code:
|
|
184
|
+
|
|
185
|
+
function getData(id) {
|
|
186
|
+
var result = fetch('/api/data/' + id);
|
|
187
|
+
console.log(result);
|
|
188
|
+
return result;
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
The bot should activate the `code-standards` skill and provide structured feedback. Since agent responses are non-deterministic, your output may vary, but you should see something similar to:
|
|
193
|
+
|
|
194
|
+
```md
|
|
195
|
+
**Summary**: Function has several issues with variable declaration,
|
|
196
|
+
debugging statements, and missing error handling.
|
|
197
|
+
|
|
198
|
+
**Critical Issues**:
|
|
199
|
+
|
|
200
|
+
- Missing error handling for fetch (line 2)
|
|
201
|
+
- No async/await for asynchronous operation (line 2)
|
|
202
|
+
|
|
203
|
+
**Suggestions**:
|
|
204
|
+
|
|
205
|
+
- Use const instead of var (line 2)
|
|
206
|
+
- Remove console.log before committing (line 3)
|
|
207
|
+
- Add TypeScript type for id parameter
|
|
208
|
+
- Use template literals instead of concatenation
|
|
209
|
+
|
|
210
|
+
**Positive Notes**:
|
|
211
|
+
|
|
212
|
+
- Function name is clear and descriptive
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Next steps
|
|
216
|
+
|
|
217
|
+
You can extend this bot to:
|
|
218
|
+
|
|
219
|
+
- Add skills for different languages or frameworks
|
|
220
|
+
- Create skills for security checks and performance reviews
|
|
221
|
+
- Integrate with GitHub Actions for automatic PR reviews
|
|
222
|
+
- Build a PR comment bot that leaves inline feedback
|
|
223
|
+
|
|
224
|
+
Learn more:
|
|
225
|
+
|
|
226
|
+
- [Agent Skills spec](https://agentskills.io)
|