@mastra/mcp-docs-server 1.2.15-alpha.13 → 1.2.15-alpha.19
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/agent-approval.md +14 -0
- package/.docs/docs/agents/code-mode.md +16 -1
- package/.docs/docs/agents/processors.md +3 -3
- package/.docs/docs/browser/recording.md +2 -2
- package/.docs/docs/capabilities/subagents.md +4 -1
- package/.docs/docs/datasets/running-experiments.md +49 -0
- package/.docs/docs/deployment/workers.md +1 -1
- package/.docs/docs/getting-started/develop.md +1 -1
- package/.docs/docs/harness/agent-controller.md +43 -2
- package/.docs/docs/harness/overview.md +2 -4
- package/.docs/docs/long-running-agents/durable-agents.md +1 -1
- package/.docs/docs/long-running-agents/goals.md +1 -1
- package/.docs/docs/long-running-agents/schedules.md +1 -1
- package/.docs/docs/long-running-agents/signal-providers.md +1 -1
- package/.docs/docs/long-running-agents/signals.md +1 -1
- package/.docs/docs/memory/message-history.md +2 -2
- package/.docs/docs/observability/integrations/exporters/mastra-platform.md +1 -1
- package/.docs/docs/observability/integrations/exporters/otel.md +2 -2
- package/.docs/docs/server/auth/auth0.md +1 -1
- package/.docs/docs/server/auth/clerk.md +2 -2
- package/.docs/docs/server/auth/firebase.md +1 -1
- package/.docs/docs/server/auth/okta.md +24 -4
- package/.docs/docs/server/auth/supabase.md +2 -2
- package/.docs/docs/server/auth/workers.md +2 -0
- package/.docs/docs/server/auth/workos.md +1 -1
- package/.docs/docs/server/custom-adapters.md +1 -1
- package/.docs/docs/server/mastra-client.md +2 -2
- package/.docs/docs/server/mastra-server.md +1 -1
- package/.docs/docs/workflows/dynamic-workflows.md +1 -1
- package/.docs/docs/workflows/overview.md +1 -1
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +3 -3
- package/.docs/guides/build-your-ui/assistant-ui.md +1 -1
- package/.docs/guides/build-your-ui/copilotkit/channels.md +1 -1
- package/.docs/guides/build-your-ui/copilotkit/overview.md +1 -1
- package/.docs/guides/deployment/amazon-ec2.md +1 -1
- package/.docs/guides/deployment/aws-bedrock-agentcore.md +1 -1
- package/.docs/guides/deployment/aws-lambda.md +1 -1
- package/.docs/guides/deployment/azure-app-services.md +1 -1
- package/.docs/guides/deployment/cloudflare.md +1 -1
- package/.docs/guides/deployment/digital-ocean.md +2 -2
- package/.docs/guides/deployment/kubernetes.md +2 -2
- package/.docs/guides/deployment/mastra-workers.md +3 -1
- package/.docs/guides/deployment/netlify.md +2 -2
- package/.docs/guides/deployment/vercel.md +1 -1
- package/.docs/guides/getting-started/electron.md +2 -2
- package/.docs/guides/getting-started/manual-install.md +2 -2
- package/.docs/guides/guide/signal-provider.md +1 -1
- package/.docs/guides/migrations/mastra-cloud.md +1 -1
- package/.docs/models/embeddings.md +1 -1
- package/.docs/models/gateways/neon.md +1 -1
- package/.docs/models/gateways/netlify.md +1 -1
- package/.docs/models/gateways/openrouter.md +1 -1
- package/.docs/models/gateways/vercel.md +3 -4
- package/.docs/models/index.md +3 -3
- package/.docs/models/providers/302ai.md +1 -1
- package/.docs/models/providers/abacus.md +1 -1
- package/.docs/models/providers/abliteration-ai.md +1 -1
- package/.docs/models/providers/agentrouter.md +1 -1
- package/.docs/models/providers/ai-router.md +1 -1
- package/.docs/models/providers/aiand.md +1 -1
- package/.docs/models/providers/aki-io.md +1 -1
- package/.docs/models/providers/alibaba-cn.md +1 -1
- package/.docs/models/providers/alibaba-coding-plan-cn.md +1 -1
- package/.docs/models/providers/alibaba-coding-plan.md +1 -1
- package/.docs/models/providers/alibaba-token-plan-cn.md +1 -1
- package/.docs/models/providers/alibaba-token-plan.md +1 -1
- package/.docs/models/providers/alibaba.md +7 -5
- package/.docs/models/providers/ambient.md +1 -1
- package/.docs/models/providers/anyapi.md +1 -1
- package/.docs/models/providers/atomic-chat.md +1 -1
- package/.docs/models/providers/auriko.md +1 -1
- package/.docs/models/providers/bailing.md +1 -1
- package/.docs/models/providers/baseten.md +1 -1
- package/.docs/models/providers/berget.md +1 -1
- package/.docs/models/providers/blueclaw.md +1 -1
- package/.docs/models/providers/chutes.md +1 -1
- package/.docs/models/providers/clarifai.md +1 -1
- package/.docs/models/providers/claudinio.md +1 -1
- package/.docs/models/providers/cline-pass.md +1 -1
- package/.docs/models/providers/cloudferro-sherlock.md +1 -1
- package/.docs/models/providers/cloudflare-workers-ai.md +1 -1
- package/.docs/models/providers/cortecs.md +2 -3
- package/.docs/models/providers/crof.md +1 -1
- package/.docs/models/providers/crossmodel.md +2 -3
- package/.docs/models/providers/daoxe.md +1 -1
- package/.docs/models/providers/databricks.md +1 -1
- package/.docs/models/providers/deepinfra.md +1 -1
- package/.docs/models/providers/digitalocean.md +3 -3
- package/.docs/models/providers/dinference.md +1 -1
- package/.docs/models/providers/drun.md +1 -1
- package/.docs/models/providers/ebcloud.md +1 -1
- package/.docs/models/providers/empiriolabs.md +1 -1
- package/.docs/models/providers/evroc.md +1 -1
- package/.docs/models/providers/fastrouter.md +1 -1
- package/.docs/models/providers/firepass.md +1 -1
- package/.docs/models/providers/fireworks-ai.md +1 -1
- package/.docs/models/providers/firmware.md +1 -1
- package/.docs/models/providers/freemodel.md +1 -1
- package/.docs/models/providers/friendli.md +1 -1
- package/.docs/models/providers/frogbot.md +1 -1
- package/.docs/models/providers/github-models.md +1 -1
- package/.docs/models/providers/gmicloud.md +1 -1
- package/.docs/models/providers/google.md +1 -1
- package/.docs/models/providers/greenpt.md +1 -1
- package/.docs/models/providers/helicone.md +1 -1
- package/.docs/models/providers/hetzner.md +1 -1
- package/.docs/models/providers/hpc-ai.md +1 -1
- package/.docs/models/providers/huggingface.md +1 -1
- package/.docs/models/providers/hyper.md +1 -1
- package/.docs/models/providers/iflowcn.md +1 -1
- package/.docs/models/providers/impossibl.md +1 -1
- package/.docs/models/providers/inception.md +1 -1
- package/.docs/models/providers/inceptron.md +1 -1
- package/.docs/models/providers/inference.md +1 -1
- package/.docs/models/providers/inferx.md +1 -1
- package/.docs/models/providers/infomaniak.md +1 -1
- package/.docs/models/providers/io-intelligence.md +1 -1
- package/.docs/models/providers/io-net.md +1 -1
- package/.docs/models/providers/jiekou.md +1 -1
- package/.docs/models/providers/kenari.md +1 -1
- package/.docs/models/providers/kilo.md +6 -6
- package/.docs/models/providers/kimi-for-coding.md +1 -1
- package/.docs/models/providers/kiro.md +1 -1
- package/.docs/models/providers/kuae-cloud-coding-plan.md +1 -1
- package/.docs/models/providers/lilac.md +1 -1
- package/.docs/models/providers/llama.md +1 -1
- package/.docs/models/providers/llmgateway.md +2 -4
- package/.docs/models/providers/llmtr.md +1 -1
- package/.docs/models/providers/lmstudio.md +1 -1
- package/.docs/models/providers/longcat.md +1 -1
- package/.docs/models/providers/lucidquery.md +1 -1
- package/.docs/models/providers/lynkr.md +1 -1
- package/.docs/models/providers/meganova.md +1 -1
- package/.docs/models/providers/meta.md +1 -1
- package/.docs/models/providers/minimax-cn-coding-plan.md +1 -1
- package/.docs/models/providers/minimax-cn.md +1 -1
- package/.docs/models/providers/minimax-coding-plan.md +1 -1
- package/.docs/models/providers/minimax.md +1 -1
- package/.docs/models/providers/mixlayer.md +1 -1
- package/.docs/models/providers/moark.md +1 -1
- package/.docs/models/providers/modal.md +1 -1
- package/.docs/models/providers/model-oracle-ai.md +1 -1
- package/.docs/models/providers/modelis.md +1 -1
- package/.docs/models/providers/modelscope.md +1 -1
- package/.docs/models/providers/moonshotai-cn.md +1 -1
- package/.docs/models/providers/moonshotai.md +1 -1
- package/.docs/models/providers/morph.md +1 -1
- package/.docs/models/providers/nano-gpt.md +4 -2
- package/.docs/models/providers/nearai.md +1 -1
- package/.docs/models/providers/nebius.md +3 -2
- package/.docs/models/providers/neuralwatt.md +1 -1
- package/.docs/models/providers/nova.md +1 -1
- package/.docs/models/providers/novita-ai.md +1 -1
- package/.docs/models/providers/nvidia.md +1 -1
- package/.docs/models/providers/ofox.md +4 -3
- package/.docs/models/providers/ollama-cloud.md +1 -1
- package/.docs/models/providers/opencode-go.md +1 -1
- package/.docs/models/providers/opencode.md +1 -1
- package/.docs/models/providers/orcarouter.md +1 -1
- package/.docs/models/providers/ovhcloud.md +1 -1
- package/.docs/models/providers/perplexity-agent.md +1 -1
- package/.docs/models/providers/pioneer.md +1 -1
- package/.docs/models/providers/poe.md +1 -1
- package/.docs/models/providers/poolside.md +1 -1
- package/.docs/models/providers/privatemode-ai.md +1 -1
- package/.docs/models/providers/qihang-ai.md +1 -1
- package/.docs/models/providers/qiniu-ai.md +1 -1
- package/.docs/models/providers/regolo-ai.md +1 -1
- package/.docs/models/providers/requesty.md +3 -3
- package/.docs/models/providers/routing-run.md +1 -1
- package/.docs/models/providers/sakana.md +1 -1
- package/.docs/models/providers/sarvam.md +1 -1
- package/.docs/models/providers/scaleway.md +1 -1
- package/.docs/models/providers/scx.md +1 -1
- package/.docs/models/providers/siliconflow-cn.md +1 -1
- package/.docs/models/providers/siliconflow.md +1 -1
- package/.docs/models/providers/snowflake-cortex.md +1 -1
- package/.docs/models/providers/stackit.md +1 -1
- package/.docs/models/providers/stepfun-ai-step-plan.md +1 -1
- package/.docs/models/providers/stepfun-ai.md +1 -1
- package/.docs/models/providers/stepfun-step-plan.md +1 -1
- package/.docs/models/providers/stepfun.md +1 -1
- package/.docs/models/providers/subconscious.md +1 -1
- package/.docs/models/providers/submodel.md +1 -1
- package/.docs/models/providers/synthetic.md +1 -1
- package/.docs/models/providers/tencent-coding-plan.md +1 -1
- package/.docs/models/providers/tencent-token-plan.md +1 -1
- package/.docs/models/providers/tencent-tokenhub.md +1 -1
- package/.docs/models/providers/tensorx.md +1 -1
- package/.docs/models/providers/the-grid-ai.md +1 -1
- package/.docs/models/providers/thinkingmachines.md +1 -1
- package/.docs/models/providers/tinfoil.md +2 -2
- package/.docs/models/providers/togetherai.md +1 -1
- package/.docs/models/providers/trustedrouter.md +1 -1
- package/.docs/models/providers/umans-ai-coding-plan.md +1 -1
- package/.docs/models/providers/umans-ai.md +1 -1
- package/.docs/models/providers/unorouter.md +1 -1
- package/.docs/models/providers/upstage.md +1 -1
- package/.docs/models/providers/venice.md +1 -1
- package/.docs/models/providers/vivgrid.md +1 -1
- package/.docs/models/providers/vultr.md +1 -1
- package/.docs/models/providers/wafer.ai.md +1 -1
- package/.docs/models/providers/wandb.md +1 -1
- package/.docs/models/providers/xiaomi-token-plan-ams.md +1 -1
- package/.docs/models/providers/xiaomi-token-plan-cn.md +1 -1
- package/.docs/models/providers/xiaomi-token-plan-sgp.md +1 -1
- package/.docs/models/providers/xiaomi.md +1 -1
- package/.docs/models/providers/xpersona.md +1 -1
- package/.docs/models/providers/zai-coding-plan.md +1 -1
- package/.docs/models/providers/zai.md +1 -1
- package/.docs/models/providers/zeldoc.md +8 -8
- package/.docs/models/providers/zenifra.md +1 -1
- package/.docs/models/providers/zenmux.md +1 -1
- package/.docs/models/providers/zhipuai-coding-plan.md +1 -1
- package/.docs/models/providers/zhipuai.md +1 -1
- package/.docs/reference/agent-controller/agent-controller-class.md +3 -3
- package/.docs/reference/agent-controller/session.md +5 -3
- package/.docs/reference/agents/durable-agent.md +2 -0
- package/.docs/reference/agents/generateLegacy.md +1 -1
- package/.docs/reference/agents/inngest-agent.md +2 -0
- package/.docs/reference/auth/okta.md +5 -1
- package/.docs/reference/cli/mastra.md +4 -4
- package/.docs/reference/client-js/agents.md +2 -1
- package/.docs/reference/client-js/workflows.md +3 -3
- package/.docs/reference/code-sdk/mount-agent-controller.md +1 -1
- package/.docs/reference/configuration.md +1 -1
- package/.docs/reference/core/addDynamicWorkflow.md +1 -1
- package/.docs/reference/core/addDynamicWorkflows.md +1 -1
- package/.docs/reference/datasets/startExperiment.md +8 -0
- package/.docs/reference/file-based-agents/config.md +2 -0
- package/.docs/reference/file-based-agents/instructions.md +2 -0
- package/.docs/reference/file-based-agents/logger.md +2 -0
- package/.docs/reference/file-based-agents/memory.md +2 -0
- package/.docs/reference/file-based-agents/observability.md +2 -0
- package/.docs/reference/file-based-agents/processors.md +2 -0
- package/.docs/reference/file-based-agents/schedules.md +2 -0
- package/.docs/reference/file-based-agents/scorers.md +2 -0
- package/.docs/reference/file-based-agents/server.md +2 -0
- package/.docs/reference/file-based-agents/skills.md +2 -0
- package/.docs/reference/file-based-agents/storage.md +2 -0
- package/.docs/reference/file-based-agents/studio.md +2 -0
- package/.docs/reference/file-based-agents/subagents.md +2 -0
- package/.docs/reference/file-based-agents/tools.md +2 -0
- package/.docs/reference/file-based-agents/workflows.md +2 -0
- package/.docs/reference/file-based-agents/workspace.md +2 -0
- package/.docs/reference/index.md +1 -0
- package/.docs/reference/observability/tracing/exporters/datadog.md +1 -1
- package/.docs/reference/processors/pii-detector.md +2 -0
- package/.docs/reference/processors/prompt-injection-detector.md +2 -0
- package/.docs/reference/processors/response-cache.md +2 -0
- package/.docs/reference/schedules/overview.md +2 -0
- package/.docs/reference/signals/create-notification-inbox-tool.md +2 -0
- package/.docs/reference/signals/signal-provider.md +2 -0
- package/.docs/reference/signals/task-signal-provider.md +2 -0
- package/.docs/reference/signals/webhook-signal-provider.md +2 -0
- package/.docs/reference/storage/composite.md +1 -1
- package/.docs/reference/streaming/agents/stream.md +1 -1
- package/.docs/reference/streaming/agents/streamLegacy.md +1 -1
- package/.docs/reference/streaming/agents/streamUntilIdle.md +1 -1
- package/.docs/reference/tools/create-code-mode.md +3 -1
- package/.docs/reference/tools/isolated-vm-transport.md +1 -1
- package/.docs/reference/tools/mcp-client.md +51 -0
- package/.docs/reference/tools/quickjs-transport.md +92 -0
- package/.docs/reference/vectors/chroma.md +1 -1
- package/.docs/reference/workers/overview.md +2 -0
- package/.docs/reference/workflows/dynamic-workflow-definition.md +1 -1
- package/.docs/reference/workspace/mesa-filesystem.md +1 -1
- package/.docs/reference/workspace/platform-filesystem.md +1 -1
- package/.docs/reference/workspace/platform-sandbox.md +1 -1
- package/CHANGELOG.md +29 -0
- package/package.json +6 -6
|
@@ -421,12 +421,13 @@ Returns `{ accepted: true, runId: string, toolCallId?: string }`.
|
|
|
421
421
|
|
|
422
422
|
### `declineToolCall()`
|
|
423
423
|
|
|
424
|
-
Decline a pending tool call and return a continuation stream. Use this when you are rendering the resumed chunks from the decline response.
|
|
424
|
+
Decline a pending tool call and return a continuation stream. Use this when you are rendering the resumed chunks from the decline response. Pass an optional `reason` to tell the model why the call was rejected. The default is `Tool call was not approved by the user`.
|
|
425
425
|
|
|
426
426
|
```typescript
|
|
427
427
|
const response = await agent.declineToolCall({
|
|
428
428
|
runId: 'run-123',
|
|
429
429
|
toolCallId: 'tool-call-456',
|
|
430
|
+
reason: 'This file is outside the allowed directory', // optional
|
|
430
431
|
})
|
|
431
432
|
|
|
432
433
|
response.processDataStream({
|
|
@@ -14,7 +14,7 @@ const workflows = await mastraClient.listWorkflows()
|
|
|
14
14
|
|
|
15
15
|
## Getting workflow run counts
|
|
16
16
|
|
|
17
|
-
Retrieve per-workflow counts of `running` and [`suspended`](https://mastra.ai/docs/workflows/suspend-and-resume) runs in a single request. The counts are computed on the server and keyed by the workflow's registry key
|
|
17
|
+
Retrieve per-workflow counts of `running` and [`suspended`](https://mastra.ai/docs/workflows/suspend-and-resume) runs in a single request. The counts are computed on the server and keyed by the workflow's registry key, the key used when registering the workflow in the Mastra config, which can differ from the workflow's own `id`:
|
|
18
18
|
|
|
19
19
|
```typescript
|
|
20
20
|
const runCounts = await mastraClient.listWorkflowRunCounts()
|
|
@@ -23,7 +23,7 @@ const runCounts = await mastraClient.listWorkflowRunCounts()
|
|
|
23
23
|
|
|
24
24
|
Returns: `Record<string, { running: number; suspended: number }>`
|
|
25
25
|
|
|
26
|
-
The server may cache the counts for a few seconds between requests. Servers that predate this endpoint respond with `404 Not Found
|
|
26
|
+
The server may cache the counts for a few seconds between requests. Servers that predate this endpoint respond with `404 Not Found`. Handle the error when the client can talk to older deployments.
|
|
27
27
|
|
|
28
28
|
## Working with a specific workflow
|
|
29
29
|
|
|
@@ -227,7 +227,7 @@ A workflow run result yields the following:
|
|
|
227
227
|
|
|
228
228
|
## Dynamic workflows
|
|
229
229
|
|
|
230
|
-
> **Beta:**
|
|
230
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
231
231
|
|
|
232
232
|
Dynamic workflows are workflow definitions expressed as JSON. The server persists each definition and registers it as a runnable workflow. See [Dynamic workflows](https://mastra.ai/docs/workflows/dynamic-workflows) for the definition format.
|
|
233
233
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# mountAgentControllerOnMastra()
|
|
4
4
|
|
|
5
|
-
> **Beta:**
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
6
|
|
|
7
7
|
The `mountAgentControllerOnMastra()` function builds the Mastra Code agent controller (the coding agent behind the [`mastracode`](https://www.npmjs.com/package/mastracode) CLI, with its modes, tools, memory, and thread management) and registers it on a server-owned [Mastra](https://mastra.ai/reference/core/mastra-class) instance. Use it to serve the Mastra Code agent to your own UI (web app, editor, bot): each client creates or resumes its own isolated session through the returned [`AgentController`](https://mastra.ai/reference/agent-controller/agent-controller-class).
|
|
8
8
|
|
|
@@ -574,7 +574,7 @@ export const mastra = new Mastra({
|
|
|
574
574
|
|
|
575
575
|
Minifies the bundled output, stripping comments and whitespace and shortening local identifiers. Exported names are preserved.
|
|
576
576
|
|
|
577
|
-
Off by default so build output stays readable and stack traces stay
|
|
577
|
+
Off by default so build output stays readable and stack traces stay usable. Enable it when bundle size matters, such as packaging a container image for an on-prem deployment. `mastra dev` is never minified.
|
|
578
578
|
|
|
579
579
|
```typescript
|
|
580
580
|
import { Mastra } from '@mastra/core'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Mastra.addDynamicWorkflow()
|
|
4
4
|
|
|
5
|
-
> **Beta:**
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
6
|
|
|
7
7
|
The `.addDynamicWorkflow()` method validates a dynamic workflow definition and registers it as a live workflow on the instance, persisting it through the `workflowDefinitions` storage domain. Once registered, the workflow runs like any other workflow via [`getWorkflow()`](https://mastra.ai/reference/core/getWorkflow).
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Mastra.addDynamicWorkflows()
|
|
4
4
|
|
|
5
|
-
> **Beta:**
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
6
|
|
|
7
7
|
The `.addDynamicWorkflows()` method adds a bundle of dynamic workflow definitions that may reference each other. The typical case is a root workflow plus helper workflows it nests, where none of the definitions exist yet.
|
|
8
8
|
|
|
@@ -79,6 +79,14 @@ console.log(`Status: ${summary2.status}`)
|
|
|
79
79
|
|
|
80
80
|
**unmockedToolPolicy** (`'allow' | 'deny'`): Controls undeclared agent tool calls. allow executes them live. deny fails the item with TOOL\_MOCK\_NOT\_DECLARED before execution. An item-level value overrides this experiment default. (Default: `'allow'`)
|
|
81
81
|
|
|
82
|
+
**beforeAll** (`(args: ExperimentHookArgs) => void | Promise<void>`): Runs once before any item executes. Receives experimentId, mastra, and signal. A failure fails the experiment and no items run.
|
|
83
|
+
|
|
84
|
+
**beforeEach** (`(args: ExperimentItemHookArgs) => void | Promise<void>`): Runs before each item executes. Also receives the item (id, input, groundTruth, metadata). A failure fails that item with EXPERIMENT\_ITEM\_BEFORE\_EACH\_FAILED and skips its target, scorers, and afterEach.
|
|
85
|
+
|
|
86
|
+
**afterEach** (`(args: ExperimentItemResultHookArgs) => void | Promise<void>`): Runs after each item completes. Also receives the item's result with its scores. Skipped when beforeEach failed. A failure is logged and doesn't change the item's outcome.
|
|
87
|
+
|
|
88
|
+
**afterAll** (`(args: ExperimentRunResultHookArgs) => void | Promise<void>`): Runs once after the experiment finishes, on every exit path including failure. Also receives the summary. A failure is logged and doesn't change the summary.
|
|
89
|
+
|
|
82
90
|
**persistence** (`ExperimentPersistencePolicy`): Controls whether this run writes experiment records and score records. Targets and scorers still execute, and results remain available in the returned summary.
|
|
83
91
|
|
|
84
92
|
**persistence.experiments** (`'default' | 'none'`): Set to none to skip experiment creation, item results, progress, and terminal status writes.
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# config.ts
|
|
4
4
|
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
5
7
|
An agent's `config.ts` sets its model and runtime options. Use it for options that belong to the [`Agent`](https://mastra.ai/reference/agents/agent) itself, while sibling files provide instructions, tools, skills, et cetera.
|
|
6
8
|
|
|
7
9
|
## What belongs in `config.ts`
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Instructions
|
|
4
4
|
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
5
7
|
An agent's instructions hold its always-on system prompt: the model reads it on every turn. Use them to define the agent's identity, tone, role, and standing rules.
|
|
6
8
|
|
|
7
9
|
Write them in one of two files at the agent root. Use `instructions.md` when the prompt is fixed text. Use `instructions.ts` when the prompt needs code, for example when it's built from shared constants or resolved per request.
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Logger
|
|
4
4
|
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
5
7
|
Mastra sets the project's [logger](https://mastra.ai/docs/observability/logging) from a `logger.ts` file directly under `src/mastra/`. The file default-exports a logger, which replaces the built-in `ConsoleLogger` used across agents, workflows, and other components.
|
|
6
8
|
|
|
7
9
|
Use this page for the file-based convention. For log levels, transports, and provider details, see [logging](https://mastra.ai/docs/observability/logging).
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Memory
|
|
4
4
|
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
5
7
|
A file-based agent gets [memory](https://mastra.ai/docs/memory/overview) from a `memory.ts` file that default-exports a [`Memory`](https://mastra.ai/reference/memory/memory-class) instance. Use this page for the file-based convention; use the memory docs for message history, semantic recall, storage, and processors.
|
|
6
8
|
|
|
7
9
|
Without `memory.ts` or `config.memory`, the agent has no memory by default. Each `generate()` or `stream()` call starts without remembered conversation state unless you pass the prior context yourself.
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Observability
|
|
4
4
|
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
5
7
|
Mastra configures [observability](https://mastra.ai/docs/observability/overview) from an `observability.ts` file directly under `src/mastra/`. The file default-exports an `Observability` instance that sets up tracing, logging, metrics, and feedback for the project.
|
|
6
8
|
|
|
7
9
|
Use this page for the file-based convention. For the signal model, exporters, storage, and multi-config setup, see the [observability overview](https://mastra.ai/docs/observability/overview) and [observability configuration](https://mastra.ai/docs/observability/overview).
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Processors
|
|
4
4
|
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
5
7
|
A file-based agent discovers [processors](https://mastra.ai/docs/agents/processors) from its `processors/` directory. Use this page for the file-based convention; use the processors guide for built-in processors, custom processors, streaming behavior, and advanced patterns.
|
|
6
8
|
|
|
7
9
|
Files under `processors/input/` run before messages reach the model. Files under `processors/output/` run after the model responds. Each file default-exports one [`Processor`](https://mastra.ai/reference/processors/processor-interface), and the filename becomes its discovery key.
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Schedules
|
|
4
4
|
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
5
7
|
A file-based agent discovers **schedules** from its `schedules/` directory. Each file declares one recurring task: a cron expression plus what the agent should do when it fires. Mastra registers them into schedule storage at startup, so a scheduled agent needs no runtime registration code.
|
|
6
8
|
|
|
7
9
|
Use this page for the file-based convention. To create schedules at runtime instead, see [Schedules](https://mastra.ai/reference/schedules/overview).
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Scorers
|
|
4
4
|
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
5
7
|
A file-based agent discovers [scorers](https://mastra.ai/docs/evals/overview) from its `scorers/` directory. Use this page for the file-based convention; use the scorers guide for built-in scorers, custom scorers, and sampling.
|
|
6
8
|
|
|
7
9
|
Each file under `scorers/` default-exports one scorer, and the filename becomes its key. The default export is either a [`MastraScorer`](https://mastra.ai/reference/evals/create-scorer) or a `{ scorer, sampling }` entry.
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Server
|
|
4
4
|
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
5
7
|
Mastra configures its HTTP [server](https://mastra.ai/docs/server/mastra-server) from a `server.ts` file directly under `src/mastra/`. The server exposes agents, workflows, and other registered primitives as REST endpoints, and the file default-exports the same `ServerConfig` shape you'd pass to [`new Mastra()`](https://mastra.ai/reference/core/mastra-class).
|
|
6
8
|
|
|
7
9
|
Use this page for the file-based convention. For server features, middleware, custom routes, generated API docs, and deployment behavior, see [Server overview](https://mastra.ai/docs/server/mastra-server).
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Skills
|
|
4
4
|
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
5
7
|
A file-based agent discovers skills from its `skills/` directory and bundles them at build time. Skills are reusable procedures or reference material that the agent can load when relevant, instead of putting every detail into the always-on prompt.
|
|
6
8
|
|
|
7
9
|
Use this page for the file-based convention. For code-defined skills, see [Agent skills](https://mastra.ai/docs/agents/skills). For the `SKILL.md` package format, see [Workspace skills](https://mastra.ai/docs/workspace/skills).
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Storage
|
|
4
4
|
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
5
7
|
Mastra sets the project's default [storage](https://mastra.ai/docs/storage/overview) from a `storage.ts` file directly under `src/mastra/`. The file default-exports a store, which replaces the built-in in-memory store used for memory, workflows, observability, and other storage domains.
|
|
6
8
|
|
|
7
9
|
Use this page for the file-based convention. For backend choice, storage domains, retention, and provider details, see [storage overview](https://mastra.ai/docs/storage/overview).
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Studio
|
|
4
4
|
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
5
7
|
Mastra configures [Studio](https://mastra.ai/docs/studio/overview) from a `studio.ts` file directly under `src/mastra/`. The file default-exports a `StudioConfig` object for Studio authentication and authorization: who can access Studio, and what authenticated users can do.
|
|
6
8
|
|
|
7
9
|
Use this page for the file-based convention. For auth providers, role-based access control (RBAC), and fine-grained authorization (FGA), see [Studio auth](https://mastra.ai/docs/studio/auth).
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Subagents
|
|
4
4
|
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
5
7
|
A file-based agent can declare **subagents**, specialist child agents it delegates to. The parent model sees each subagent as a delegation tool named after the subagent directory and calls that tool to hand off a task. The subagent's result returns to the parent conversation.
|
|
6
8
|
|
|
7
9
|
Use this page for the file-based convention. For broader delegation patterns, hooks, memory isolation, tool approval propagation, and scoring, see [Supervisor agents](https://mastra.ai/docs/capabilities/subagents).
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Tools
|
|
4
4
|
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
5
7
|
A file-based agent discovers tools from `.ts` and `.js` files directly under its `tools/` directory. Each discovered file is imported at build time, the file must default-export a [`createTool()`](https://mastra.ai/reference/tools/create-tool) result, and the filename without its extension becomes the tool key the model can call.
|
|
6
8
|
|
|
7
9
|
Use this page for the file-based convention. For tool schemas, execution options, output shaping, and approval options, see the [`createTool()` reference](https://mastra.ai/reference/tools/create-tool).
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Workflows
|
|
4
4
|
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
5
7
|
Mastra discovers project-level workflows from `.ts` and `.js` files under `src/mastra/workflows/`. This convention isn't scoped to one agent: every file with a default export becomes a registered workflow, and the filename becomes the workflow key.
|
|
6
8
|
|
|
7
9
|
Use this page for the file-based convention. For steps, schemas, control flow, streaming, state, and workflow execution, see [Workflows overview](https://mastra.ai/docs/workflows/overview).
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Workspace
|
|
4
4
|
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
5
7
|
A [workspace](https://mastra.ai/docs/workspace/overview) gives an agent filesystem access and command execution. File-based agents get a default workspace automatically when discovered through `mastra dev` or `mastra build`, so they can read and write files and run shell commands without extra configuration.
|
|
6
8
|
|
|
7
9
|
Use this page for the file-based convention. For workspace providers, tools, search, lifecycle, and sandbox details, see [Workspaces](https://mastra.ai/docs/workspace/overview).
|
package/.docs/reference/index.md
CHANGED
|
@@ -313,6 +313,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
313
313
|
- [MCPClient](https://mastra.ai/reference/tools/mcp-client)
|
|
314
314
|
- [MCPServer](https://mastra.ai/reference/tools/mcp-server)
|
|
315
315
|
- [Perplexity Tools](https://mastra.ai/reference/tools/perplexity)
|
|
316
|
+
- [QuickJsCodeModeTransport](https://mastra.ai/reference/tools/quickjs-transport)
|
|
316
317
|
- [submitPlanTool](https://mastra.ai/reference/tools/submit-plan-tool)
|
|
317
318
|
- [Task tools](https://mastra.ai/reference/tools/task-tools)
|
|
318
319
|
- [Tavily Tools](https://mastra.ai/reference/tools/tavily)
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Sends Tracing data to Datadog's LLM Observability product for monitoring and analytics.
|
|
6
6
|
|
|
7
|
-
> **
|
|
7
|
+
> **Note:** If you also use `dd-trace` APM auto-instrumentation and need it correctly parented under Mastra spans, use the [DatadogBridge](https://mastra.ai/reference/observability/tracing/bridges/datadog) instead. The exporter sends LLM Observability data after execution completes, so it doesn't participate in `dd-trace`'s live scope.
|
|
8
8
|
|
|
9
9
|
## Constructor
|
|
10
10
|
|
|
@@ -42,6 +42,8 @@ const processor = new PIIDetector({
|
|
|
42
42
|
|
|
43
43
|
**options.providerOptions** (`ProviderOptions`): Provider-specific options passed to the internal detection agent. Use this to control model behavior like reasoning effort for thinking models (e.g., { openai: { reasoningEffort: 'low' } })
|
|
44
44
|
|
|
45
|
+
**options.onDetection** (`(event: PIIDetectionEvent) => void | Promise<void>`): Called whenever a detection result is produced, with detectionResult, the analyzed input, whether it was flagged, and the strategyApplied (the configured strategy when flagged, otherwise none). Fires for every analyzed message in processInput and processOutputResult, and for every LLM buffer flush during streaming; the streaming regex pass only reports when PII is found. Errors thrown by the callback are logged and ignored
|
|
46
|
+
|
|
45
47
|
## Returns
|
|
46
48
|
|
|
47
49
|
**id** (`string`): Processor identifier set to 'pii-detector'
|
|
@@ -38,6 +38,8 @@ const processor = new PromptInjectionDetector({
|
|
|
38
38
|
|
|
39
39
|
**options.providerOptions** (`ProviderOptions`): Provider-specific options passed to the internal detection agent. Use this to control model behavior like reasoning effort for thinking models (e.g., { openai: { reasoningEffort: 'low' } })
|
|
40
40
|
|
|
41
|
+
**options.onDetection** (`(event: PromptInjectionDetectionEvent) => void | Promise<void>`): Called for every analyzed message with detectionResult, the analyzed input, whether it was flagged, and the strategyApplied (the configured strategy when flagged, otherwise none). Use it to emit custom metrics. Errors thrown by the callback are logged and ignored
|
|
42
|
+
|
|
41
43
|
## Returns
|
|
42
44
|
|
|
43
45
|
**id** (`string`): Processor identifier set to 'prompt-injection-detector'
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# ResponseCache
|
|
4
4
|
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
5
7
|
`ResponseCache` is an input processor that caches LLM responses on the request/response boundary inside the agentic loop. It hooks into `processLLMRequest` for cache lookup and short-circuits on a hit. It uses `processLLMResponse` to write the completed response.
|
|
6
8
|
|
|
7
9
|
The cache key is derived from the resolved `LanguageModelV2Prompt` Mastra is about to send to the model (i.e. _after_ memory has loaded and earlier input processors have transformed the prompt) so two users with different memory contexts produce different cache keys. Each step in an agentic tool loop is independently cached.
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
**Added in:** `@mastra/core@1.50.0`
|
|
6
6
|
|
|
7
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
8
|
+
|
|
7
9
|
`mastra.schedules` is the CRUD service for persisted cron schedules. Use it to create, list, update, pause, resume, manually run, and delete schedules for agents or workflows.
|
|
8
10
|
|
|
9
11
|
For usage patterns and concepts, see [Schedules](https://mastra.ai/docs/long-running-agents/schedules).
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
**Added in:** `@mastra/core@1.39.0`
|
|
6
6
|
|
|
7
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
8
|
+
|
|
7
9
|
`createNotificationInboxTool()` creates a Mastra tool that lets an agent inspect and manage notification inbox records for the current thread.
|
|
8
10
|
|
|
9
11
|
Use this tool with durable notification signals. For sending notification records, see [`Agent.sendNotificationSignal()`](https://mastra.ai/reference/agents/agent).
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
**Added in:** `@mastra/core@1.39.0`
|
|
6
6
|
|
|
7
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
8
|
+
|
|
7
9
|
Abstract base class for building signal providers. A signal provider monitors external sources (APIs, webhooks, event streams) and pushes notification signals into agent threads through a built-in subscription registry.
|
|
8
10
|
|
|
9
11
|
Signal providers aren't processors by default. Providers that need to intercept agent execution return processors from `getInputProcessors()` or `getOutputProcessors()`. Providers that expose agent-callable tools return them from `getTools()`.
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# TaskSignalProvider
|
|
4
4
|
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
5
7
|
Bundles the built-in task tools (`task_write`, `task_update`, `task_complete`, `task_check`) and the `TaskStateProcessor` behind a single agent registration. Use it to add a structured, durable task list to an agent without wiring the tools and processor separately.
|
|
6
8
|
|
|
7
9
|
Extends [`SignalProvider`](https://mastra.ai/reference/signals/signal-provider). The task list is stored in the thread-scoped `tasks` storage domain (the source of truth) and projected onto the agent state-signal lane by the processor, so it survives observational-memory truncation without invalidating the prompt cache.
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
**Added in:** `@mastra/core@1.39.0`
|
|
6
6
|
|
|
7
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
8
|
+
|
|
7
9
|
Concrete signal provider for push-based event delivery. Routes incoming webhook payloads to subscribed agent threads by matching the payload against a configurable resource ID extractor.
|
|
8
10
|
|
|
9
11
|
Extends [`SignalProvider`](https://mastra.ai/reference/signals/signal-provider) with public subscription management and a built-in `handleWebhook()` implementation.
|
|
@@ -394,4 +394,4 @@ const storage = new MastraCompositeStore({
|
|
|
394
394
|
|
|
395
395
|
Don't set `replication` on ClickHouse Cloud. Cloud rewrites `MergeTree` to `SharedMergeTree` server-side. See the [ClickHouse storage reference](https://mastra.ai/reference/storage/clickhouse) for the full config shape and operator notes.
|
|
396
396
|
|
|
397
|
-
> **
|
|
397
|
+
> **Note:** This approach is also required when using storage providers that don't support observability (like Convex, DynamoDB, or Cloudflare). See the [MastraStorageExporter documentation](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage) for the full list of supported providers.
|
|
@@ -10,7 +10,7 @@ The `.stream()` method enables real-time streaming of responses from an agent wi
|
|
|
10
10
|
const stream = await agent.stream('message for agent')
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
> **
|
|
13
|
+
> **Note:** **Model Compatibility**: This method is designed for V2 models. V1 models should use the [`.streamLegacy()`](https://mastra.ai/reference/streaming/agents/streamLegacy) method. The framework automatically detects your model version and will throw an error if there's a mismatch.
|
|
14
14
|
|
|
15
15
|
## Parameters
|
|
16
16
|
|
|
@@ -152,7 +152,7 @@ await agent.streamLegacy('message for agent', {
|
|
|
152
152
|
|
|
153
153
|
## Migration to new API
|
|
154
154
|
|
|
155
|
-
> **
|
|
155
|
+
> **Note:** The new `.stream()` method offers enhanced capabilities including AI SDK v5+ compatibility, better structured output handling, and improved callback system. See the [migration guide](https://mastra.ai/guides/migrations/vnext-to-standard-apis) for detailed migration instructions.
|
|
156
156
|
|
|
157
157
|
### Quick Migration Example
|
|
158
158
|
|
|
@@ -32,7 +32,7 @@ for await (const chunk of stream.fullStream) {
|
|
|
32
32
|
}
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
> **
|
|
35
|
+
> **Note:** `streamUntilIdle()` requires both a [`BackgroundTaskManager`](https://mastra.ai/reference/configuration) and a [memory](https://mastra.ai/docs/memory/overview) backend. Without either, it uses a plain `agent.stream()` call.
|
|
36
36
|
|
|
37
37
|
## Parameters
|
|
38
38
|
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
**Added in:** `@mastra/core@1.38.0`
|
|
6
6
|
|
|
7
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
8
|
+
|
|
7
9
|
The `createCodeMode()` function returns a tool and generated instructions that let an agent run multi-tool computations as one TypeScript function. The generated code runs in a workspace sandbox, and each `external_*` call runs the real tool on the host with validation, request context, and tracing.
|
|
8
10
|
|
|
9
11
|
For a conceptual overview, see [Code mode](https://mastra.ai/docs/agents/code-mode).
|
|
@@ -62,7 +64,7 @@ export const shopAgent = new Agent({
|
|
|
62
64
|
|
|
63
65
|
**config.id** (`string`): The generated tool id.
|
|
64
66
|
|
|
65
|
-
**transport** (`CodeModeTransport`): Optional transport implementation used to run the generated code in the sandbox. The default transport uses stdio JSON-RPC over the workspace sandbox process API. Transports that declare requiresSandbox: false (such as IsolatedVmCodeModeTransport) run without a sandbox.
|
|
67
|
+
**transport** (`CodeModeTransport`): Optional transport implementation used to run the generated code in the sandbox. The default transport uses stdio JSON-RPC over the workspace sandbox process API. Transports that declare requiresSandbox: false (such as IsolatedVmCodeModeTransport and QuickJsCodeModeTransport) run without a sandbox.
|
|
66
68
|
|
|
67
69
|
## Returns
|
|
68
70
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# IsolatedVmCodeModeTransport
|
|
4
4
|
|
|
5
|
-
> **Beta:**
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
6
|
|
|
7
7
|
The `IsolatedVmCodeModeTransport` class runs [Code mode](https://mastra.ai/docs/agents/code-mode) programs in an in-process V8 isolate, backed by [isolated-vm](https://github.com/laverdet/isolated-vm). The isolate is the execution boundary, so no workspace sandbox is required: the program has no filesystem, network, process, or module access. Its only capabilities are the `external_*` functions, which call back into the real tools on the host.
|
|
8
8
|
|
|
@@ -244,6 +244,57 @@ const res = await agent.stream(prompt, {
|
|
|
244
244
|
})
|
|
245
245
|
```
|
|
246
246
|
|
|
247
|
+
### `listToolDefinitions()`
|
|
248
|
+
|
|
249
|
+
Returns every server's tools as plain, serializable definitions, grouped by server name and keyed by the server's own tool name (without the `serverName_toolName` namespacing that `listTools()` applies).
|
|
250
|
+
|
|
251
|
+
Unlike `listTools()`, the result contains no functions or references to a live client, so it can be passed through `JSON.stringify` and cached in Redis, a database, or a build artifact. Each definition holds the data from the MCP `tools/list` response (name, description, input schema, output schema, annotations, and `_meta`), plus the server name, version, and instructions captured at discovery time.
|
|
252
|
+
|
|
253
|
+
```typescript
|
|
254
|
+
const definitions = await mcp.listToolDefinitions()
|
|
255
|
+
|
|
256
|
+
await cache.set('mcp-tools', JSON.stringify(definitions))
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### `listToolDefinitionsWithErrors()`
|
|
260
|
+
|
|
261
|
+
Like `listToolDefinitions()`, but also returns per-server errors for servers that failed to connect. Use this when caching a catalog, so you don't persist a partial manifest that omits a server that was down at discovery time.
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
const { definitions, errors } = await mcp.listToolDefinitionsWithErrors()
|
|
265
|
+
|
|
266
|
+
if (Object.keys(errors).length === 0) {
|
|
267
|
+
await cache.set('mcp-tools', JSON.stringify(definitions))
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### `toolFromDefinition()`
|
|
272
|
+
|
|
273
|
+
Rebuilds a single executable tool from a cached definition. No connection is opened here. The client connects lazily, the first time the tool is executed.
|
|
274
|
+
|
|
275
|
+
The returned tool behaves exactly like one from `listTools()`, with the same strict-mode metadata, approval policy, structured content handling, tool error handling, and reconnect behavior.
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
const definitions = JSON.parse(await cache.get('mcp-tools'))
|
|
279
|
+
|
|
280
|
+
const tool = await mcp.toolFromDefinition({
|
|
281
|
+
serverName: 'weather',
|
|
282
|
+
definition: definitions.weather.getForecast,
|
|
283
|
+
})
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### `toolsFromDefinitions()`
|
|
287
|
+
|
|
288
|
+
Rebuilds an entire cached catalog into a namespaced tool map, without connecting. This is the cached counterpart to `listTools()`. It produces the same `serverName_toolName` keys, so you can reconstruct an agent's tool map on a cold start, and connections only open for the servers whose tools are actually called.
|
|
289
|
+
|
|
290
|
+
Servers present in the catalog but no longer configured on the client are skipped, so a stale cached manifest degrades gracefully.
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
const definitions = JSON.parse(await cache.get('mcp-tools'))
|
|
294
|
+
|
|
295
|
+
new Agent({ id: 'agent', tools: await mcp.toolsFromDefinitions({ definitions }) })
|
|
296
|
+
```
|
|
297
|
+
|
|
247
298
|
### `getServerInstructions()`
|
|
248
299
|
|
|
249
300
|
Returns the instructions currently known for each configured MCP server. Servers that haven't connected yet, or don't advertise instructions, return `undefined`.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# QuickJsCodeModeTransport
|
|
4
|
+
|
|
5
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
7
|
+
The `QuickJsCodeModeTransport` class runs [Code mode](https://mastra.ai/docs/agents/code-mode) programs in an in-process [QuickJS](https://bellard.org/quickjs/) runtime compiled to WebAssembly. The runtime is the execution boundary, so no workspace sandbox is required: the program has no filesystem, network, process, or module access. Its only capabilities are the `external_*` functions, which call back into the real tools on the host.
|
|
8
|
+
|
|
9
|
+
Unlike [`IsolatedVmCodeModeTransport`](https://mastra.ai/reference/tools/isolated-vm-transport), this transport installs no native binaries and needs no Node.js flags, so it runs on serverless platforms that disallow both. The tradeoff is speed: see [Choosing a transport](#choosing-a-transport).
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
**npm**:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @mastra/quickjs
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**pnpm**:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm add @mastra/quickjs
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Yarn**:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
yarn add @mastra/quickjs
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Bun**:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
bun add @mastra/quickjs
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The package contains the WebAssembly module, so installing it copies files and runs nothing else.
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
Pass the transport as the second argument to `createCodeMode()`. No `sandbox` is needed:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { createCodeMode } from '@mastra/core/tools'
|
|
45
|
+
import { QuickJsCodeModeTransport } from '@mastra/quickjs'
|
|
46
|
+
|
|
47
|
+
const { tool, instructions } = createCodeMode(
|
|
48
|
+
{ tools: { getTopProducts, getProductRatings } },
|
|
49
|
+
new QuickJsCodeModeTransport({ memoryLimitMb: 128 }),
|
|
50
|
+
)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Constructor parameters
|
|
54
|
+
|
|
55
|
+
**options** (`QuickJsCodeModeTransportOptions`): Configuration for the QuickJS runtime.
|
|
56
|
+
|
|
57
|
+
**options.memoryLimitMb** (`number`): Runtime heap limit in MiB. A program that exceeds the limit is terminated and the tool returns an error result.
|
|
58
|
+
|
|
59
|
+
**options.maxStackSizeBytes** (`number`): Runtime stack limit in bytes. A program that exceeds the limit, usually through runaway recursion, is terminated and the tool returns an error result.
|
|
60
|
+
|
|
61
|
+
**options.module** (`QuickJSWASMModule`): A preloaded QuickJS WebAssembly module. Supply one to control when the module is loaded, or to share a single module across transports. Loaded on first run when omitted.
|
|
62
|
+
|
|
63
|
+
## Choosing a transport
|
|
64
|
+
|
|
65
|
+
All three transports enforce the same allow-list, tool validation, and tracing on the host. They differ in what the program itself can reach and what the host has to provide.
|
|
66
|
+
|
|
67
|
+
| | `StdioCodeModeTransport` | `IsolatedVmCodeModeTransport` | `QuickJsCodeModeTransport` |
|
|
68
|
+
| ------------------- | ------------------------------ | -------------------------------------------- | --------------------------- |
|
|
69
|
+
| Isolation boundary | Workspace sandbox | V8 isolate | QuickJS WebAssembly runtime |
|
|
70
|
+
| Requires a sandbox | Yes | No | No |
|
|
71
|
+
| Native binary | Node.js runtime in the sandbox | Yes | No |
|
|
72
|
+
| Node.js flags | None | `--no-node-snapshot` on Node.js 20 and later | None |
|
|
73
|
+
| Runs in the browser | No | No | Yes |
|
|
74
|
+
| Execution speed | Fastest | Fast | Slowest |
|
|
75
|
+
|
|
76
|
+
Choose `QuickJsCodeModeTransport` when the host can't install native addons or set Node.js flags, which is common on serverless platforms. Choose `IsolatedVmCodeModeTransport` when the host allows both and programs do heavy computation.
|
|
77
|
+
|
|
78
|
+
The speed difference is in the program body, not the tool calls. QuickJS interprets rather than JIT-compiles, so a compute-heavy loop can run tens of times slower than in a V8 isolate, while a program that mostly awaits `external_*` calls performs about the same because the time goes to the tools. Code Mode programs are usually the second kind.
|
|
79
|
+
|
|
80
|
+
## How it works
|
|
81
|
+
|
|
82
|
+
Each run creates a fresh QuickJS runtime with its own heap. TypeScript is stripped on the host with [ts-blank-space](https://github.com/bloomberg/ts-blank-space), which erases type annotations without a native compiler, then the program is evaluated inside the runtime. Every `external_*` call crosses the boundary as JSON strings in both directions, so no host object references leak into model-authored code.
|
|
83
|
+
|
|
84
|
+
An `external_*` call returns a pending promise to the program and hands control straight back to the host, so many calls can be in flight at once and `Promise.all` behaves as expected.
|
|
85
|
+
|
|
86
|
+
The `timeout` configured on `createCodeMode()` applies to both asynchronous hangs and synchronous infinite loops, and the runtime is disposed after every run.
|
|
87
|
+
|
|
88
|
+
## Related
|
|
89
|
+
|
|
90
|
+
- [Code mode](https://mastra.ai/docs/agents/code-mode)
|
|
91
|
+
- [createCodeMode() reference](https://mastra.ai/reference/tools/create-code-mode)
|
|
92
|
+
- [IsolatedVmCodeModeTransport reference](https://mastra.ai/reference/tools/isolated-vm-transport)
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
The ChromaVector class provides vector search using [Chroma](https://docs.trychroma.com/docs/overview/getting-started), an open-source embedding database. It offers efficient vector search with metadata filtering and hybrid search capabilities.
|
|
6
6
|
|
|
7
|
-
> **
|
|
7
|
+
> **Note:**
|
|
8
8
|
>
|
|
9
9
|
> **Chroma Cloud**
|
|
10
10
|
>
|