@mastra/mcp-docs-server 1.1.5 → 1.1.6-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/.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 +8 -0
- package/package.json +5 -5
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Run.timeTravelStream()
|
|
2
|
+
|
|
3
|
+
The `.timeTravelStream()` method re-executes a workflow starting from any specific step with streaming events. This allows you to receive real-time updates during time travel execution while maintaining full visibility into each step's progress.
|
|
4
|
+
|
|
5
|
+
## Usage example
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
const run = await workflow.createRun()
|
|
9
|
+
|
|
10
|
+
const output = run.timeTravelStream({
|
|
11
|
+
step: 'step2',
|
|
12
|
+
inputData: { value: 10 },
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
// Process events as they arrive
|
|
16
|
+
for await (const event of output.fullStream) {
|
|
17
|
+
console.log(event.type, event.payload)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Get the final result
|
|
21
|
+
const result = await output.result
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Parameters
|
|
25
|
+
|
|
26
|
+
All parameters are the same as [`Run.timeTravel()`](https://mastra.ai/reference/workflows/run-methods/timeTravel). See the [timeTravel reference](https://mastra.ai/reference/workflows/run-methods/timeTravel) for detailed parameter documentation.
|
|
27
|
+
|
|
28
|
+
## Returns
|
|
29
|
+
|
|
30
|
+
**output:** (`WorkflowRunOutput<WorkflowResult<TState, TInput, TOutput, TSteps>>`): An object containing both the stream and result promise
|
|
31
|
+
|
|
32
|
+
**output.fullStream:** (`ReadableStream<WorkflowStreamEvent>`): A readable stream that emits workflow events as execution progresses
|
|
33
|
+
|
|
34
|
+
**output.result:** (`Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>`): A promise that resolves to the final workflow execution result
|
|
35
|
+
|
|
36
|
+
**output.traceId?:** (`string`): The trace ID associated with this execution when Tracing is enabled
|
|
37
|
+
|
|
38
|
+
## Stream events
|
|
39
|
+
|
|
40
|
+
The stream emits various workflow events during execution:
|
|
41
|
+
|
|
42
|
+
- `workflow-step-start`: Emitted when a step begins execution
|
|
43
|
+
- `workflow-step-finish`: Emitted when a step completes successfully
|
|
44
|
+
- `workflow-step-error`: Emitted when a step encounters an error
|
|
45
|
+
- `workflow-step-suspended`: Emitted when a step suspends
|
|
46
|
+
- Additional events depending on step types (agents, tools, etc.)
|
|
47
|
+
|
|
48
|
+
## Extended usage examples
|
|
49
|
+
|
|
50
|
+
### Processing events during time travel
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
const run = await workflow.createRun()
|
|
54
|
+
|
|
55
|
+
const output = run.timeTravelStream({
|
|
56
|
+
step: 'step2',
|
|
57
|
+
inputData: { value: 10 },
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
for await (const event of output.fullStream) {
|
|
61
|
+
switch (event.type) {
|
|
62
|
+
case 'workflow-step-start':
|
|
63
|
+
console.log(`Starting step: ${event.payload.stepName}`)
|
|
64
|
+
break
|
|
65
|
+
case 'workflow-step-finish':
|
|
66
|
+
console.log(`Completed step: ${event.payload.stepName}`)
|
|
67
|
+
break
|
|
68
|
+
case 'workflow-step-error':
|
|
69
|
+
console.error(`Error in step: ${event.payload.stepName}`, event.payload.error)
|
|
70
|
+
break
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const result = await output.result
|
|
75
|
+
console.log('Time travel completed:', result)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Time travel stream with context
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
const output = run.timeTravelStream({
|
|
82
|
+
step: 'step2',
|
|
83
|
+
context: {
|
|
84
|
+
step1: {
|
|
85
|
+
status: 'success',
|
|
86
|
+
payload: { value: 0 },
|
|
87
|
+
output: { step1Result: 2 },
|
|
88
|
+
startedAt: Date.now(),
|
|
89
|
+
endedAt: Date.now(),
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
for await (const event of output.fullStream) {
|
|
95
|
+
// Handle events
|
|
96
|
+
console.log(event)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const result = await output.result
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Time travel stream with nested workflows
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
const output = run.timeTravelStream({
|
|
106
|
+
step: ['nestedWorkflow', 'step3'],
|
|
107
|
+
inputData: { value: 10 },
|
|
108
|
+
nestedStepsContext: {
|
|
109
|
+
nestedWorkflow: {
|
|
110
|
+
step2: {
|
|
111
|
+
status: 'success',
|
|
112
|
+
payload: { step1Result: 2 },
|
|
113
|
+
output: { step2Result: 3 },
|
|
114
|
+
startedAt: Date.now(),
|
|
115
|
+
endedAt: Date.now(),
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
for await (const event of output.fullStream) {
|
|
122
|
+
console.log(event.type, event.payload)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const result = await output.result
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Notes
|
|
129
|
+
|
|
130
|
+
- The stream closes automatically when time travel execution completes or encounters an error
|
|
131
|
+
- You can process events from the stream while the workflow is still executing
|
|
132
|
+
- The `result` promise resolves only after all steps have completed
|
|
133
|
+
- Stream events follow the same format as regular workflow streaming
|
|
134
|
+
- Time travel streaming requires storage to be configured since it relies on persisted workflow snapshots
|
|
135
|
+
|
|
136
|
+
## Related
|
|
137
|
+
|
|
138
|
+
- [Run.timeTravel()](https://mastra.ai/reference/workflows/run-methods/timeTravel)
|
|
139
|
+
- [Time Travel](https://mastra.ai/docs/workflows/time-travel)
|
|
140
|
+
- [Workflow Streaming](https://mastra.ai/docs/streaming/workflow-streaming)
|
|
141
|
+
- [Run.stream()](https://mastra.ai/reference/streaming/workflows/stream)
|
|
142
|
+
- [Run.resumeStream()](https://mastra.ai/reference/streaming/workflows/resumeStream)
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# Overview
|
|
2
|
+
|
|
3
|
+
This reference provides comprehensive information about Mastra templates, including how to use existing templates, create your own, and contribute to the community ecosystem.
|
|
4
|
+
|
|
5
|
+
Mastra templates are pre-built project structures that demonstrate specific use cases and patterns. They provide:
|
|
6
|
+
|
|
7
|
+
- **Working examples** - Complete, functional Mastra applications
|
|
8
|
+
- **Best practices** - Proper project structure and coding conventions
|
|
9
|
+
- **Educational resources** - Learn Mastra patterns through real implementations
|
|
10
|
+
- **Quick starts** - Bootstrap projects faster than building from scratch
|
|
11
|
+
|
|
12
|
+
## Using Templates
|
|
13
|
+
|
|
14
|
+
### Installation
|
|
15
|
+
|
|
16
|
+
Install a template using the `create-mastra` command:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npx create-mastra@latest --template template-name
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
This creates a complete project with all necessary code and configuration.
|
|
23
|
+
|
|
24
|
+
### Setup Process
|
|
25
|
+
|
|
26
|
+
After installation:
|
|
27
|
+
|
|
28
|
+
1. **Navigate to project directory**:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
cd your-project-name
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
2. **Configure environment variables**:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
cp .env.example .env
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Edit `.env` with required API keys as documented in the template's README.
|
|
41
|
+
|
|
42
|
+
3. **Install dependencies** (if not done automatically):
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
4. **Start development server**:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm run dev
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Template Structure
|
|
55
|
+
|
|
56
|
+
All templates follow this standardized structure:
|
|
57
|
+
|
|
58
|
+
## Creating Templates
|
|
59
|
+
|
|
60
|
+
### Requirements
|
|
61
|
+
|
|
62
|
+
Templates must meet these technical requirements:
|
|
63
|
+
|
|
64
|
+
#### Project Structure
|
|
65
|
+
|
|
66
|
+
- **Mastra code location**: All Mastra code must be in `src/mastra/` directory
|
|
67
|
+
|
|
68
|
+
- **Component organization**:
|
|
69
|
+
|
|
70
|
+
- Agents: `src/mastra/agents/`
|
|
71
|
+
- Tools: `src/mastra/tools/`
|
|
72
|
+
- Workflows: `src/mastra/workflows/`
|
|
73
|
+
- Main config: `src/mastra/index.ts`
|
|
74
|
+
|
|
75
|
+
#### TypeScript Configuration
|
|
76
|
+
|
|
77
|
+
Use the standard Mastra TypeScript configuration:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"compilerOptions": {
|
|
82
|
+
"target": "ES2022",
|
|
83
|
+
"module": "ES2022",
|
|
84
|
+
"moduleResolution": "bundler",
|
|
85
|
+
"esModuleInterop": true,
|
|
86
|
+
"forceConsistentCasingInFileNames": true,
|
|
87
|
+
"strict": true,
|
|
88
|
+
"skipLibCheck": true,
|
|
89
|
+
"noEmit": true,
|
|
90
|
+
"outDir": "dist"
|
|
91
|
+
},
|
|
92
|
+
"include": ["src/**/*"]
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### Environment Configuration
|
|
97
|
+
|
|
98
|
+
Include a `.env.example` file with all required environment variables:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# LLM provider API keys (choose one or more)
|
|
102
|
+
OPENAI_API_KEY=your_openai_api_key_here
|
|
103
|
+
ANTHROPIC_API_KEY=your_anthropic_api_key_here
|
|
104
|
+
GOOGLE_GENERATIVE_AI_API_KEY=your_google_api_key_here
|
|
105
|
+
|
|
106
|
+
# Other service API keys as needed
|
|
107
|
+
OTHER_SERVICE_API_KEY=your_api_key_here
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Code Standards
|
|
111
|
+
|
|
112
|
+
#### LLM Provider
|
|
113
|
+
|
|
114
|
+
We recommend using OpenAI, Anthropic, or Google model providers for templates. Choose the provider that best fits your use case:
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import { Agent } from '@mastra/core/agent'
|
|
118
|
+
|
|
119
|
+
const agent = new Agent({
|
|
120
|
+
name: 'example-agent',
|
|
121
|
+
model: 'openai/gpt-5.1', // or other provider strings
|
|
122
|
+
instructions: 'Your agent instructions here',
|
|
123
|
+
})
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### Compatibility Requirements
|
|
127
|
+
|
|
128
|
+
Templates must be:
|
|
129
|
+
|
|
130
|
+
- **Single projects** - Not monorepos with multiple applications
|
|
131
|
+
- **Framework-free** - No Next.js, Express, or other web framework boilerplate
|
|
132
|
+
- **Mastra-focused** - Demonstrate Mastra functionality without additional layers
|
|
133
|
+
- **Mergeable** - Structure code for easy integration into existing projects
|
|
134
|
+
- **Node.js compatible** - Support Node.js v22.13.0 and later
|
|
135
|
+
- **ESM modules** - Use ES modules (`"type": "module"` in package.json)
|
|
136
|
+
|
|
137
|
+
### Documentation Requirements
|
|
138
|
+
|
|
139
|
+
#### README Structure
|
|
140
|
+
|
|
141
|
+
Every template must include a comprehensive README:
|
|
142
|
+
|
|
143
|
+
```markdown
|
|
144
|
+
# Template Name
|
|
145
|
+
|
|
146
|
+
Brief description of what the template demonstrates.
|
|
147
|
+
|
|
148
|
+
## Overview
|
|
149
|
+
|
|
150
|
+
Detailed explanation of the template's functionality and use case.
|
|
151
|
+
|
|
152
|
+
## Setup
|
|
153
|
+
|
|
154
|
+
1. Copy `.env.example` to `.env` and fill in your API keys
|
|
155
|
+
2. Install dependencies: `npm install`
|
|
156
|
+
3. Run the project: `npm run dev`
|
|
157
|
+
|
|
158
|
+
## Environment Variables
|
|
159
|
+
|
|
160
|
+
- `OPENAI_API_KEY`: Your OpenAI API key. Get one at [OpenAI Platform](https://platform.openai.com/api-keys)
|
|
161
|
+
- `ANTHROPIC_API_KEY`: Your Anthropic API key. Get one at [Anthropic Console](https://console.anthropic.com/settings/keys)
|
|
162
|
+
- `GOOGLE_GENERATIVE_AI_API_KEY`: Your Google AI API key. Get one at [Google AI Studio](https://makersuite.google.com/app/apikey)
|
|
163
|
+
- `OTHER_API_KEY`: Description of what this key is for
|
|
164
|
+
|
|
165
|
+
## Usage
|
|
166
|
+
|
|
167
|
+
Instructions on how to use the template and examples of expected behavior.
|
|
168
|
+
|
|
169
|
+
## Customization
|
|
170
|
+
|
|
171
|
+
Guidelines for modifying the template for different use cases.
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
#### Code Comments
|
|
175
|
+
|
|
176
|
+
Include clear comments explaining:
|
|
177
|
+
|
|
178
|
+
- Complex logic or algorithms
|
|
179
|
+
- API integrations and their purpose
|
|
180
|
+
- Configuration options and their effects
|
|
181
|
+
- Example usage patterns
|
|
182
|
+
|
|
183
|
+
### Quality Standards
|
|
184
|
+
|
|
185
|
+
Templates must demonstrate:
|
|
186
|
+
|
|
187
|
+
- **Code quality** - Clean, well-commented, maintainable code
|
|
188
|
+
- **Error handling** - Proper handling for external APIs and user inputs
|
|
189
|
+
- **Type safety** - Full TypeScript typing with Zod validation
|
|
190
|
+
- **Testing** - Verified functionality with fresh installations
|
|
191
|
+
|
|
192
|
+
For information on contributing your own templates to the Mastra ecosystem, see the [Contributing Templates](https://mastra.ai/docs/community/contributing-templates) guide in the community section.
|
|
193
|
+
|
|
194
|
+
> **Info:** Templates provide an excellent way to learn Mastra patterns and accelerate development. Contributing templates helps the entire community build better AI applications.
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# createTool()
|
|
2
|
+
|
|
3
|
+
The `createTool()` function is used to define custom tools that your Mastra agents can execute. Tools extend an agent's capabilities by allowing it to interact with external systems, perform calculations, or access specific data.
|
|
4
|
+
|
|
5
|
+
## Usage example
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { createTool } from '@mastra/core/tools'
|
|
9
|
+
import { z } from 'zod'
|
|
10
|
+
|
|
11
|
+
export const tool = createTool({
|
|
12
|
+
id: 'test-tool',
|
|
13
|
+
description: 'Reverse the input string',
|
|
14
|
+
inputSchema: z.object({
|
|
15
|
+
input: z.string(),
|
|
16
|
+
}),
|
|
17
|
+
outputSchema: z.object({
|
|
18
|
+
output: z.string(),
|
|
19
|
+
}),
|
|
20
|
+
execute: async inputData => {
|
|
21
|
+
const reversed = inputData.input.split('').reverse().join('')
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
output: reversed,
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Example with MCP Annotations
|
|
31
|
+
|
|
32
|
+
When exposing tools via MCP (Model Context Protocol), you can add annotations to describe tool behavior and customize how clients display the tool. These MCP-specific properties are grouped under the `mcp` property:
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { createTool } from '@mastra/core/tools'
|
|
36
|
+
import { z } from 'zod'
|
|
37
|
+
|
|
38
|
+
export const weatherTool = createTool({
|
|
39
|
+
id: 'get-weather',
|
|
40
|
+
description: 'Get current weather for a location',
|
|
41
|
+
inputSchema: z.object({
|
|
42
|
+
location: z.string().describe('City name or coordinates'),
|
|
43
|
+
}),
|
|
44
|
+
// MCP-specific properties
|
|
45
|
+
mcp: {
|
|
46
|
+
// Annotations for client behavior hints
|
|
47
|
+
annotations: {
|
|
48
|
+
title: 'Weather Lookup', // Human-readable display name
|
|
49
|
+
readOnlyHint: true, // Tool doesn't modify environment
|
|
50
|
+
destructiveHint: false, // Tool doesn't perform destructive updates
|
|
51
|
+
idempotentHint: true, // Same args = same result
|
|
52
|
+
openWorldHint: true, // Interacts with external API
|
|
53
|
+
},
|
|
54
|
+
// Custom metadata for client-specific functionality
|
|
55
|
+
_meta: {
|
|
56
|
+
version: '1.0.0',
|
|
57
|
+
category: 'weather',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
execute: async inputData => {
|
|
61
|
+
const weather = await fetchWeather(inputData.location)
|
|
62
|
+
return { weather }
|
|
63
|
+
},
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Parameters
|
|
68
|
+
|
|
69
|
+
**id:** (`string`): A unique identifier for the tool.
|
|
70
|
+
|
|
71
|
+
**description:** (`string`): A description of what the tool does. This is used by the agent to decide when to use the tool.
|
|
72
|
+
|
|
73
|
+
**inputSchema?:** (`Zod schema`): A Zod schema defining the expected input parameters for the tool's \`execute\` function.
|
|
74
|
+
|
|
75
|
+
**outputSchema?:** (`Zod schema`): A Zod schema defining the expected output structure of the tool's \`execute\` function.
|
|
76
|
+
|
|
77
|
+
**suspendSchema?:** (`Zod schema`): A Zod schema defining the structure of the payload passed to \`suspend()\`. This payload is returned to the client when the tool suspends execution.
|
|
78
|
+
|
|
79
|
+
**resumeSchema?:** (`Zod schema`): A Zod schema defining the expected structure of \`resumeData\` when the tool is resumed. Used by the agent to extract data from user messages when \`autoResumeSuspendedTools\` is enabled.
|
|
80
|
+
|
|
81
|
+
**requireApproval?:** (`boolean`): When true, the tool requires explicit approval before execution. The agent will emit a \`tool-call-approval\` chunk and pause until approved or declined.
|
|
82
|
+
|
|
83
|
+
**mcp?:** (`MCPToolProperties`): MCP-specific properties for tools exposed via Model Context Protocol. Includes \`annotations\` (tool behavior hints like \`title\`, \`readOnlyHint\`, \`destructiveHint\`, \`idempotentHint\`, \`openWorldHint\`) and \`\_meta\` (arbitrary metadata passed through to MCP clients).
|
|
84
|
+
|
|
85
|
+
**requestContextSchema?:** (`Zod schema`): A Zod schema for validating request context values. When provided, the context is validated before execute() runs, returning an error object if validation fails.
|
|
86
|
+
|
|
87
|
+
**execute:** (`function`): input:z.infer\<TInput>The validated input data based on inputSchemacontext?:ToolExecutionContextOptional execution context containing metadataRequestContextTracingContextAbortSignalAgentToolExecutionContextWorkflowToolExecutionContextMCPToolExecutionContext
|
|
88
|
+
|
|
89
|
+
**onInputStart?:** (`function`): Optional callback invoked when the tool call input streaming begins. Receives \`toolCallId\`, \`messages\`, and \`abortSignal\`.
|
|
90
|
+
|
|
91
|
+
**onInputDelta?:** (`function`): Optional callback invoked for each incremental chunk of input text as it streams in. Receives \`inputTextDelta\`, \`toolCallId\`, \`messages\`, and \`abortSignal\`.
|
|
92
|
+
|
|
93
|
+
**onInputAvailable?:** (`function`): Optional callback invoked when the complete tool input is available and parsed. Receives the validated \`input\` object, \`toolCallId\`, \`messages\`, and \`abortSignal\`.
|
|
94
|
+
|
|
95
|
+
**onOutput?:** (`function`): Optional callback invoked after the tool has successfully executed and returned output. Receives the tool's \`output\`, \`toolCallId\`, \`messages\`, and \`abortSignal\`.
|
|
96
|
+
|
|
97
|
+
## Returns
|
|
98
|
+
|
|
99
|
+
The `createTool()` function returns a `Tool` object.
|
|
100
|
+
|
|
101
|
+
**Tool:** (`object`): An object representing the defined tool, ready to be added to an agent.
|
|
102
|
+
|
|
103
|
+
## Tool Lifecycle Hooks
|
|
104
|
+
|
|
105
|
+
Tools support lifecycle hooks that allow you to monitor and react to different stages of tool execution. These hooks are particularly useful for logging, analytics, validation, and real-time updates during streaming.
|
|
106
|
+
|
|
107
|
+
### Available Hooks
|
|
108
|
+
|
|
109
|
+
#### onInputStart
|
|
110
|
+
|
|
111
|
+
Called when tool call input streaming begins, before any input data is received.
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
export const tool = createTool({
|
|
115
|
+
id: 'example-tool',
|
|
116
|
+
description: 'Example tool with hooks',
|
|
117
|
+
onInputStart: ({ toolCallId, messages, abortSignal }) => {
|
|
118
|
+
console.log(`Tool ${toolCallId} input streaming started`)
|
|
119
|
+
},
|
|
120
|
+
})
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### onInputDelta
|
|
124
|
+
|
|
125
|
+
Called for each incremental chunk of input text as it streams in. Useful for showing real-time progress or parsing partial JSON.
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
export const tool = createTool({
|
|
129
|
+
id: 'example-tool',
|
|
130
|
+
description: 'Example tool with hooks',
|
|
131
|
+
onInputDelta: ({ inputTextDelta, toolCallId, messages, abortSignal }) => {
|
|
132
|
+
console.log(`Received input chunk: ${inputTextDelta}`)
|
|
133
|
+
},
|
|
134
|
+
})
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### onInputAvailable
|
|
138
|
+
|
|
139
|
+
Called when the complete tool input is available and has been parsed and validated against the `inputSchema`.
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
export const tool = createTool({
|
|
143
|
+
id: 'example-tool',
|
|
144
|
+
description: 'Example tool with hooks',
|
|
145
|
+
inputSchema: z.object({
|
|
146
|
+
city: z.string(),
|
|
147
|
+
}),
|
|
148
|
+
onInputAvailable: ({ input, toolCallId, messages, abortSignal }) => {
|
|
149
|
+
console.log(`Tool received complete input:`, input)
|
|
150
|
+
// input is fully typed based on inputSchema
|
|
151
|
+
},
|
|
152
|
+
})
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
#### onOutput
|
|
156
|
+
|
|
157
|
+
Called after the tool has successfully executed and returned output. Useful for logging results, triggering follow-up actions, or analytics.
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
export const tool = createTool({
|
|
161
|
+
id: 'example-tool',
|
|
162
|
+
description: 'Example tool with hooks',
|
|
163
|
+
outputSchema: z.object({
|
|
164
|
+
result: z.string(),
|
|
165
|
+
}),
|
|
166
|
+
execute: async input => {
|
|
167
|
+
return { result: 'Success' }
|
|
168
|
+
},
|
|
169
|
+
onOutput: ({ output, toolCallId, toolName, abortSignal }) => {
|
|
170
|
+
console.log(`${toolName} execution completed:`, output)
|
|
171
|
+
// output is fully typed based on outputSchema
|
|
172
|
+
},
|
|
173
|
+
})
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Hook Execution Order
|
|
177
|
+
|
|
178
|
+
For a typical streaming tool call, the hooks are invoked in this order:
|
|
179
|
+
|
|
180
|
+
1. **onInputStart** - Input streaming begins
|
|
181
|
+
2. **onInputDelta** - Called multiple times as chunks arrive
|
|
182
|
+
3. **onInputAvailable** - Complete input is parsed and validated
|
|
183
|
+
4. Tool's **execute** function runs
|
|
184
|
+
5. **onOutput** - Tool has completed successfully
|
|
185
|
+
|
|
186
|
+
### Hook Parameters
|
|
187
|
+
|
|
188
|
+
All hooks receive a parameter object with these common properties:
|
|
189
|
+
|
|
190
|
+
- `toolCallId` (string): Unique identifier for this specific tool call
|
|
191
|
+
- `abortSignal` (AbortSignal): Signal for detecting if the operation should be cancelled
|
|
192
|
+
|
|
193
|
+
Additionally:
|
|
194
|
+
|
|
195
|
+
- `onInputStart`, `onInputDelta`, and `onInputAvailable` receive `messages` (array): The conversation messages at the time of the tool call
|
|
196
|
+
- `onInputDelta` receives `inputTextDelta` (string): The incremental text chunk
|
|
197
|
+
- `onInputAvailable` receives `input`: The validated input data (typed according to `inputSchema`)
|
|
198
|
+
- `onOutput` receives `output`: The tool's return value (typed according to `outputSchema`) and `toolName` (string): The name of the tool
|
|
199
|
+
|
|
200
|
+
### Error Handling
|
|
201
|
+
|
|
202
|
+
Hook errors are caught and logged automatically, but do not prevent tool execution from continuing. If a hook throws an error, it will be logged to the console but will not fail the tool call.
|
|
203
|
+
|
|
204
|
+
## MCP Tool Annotations
|
|
205
|
+
|
|
206
|
+
When exposing tools via the Model Context Protocol (MCP), you can provide annotations that describe tool behavior. These annotations help MCP clients like OpenAI Apps SDK understand how to present and handle your tools.
|
|
207
|
+
|
|
208
|
+
MCP-specific properties are grouped under the `mcp` property, which includes `annotations` and `_meta`:
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
mcp: {
|
|
212
|
+
annotations: { /* behavior hints */ },
|
|
213
|
+
_meta: { /* custom metadata */ },
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### ToolAnnotations Properties
|
|
218
|
+
|
|
219
|
+
**title?:** (`string`): A human-readable title for the tool. Used for display purposes in UI components.
|
|
220
|
+
|
|
221
|
+
**readOnlyHint?:** (`boolean`): If true, the tool does not modify its environment. This hint indicates the tool only reads data and has no side effects. Defaults to false.
|
|
222
|
+
|
|
223
|
+
**destructiveHint?:** (`boolean`): If true, the tool may perform destructive updates to its environment. If false, the tool performs only additive updates. This hint helps clients determine if confirmation should be required. Defaults to true.
|
|
224
|
+
|
|
225
|
+
**idempotentHint?:** (`boolean`): If true, calling the tool repeatedly with the same arguments will have no additional effect on its environment. This hint indicates idempotent behavior. Defaults to false.
|
|
226
|
+
|
|
227
|
+
**openWorldHint?:** (`boolean`): If true, this tool may interact with an 'open world' of external entities (e.g., web search, external APIs). If false, the tool's domain is closed and fully defined. Defaults to true.
|
|
228
|
+
|
|
229
|
+
These annotations follow the [MCP specification](https://spec.modelcontextprotocol.io/specification/2025-03-26/server/tools/#tool-annotations) and are passed through when tools are listed via MCP.
|
|
230
|
+
|
|
231
|
+
## Related
|
|
232
|
+
|
|
233
|
+
- [MCP Overview](https://mastra.ai/docs/mcp/overview)
|
|
234
|
+
- [Using Tools with Agents](https://mastra.ai/docs/agents/using-tools)
|
|
235
|
+
- [Agent Approval](https://mastra.ai/docs/agents/agent-approval)
|
|
236
|
+
- [Tool Streaming](https://mastra.ai/docs/streaming/tool-streaming)
|
|
237
|
+
- [Request Context](https://mastra.ai/docs/server/request-context)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# createDocumentChunkerTool()
|
|
2
|
+
|
|
3
|
+
The `createDocumentChunkerTool()` function creates a tool for splitting documents into smaller chunks for efficient processing and retrieval. It supports different chunking strategies and configurable parameters.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { createDocumentChunkerTool, MDocument } from '@mastra/rag'
|
|
9
|
+
|
|
10
|
+
const document = new MDocument({
|
|
11
|
+
text: 'Your document content here...',
|
|
12
|
+
metadata: { source: 'user-manual' },
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const chunker = createDocumentChunkerTool({
|
|
16
|
+
doc: document,
|
|
17
|
+
params: {
|
|
18
|
+
strategy: 'recursive',
|
|
19
|
+
size: 512,
|
|
20
|
+
overlap: 50,
|
|
21
|
+
separator: '\n',
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const { chunks } = await chunker.execute()
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Parameters
|
|
29
|
+
|
|
30
|
+
**doc:** (`MDocument`): The document to be chunked
|
|
31
|
+
|
|
32
|
+
**params?:** (`ChunkParams`): Configuration parameters for chunking (Default: `Default chunking parameters`)
|
|
33
|
+
|
|
34
|
+
### ChunkParams
|
|
35
|
+
|
|
36
|
+
**strategy?:** (`'recursive'`): The chunking strategy to use (Default: `'recursive'`)
|
|
37
|
+
|
|
38
|
+
**size?:** (`number`): Target size of each chunk in tokens/characters (Default: `512`)
|
|
39
|
+
|
|
40
|
+
**overlap?:** (`number`): Number of overlapping tokens/characters between chunks (Default: `50`)
|
|
41
|
+
|
|
42
|
+
**separator?:** (`string`): Character(s) to use as chunk separator (Default: `'\n'`)
|
|
43
|
+
|
|
44
|
+
## Returns
|
|
45
|
+
|
|
46
|
+
**chunks:** (`DocumentChunk[]`): Array of document chunks with their content and metadata
|
|
47
|
+
|
|
48
|
+
## Example with Custom Parameters
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
const technicalDoc = new MDocument({
|
|
52
|
+
text: longDocumentContent,
|
|
53
|
+
metadata: {
|
|
54
|
+
type: 'technical',
|
|
55
|
+
version: '1.0',
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const chunker = createDocumentChunkerTool({
|
|
60
|
+
doc: technicalDoc,
|
|
61
|
+
params: {
|
|
62
|
+
strategy: 'recursive',
|
|
63
|
+
size: 1024, // Larger chunks
|
|
64
|
+
overlap: 100, // More overlap
|
|
65
|
+
separator: '\n\n', // Split on double newlines
|
|
66
|
+
},
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
const { chunks } = await chunker.execute()
|
|
70
|
+
|
|
71
|
+
// Process the chunks
|
|
72
|
+
chunks.forEach((chunk, index) => {
|
|
73
|
+
console.log(`Chunk ${index + 1} length: ${chunk.content.length}`)
|
|
74
|
+
})
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Tool Details
|
|
78
|
+
|
|
79
|
+
The chunker is created as a Mastra tool with the following properties:
|
|
80
|
+
|
|
81
|
+
- **Tool ID**: `Document Chunker {strategy} {size}`
|
|
82
|
+
- **Description**: `Chunks document using {strategy} strategy with size {size} and {overlap} overlap`
|
|
83
|
+
- **Input Schema**: Empty object (no additional inputs required)
|
|
84
|
+
- **Output Schema**: Object containing the chunks array
|
|
85
|
+
|
|
86
|
+
## Related
|
|
87
|
+
|
|
88
|
+
- [MDocument](https://mastra.ai/reference/rag/document)
|
|
89
|
+
- [createVectorQueryTool](https://mastra.ai/reference/tools/vector-query-tool)
|