@mastra/core 1.2.1-alpha.0 → 1.3.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +341 -0
- package/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +2093 -262
- package/dist/agent/agent-legacy.d.ts.map +1 -1
- package/dist/agent/agent.d.ts +12 -3
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/index.cjs +13 -13
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/index.cjs +18 -18
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/message-list/message-list.d.ts.map +1 -1
- package/dist/agent/types.d.ts +6 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts +3 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts +3 -1
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts.map +1 -1
- package/dist/base.cjs +2 -2
- package/dist/base.d.ts +13 -1
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +1 -1
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.js +1 -1
- package/dist/cache/index.cjs +3 -3
- package/dist/cache/index.js +1 -1
- package/dist/{chunk-ENCTSDWC.js → chunk-2GWTJFVM.js} +2410 -1402
- package/dist/chunk-2GWTJFVM.js.map +1 -0
- package/dist/{chunk-OB4V67IX.cjs → chunk-2K5PNW2U.cjs} +4 -4
- package/dist/{chunk-OB4V67IX.cjs.map → chunk-2K5PNW2U.cjs.map} +1 -1
- package/dist/{chunk-VZXYBFCX.cjs → chunk-2P6DD7M5.cjs} +10 -10
- package/dist/{chunk-VZXYBFCX.cjs.map → chunk-2P6DD7M5.cjs.map} +1 -1
- package/dist/{chunk-Q2D7LERO.cjs → chunk-2VD5OGOT.cjs} +4 -4
- package/dist/{chunk-Q2D7LERO.cjs.map → chunk-2VD5OGOT.cjs.map} +1 -1
- package/dist/{chunk-2DMSFLJY.cjs → chunk-6TZKQI4R.cjs} +8 -8
- package/dist/chunk-6TZKQI4R.cjs.map +1 -0
- package/dist/{chunk-4NG7CKEG.js → chunk-6VGCVSP4.js} +3 -3
- package/dist/{chunk-4NG7CKEG.js.map → chunk-6VGCVSP4.js.map} +1 -1
- package/dist/{chunk-IIZF4W7B.cjs → chunk-7UWHFWST.cjs} +52 -5
- package/dist/chunk-7UWHFWST.cjs.map +1 -0
- package/dist/{chunk-VW7YQWDW.cjs → chunk-BFIOQFGF.cjs} +28 -2
- package/dist/chunk-BFIOQFGF.cjs.map +1 -0
- package/dist/{chunk-E3VFKTIA.js → chunk-BXLLXTT4.js} +2245 -179
- package/dist/chunk-BXLLXTT4.js.map +1 -0
- package/dist/{chunk-HMCXNOF6.cjs → chunk-CGPH7CMG.cjs} +2431 -1417
- package/dist/chunk-CGPH7CMG.cjs.map +1 -0
- package/dist/{chunk-GVLPTDJA.cjs → chunk-D5JZT6EK.cjs} +236 -63
- package/dist/chunk-D5JZT6EK.cjs.map +1 -0
- package/dist/{chunk-5SOS47PH.cjs → chunk-FLHFB23E.cjs} +454 -222
- package/dist/chunk-FLHFB23E.cjs.map +1 -0
- package/dist/{chunk-XCPEEIHI.cjs → chunk-GCTAD6B7.cjs} +3012 -927
- package/dist/chunk-GCTAD6B7.cjs.map +1 -0
- package/dist/{chunk-W3AQUG66.js → chunk-GIY5BINT.js} +4 -4
- package/dist/{chunk-W3AQUG66.js.map → chunk-GIY5BINT.js.map} +1 -1
- package/dist/{chunk-M6VFJX5A.js → chunk-GMSAGYTB.js} +3 -3
- package/dist/{chunk-M6VFJX5A.js.map → chunk-GMSAGYTB.js.map} +1 -1
- package/dist/{chunk-JRJJ5VQE.cjs → chunk-GZD6443M.cjs} +99 -55
- package/dist/chunk-GZD6443M.cjs.map +1 -0
- package/dist/{chunk-Z6NRYYOH.js → chunk-ILQXPZCD.js} +9 -4
- package/dist/chunk-ILQXPZCD.js.map +1 -0
- package/dist/{chunk-5YVR7B4R.js → chunk-JQNREL64.js} +29 -9
- package/dist/chunk-JQNREL64.js.map +1 -0
- package/dist/{chunk-QOFI2WBM.cjs → chunk-JU6K7UDX.cjs} +991 -229
- package/dist/chunk-JU6K7UDX.cjs.map +1 -0
- package/dist/{chunk-HN2MSTR6.cjs → chunk-KAJNBNWP.cjs} +283 -38
- package/dist/chunk-KAJNBNWP.cjs.map +1 -0
- package/dist/{chunk-MSWXEOZC.js → chunk-KL2JPSRX.js} +5 -5
- package/dist/chunk-KL2JPSRX.js.map +1 -0
- package/dist/{chunk-MQB7XFXP.js → chunk-LHRHOPUC.js} +3 -3
- package/dist/{chunk-MQB7XFXP.js.map → chunk-LHRHOPUC.js.map} +1 -1
- package/dist/{chunk-VX7UA3SO.js → chunk-MOOJ3H3C.js} +974 -217
- package/dist/chunk-MOOJ3H3C.js.map +1 -0
- package/dist/{chunk-HU2ONA2W.cjs → chunk-ON2KVIUJ.cjs} +17 -17
- package/dist/{chunk-HU2ONA2W.cjs.map → chunk-ON2KVIUJ.cjs.map} +1 -1
- package/dist/{chunk-I66TMZJ3.cjs → chunk-OOCEAC6U.cjs} +21 -18
- package/dist/chunk-OOCEAC6U.cjs.map +1 -0
- package/dist/{chunk-MNWW2R3U.js → chunk-OV7OOUUR.js} +90 -54
- package/dist/chunk-OV7OOUUR.js.map +1 -0
- package/dist/{chunk-C4WWWQHT.cjs → chunk-RO47SMI7.cjs} +23 -3
- package/dist/chunk-RO47SMI7.cjs.map +1 -0
- package/dist/{chunk-6FG6FU5Y.cjs → chunk-RQ56ZSIR.cjs} +4 -4
- package/dist/{chunk-6FG6FU5Y.cjs.map → chunk-RQ56ZSIR.cjs.map} +1 -1
- package/dist/{chunk-IW3BNL7A.js → chunk-RS6CZXGA.js} +50 -3
- package/dist/chunk-RS6CZXGA.js.map +1 -0
- package/dist/{chunk-AIJLACR2.js → chunk-S53FKKVL.js} +27 -3
- package/dist/chunk-S53FKKVL.js.map +1 -0
- package/dist/{chunk-G6E3QNJC.js → chunk-SBPPGJL6.js} +4078 -4333
- package/dist/chunk-SBPPGJL6.js.map +1 -0
- package/dist/{chunk-UZL4H5P2.cjs → chunk-SH4PCZ3X.cjs} +5375 -5648
- package/dist/chunk-SH4PCZ3X.cjs.map +1 -0
- package/dist/{chunk-ZWM2CAIM.js → chunk-STKNQDVA.js} +4 -4
- package/dist/{chunk-ZWM2CAIM.js.map → chunk-STKNQDVA.js.map} +1 -1
- package/dist/{chunk-A5QFWX67.cjs → chunk-U2CABSMC.cjs} +79 -59
- package/dist/chunk-U2CABSMC.cjs.map +1 -0
- package/dist/{chunk-7MDVYPWX.cjs → chunk-UE2G2LRP.cjs} +9 -4
- package/dist/chunk-UE2G2LRP.cjs.map +1 -0
- package/dist/{chunk-AUF6U2BL.js → chunk-VM25PDSW.js} +5 -5
- package/dist/{chunk-AUF6U2BL.js.map → chunk-VM25PDSW.js.map} +1 -1
- package/dist/{chunk-RXD5EGQF.js → chunk-VVD56FI4.js} +228 -55
- package/dist/chunk-VVD56FI4.js.map +1 -0
- package/dist/{chunk-JIT2OY3X.js → chunk-WCAFTXGK.js} +23 -3
- package/dist/chunk-WCAFTXGK.js.map +1 -0
- package/dist/{chunk-P62OJXQ4.js → chunk-WL3AW3YA.js} +282 -37
- package/dist/chunk-WL3AW3YA.js.map +1 -0
- package/dist/{chunk-YLODOPYM.cjs → chunk-XDD5V446.cjs} +4163 -5352
- package/dist/chunk-XDD5V446.cjs.map +1 -0
- package/dist/{chunk-B4M33FCS.cjs → chunk-XQVYEOI7.cjs} +7 -7
- package/dist/{chunk-B4M33FCS.cjs.map → chunk-XQVYEOI7.cjs.map} +1 -1
- package/dist/{chunk-BP2TSCBW.js → chunk-ZATLLPIH.js} +4391 -5561
- package/dist/chunk-ZATLLPIH.js.map +1 -0
- package/dist/{chunk-T6PRRKMW.js → chunk-ZHFM7HCQ.js} +9 -6
- package/dist/chunk-ZHFM7HCQ.js.map +1 -0
- package/dist/{chunk-WFUNLRQX.js → chunk-ZRUTE56J.js} +366 -134
- package/dist/chunk-ZRUTE56J.js.map +1 -0
- package/dist/deployer/index.cjs +2 -2
- package/dist/deployer/index.js +1 -1
- package/dist/docs/SKILL.md +2 -9
- package/dist/docs/assets/SOURCE_MAP.json +399 -342
- package/dist/docs/references/docs-agents-agent-memory.md +45 -1
- package/dist/docs/references/docs-agents-network-approval.md +1 -1
- package/dist/docs/references/docs-agents-networks.md +3 -3
- package/dist/docs/references/docs-agents-overview.md +8 -0
- package/dist/docs/references/docs-agents-using-tools.md +82 -72
- package/dist/docs/references/docs-memory-observational-memory.md +11 -8
- package/dist/docs/references/docs-observability-overview.md +1 -1
- package/dist/docs/references/docs-observability-tracing-exporters-langsmith.md +70 -0
- package/dist/docs/references/docs-observability-tracing-overview.md +1 -1
- package/dist/docs/references/docs-server-middleware.md +0 -2
- package/dist/docs/references/docs-server-request-context.md +17 -0
- package/dist/docs/references/docs-workflows-agents-and-tools.md +2 -2
- package/dist/docs/references/docs-workflows-overview.md +1 -1
- package/dist/docs/references/docs-workspace-filesystem.md +2 -0
- package/dist/docs/references/docs-workspace-overview.md +3 -1
- package/dist/docs/references/docs-workspace-sandbox.md +2 -0
- package/dist/docs/references/docs-workspace-search.md +2 -0
- package/dist/docs/references/docs-workspace-skills.md +3 -1
- package/dist/docs/references/reference-agents-getTools.md +1 -6
- package/dist/docs/references/reference-agents-listAgents.md +1 -1
- package/dist/docs/references/reference-agents-network.md +0 -2
- package/dist/docs/references/reference-cli-mastra.md +29 -4
- package/dist/docs/references/reference-client-js-agents.md +1 -1
- package/dist/docs/references/reference-configuration.md +1 -1
- package/dist/docs/references/reference-core-getStoredAgentById.md +2 -2
- package/dist/docs/references/reference-core-listStoredAgents.md +1 -1
- package/dist/docs/references/reference-memory-observational-memory.md +2 -0
- package/dist/docs/references/reference-tools-mcp-client.md +0 -2
- package/dist/docs/references/reference-workflows-step.md +2 -0
- package/dist/docs/references/reference-workflows-workflow-methods-map.md +2 -2
- package/dist/docs/references/reference-workspace-filesystem.md +2 -0
- package/dist/docs/references/reference-workspace-local-filesystem.md +2 -0
- package/dist/docs/references/reference-workspace-local-sandbox.md +2 -0
- package/dist/docs/references/reference-workspace-sandbox.md +2 -0
- package/dist/docs/references/reference-workspace-workspace-class.md +2 -0
- package/dist/docs/references/reference.md +7 -2
- package/dist/editor/index.d.ts +1 -1
- package/dist/editor/index.d.ts.map +1 -1
- package/dist/editor/types.d.ts +53 -48
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/evals/base.d.ts +15 -0
- package/dist/evals/base.d.ts.map +1 -1
- package/dist/evals/index.cjs +20 -20
- package/dist/evals/index.js +3 -3
- package/dist/evals/run/index.d.ts +3 -3
- package/dist/evals/run/index.d.ts.map +1 -1
- package/dist/evals/scoreTraces/index.cjs +5 -5
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/features/index.cjs +1 -1
- package/dist/features/index.cjs.map +1 -1
- package/dist/features/index.d.ts.map +1 -1
- package/dist/features/index.js +1 -1
- package/dist/features/index.js.map +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/integration/index.cjs +2 -2
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.cjs +16 -16
- package/dist/llm/index.js +5 -5
- package/dist/llm/model/gateways/constants.d.ts.map +1 -1
- package/dist/llm/model/gateways/models-dev.d.ts.map +1 -1
- package/dist/llm/model/model.loop.d.ts +1 -1
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +128 -10
- package/dist/llm/model/resolve-model.d.ts.map +1 -1
- package/dist/loop/index.cjs +12 -12
- package/dist/loop/index.js +1 -1
- package/dist/loop/network/index.d.ts +3 -3
- package/dist/loop/network/index.d.ts.map +1 -1
- package/dist/loop/network/run-command-tool.d.ts +1 -1
- package/dist/loop/types.d.ts +13 -0
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +9 -9
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +7 -7
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +3 -3
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts +9 -9
- package/dist/loop/workflows/schema.d.ts +12 -12
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +91 -5
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/mcp/index.cjs +2 -2
- package/dist/mcp/index.js +1 -1
- package/dist/memory/index.cjs +14 -14
- package/dist/memory/index.js +1 -1
- package/dist/memory/mock.d.ts.map +1 -1
- package/dist/memory/types.d.ts +128 -0
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/models-dev-FQVUTQ7L.js +3 -0
- package/dist/{models-dev-Z45JSLWD.js.map → models-dev-FQVUTQ7L.js.map} +1 -1
- package/dist/models-dev-PPIXUUCU.cjs +12 -0
- package/dist/{models-dev-OQKVMEIT.cjs.map → models-dev-PPIXUUCU.cjs.map} +1 -1
- package/dist/netlify-4RIKF7Y3.js +3 -0
- package/dist/{netlify-SSWMYSAX.js.map → netlify-4RIKF7Y3.js.map} +1 -1
- package/dist/netlify-V5F7JEJH.cjs +12 -0
- package/dist/{netlify-TXZZCT6N.cjs.map → netlify-V5F7JEJH.cjs.map} +1 -1
- package/dist/processors/index.cjs +41 -41
- package/dist/processors/index.js +1 -1
- package/dist/processors/step-schema.d.ts +44 -44
- package/dist/provider-registry-C6XCYX44.cjs +40 -0
- package/dist/{provider-registry-NR7FXV2Q.cjs.map → provider-registry-C6XCYX44.cjs.map} +1 -1
- package/dist/provider-registry-NWU4YFQW.js +3 -0
- package/dist/{provider-registry-RPOTQNHI.js.map → provider-registry-NWU4YFQW.js.map} +1 -1
- package/dist/provider-registry.json +278 -33
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/server/index.cjs +3 -3
- package/dist/server/index.js +1 -1
- package/dist/storage/base.d.ts +3 -1
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/constants.cjs +51 -19
- package/dist/storage/constants.d.ts +10 -2
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/agents/base.d.ts +13 -164
- package/dist/storage/domains/agents/base.d.ts.map +1 -1
- package/dist/storage/domains/agents/index.d.ts +0 -1
- package/dist/storage/domains/agents/index.d.ts.map +1 -1
- package/dist/storage/domains/agents/inmemory.d.ts +6 -10
- package/dist/storage/domains/agents/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/index.d.ts +3 -0
- package/dist/storage/domains/index.d.ts.map +1 -1
- package/dist/storage/domains/inmemory-db.d.ts +7 -1
- package/dist/storage/domains/inmemory-db.d.ts.map +1 -1
- package/dist/storage/domains/memory/base.d.ts +45 -5
- package/dist/storage/domains/memory/base.d.ts.map +1 -1
- package/dist/storage/domains/memory/inmemory.d.ts +7 -7
- package/dist/storage/domains/memory/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/observability/types.d.ts +62 -62
- package/dist/storage/domains/operations/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/prompt-blocks/base.d.ts +47 -0
- package/dist/storage/domains/prompt-blocks/base.d.ts.map +1 -0
- package/dist/storage/domains/prompt-blocks/index.d.ts +3 -0
- package/dist/storage/domains/prompt-blocks/index.d.ts.map +1 -0
- package/dist/storage/domains/prompt-blocks/inmemory.d.ts +31 -0
- package/dist/storage/domains/prompt-blocks/inmemory.d.ts.map +1 -0
- package/dist/storage/domains/scorer-definitions/base.d.ts +47 -0
- package/dist/storage/domains/scorer-definitions/base.d.ts.map +1 -0
- package/dist/storage/domains/scorer-definitions/index.d.ts +3 -0
- package/dist/storage/domains/scorer-definitions/index.d.ts.map +1 -0
- package/dist/storage/domains/scorer-definitions/inmemory.d.ts +31 -0
- package/dist/storage/domains/scorer-definitions/inmemory.d.ts.map +1 -0
- package/dist/storage/domains/versioned.d.ts +136 -0
- package/dist/storage/domains/versioned.d.ts.map +1 -0
- package/dist/storage/index.cjs +156 -104
- package/dist/storage/index.js +2 -2
- package/dist/storage/mock.d.ts.map +1 -1
- package/dist/storage/types.d.ts +481 -27
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/MastraAgentNetworkStream.d.ts +1 -1
- package/dist/stream/MastraWorkflowStream.d.ts +1 -1
- package/dist/stream/RunOutput.d.ts +1 -1
- package/dist/stream/RunOutput.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts +4 -0
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +11 -11
- package/dist/stream/index.js +2 -2
- package/dist/test-utils/llm-mock.cjs +4 -4
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.js +1 -1
- package/dist/tools/is-vercel-tool.cjs +2 -2
- package/dist/tools/is-vercel-tool.js +1 -1
- package/dist/tools/tool-builder/builder.d.ts.map +1 -1
- package/dist/tools/types.d.ts +15 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/validation.d.ts.map +1 -1
- package/dist/tts/index.cjs +2 -2
- package/dist/tts/index.js +1 -1
- package/dist/types/zod-compat.d.ts +2 -2
- package/dist/types/zod-compat.d.ts.map +1 -1
- package/dist/utils/zod-utils.d.ts +19 -0
- package/dist/utils/zod-utils.d.ts.map +1 -1
- package/dist/utils.cjs +28 -28
- package/dist/utils.d.ts +7 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -2
- package/dist/vector/index.cjs +9 -9
- package/dist/vector/index.js +2 -2
- package/dist/voice/index.cjs +6 -6
- package/dist/voice/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/step-executor.d.ts.map +1 -1
- package/dist/workflows/evented/workflow.d.ts +3 -1
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/execution-engine.d.ts.map +1 -1
- package/dist/workflows/index.cjs +25 -25
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/step.d.ts +4 -3
- package/dist/workflows/step.d.ts.map +1 -1
- package/dist/workflows/types.d.ts +2 -1
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts +12 -4
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/dist/workspace/errors.d.ts +6 -0
- package/dist/workspace/errors.d.ts.map +1 -1
- package/dist/workspace/filesystem/composite-filesystem.d.ts +93 -0
- package/dist/workspace/filesystem/composite-filesystem.d.ts.map +1 -0
- package/dist/workspace/filesystem/filesystem.d.ts +35 -0
- package/dist/workspace/filesystem/filesystem.d.ts.map +1 -1
- package/dist/workspace/filesystem/index.d.ts +2 -0
- package/dist/workspace/filesystem/index.d.ts.map +1 -1
- package/dist/workspace/filesystem/local-filesystem.d.ts +9 -1
- package/dist/workspace/filesystem/local-filesystem.d.ts.map +1 -1
- package/dist/workspace/filesystem/mastra-filesystem.d.ts +92 -3
- package/dist/workspace/filesystem/mastra-filesystem.d.ts.map +1 -1
- package/dist/workspace/filesystem/mount.d.ts +34 -0
- package/dist/workspace/filesystem/mount.d.ts.map +1 -0
- package/dist/workspace/index.cjs +62 -34
- package/dist/workspace/index.d.ts +6 -2
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/lifecycle.d.ts +29 -0
- package/dist/workspace/lifecycle.d.ts.map +1 -1
- package/dist/workspace/sandbox/errors.d.ts +50 -0
- package/dist/workspace/sandbox/errors.d.ts.map +1 -0
- package/dist/workspace/sandbox/index.d.ts +3 -0
- package/dist/workspace/sandbox/index.d.ts.map +1 -1
- package/dist/workspace/sandbox/local-sandbox.d.ts +17 -2
- package/dist/workspace/sandbox/local-sandbox.d.ts.map +1 -1
- package/dist/workspace/sandbox/mastra-sandbox.d.ts +153 -6
- package/dist/workspace/sandbox/mastra-sandbox.d.ts.map +1 -1
- package/dist/workspace/sandbox/mount-manager.d.ts +195 -0
- package/dist/workspace/sandbox/mount-manager.d.ts.map +1 -0
- package/dist/workspace/sandbox/sandbox.d.ts +37 -84
- package/dist/workspace/sandbox/sandbox.d.ts.map +1 -1
- package/dist/workspace/sandbox/types.d.ts +92 -0
- package/dist/workspace/sandbox/types.d.ts.map +1 -0
- package/dist/workspace/tools/tools.d.ts.map +1 -1
- package/dist/workspace/tools/tree-formatter.d.ts.map +1 -1
- package/dist/workspace/workspace.d.ts +73 -3
- package/dist/workspace/workspace.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/llm/model/provider-types.generated.d.ts +128 -10
- package/dist/chunk-2DMSFLJY.cjs.map +0 -1
- package/dist/chunk-5SOS47PH.cjs.map +0 -1
- package/dist/chunk-5YVR7B4R.js.map +0 -1
- package/dist/chunk-7MDVYPWX.cjs.map +0 -1
- package/dist/chunk-A5QFWX67.cjs.map +0 -1
- package/dist/chunk-AIJLACR2.js.map +0 -1
- package/dist/chunk-BP2TSCBW.js.map +0 -1
- package/dist/chunk-C4WWWQHT.cjs.map +0 -1
- package/dist/chunk-E3VFKTIA.js.map +0 -1
- package/dist/chunk-ENCTSDWC.js.map +0 -1
- package/dist/chunk-G6E3QNJC.js.map +0 -1
- package/dist/chunk-GVLPTDJA.cjs.map +0 -1
- package/dist/chunk-HMCXNOF6.cjs.map +0 -1
- package/dist/chunk-HN2MSTR6.cjs.map +0 -1
- package/dist/chunk-I66TMZJ3.cjs.map +0 -1
- package/dist/chunk-IIZF4W7B.cjs.map +0 -1
- package/dist/chunk-IW3BNL7A.js.map +0 -1
- package/dist/chunk-JIT2OY3X.js.map +0 -1
- package/dist/chunk-JRJJ5VQE.cjs.map +0 -1
- package/dist/chunk-MNWW2R3U.js.map +0 -1
- package/dist/chunk-MSWXEOZC.js.map +0 -1
- package/dist/chunk-P62OJXQ4.js.map +0 -1
- package/dist/chunk-QOFI2WBM.cjs.map +0 -1
- package/dist/chunk-RXD5EGQF.js.map +0 -1
- package/dist/chunk-T6PRRKMW.js.map +0 -1
- package/dist/chunk-UZL4H5P2.cjs.map +0 -1
- package/dist/chunk-VW7YQWDW.cjs.map +0 -1
- package/dist/chunk-VX7UA3SO.js.map +0 -1
- package/dist/chunk-WFUNLRQX.js.map +0 -1
- package/dist/chunk-XCPEEIHI.cjs.map +0 -1
- package/dist/chunk-YLODOPYM.cjs.map +0 -1
- package/dist/chunk-Z6NRYYOH.js.map +0 -1
- package/dist/docs/references/docs-tools-mcp-advanced-usage.md +0 -143
- package/dist/docs/references/docs-tools-mcp-mcp-overview.md +0 -383
- package/dist/docs/references/docs-tools-mcp-overview.md +0 -78
- package/dist/docs/references/docs-workflows-input-data-mapping.md +0 -102
- package/dist/docs/references/reference-deployer-netlify.md +0 -14
- package/dist/docs/references/reference-deployer-vercel.md +0 -39
- package/dist/docs/references/reference-tools-client.md +0 -228
- package/dist/models-dev-OQKVMEIT.cjs +0 -12
- package/dist/models-dev-Z45JSLWD.js +0 -3
- package/dist/netlify-SSWMYSAX.js +0 -3
- package/dist/netlify-TXZZCT6N.cjs +0 -12
- package/dist/provider-registry-NR7FXV2Q.cjs +0 -40
- package/dist/provider-registry-RPOTQNHI.js +0 -3
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
# Advanced Tool Usage
|
|
2
|
-
|
|
3
|
-
This page covers more advanced techniques and features related to using tools in Mastra.
|
|
4
|
-
|
|
5
|
-
## Abort Signals
|
|
6
|
-
|
|
7
|
-
When you initiate an agent interaction using `generate()` or `stream()`, you can provide an `AbortSignal`. Mastra automatically forwards this signal to any tool executions that occur during that interaction.
|
|
8
|
-
|
|
9
|
-
This allows you to cancel long-running operations within your tools, such as network requests or intensive computations, if the parent agent call is aborted.
|
|
10
|
-
|
|
11
|
-
You access the `abortSignal` in the second parameter of the tool's `execute` function.
|
|
12
|
-
|
|
13
|
-
```typescript
|
|
14
|
-
import { createTool } from "@mastra/core/tools";
|
|
15
|
-
import { z } from "zod";
|
|
16
|
-
|
|
17
|
-
export const longRunningTool = createTool({
|
|
18
|
-
id: "long-computation",
|
|
19
|
-
description: "Performs a potentially long computation",
|
|
20
|
-
inputSchema: z.object({ /* ... */ }),
|
|
21
|
-
execute: async (inputData, context) => {
|
|
22
|
-
// Example: Forwarding signal to fetch
|
|
23
|
-
const response = await fetch("https://api.example.com/data", {
|
|
24
|
-
signal: context?.abortSignal, // Pass the signal here
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
if (context?.abortSignal?.aborted) {
|
|
28
|
-
console.log("Tool execution aborted.");
|
|
29
|
-
throw new Error("Aborted");
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Example: Checking signal during a loop
|
|
33
|
-
for (let i = 0; i < 1000000; i++) {
|
|
34
|
-
if (context?.abortSignal?.aborted) {
|
|
35
|
-
console.log("Tool execution aborted during loop.");
|
|
36
|
-
throw new Error("Aborted");
|
|
37
|
-
}
|
|
38
|
-
// ... perform computation step ...
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const data = await response.json();
|
|
42
|
-
return { result: data };
|
|
43
|
-
},\n});
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
To use this, provide an `AbortController`'s signal when calling the agent:
|
|
47
|
-
|
|
48
|
-
```typescript
|
|
49
|
-
import { Agent } from "@mastra/core/agent";
|
|
50
|
-
// Assume 'agent' is an Agent instance with longRunningTool configured
|
|
51
|
-
|
|
52
|
-
const controller = new AbortController();
|
|
53
|
-
|
|
54
|
-
// Start the agent call
|
|
55
|
-
const promise = agent.generate("Perform the long computation.", {
|
|
56
|
-
abortSignal: controller.signal,
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
// Sometime later, if needed:
|
|
60
|
-
// controller.abort();
|
|
61
|
-
|
|
62
|
-
try {
|
|
63
|
-
const result = await promise;
|
|
64
|
-
console.log(result.text);
|
|
65
|
-
} catch (error) {
|
|
66
|
-
if (error.name === "AbortError") {
|
|
67
|
-
console.log("Agent generation was aborted.");
|
|
68
|
-
} else {
|
|
69
|
-
console.error("An error occurred:", error);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## AI SDK Tool Format
|
|
75
|
-
|
|
76
|
-
Mastra maintains compatibility with the tool format used by the Vercel AI SDK (`ai` package). You can define tools using the `tool` function from the `ai` package and use them directly within your Mastra agents alongside tools created with Mastra's `createTool`.
|
|
77
|
-
|
|
78
|
-
First, ensure you have the `ai` package installed:
|
|
79
|
-
|
|
80
|
-
**npm**:
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
|
-
npm install ai
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
**pnpm**:
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
pnpm add ai
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
**Yarn**:
|
|
93
|
-
|
|
94
|
-
```bash
|
|
95
|
-
yarn add ai
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
**Bun**:
|
|
99
|
-
|
|
100
|
-
```bash
|
|
101
|
-
bun add ai
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
Here's an example of a tool defined using the Vercel AI SDK format:
|
|
105
|
-
|
|
106
|
-
```typescript
|
|
107
|
-
import { tool } from "ai";
|
|
108
|
-
import { z } from "zod";
|
|
109
|
-
|
|
110
|
-
export const vercelWeatherTool = tool({
|
|
111
|
-
description: "Fetches current weather using Vercel AI SDK format",
|
|
112
|
-
parameters: z.object({
|
|
113
|
-
city: z.string().describe("The city to get weather for"),
|
|
114
|
-
}),
|
|
115
|
-
execute: async ({ city }) => {
|
|
116
|
-
console.log(`Fetching weather for ${city} (Vercel format tool)`);
|
|
117
|
-
// Replace with actual API call
|
|
118
|
-
const data = await fetch(`https://api.example.com/weather?city=${city}`);
|
|
119
|
-
return data.json();
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
You can then add this tool to your Mastra agent just like any other tool:
|
|
125
|
-
|
|
126
|
-
```typescript
|
|
127
|
-
import { Agent } from "@mastra/core/agent";
|
|
128
|
-
import { vercelWeatherTool } from "../tools/vercelWeatherTool"; // Vercel AI SDK tool
|
|
129
|
-
import { mastraTool } from "../tools/mastraTool"; // Mastra createTool tool
|
|
130
|
-
|
|
131
|
-
export const mixedToolsAgent = new Agent({
|
|
132
|
-
id: "mixed-tools-agent",
|
|
133
|
-
name: "Mixed Tools Agent",
|
|
134
|
-
instructions: "You can use tools defined in different formats.",
|
|
135
|
-
model: "openai/gpt-5.1",
|
|
136
|
-
tools: {
|
|
137
|
-
weatherVercel: vercelWeatherTool,
|
|
138
|
-
someMastraTool: mastraTool,
|
|
139
|
-
},
|
|
140
|
-
});
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
Mastra supports both tool formats, allowing you to mix and match as needed.
|
|
@@ -1,383 +0,0 @@
|
|
|
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
|
-
## Getting 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
|
-
|
|
74
|
-
import { testMcpClient } from "../mcp/test-mcp-client";
|
|
75
|
-
|
|
76
|
-
export const testAgent = new Agent({
|
|
77
|
-
id: "test-agent",
|
|
78
|
-
name: "Test Agent",
|
|
79
|
-
description: "You are a helpful AI assistant",
|
|
80
|
-
instructions: `
|
|
81
|
-
You are a helpful assistant that has access to the following MCP Servers.
|
|
82
|
-
- Wikipedia MCP Server
|
|
83
|
-
- US National Weather Service
|
|
84
|
-
|
|
85
|
-
Answer questions using the information you find using the MCP Servers.`,
|
|
86
|
-
model: "openai/gpt-5.1",
|
|
87
|
-
tools: await testMcpClient.listTools(),
|
|
88
|
-
});
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
> **Info:** Visit [Agent Class](https://mastra.ai/reference/agents/agent) for a full list of configuration options.
|
|
92
|
-
|
|
93
|
-
## Configuring `MCPServer`
|
|
94
|
-
|
|
95
|
-
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.
|
|
96
|
-
|
|
97
|
-
```typescript
|
|
98
|
-
import { MCPServer } from "@mastra/mcp";
|
|
99
|
-
|
|
100
|
-
import { testAgent } from "../agents/test-agent";
|
|
101
|
-
import { testWorkflow } from "../workflows/test-workflow";
|
|
102
|
-
import { testTool } from "../tools/test-tool";
|
|
103
|
-
|
|
104
|
-
export const testMcpServer = new MCPServer({
|
|
105
|
-
id: "test-mcp-server", // Required: unique identifier for the server
|
|
106
|
-
name: "Test MCP Server",
|
|
107
|
-
version: "1.0.0",
|
|
108
|
-
agents: { testAgent },
|
|
109
|
-
tools: { testTool },
|
|
110
|
-
workflows: { testWorkflow },
|
|
111
|
-
});
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
> **Info:** Visit [MCPServer](https://mastra.ai/reference/tools/mcp-server) for a full list of configuration options.
|
|
115
|
-
|
|
116
|
-
> **Authentication:** To protect your MCP server with OAuth, see the [OAuth Protection](https://mastra.ai/reference/tools/mcp-server) section.
|
|
117
|
-
|
|
118
|
-
### Serverless deployments
|
|
119
|
-
|
|
120
|
-
`MCPServer` can be deployed in serverless environments (Cloudflare Workers, Vercel Edge Functions, AWS Lambda, etc.) by enabling the `serverless: true` option in `startHTTP()`. This runs the server in stateless mode, where each request is handled independently without session management.
|
|
121
|
-
|
|
122
|
-
**Note:** Some MCP features require persistent connections and won't work in serverless mode, including elicitation, resource subscriptions, and update notifications. See the [serverless section](https://mastra.ai/reference/tools/mcp-server) in the API reference for full details and limitations.
|
|
123
|
-
|
|
124
|
-
## Registering an `MCPServer`
|
|
125
|
-
|
|
126
|
-
To make an MCP server available to other systems or agents that support the protocol, register it in the main `Mastra` instance using `mcpServers`.
|
|
127
|
-
|
|
128
|
-
```typescript
|
|
129
|
-
import { Mastra } from "@mastra/core";
|
|
130
|
-
|
|
131
|
-
import { testMcpServer } from "./mcp/test-mcp-server";
|
|
132
|
-
|
|
133
|
-
export const mastra = new Mastra({
|
|
134
|
-
mcpServers: {
|
|
135
|
-
testMcpServer, // Registry key: 'testMcpServer'
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
// Both retrieval methods work:
|
|
140
|
-
mastra.getMCPServer('testMcpServer'); // By registry key
|
|
141
|
-
mastra.getMCPServerById('test-mcp-server'); // By intrinsic ID
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
## Static and dynamic tools
|
|
145
|
-
|
|
146
|
-
`MCPClient` offers two approaches to retrieving tools from connected servers, suitable for different application architectures:
|
|
147
|
-
|
|
148
|
-
| Feature | Static Configuration (`await mcp.listTools()`) | Dynamic Configuration (`await mcp.listToolsets()`) |
|
|
149
|
-
| ----------------- | ---------------------------------------------- | ---------------------------------------------------- |
|
|
150
|
-
| **Use Case** | Single-user, static config (e.g., CLI tool) | Multi-user, dynamic config (e.g., SaaS app) |
|
|
151
|
-
| **Configuration** | Fixed at agent initialization | Per-request, dynamic |
|
|
152
|
-
| **Credentials** | Shared across all uses | Can vary per user/request |
|
|
153
|
-
| **Agent Setup** | Tools added in `Agent` constructor | Tools passed in `.generate()` or `.stream()` options |
|
|
154
|
-
|
|
155
|
-
### Static tools
|
|
156
|
-
|
|
157
|
-
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.
|
|
158
|
-
|
|
159
|
-
> **Info:** Visit [listTools()](https://mastra.ai/reference/tools/mcp-client) for more information.
|
|
160
|
-
|
|
161
|
-
```typescript
|
|
162
|
-
import { Agent } from "@mastra/core/agent";
|
|
163
|
-
|
|
164
|
-
import { testMcpClient } from "../mcp/test-mcp-client";
|
|
165
|
-
|
|
166
|
-
export const testAgent = new Agent({
|
|
167
|
-
// ...
|
|
168
|
-
tools: await testMcpClient.listTools(),
|
|
169
|
-
});
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
### Dynamic tools
|
|
173
|
-
|
|
174
|
-
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.
|
|
175
|
-
|
|
176
|
-
```typescript
|
|
177
|
-
import { MCPClient } from "@mastra/mcp";
|
|
178
|
-
import { mastra } from "./mastra";
|
|
179
|
-
|
|
180
|
-
async function handleRequest(userPrompt: string, userApiKey: string) {
|
|
181
|
-
const userMcp = new MCPClient({
|
|
182
|
-
servers: {
|
|
183
|
-
weather: {
|
|
184
|
-
url: new URL("http://localhost:8080/mcp"),
|
|
185
|
-
requestInit: {
|
|
186
|
-
headers: {
|
|
187
|
-
Authorization: `Bearer ${userApiKey}`,
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
const agent = mastra.getAgent("testAgent");
|
|
195
|
-
|
|
196
|
-
const response = await agent.generate(userPrompt, {
|
|
197
|
-
toolsets: await userMcp.listToolsets(),
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
await userMcp.disconnect();
|
|
201
|
-
|
|
202
|
-
return Response.json({
|
|
203
|
-
data: response.text,
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
> **Info:** Visit [listToolsets()](https://mastra.ai/reference/tools/mcp-client) for more information.
|
|
209
|
-
|
|
210
|
-
## Connecting to an MCP registry
|
|
211
|
-
|
|
212
|
-
MCP servers can be discovered through registries. Here's how to connect to some popular ones using `MCPClient`:
|
|
213
|
-
|
|
214
|
-
**Klavis AI**:
|
|
215
|
-
|
|
216
|
-
[Klavis AI](https://klavis.ai) provides hosted, enterprise-authenticated, high-quality MCP servers.
|
|
217
|
-
|
|
218
|
-
```typescript
|
|
219
|
-
import { MCPClient } from "@mastra/mcp";
|
|
220
|
-
|
|
221
|
-
const mcp = new MCPClient({
|
|
222
|
-
servers: {
|
|
223
|
-
salesforce: {
|
|
224
|
-
url: new URL("https://salesforce-mcp-server.klavis.ai/mcp/?instance_id={private-instance-id}"),
|
|
225
|
-
},
|
|
226
|
-
hubspot: {
|
|
227
|
-
url: new URL("https://hubspot-mcp-server.klavis.ai/mcp/?instance_id={private-instance-id}"),
|
|
228
|
-
},
|
|
229
|
-
},
|
|
230
|
-
});
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
Klavis AI offers enterprise-grade authentication and security for production deployments.
|
|
234
|
-
|
|
235
|
-
For more details on how to integrate Mastra with Klavis, check out their [documentation](https://docs.klavis.ai/documentation/ai-platform-integration/mastra).
|
|
236
|
-
|
|
237
|
-
**mcp.run**:
|
|
238
|
-
|
|
239
|
-
[mcp.run](https://www.mcp.run/) provides pre-authenticated, managed MCP servers. Tools are grouped into Profiles, each with a unique, signed URL.
|
|
240
|
-
|
|
241
|
-
```typescript
|
|
242
|
-
import { MCPClient } from "@mastra/mcp";
|
|
243
|
-
|
|
244
|
-
const mcp = new MCPClient({
|
|
245
|
-
servers: {
|
|
246
|
-
marketing: { // Example profile name
|
|
247
|
-
url: new URL(process.env.MCP_RUN_SSE_URL!), // Get URL from mcp.run profile
|
|
248
|
-
},
|
|
249
|
-
},
|
|
250
|
-
});
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
> **Important:** Treat the mcp.run SSE URL like a password. Store it securely, for example, in an environment variable.
|
|
254
|
-
>
|
|
255
|
-
> ```bash
|
|
256
|
-
> MCP_RUN_SSE_URL=https://www.mcp.run/api/mcp/sse?nonce=...
|
|
257
|
-
> ```
|
|
258
|
-
|
|
259
|
-
**Composio.dev**:
|
|
260
|
-
|
|
261
|
-
[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.
|
|
262
|
-
|
|
263
|
-
```typescript
|
|
264
|
-
import { MCPClient } from "@mastra/mcp";
|
|
265
|
-
|
|
266
|
-
const mcp = new MCPClient({
|
|
267
|
-
servers: {
|
|
268
|
-
googleSheets: {
|
|
269
|
-
url: new URL("https://mcp.composio.dev/googlesheets/[private-url-path]"),
|
|
270
|
-
},
|
|
271
|
-
gmail: {
|
|
272
|
-
url: new URL("https://mcp.composio.dev/gmail/[private-url-path]"),
|
|
273
|
-
},
|
|
274
|
-
},
|
|
275
|
-
});
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
Authentication with services like Google Sheets often happens interactively through the agent conversation.
|
|
279
|
-
|
|
280
|
-
_Note: Composio URLs are typically tied to a single user account, making them best suited for personal automation rather than multi-tenant applications._
|
|
281
|
-
|
|
282
|
-
**Smithery.ai**:
|
|
283
|
-
|
|
284
|
-
[Smithery.ai](https://smithery.ai) provides a registry accessible via their CLI.
|
|
285
|
-
|
|
286
|
-
```typescript
|
|
287
|
-
// Unix/Mac
|
|
288
|
-
import { MCPClient } from "@mastra/mcp";
|
|
289
|
-
|
|
290
|
-
const mcp = new MCPClient({
|
|
291
|
-
servers: {
|
|
292
|
-
sequentialThinking: {
|
|
293
|
-
command: "npx",
|
|
294
|
-
args: [
|
|
295
|
-
"-y",
|
|
296
|
-
"@smithery/cli@latest",
|
|
297
|
-
"run",
|
|
298
|
-
"@smithery-ai/server-sequential-thinking",
|
|
299
|
-
"--config",
|
|
300
|
-
"{}",
|
|
301
|
-
],
|
|
302
|
-
},
|
|
303
|
-
},
|
|
304
|
-
});
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
```typescript
|
|
308
|
-
// Windows
|
|
309
|
-
import { MCPClient } from "@mastra/mcp";
|
|
310
|
-
|
|
311
|
-
const mcp = new MCPClient({
|
|
312
|
-
servers: {
|
|
313
|
-
sequentialThinking: {
|
|
314
|
-
command: "npx",
|
|
315
|
-
args: [
|
|
316
|
-
"-y",
|
|
317
|
-
"@smithery/cli@latest",
|
|
318
|
-
"run",
|
|
319
|
-
"@smithery-ai/server-sequential-thinking",
|
|
320
|
-
"--config",
|
|
321
|
-
"{}",
|
|
322
|
-
],
|
|
323
|
-
},
|
|
324
|
-
},
|
|
325
|
-
});
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
**Ampersand**:
|
|
329
|
-
|
|
330
|
-
[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.
|
|
331
|
-
|
|
332
|
-
```typescript
|
|
333
|
-
// MCPClient with Ampersand MCP Server using SSE
|
|
334
|
-
export const mcp = new MCPClient({
|
|
335
|
-
servers: {
|
|
336
|
-
"@amp-labs/mcp-server": {
|
|
337
|
-
url: `https://mcp.withampersand.com/v1/sse?${new URLSearchParams({
|
|
338
|
-
apiKey: process.env.AMPERSAND_API_KEY,
|
|
339
|
-
project: process.env.AMPERSAND_PROJECT_ID,
|
|
340
|
-
integrationName: process.env.AMPERSAND_INTEGRATION_NAME,
|
|
341
|
-
groupRef: process.env.AMPERSAND_GROUP_REF,
|
|
342
|
-
})}`,
|
|
343
|
-
},
|
|
344
|
-
},
|
|
345
|
-
});
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
```typescript
|
|
349
|
-
// If you prefer to run the MCP server locally:
|
|
350
|
-
import { MCPClient } from "@mastra/mcp";
|
|
351
|
-
|
|
352
|
-
// MCPClient with Ampersand MCP Server using stdio transport
|
|
353
|
-
export const mcp = new MCPClient({
|
|
354
|
-
servers: {
|
|
355
|
-
"@amp-labs/mcp-server": {
|
|
356
|
-
command: "npx",
|
|
357
|
-
args: [
|
|
358
|
-
"-y",
|
|
359
|
-
"@amp-labs/mcp-server@latest",
|
|
360
|
-
"--transport",
|
|
361
|
-
"stdio",
|
|
362
|
-
"--project",
|
|
363
|
-
process.env.AMPERSAND_PROJECT_ID,
|
|
364
|
-
"--integrationName",
|
|
365
|
-
process.env.AMPERSAND_INTEGRATION_NAME,
|
|
366
|
-
"--groupRef",
|
|
367
|
-
process.env.AMPERSAND_GROUP_REF, // optional
|
|
368
|
-
],
|
|
369
|
-
env: {
|
|
370
|
-
AMPERSAND_API_KEY: process.env.AMPERSAND_API_KEY,
|
|
371
|
-
},
|
|
372
|
-
},
|
|
373
|
-
},
|
|
374
|
-
});
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
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.
|
|
378
|
-
|
|
379
|
-
## Related
|
|
380
|
-
|
|
381
|
-
- [Using Tools](https://mastra.ai/docs/agents/using-tools)
|
|
382
|
-
- [MCPClient](https://mastra.ai/reference/tools/mcp-client)
|
|
383
|
-
- [MCPServer](https://mastra.ai/reference/tools/mcp-server)
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# Using Tools
|
|
2
|
-
|
|
3
|
-
Tools are functions that agents can execute to perform specific tasks or access external information. They extend an agent's capabilities beyond simple text generation, allowing interaction with APIs, databases, or other systems.
|
|
4
|
-
|
|
5
|
-
Each tool typically defines:
|
|
6
|
-
|
|
7
|
-
- **Inputs:** What information the tool needs to run (defined with an `inputSchema`, often using Zod).
|
|
8
|
-
- **Outputs:** The structure of the data the tool returns (defined with an `outputSchema`).
|
|
9
|
-
- **Execution Logic:** The code that performs the tool's action.
|
|
10
|
-
- **Description:** Text that helps the agent understand what the tool does and when to use it.
|
|
11
|
-
|
|
12
|
-
## Creating Tools
|
|
13
|
-
|
|
14
|
-
In Mastra, you create tools using the [`createTool`](https://mastra.ai/reference/tools/create-tool) function from the `@mastra/core/tools` package.
|
|
15
|
-
|
|
16
|
-
```typescript
|
|
17
|
-
import { createTool } from "@mastra/core/tools";
|
|
18
|
-
import { z } from "zod";
|
|
19
|
-
|
|
20
|
-
const getWeatherInfo = async (city: string) => {
|
|
21
|
-
// Replace with an actual API call to a weather service
|
|
22
|
-
console.log(`Fetching weather for ${city}...`);
|
|
23
|
-
// Example data structure
|
|
24
|
-
return { temperature: 20, conditions: "Sunny" };
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const weatherTool = createTool({
|
|
28
|
-
id: "Get Weather Information",
|
|
29
|
-
description: `Fetches the current weather information for a given city`,
|
|
30
|
-
inputSchema: z.object({
|
|
31
|
-
city: z.string().describe("City name"),
|
|
32
|
-
}),
|
|
33
|
-
outputSchema: z.object({
|
|
34
|
-
temperature: z.number(),
|
|
35
|
-
conditions: z.string(),
|
|
36
|
-
}),
|
|
37
|
-
execute: async (inputData) => {
|
|
38
|
-
console.log("Using tool to fetch weather information for", inputData.city);
|
|
39
|
-
return await getWeatherInfo(inputData.city);
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
This example defines a `weatherTool` with an input schema for the city, an output schema for the weather data, and an `execute` function that contains the tool's logic.
|
|
45
|
-
|
|
46
|
-
When creating tools, keep tool descriptions simple and focused on **what** the tool does and **when** to use it, emphasizing its primary use case. Technical details belong in the parameter schemas, guiding the agent on _how_ to use the tool correctly with descriptive names, clear descriptions, and explanations of default values.
|
|
47
|
-
|
|
48
|
-
## Adding Tools to an Agent
|
|
49
|
-
|
|
50
|
-
To make tools available to an agent, you configure them in the agent's definition. Mentioning available tools and their general purpose in the agent's system prompt can also improve tool usage. For detailed steps and examples, see the guide on [Using Tools with Agents](https://mastra.ai/docs/agents/using-tools).
|
|
51
|
-
|
|
52
|
-
## Using `RequestContext`
|
|
53
|
-
|
|
54
|
-
Use [RequestContext](https://mastra.ai/docs/server/request-context) to access request-specific values. This lets you conditionally adjust behavior based on the context of the request.
|
|
55
|
-
|
|
56
|
-
```typescript
|
|
57
|
-
export type UserTier = {
|
|
58
|
-
"user-tier": "enterprise" | "pro";
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const advancedTools = () => {};
|
|
62
|
-
|
|
63
|
-
const baseTools = () => {};
|
|
64
|
-
|
|
65
|
-
export const testTool = createTool({
|
|
66
|
-
execute: async (inputData, context) => {
|
|
67
|
-
const userTier = context?.requestContext?.get("user-tier") as UserTier["user-tier"];
|
|
68
|
-
|
|
69
|
-
return userTier === "enterprise" ? advancedTools : baseTools;
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
> **Info:** Visit [Request Context](https://mastra.ai/docs/server/request-context) for more information.
|
|
75
|
-
|
|
76
|
-
## Testing with Studio
|
|
77
|
-
|
|
78
|
-
Use [Studio](https://mastra.ai/docs/getting-started/studio) to test tools with different inputs, inspect execution results, and verify tool behavior.
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
# Input Data Mapping
|
|
2
|
-
|
|
3
|
-
Input data mapping allows explicit mapping of values for the inputs of the next step. These values can come from a number of sources:
|
|
4
|
-
|
|
5
|
-
- The outputs of a previous step
|
|
6
|
-
- The request context
|
|
7
|
-
- A constant value
|
|
8
|
-
- The initial input of the workflow
|
|
9
|
-
|
|
10
|
-
## Mapping with `.map()`
|
|
11
|
-
|
|
12
|
-
In this example the `output` from `step1` is transformed to match the `inputSchema` required for the `step2`. The value from `step1` is available using the `inputData` parameter of the `.map` function.
|
|
13
|
-
|
|
14
|
-

|
|
15
|
-
|
|
16
|
-
```typescript
|
|
17
|
-
const step1 = createStep({...});
|
|
18
|
-
const step2 = createStep({...});
|
|
19
|
-
|
|
20
|
-
export const testWorkflow = createWorkflow({...})
|
|
21
|
-
.then(step1)
|
|
22
|
-
.map(async ({ inputData }) => {
|
|
23
|
-
const { value } = inputData;
|
|
24
|
-
return {
|
|
25
|
-
output: `new ${value}`
|
|
26
|
-
};
|
|
27
|
-
})
|
|
28
|
-
.then(step2)
|
|
29
|
-
.commit();
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Using `inputData`
|
|
33
|
-
|
|
34
|
-
Use `inputData` to access the full output of the previous step:
|
|
35
|
-
|
|
36
|
-
```typescript
|
|
37
|
-
.then(step1)
|
|
38
|
-
.map(({ inputData }) => {
|
|
39
|
-
console.log(inputData);
|
|
40
|
-
})
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Using `getStepResult()`
|
|
44
|
-
|
|
45
|
-
Use `getStepResult` to access the full output of a specific step by referencing the step's instance:
|
|
46
|
-
|
|
47
|
-
```typescript
|
|
48
|
-
.then(step1)
|
|
49
|
-
.map(async ({ getStepResult }) => {
|
|
50
|
-
console.log(getStepResult(step1));
|
|
51
|
-
})
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Using `getInitData<any>()`
|
|
55
|
-
|
|
56
|
-
Use `getInitData<any>` to access the initial input data provided to the workflow:
|
|
57
|
-
|
|
58
|
-
```typescript
|
|
59
|
-
.then(step1)
|
|
60
|
-
.map(async ({ getInitData }) => {
|
|
61
|
-
console.log(getInitData<any>());
|
|
62
|
-
})
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Using `mapVariable()`
|
|
66
|
-
|
|
67
|
-
To use `mapVariable` import the necessary function from the workflows module:
|
|
68
|
-
|
|
69
|
-
```typescript
|
|
70
|
-
import { mapVariable } from "@mastra/core/workflows";
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### Renaming step with `mapVariable()`
|
|
74
|
-
|
|
75
|
-
You can rename step outputs using the object syntax in `.map()`. In the example below, the `value` output from `step1` is renamed to `details`:
|
|
76
|
-
|
|
77
|
-
```typescript
|
|
78
|
-
.then(step1)
|
|
79
|
-
.map({
|
|
80
|
-
details: mapVariable({
|
|
81
|
-
step: step,
|
|
82
|
-
path: "value"
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Renaming workflows with `mapVariable()`
|
|
88
|
-
|
|
89
|
-
You can rename workflow outputs by using **referential composition**. This involves passing the workflow instance as the `initData`.
|
|
90
|
-
|
|
91
|
-
```typescript
|
|
92
|
-
export const testWorkflow = createWorkflow({...});
|
|
93
|
-
|
|
94
|
-
testWorkflow
|
|
95
|
-
.then(step1)
|
|
96
|
-
.map({
|
|
97
|
-
details: mapVariable({
|
|
98
|
-
initData: testWorkflow,
|
|
99
|
-
path: "value"
|
|
100
|
-
})
|
|
101
|
-
})
|
|
102
|
-
```
|