@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,229 @@
|
|
|
1
|
+
# Tools
|
|
2
|
+
|
|
3
|
+
Mastra Code provides built-in tools that the agent uses to interact with your codebase. Each tool is designed for a specific task, and the agent selects the right one based on what it needs to do.
|
|
4
|
+
|
|
5
|
+
## File tools
|
|
6
|
+
|
|
7
|
+
### `view`
|
|
8
|
+
|
|
9
|
+
Read file contents with line numbers or list directory contents. The agent uses this tool before editing a file.
|
|
10
|
+
|
|
11
|
+
- Displays line-numbered output (like `cat -n`) for easy reference.
|
|
12
|
+
- For directories, lists files up to 2 levels deep, excluding hidden items.
|
|
13
|
+
- Supports `view_range` to read specific line ranges in large files.
|
|
14
|
+
- Output is truncated if the file exceeds the token limit. Use `view_range` to read specific sections.
|
|
15
|
+
|
|
16
|
+
| Parameter | Type | Required | Description |
|
|
17
|
+
| ------------ | ------------------ | -------- | -------------------------------------------------------- |
|
|
18
|
+
| `path` | `string` | Yes | Path to the file or directory (relative to project root) |
|
|
19
|
+
| `view_range` | `[number, number]` | No | Line range `[start, end]` to view a section of the file |
|
|
20
|
+
|
|
21
|
+
### `string_replace_lsp`
|
|
22
|
+
|
|
23
|
+
Edit a file by replacing an exact text match with new content. Returns Language Server Protocol (LSP) diagnostics showing any errors or warnings introduced by the edit.
|
|
24
|
+
|
|
25
|
+
- The agent reads the file first with `view` before editing.
|
|
26
|
+
- `old_str` must be an exact substring of the current file content.
|
|
27
|
+
- Include enough surrounding context to uniquely identify the replacement location.
|
|
28
|
+
- When `new_str` is omitted or empty, the matched text is deleted.
|
|
29
|
+
- After editing, TypeScript errors, linting warnings, and other diagnostics are returned automatically.
|
|
30
|
+
|
|
31
|
+
| Parameter | Type | Required | Description |
|
|
32
|
+
| ------------ | -------- | -------- | -------------------------------------------------- |
|
|
33
|
+
| `path` | `string` | Yes | Path to the file |
|
|
34
|
+
| `old_str` | `string` | Yes | Exact text to find and replace |
|
|
35
|
+
| `new_str` | `string` | No | Replacement text (omit to delete the matched text) |
|
|
36
|
+
| `start_line` | `number` | No | Line number to narrow the search region |
|
|
37
|
+
|
|
38
|
+
### `ast_smart_edit`
|
|
39
|
+
|
|
40
|
+
Edit code using abstract syntax tree (AST) analysis for intelligent, structure-aware transformations. Powered by [ast-grep](https://ast-grep.github.io/), this tool understands code structure rather than treating files as raw text.
|
|
41
|
+
|
|
42
|
+
Supported transformations:
|
|
43
|
+
|
|
44
|
+
- **Pattern-based search and replace**: Find and replace code using AST patterns with `$VARIABLE` placeholders (e.g., replace `console.log($ARG)` with `logger.debug($ARG)`).
|
|
45
|
+
- **Add/remove imports**: Intelligently insert or remove import statements.
|
|
46
|
+
- **Rename functions**: Rename function declarations and all call sites with scope awareness.
|
|
47
|
+
- **Rename variables**: Rename variable declarations and all references.
|
|
48
|
+
- **Selector queries**: Find AST nodes matching a CSS-like selector (e.g., `"FunctionDeclaration"`).
|
|
49
|
+
|
|
50
|
+
| Parameter | Type | Required | Description |
|
|
51
|
+
| ------------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
52
|
+
| `path` | `string` | Yes | File path relative to project root |
|
|
53
|
+
| `pattern` | `string` | No | AST pattern to search for (supports `$VARIABLE` placeholders) |
|
|
54
|
+
| `replacement` | `string` | No | Replacement pattern (can use captured `$VARIABLES`) |
|
|
55
|
+
| `selector` | `string` | No | CSS-like selector for AST nodes |
|
|
56
|
+
| `transform` | `string` | No | Transformation type: `add-import`, `remove-import`, `rename-function`, `rename-variable`, `extract-function`, `inline-variable` |
|
|
57
|
+
| `targetName` | `string` | No | Name of the target element (for rename/remove operations) |
|
|
58
|
+
| `newName` | `string` | No | New name (for rename operations) |
|
|
59
|
+
| `importSpec` | `object` | No | Import specification for `add-import`: `{ module, names, isDefault? }` |
|
|
60
|
+
|
|
61
|
+
### `write_file`
|
|
62
|
+
|
|
63
|
+
Create a new file or overwrite an existing file entirely.
|
|
64
|
+
|
|
65
|
+
- Use for creating new files. For editing existing files, prefer `string_replace_lsp`.
|
|
66
|
+
- Parent directories are created automatically if they don't exist.
|
|
67
|
+
- If overwriting an existing file, the agent reads it first with `view`.
|
|
68
|
+
|
|
69
|
+
| Parameter | Type | Required | Description |
|
|
70
|
+
| --------- | -------- | -------- | ------------------------------------------------ |
|
|
71
|
+
| `path` | `string` | Yes | File path to write to (relative to project root) |
|
|
72
|
+
| `content` | `string` | Yes | Full content to write to the file |
|
|
73
|
+
|
|
74
|
+
## Search tools
|
|
75
|
+
|
|
76
|
+
### `search_content`
|
|
77
|
+
|
|
78
|
+
Search file contents using regular expressions. Uses ripgrep when available, falling back to grep.
|
|
79
|
+
|
|
80
|
+
- Supports full regex syntax (e.g., `"function\\s+\\w+"`, `"import.*from"`).
|
|
81
|
+
- Respects `.gitignore` automatically in Git repositories.
|
|
82
|
+
- Always preferred over running `grep` or `rg` via `execute_command`.
|
|
83
|
+
|
|
84
|
+
| Parameter | Type | Required | Description |
|
|
85
|
+
| --------------- | --------- | -------- | ----------------------------------------------------------------------------------- |
|
|
86
|
+
| `pattern` | `string` | Yes | Regex pattern to search for in file contents |
|
|
87
|
+
| `path` | `string` | No | Directory or file to search in (relative to project root, defaults to project root) |
|
|
88
|
+
| `glob` | `string` | No | Glob pattern to filter files (e.g., `"*.ts"`, `"*.{js,jsx}"`, `"test/**"`) |
|
|
89
|
+
| `contextLines` | `number` | No | Number of lines to show before and after each match (default: 0) |
|
|
90
|
+
| `maxResults` | `number` | No | Maximum number of matching lines to return (default: 100) |
|
|
91
|
+
| `caseSensitive` | `boolean` | No | Whether the search is case-sensitive (default: true) |
|
|
92
|
+
|
|
93
|
+
### `find_files`
|
|
94
|
+
|
|
95
|
+
Find files by name pattern using glob matching. Results are sorted by modification time (most recent first).
|
|
96
|
+
|
|
97
|
+
- Supports standard glob syntax: `*` (any characters), `**` (any path segments), `?` (single character), `{a,b}` (alternatives).
|
|
98
|
+
- Respects `.gitignore` automatically in Git repositories.
|
|
99
|
+
- Always preferred over running `find` or `ls` via `execute_command`.
|
|
100
|
+
|
|
101
|
+
| Parameter | Type | Required | Description |
|
|
102
|
+
| --------- | -------- | -------- | --------------------------------------------------------------------------- |
|
|
103
|
+
| `pattern` | `string` | Yes | Glob pattern (e.g., `"**/*.ts"`, `"src/**/*.test.*"`, `"**/package.json"`) |
|
|
104
|
+
| `path` | `string` | No | Directory to search in (relative to project root, defaults to project root) |
|
|
105
|
+
|
|
106
|
+
## Shell execution
|
|
107
|
+
|
|
108
|
+
### `execute_command`
|
|
109
|
+
|
|
110
|
+
Execute a shell command in the project directory.
|
|
111
|
+
|
|
112
|
+
- Use for Git commands, package managers (`npm`, `pnpm`), build tools, test runners, Docker, and other terminal operations.
|
|
113
|
+
- Commands run with a 30-second default timeout. Use the `timeout` parameter for longer operations.
|
|
114
|
+
- Output is stripped of ANSI codes and streamed to the TUI in real time.
|
|
115
|
+
- Pipe to `| tail -N` for commands with long output — full output streams to the user, but only the last N lines are returned to the agent.
|
|
116
|
+
- The `CI=true` environment variable is set automatically to prevent interactive prompts.
|
|
117
|
+
|
|
118
|
+
| Parameter | Type | Required | Description |
|
|
119
|
+
| --------- | -------- | -------- | -------------------------------------------- |
|
|
120
|
+
| `command` | `string` | Yes | Shell command to execute |
|
|
121
|
+
| `cwd` | `string` | No | Working directory (defaults to project root) |
|
|
122
|
+
| `timeout` | `number` | No | Timeout in seconds (default: 30) |
|
|
123
|
+
|
|
124
|
+
### `request_sandbox_access`
|
|
125
|
+
|
|
126
|
+
Request access to directories outside the project root. The user is prompted to approve or deny the request.
|
|
127
|
+
|
|
128
|
+
| Parameter | Type | Required | Description |
|
|
129
|
+
| --------- | -------- | -------- | --------------------------------------------- |
|
|
130
|
+
| `path` | `string` | Yes | Absolute path to the directory needing access |
|
|
131
|
+
| `reason` | `string` | Yes | Explanation of why access is needed |
|
|
132
|
+
|
|
133
|
+
## Web tools
|
|
134
|
+
|
|
135
|
+
### `web_search`
|
|
136
|
+
|
|
137
|
+
Search the web for documentation, error messages, package APIs, and other information.
|
|
138
|
+
|
|
139
|
+
This tool is available through two providers:
|
|
140
|
+
|
|
141
|
+
- **Tavily**: When the `TAVILY_API_KEY` environment variable is set.
|
|
142
|
+
- **Anthropic web search**: Built into Anthropic models, used as a fallback when no Tavily key is configured.
|
|
143
|
+
|
|
144
|
+
| Parameter | Type | Required | Description |
|
|
145
|
+
| --------------- | ----------------------- | -------- | --------------------------------------- |
|
|
146
|
+
| `query` | `string` | Yes | The search query |
|
|
147
|
+
| `searchDepth` | `"basic" \| "advanced"` | No | Search depth (default: `"basic"`) |
|
|
148
|
+
| `maxResults` | `number` | No | Maximum number of results (default: 10) |
|
|
149
|
+
| `includeImages` | `boolean` | No | Include related images (default: false) |
|
|
150
|
+
|
|
151
|
+
### `web_extract`
|
|
152
|
+
|
|
153
|
+
Extract the full content of one or more web pages. Requires a Tavily API key (`TAVILY_API_KEY`).
|
|
154
|
+
|
|
155
|
+
| Parameter | Type | Required | Description |
|
|
156
|
+
| --------------- | ----------------------- | -------- | --------------------------------------------- |
|
|
157
|
+
| `urls` | `string[]` | Yes | URLs to extract content from (max 20) |
|
|
158
|
+
| `extractDepth` | `"basic" \| "advanced"` | No | Extraction depth (default: `"basic"`) |
|
|
159
|
+
| `includeImages` | `boolean` | No | Include extracted image URLs (default: false) |
|
|
160
|
+
|
|
161
|
+
## Task management
|
|
162
|
+
|
|
163
|
+
### `task_write`
|
|
164
|
+
|
|
165
|
+
Create or update a structured task list for tracking progress on complex, multi-step work.
|
|
166
|
+
|
|
167
|
+
- Each task has a `content` (imperative form), `status` (`pending`, `in_progress`, `completed`), and `activeForm` (present continuous form shown during execution).
|
|
168
|
+
- Pass the full task list each time — it replaces the previous list.
|
|
169
|
+
- Only one task should be `in_progress` at a time.
|
|
170
|
+
|
|
171
|
+
### `task_check`
|
|
172
|
+
|
|
173
|
+
Check the completion status of the current task list. The agent uses this before finishing to verify all tasks are complete.
|
|
174
|
+
|
|
175
|
+
## Interactive tools
|
|
176
|
+
|
|
177
|
+
### `ask_user`
|
|
178
|
+
|
|
179
|
+
Ask the user a structured question. The agent uses this when it needs clarification, wants to validate assumptions, or needs the user to make a decision. Questions render inline in the conversation flow and support optional multiple-choice options.
|
|
180
|
+
|
|
181
|
+
### `submit_plan`
|
|
182
|
+
|
|
183
|
+
Submit a structured implementation plan for user review and approval (Plan mode only). The plan renders inline, and the user can approve, reject, or request changes.
|
|
184
|
+
|
|
185
|
+
## MCP tools
|
|
186
|
+
|
|
187
|
+
When [MCP servers](https://mastra.ai/docs/mastra-code/configuration) are configured, their tools are automatically available to the agent. MCP tools are namespaced as `serverName_toolName` to avoid collisions with built-in tools.
|
|
188
|
+
|
|
189
|
+
MCP tools fall under the `mcp` permission category. When YOLO mode is disabled, they require approval before execution.
|
|
190
|
+
|
|
191
|
+
## Tool availability by mode
|
|
192
|
+
|
|
193
|
+
Not all tools are available in every mode:
|
|
194
|
+
|
|
195
|
+
| Tool | Build | Plan | Fast |
|
|
196
|
+
| ------------------------ | ----- | --------- | ---- |
|
|
197
|
+
| `view` | Yes | Yes | Yes |
|
|
198
|
+
| `search_content` | Yes | Yes | Yes |
|
|
199
|
+
| `find_files` | Yes | Yes | Yes |
|
|
200
|
+
| `execute_command` | Yes | Read-only | Yes |
|
|
201
|
+
| `string_replace_lsp` | Yes | No | Yes |
|
|
202
|
+
| `ast_smart_edit` | Yes | No | Yes |
|
|
203
|
+
| `write_file` | Yes | No | Yes |
|
|
204
|
+
| `web_search` | Yes | Yes | Yes |
|
|
205
|
+
| `web_extract` | Yes | Yes | Yes |
|
|
206
|
+
| `task_write` | Yes | Yes | Yes |
|
|
207
|
+
| `task_check` | Yes | Yes | Yes |
|
|
208
|
+
| `ask_user` | Yes | Yes | Yes |
|
|
209
|
+
| `submit_plan` | No | Yes | No |
|
|
210
|
+
| `request_sandbox_access` | Yes | Yes | Yes |
|
|
211
|
+
|
|
212
|
+
In Plan mode, `execute_command` is available but restricted to read-only commands (`git status`, `git log`, `git diff`, etc.).
|
|
213
|
+
|
|
214
|
+
## Permission system
|
|
215
|
+
|
|
216
|
+
Tools are grouped into four categories, each with a configurable approval policy:
|
|
217
|
+
|
|
218
|
+
| Category | Tools | Default policy |
|
|
219
|
+
| ----------- | ------------------------------------------------------------------- | -------------- |
|
|
220
|
+
| **Read** | `view`, `search_content`, `find_files`, `web_search`, `web_extract` | `allow` |
|
|
221
|
+
| **Edit** | `string_replace_lsp`, `ast_smart_edit`, `write_file`, `subagent` | `ask` |
|
|
222
|
+
| **Execute** | `execute_command` | `ask` |
|
|
223
|
+
| **MCP** | All MCP server tools | `ask` |
|
|
224
|
+
|
|
225
|
+
When YOLO mode is enabled (the default), all categories are set to `allow`. When disabled, the agent prompts for approval based on the category policy.
|
|
226
|
+
|
|
227
|
+
You can configure per-category or per-tool overrides through `/settings`, and session-level grants let you approve a category once for the rest of the session.
|
|
228
|
+
|
|
229
|
+
> **Note:** Visit [Modes](https://mastra.ai/docs/mastra-code/modes) for details on how modes affect tool access and approval behavior.
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
# MCP Overview
|
|
2
|
+
|
|
3
|
+
Mastra supports the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction), an open standard for connecting AI agents to external tools and resources. It serves as a universal plugin system, enabling agents to call tools regardless of language or hosting environment.
|
|
4
|
+
|
|
5
|
+
Mastra can also be used to author MCP servers, exposing agents, tools, and other structured resources via the MCP interface. These can then be accessed by any system or agent that supports the protocol.
|
|
6
|
+
|
|
7
|
+
Mastra currently supports two MCP classes:
|
|
8
|
+
|
|
9
|
+
1. `MCPClient`: Connects to one or many MCP servers to access their tools, resources, prompts, and handle elicitation requests.
|
|
10
|
+
2. `MCPServer`: Exposes Mastra tools, agents, workflows, prompts, and resources to MCP-compatible clients.
|
|
11
|
+
|
|
12
|
+
## Get started
|
|
13
|
+
|
|
14
|
+
To use MCP, install the required dependency:
|
|
15
|
+
|
|
16
|
+
**npm**:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @mastra/mcp@latest
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**pnpm**:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm add @mastra/mcp@latest
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Yarn**:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
yarn add @mastra/mcp@latest
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Bun**:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
bun add @mastra/mcp@latest
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Configuring `MCPClient`
|
|
41
|
+
|
|
42
|
+
The `MCPClient` connects Mastra primitives to external MCP servers, which can be local packages (invoked using `npx`) or remote HTTP(S) endpoints. Each server must be configured with either a `command` or a `url`, depending on how it's hosted.
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { MCPClient } from '@mastra/mcp'
|
|
46
|
+
|
|
47
|
+
export const testMcpClient = new MCPClient({
|
|
48
|
+
id: 'test-mcp-client',
|
|
49
|
+
servers: {
|
|
50
|
+
wikipedia: {
|
|
51
|
+
command: 'npx',
|
|
52
|
+
args: ['-y', 'wikipedia-mcp'],
|
|
53
|
+
},
|
|
54
|
+
weather: {
|
|
55
|
+
url: new URL(
|
|
56
|
+
`https://server.smithery.ai/@smithery-ai/national-weather-service/mcp?api_key=${process.env.SMITHERY_API_KEY}`,
|
|
57
|
+
),
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
})
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
> **Info:** Visit [MCPClient](https://mastra.ai/reference/tools/mcp-client) for a full list of configuration options.
|
|
64
|
+
|
|
65
|
+
> **Authentication:** For connecting to OAuth-protected MCP servers, see the [OAuth Authentication](https://mastra.ai/reference/tools/mcp-client) section.
|
|
66
|
+
|
|
67
|
+
## Using `MCPClient` with an agent
|
|
68
|
+
|
|
69
|
+
To use tools from an MCP server in an agent, import your `MCPClient` and call `.listTools()` in the `tools` parameter. This loads from the defined MCP servers, making them available to the agent.
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { Agent } from '@mastra/core/agent'
|
|
73
|
+
import { testMcpClient } from '../mcp/test-mcp-client'
|
|
74
|
+
|
|
75
|
+
export const testAgent = new Agent({
|
|
76
|
+
id: 'test-agent',
|
|
77
|
+
name: 'Test Agent',
|
|
78
|
+
description: 'You are a helpful AI assistant',
|
|
79
|
+
instructions: `
|
|
80
|
+
You are a helpful assistant that has access to the following MCP Servers.
|
|
81
|
+
- Wikipedia MCP Server
|
|
82
|
+
- US National Weather Service
|
|
83
|
+
|
|
84
|
+
Answer questions using the information you find using the MCP Servers.`,
|
|
85
|
+
model: 'openai/gpt-5.1',
|
|
86
|
+
tools: await testMcpClient.listTools(),
|
|
87
|
+
})
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
> **Info:** Visit [Agent Class](https://mastra.ai/reference/agents/agent) for a full list of configuration options.
|
|
91
|
+
|
|
92
|
+
## Configuring `MCPServer`
|
|
93
|
+
|
|
94
|
+
To expose agents, tools, and workflows from your Mastra application to external systems over HTTP(S) use the `MCPServer` class. This makes them accessible to any system or agent that supports the protocol.
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { MCPServer } from '@mastra/mcp'
|
|
98
|
+
|
|
99
|
+
import { testAgent } from '../agents/test-agent'
|
|
100
|
+
import { testWorkflow } from '../workflows/test-workflow'
|
|
101
|
+
import { testTool } from '../tools/test-tool'
|
|
102
|
+
|
|
103
|
+
export const testMcpServer = new MCPServer({
|
|
104
|
+
id: 'test-mcp-server',
|
|
105
|
+
name: 'Test Server',
|
|
106
|
+
version: '1.0.0',
|
|
107
|
+
agents: { testAgent },
|
|
108
|
+
tools: { testTool },
|
|
109
|
+
workflows: { testWorkflow },
|
|
110
|
+
})
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
> **Info:** Visit [MCPServer](https://mastra.ai/reference/tools/mcp-server) for a full list of configuration options.
|
|
114
|
+
|
|
115
|
+
> **Authentication:** To protect your MCP server with OAuth, see the [OAuth Protection](https://mastra.ai/reference/tools/mcp-server) section.
|
|
116
|
+
|
|
117
|
+
## Registering an `MCPServer`
|
|
118
|
+
|
|
119
|
+
To make an MCP server available to other systems or agents that support the protocol, register it in the main `Mastra` instance using `mcpServers`.
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import { Mastra } from '@mastra/core/mastra'
|
|
123
|
+
|
|
124
|
+
import { testMcpServer } from './mcp/test-mcp-server'
|
|
125
|
+
|
|
126
|
+
export const mastra = new Mastra({
|
|
127
|
+
mcpServers: { testMcpServer },
|
|
128
|
+
})
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Static and dynamic tools
|
|
132
|
+
|
|
133
|
+
`MCPClient` offers two approaches to retrieving tools from connected servers, suitable for different application architectures:
|
|
134
|
+
|
|
135
|
+
| Feature | Static Configuration (`await mcp.listTools()`) | Dynamic Configuration (`await mcp.listToolsets()`) |
|
|
136
|
+
| ----------------- | ---------------------------------------------- | ---------------------------------------------------- |
|
|
137
|
+
| **Use Case** | Single-user, static config (e.g., CLI tool) | Multi-user, dynamic config (e.g., SaaS app) |
|
|
138
|
+
| **Configuration** | Fixed at agent initialization | Per-request, dynamic |
|
|
139
|
+
| **Credentials** | Shared across all uses | Can vary per user/request |
|
|
140
|
+
| **Agent Setup** | Tools added in `Agent` constructor | Tools passed in `.generate()` or `.stream()` options |
|
|
141
|
+
|
|
142
|
+
### Static tools
|
|
143
|
+
|
|
144
|
+
Use the `.listTools()` method to fetch tools from all configured MCP servers. This is suitable when configuration (such as API keys) is static and consistent across users or requests. Call it once and pass the result to the `tools` property when defining your agent.
|
|
145
|
+
|
|
146
|
+
> **Info:** Visit [listTools()](https://mastra.ai/reference/tools/mcp-client) for more information.
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import { Agent } from '@mastra/core/agent'
|
|
150
|
+
|
|
151
|
+
import { testMcpClient } from '../mcp/test-mcp-client'
|
|
152
|
+
|
|
153
|
+
export const testAgent = new Agent({
|
|
154
|
+
id: 'test-agent',
|
|
155
|
+
tools: await testMcpClient.listTools(),
|
|
156
|
+
})
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Dynamic tools
|
|
160
|
+
|
|
161
|
+
Use the `.listToolsets()` method when tool configuration may vary by request or user, such as in a multi-tenant system where each user provides their own API key. This method returns toolsets that can be passed to the `toolsets` option in the agent's `.generate()` or `.stream()` calls.
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
import { MCPClient } from '@mastra/mcp'
|
|
165
|
+
import { mastra } from './mastra'
|
|
166
|
+
|
|
167
|
+
async function handleRequest(userPrompt: string, userApiKey: string) {
|
|
168
|
+
const userMcp = new MCPClient({
|
|
169
|
+
servers: {
|
|
170
|
+
weather: {
|
|
171
|
+
url: new URL('http://localhost:8080/mcp'),
|
|
172
|
+
requestInit: {
|
|
173
|
+
headers: {
|
|
174
|
+
Authorization: `Bearer ${userApiKey}`,
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
const agent = mastra.getAgent('testAgent')
|
|
182
|
+
|
|
183
|
+
const response = await agent.generate(userPrompt, {
|
|
184
|
+
toolsets: await userMcp.listToolsets(),
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
await userMcp.disconnect()
|
|
188
|
+
|
|
189
|
+
return Response.json({
|
|
190
|
+
data: response.text,
|
|
191
|
+
})
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
> **Info:** Visit [listToolsets()](https://mastra.ai/reference/tools/mcp-client) for more information.
|
|
196
|
+
|
|
197
|
+
## Connecting to an MCP registry
|
|
198
|
+
|
|
199
|
+
MCP servers can be discovered through registries. Here's how to connect to some popular ones using `MCPClient`:
|
|
200
|
+
|
|
201
|
+
**Klavis AI**:
|
|
202
|
+
|
|
203
|
+
[Klavis AI](https://klavis.ai) provides hosted, enterprise-authenticated, high-quality MCP servers.
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
import { MCPClient } from '@mastra/mcp'
|
|
207
|
+
|
|
208
|
+
const mcp = new MCPClient({
|
|
209
|
+
servers: {
|
|
210
|
+
salesforce: {
|
|
211
|
+
url: new URL(
|
|
212
|
+
'https://salesforce-mcp-server.klavis.ai/mcp/?instance_id={private-instance-id}',
|
|
213
|
+
),
|
|
214
|
+
},
|
|
215
|
+
hubspot: {
|
|
216
|
+
url: new URL('https://hubspot-mcp-server.klavis.ai/mcp/?instance_id={private-instance-id}'),
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
})
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Klavis AI offers enterprise-grade authentication and security for production deployments.
|
|
223
|
+
|
|
224
|
+
For more details on how to integrate Mastra with Klavis, check out their [documentation](https://docs.klavis.ai/documentation/ai-platform-integration/mastra).
|
|
225
|
+
|
|
226
|
+
**mcp.run**:
|
|
227
|
+
|
|
228
|
+
[mcp.run](https://www.mcp.run/) provides pre-authenticated, managed MCP servers. Tools are grouped into Profiles, each with a unique, signed URL.
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
import { MCPClient } from '@mastra/mcp'
|
|
232
|
+
|
|
233
|
+
const mcp = new MCPClient({
|
|
234
|
+
servers: {
|
|
235
|
+
marketing: {
|
|
236
|
+
// Example profile name
|
|
237
|
+
url: new URL(process.env.MCP_RUN_SSE_URL!), // Get URL from mcp.run profile
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
})
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
> **Important:** Treat the mcp.run SSE URL like a password. Store it securely, for example, in an environment variable.
|
|
244
|
+
>
|
|
245
|
+
> ```bash
|
|
246
|
+
> MCP_RUN_SSE_URL=https://www.mcp.run/api/mcp/sse?nonce=...
|
|
247
|
+
> ```
|
|
248
|
+
|
|
249
|
+
**Composio.dev**:
|
|
250
|
+
|
|
251
|
+
[Composio.dev](https://composio.dev) offers a registry of [SSE-based MCP servers](https://mcp.composio.dev). You can use the SSE URL generated for tools like Cursor directly.
|
|
252
|
+
|
|
253
|
+
```typescript
|
|
254
|
+
import { MCPClient } from '@mastra/mcp'
|
|
255
|
+
|
|
256
|
+
const mcp = new MCPClient({
|
|
257
|
+
servers: {
|
|
258
|
+
googleSheets: {
|
|
259
|
+
url: new URL('https://mcp.composio.dev/googlesheets/[private-url-path]'),
|
|
260
|
+
},
|
|
261
|
+
gmail: {
|
|
262
|
+
url: new URL('https://mcp.composio.dev/gmail/[private-url-path]'),
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
})
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Authentication with services like Google Sheets often happens interactively through the agent conversation.
|
|
269
|
+
|
|
270
|
+
_Note: Composio URLs are typically tied to a single user account, making them best suited for personal automation rather than multi-tenant applications._
|
|
271
|
+
|
|
272
|
+
**Smithery.ai**:
|
|
273
|
+
|
|
274
|
+
[Smithery.ai](https://smithery.ai) provides a registry accessible via their CLI.
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
// Unix/Mac
|
|
278
|
+
import { MCPClient } from '@mastra/mcp'
|
|
279
|
+
|
|
280
|
+
const mcp = new MCPClient({
|
|
281
|
+
servers: {
|
|
282
|
+
sequentialThinking: {
|
|
283
|
+
command: 'npx',
|
|
284
|
+
args: [
|
|
285
|
+
'-y',
|
|
286
|
+
'@smithery/cli@latest',
|
|
287
|
+
'run',
|
|
288
|
+
'@smithery-ai/server-sequential-thinking',
|
|
289
|
+
'--config',
|
|
290
|
+
'{}',
|
|
291
|
+
],
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
})
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
```typescript
|
|
298
|
+
// Windows
|
|
299
|
+
import { MCPClient } from '@mastra/mcp'
|
|
300
|
+
|
|
301
|
+
const mcp = new MCPClient({
|
|
302
|
+
servers: {
|
|
303
|
+
sequentialThinking: {
|
|
304
|
+
command: 'npx',
|
|
305
|
+
args: [
|
|
306
|
+
'-y',
|
|
307
|
+
'@smithery/cli@latest',
|
|
308
|
+
'run',
|
|
309
|
+
'@smithery-ai/server-sequential-thinking',
|
|
310
|
+
'--config',
|
|
311
|
+
'{}',
|
|
312
|
+
],
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
})
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
**Ampersand**:
|
|
319
|
+
|
|
320
|
+
[Ampersand](https://withampersand.com?utm_source=mastra-docs) offers an [MCP Server](https://docs.withampersand.com/mcp) that allows you to connect your agent to 150+ integrations with SaaS products like Salesforce, Hubspot, and Zendesk.
|
|
321
|
+
|
|
322
|
+
```typescript
|
|
323
|
+
// MCPClient with Ampersand MCP Server using SSE
|
|
324
|
+
export const mcp = new MCPClient({
|
|
325
|
+
servers: {
|
|
326
|
+
'@amp-labs/mcp-server': {
|
|
327
|
+
url: `https://mcp.withampersand.com/v1/sse?${new URLSearchParams({
|
|
328
|
+
apiKey: process.env.AMPERSAND_API_KEY,
|
|
329
|
+
project: process.env.AMPERSAND_PROJECT_ID,
|
|
330
|
+
integrationName: process.env.AMPERSAND_INTEGRATION_NAME,
|
|
331
|
+
groupRef: process.env.AMPERSAND_GROUP_REF,
|
|
332
|
+
})}`,
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
})
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
```typescript
|
|
339
|
+
// If you prefer to run the MCP server locally:
|
|
340
|
+
import { MCPClient } from '@mastra/mcp'
|
|
341
|
+
|
|
342
|
+
// MCPClient with Ampersand MCP Server using stdio transport
|
|
343
|
+
export const mcp = new MCPClient({
|
|
344
|
+
servers: {
|
|
345
|
+
'@amp-labs/mcp-server': {
|
|
346
|
+
command: 'npx',
|
|
347
|
+
args: [
|
|
348
|
+
'-y',
|
|
349
|
+
'@amp-labs/mcp-server@latest',
|
|
350
|
+
'--transport',
|
|
351
|
+
'stdio',
|
|
352
|
+
'--project',
|
|
353
|
+
process.env.AMPERSAND_PROJECT_ID,
|
|
354
|
+
'--integrationName',
|
|
355
|
+
process.env.AMPERSAND_INTEGRATION_NAME,
|
|
356
|
+
'--groupRef',
|
|
357
|
+
process.env.AMPERSAND_GROUP_REF, // optional
|
|
358
|
+
],
|
|
359
|
+
env: {
|
|
360
|
+
AMPERSAND_API_KEY: process.env.AMPERSAND_API_KEY,
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
},
|
|
364
|
+
})
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
As an alternative to MCP, Ampersand's AI SDK also has an adapter for Mastra, so you can [directly import Ampersand tools](https://docs.withampersand.com/ai-sdk#use-with-mastra) for your agent to access.
|
|
368
|
+
|
|
369
|
+
## Related
|
|
370
|
+
|
|
371
|
+
- [Using Tools](https://mastra.ai/docs/agents/using-tools)
|
|
372
|
+
- [MCPClient](https://mastra.ai/reference/tools/mcp-client)
|
|
373
|
+
- [MCPServer](https://mastra.ai/reference/tools/mcp-server)
|