@mastra/mcp-docs-server 1.2.7-alpha.8 → 1.2.8-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/agent-builder/integrations.md +44 -2
- package/.docs/docs/agent-builder/skill-registries.md +1 -3
- package/.docs/docs/agent-controller/overview.md +1 -1
- package/.docs/docs/agent-controller/session.md +1 -3
- package/.docs/docs/agents/code-mode.md +17 -1
- package/.docs/docs/agents/guardrails.md +8 -8
- package/.docs/docs/agents/overview.md +2 -2
- package/.docs/docs/agents/processors.md +9 -3
- package/.docs/docs/agents/skills.md +2 -4
- package/.docs/docs/agents/structured-output.md +1 -1
- package/.docs/docs/agents/supervisor-agents.md +1 -3
- package/.docs/docs/agents/using-tools.md +4 -4
- package/.docs/docs/browser/agent-browser.md +1 -3
- package/.docs/docs/browser/browser-viewer.md +1 -3
- package/.docs/docs/browser/stagehand.md +1 -1
- package/.docs/docs/capabilities/channels/overview.md +1 -3
- package/.docs/docs/deployment/mastra-server.md +2 -4
- package/.docs/docs/editor/overview.md +2 -6
- package/.docs/docs/editor/prompts.md +1 -1
- package/.docs/docs/editor/tools.md +3 -5
- package/.docs/docs/evals/custom-scorers.md +1 -3
- package/.docs/docs/evals/datasets/overview.md +4 -4
- package/.docs/docs/evals/datasets/running-experiments.md +4 -2
- package/.docs/docs/evals/evals-with-memory.md +1 -3
- package/.docs/docs/evals/gates-and-verdicts.md +17 -2
- package/.docs/docs/evals/quick-checks.md +1 -3
- package/.docs/docs/getting-started/file-based-agents.md +9 -4
- package/.docs/docs/long-running-agents/background-tasks.md +1 -1
- package/.docs/docs/long-running-agents/durable-agents.md +3 -5
- package/.docs/docs/long-running-agents/goals.md +1 -3
- package/.docs/docs/long-running-agents/signal-providers.md +1 -3
- package/.docs/docs/long-running-agents/signals.md +7 -21
- package/.docs/docs/mastra-platform/configuration.md +15 -22
- package/.docs/docs/mastra-platform/database.md +50 -6
- package/.docs/docs/mastra-platform/deploy.md +142 -0
- package/.docs/docs/mastra-platform/environments.md +103 -0
- package/.docs/docs/mastra-platform/github.md +2 -2
- package/.docs/docs/mastra-platform/overview.md +5 -5
- package/.docs/docs/mastra-platform/server.md +2 -0
- package/.docs/docs/mastra-platform/studio.md +5 -3
- package/.docs/docs/mcp/mcp-apps.md +3 -3
- package/.docs/docs/mcp/overview.md +6 -10
- package/.docs/docs/memory/overview.md +4 -4
- package/.docs/docs/observability/integrations/exporters/mastra-platform.md +1 -3
- package/.docs/docs/observability/logging.md +3 -1
- package/.docs/docs/observability/metrics/querying.md +2 -0
- package/.docs/docs/observability/tracing/overview.md +3 -1
- package/.docs/docs/server/auth/auth0.md +1 -1
- package/.docs/docs/server/auth/better-auth.md +2 -2
- package/.docs/docs/server/auth/clerk.md +1 -1
- package/.docs/docs/server/auth/firebase.md +1 -1
- package/.docs/docs/server/auth/google.md +2 -2
- package/.docs/docs/server/auth/jwt.md +2 -2
- package/.docs/docs/server/auth/okta.md +2 -2
- package/.docs/docs/server/auth/workos.md +1 -1
- package/.docs/docs/server/mastra-client.md +1 -1
- package/.docs/docs/server/mastra-server.md +1 -1
- package/.docs/docs/server/pubsub.md +1 -1
- package/.docs/docs/server/request-context.md +4 -4
- package/.docs/docs/server/server-adapters.md +8 -8
- package/.docs/docs/studio/auth.md +1 -3
- package/.docs/docs/workflows/agents-and-tools.md +3 -5
- package/.docs/docs/workflows/control-flow.md +1 -1
- package/.docs/docs/workflows/overview.md +5 -5
- package/.docs/guides/build-your-ui/assistant-ui.md +1 -1
- package/.docs/guides/build-your-ui/copilotkit/overview.md +1 -1
- package/.docs/guides/concepts/streaming.md +3 -3
- package/.docs/guides/guide/chef-michel.md +1 -1
- package/.docs/guides/guide/coding-agent.md +392 -0
- package/.docs/guides/migrations/mastra-cloud.md +5 -12
- package/.docs/models/environment-variables.md +14 -2
- package/.docs/models/gateways/azure-openai.md +15 -15
- package/.docs/models/gateways/mastra.md +2 -2
- package/.docs/models/gateways/openrouter.md +4 -7
- package/.docs/models/gateways/vercel.md +5 -10
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/abacus.md +44 -14
- package/.docs/models/providers/ai-router.md +77 -0
- package/.docs/models/providers/ambient.md +10 -6
- package/.docs/models/providers/baseten.md +1 -1
- package/.docs/models/providers/blueclaw.md +74 -0
- package/.docs/models/providers/crossmodel.md +8 -2
- package/.docs/models/providers/daoxe.md +81 -0
- package/.docs/models/providers/databricks.md +7 -2
- package/.docs/models/providers/deepinfra.md +2 -2
- package/.docs/models/providers/deepseek.md +2 -2
- package/.docs/models/providers/ebcloud.md +76 -0
- package/.docs/models/providers/empiriolabs.md +108 -0
- package/.docs/models/providers/google.md +4 -0
- package/.docs/models/providers/hpc-ai.md +16 -10
- package/.docs/models/providers/inferx.md +78 -0
- package/.docs/models/providers/llmgateway.md +2 -8
- package/.docs/models/providers/lynkr.md +73 -0
- package/.docs/models/providers/model-oracle-ai.md +87 -0
- package/.docs/models/providers/neon.md +1 -1
- package/.docs/models/providers/nvidia.md +1 -3
- package/.docs/models/providers/openai.md +12 -3
- package/.docs/models/providers/opencode.md +5 -2
- package/.docs/models/providers/pioneer.md +148 -0
- package/.docs/models/providers/routing-run.md +4 -1
- package/.docs/models/providers/snowflake-cortex.md +4 -1
- package/.docs/models/providers/stepfun-ai-step-plan.md +75 -0
- package/.docs/models/providers/stepfun-ai.md +6 -6
- package/.docs/models/providers/stepfun-step-plan.md +76 -0
- package/.docs/models/providers/stepfun.md +5 -5
- package/.docs/models/providers/unorouter.md +95 -0
- package/.docs/models/providers/vivgrid.md +5 -2
- package/.docs/models/providers/wafer.ai.md +9 -12
- package/.docs/models/providers/xai.md +1 -1
- package/.docs/models/providers/zenmux.md +5 -1
- package/.docs/models/providers.md +14 -2
- package/.docs/reference/agents/generateLegacy.md +8 -2
- package/.docs/reference/cli/mastra.md +131 -10
- package/.docs/reference/code-sdk/mount-agent-controller.md +2 -0
- package/.docs/reference/coding-agent/create-coding-agent.md +5 -4
- package/.docs/reference/evals/create-scorer.md +63 -0
- package/.docs/reference/evals/run-evals.md +2 -2
- package/.docs/reference/file-based-agents/logger.md +26 -0
- package/.docs/reference/file-based-agents/scorers.md +54 -0
- package/.docs/reference/index.md +2 -0
- package/.docs/reference/mastra-platform/api.md +1 -1
- package/.docs/reference/observability/metrics/automatic-metrics.md +8 -8
- package/.docs/reference/observability/tracing/exporters/braintrust.md +1 -0
- package/.docs/reference/observability/tracing/exporters/datadog.md +10 -9
- package/.docs/reference/observability/tracing/exporters/langsmith.md +8 -7
- package/.docs/reference/observability/tracing/exporters/posthog.md +13 -12
- package/.docs/reference/observability/tracing/exporters/sentry.md +1 -0
- package/.docs/reference/observability/tracing/interfaces.md +9 -0
- package/.docs/reference/processors/stream-error-retry-processor.md +39 -2
- package/.docs/reference/pubsub/base.md +10 -0
- package/.docs/reference/pubsub/caching-pubsub.md +8 -0
- package/.docs/reference/pubsub/redis-streams.md +12 -0
- package/.docs/reference/server/express-adapter.md +1 -3
- package/.docs/reference/server/fastify-adapter.md +1 -3
- package/.docs/reference/server/hono-adapter.md +1 -3
- package/.docs/reference/server/koa-adapter.md +1 -3
- package/.docs/reference/server/nestjs-adapter.md +1 -3
- package/.docs/reference/server/register-api-route.md +5 -4
- package/.docs/reference/templates/overview.md +1 -1
- package/.docs/reference/tools/mcp-client.md +22 -0
- package/.docs/reference/tools/mcp-server.md +161 -4
- package/.docs/reference/voice/google.md +48 -8
- package/.docs/reference/voice/speechify.md +10 -6
- package/.docs/reference/workspace/agentcore-runtime-sandbox.md +1 -3
- package/.docs/reference/workspace/agentfs-filesystem.md +1 -3
- package/.docs/reference/workspace/apple-container-sandbox.md +1 -3
- package/.docs/reference/workspace/archil-filesystem.md +1 -3
- package/.docs/reference/workspace/azure-blob-filesystem.md +1 -3
- package/.docs/reference/workspace/blaxel-sandbox.md +1 -3
- package/.docs/reference/workspace/daytona-sandbox.md +1 -3
- package/.docs/reference/workspace/docker-sandbox.md +1 -3
- package/.docs/reference/workspace/e2b-sandbox.md +20 -3
- package/.docs/reference/workspace/files-sdk-filesystem.md +1 -3
- package/.docs/reference/workspace/gcs-filesystem.md +1 -3
- package/.docs/reference/workspace/google-drive-filesystem.md +1 -3
- package/.docs/reference/workspace/local-filesystem.md +1 -3
- package/.docs/reference/workspace/local-sandbox.md +1 -3
- package/.docs/reference/workspace/modal-sandbox.md +1 -3
- package/.docs/reference/workspace/railway-sandbox.md +1 -3
- package/.docs/reference/workspace/s3-filesystem.md +1 -3
- package/.docs/reference/workspace/vercel-sandbox.md +5 -7
- package/.docs/reference/workspace/vercel-serverless.md +1 -3
- package/CHANGELOG.md +79 -0
- package/package.json +10 -10
|
@@ -23,13 +23,13 @@ If metrics aren't available, see [troubleshooting](#troubleshooting).
|
|
|
23
23
|
|
|
24
24
|
Duration metrics record execution time in milliseconds, calculated from the span's start and end timestamps. Each duration metric includes a `status` label set to `ok` or `error`, derived from the span's status.
|
|
25
25
|
|
|
26
|
-
| Metric name | Span type
|
|
27
|
-
| ------------------------------ |
|
|
28
|
-
| `mastra_agent_duration_ms` | `AGENT_RUN`
|
|
29
|
-
| `mastra_tool_duration_ms` | `TOOL_CALL`, `MCP_TOOL_CALL` | Execution time of a tool call, including MCP tool calls |
|
|
30
|
-
| `mastra_workflow_duration_ms` | `WORKFLOW_RUN`
|
|
31
|
-
| `mastra_model_duration_ms` | `MODEL_GENERATION`
|
|
32
|
-
| `mastra_processor_duration_ms` | `PROCESSOR_RUN`
|
|
26
|
+
| Metric name | Span type | Description |
|
|
27
|
+
| ------------------------------ | -------------------------------------------------- | ----------------------------------------------------------------------------- |
|
|
28
|
+
| `mastra_agent_duration_ms` | `AGENT_RUN` | Execution time of an agent run |
|
|
29
|
+
| `mastra_tool_duration_ms` | `TOOL_CALL`, `MCP_TOOL_CALL`, `PROVIDER_TOOL_CALL` | Execution time of a tool call, including MCP and provider-executed tool calls |
|
|
30
|
+
| `mastra_workflow_duration_ms` | `WORKFLOW_RUN` | Execution time of a workflow run |
|
|
31
|
+
| `mastra_model_duration_ms` | `MODEL_GENERATION` | Execution time of a model generation |
|
|
32
|
+
| `mastra_processor_duration_ms` | `PROCESSOR_RUN` | Execution time of a processor run |
|
|
33
33
|
|
|
34
34
|
## Token usage metrics
|
|
35
35
|
|
|
@@ -124,7 +124,7 @@ When you spot a spike in latency or token usage on the Metrics dashboard, correl
|
|
|
124
124
|
### Duration metrics are missing
|
|
125
125
|
|
|
126
126
|
- **Span has timestamps**: Duration is calculated from `startTime` and `endTime`. If either is missing, the metric is skipped.
|
|
127
|
-
- **Span type maps to a metric**: Only `AGENT_RUN`, `TOOL_CALL`, `MCP_TOOL_CALL`, `WORKFLOW_RUN`, `MODEL_GENERATION`, and `PROCESSOR_RUN` spans produce duration metrics.
|
|
127
|
+
- **Span type maps to a metric**: Only `AGENT_RUN`, `TOOL_CALL`, `MCP_TOOL_CALL`, `PROVIDER_TOOL_CALL`, `WORKFLOW_RUN`, `MODEL_GENERATION`, and `PROCESSOR_RUN` spans produce duration metrics.
|
|
128
128
|
|
|
129
129
|
### Token metrics are missing
|
|
130
130
|
|
|
@@ -92,6 +92,7 @@ const exporter = new BraintrustExporter({
|
|
|
92
92
|
| `MODEL_CHUNK` | `llm` |
|
|
93
93
|
| `TOOL_CALL` | `tool` |
|
|
94
94
|
| `MCP_TOOL_CALL` | `tool` |
|
|
95
|
+
| `PROVIDER_TOOL_CALL` | `tool` |
|
|
95
96
|
| `WORKFLOW_CONDITIONAL_EVAL` | `function` |
|
|
96
97
|
| `WORKFLOW_WAIT_EVENT` | `function` |
|
|
97
98
|
| All others | `task` |
|
|
@@ -95,15 +95,16 @@ const exporter = new DatadogExporter({
|
|
|
95
95
|
|
|
96
96
|
Mastra span types are mapped to Datadog LLM Observability span kinds:
|
|
97
97
|
|
|
98
|
-
| Mastra SpanType
|
|
99
|
-
|
|
|
100
|
-
| `AGENT_RUN`
|
|
101
|
-
| `MODEL_GENERATION`
|
|
102
|
-
| `MODEL_STEP`
|
|
103
|
-
| `TOOL_CALL`
|
|
104
|
-
| `MCP_TOOL_CALL`
|
|
105
|
-
| `
|
|
106
|
-
|
|
|
98
|
+
| Mastra SpanType | Datadog Kind |
|
|
99
|
+
| -------------------- | ------------ |
|
|
100
|
+
| `AGENT_RUN` | `agent` |
|
|
101
|
+
| `MODEL_GENERATION` | `workflow` |
|
|
102
|
+
| `MODEL_STEP` | `llm` |
|
|
103
|
+
| `TOOL_CALL` | `tool` |
|
|
104
|
+
| `MCP_TOOL_CALL` | `tool` |
|
|
105
|
+
| `PROVIDER_TOOL_CALL` | `tool` |
|
|
106
|
+
| `WORKFLOW_RUN` | `workflow` |
|
|
107
|
+
| All other types | `task` |
|
|
107
108
|
|
|
108
109
|
All unmapped span types (including `MODEL_CHUNK`, `WORKFLOW_STEP`, `GENERIC`, and future span types) automatically default to `task`.
|
|
109
110
|
|
|
@@ -73,13 +73,14 @@ const exporter = new LangSmithExporter({
|
|
|
73
73
|
|
|
74
74
|
## Span type mapping
|
|
75
75
|
|
|
76
|
-
| Span Type
|
|
77
|
-
|
|
|
78
|
-
| `MODEL_GENERATION`
|
|
79
|
-
| `MODEL_CHUNK`
|
|
80
|
-
| `TOOL_CALL`
|
|
81
|
-
| `MCP_TOOL_CALL`
|
|
82
|
-
|
|
|
76
|
+
| Span Type | LangSmith Type |
|
|
77
|
+
| -------------------- | -------------- |
|
|
78
|
+
| `MODEL_GENERATION` | `llm` |
|
|
79
|
+
| `MODEL_CHUNK` | `llm` |
|
|
80
|
+
| `TOOL_CALL` | `tool` |
|
|
81
|
+
| `MCP_TOOL_CALL` | `tool` |
|
|
82
|
+
| `PROVIDER_TOOL_CALL` | `tool` |
|
|
83
|
+
| All others | `chain` |
|
|
83
84
|
|
|
84
85
|
## `withLangsmithMetadata`
|
|
85
86
|
|
|
@@ -80,15 +80,16 @@ const exporter = new PosthogExporter({
|
|
|
80
80
|
|
|
81
81
|
## Span type mapping
|
|
82
82
|
|
|
83
|
-
| Mastra Span Type
|
|
84
|
-
|
|
|
85
|
-
| `MODEL_GENERATION`
|
|
86
|
-
| `MODEL_STEP`
|
|
87
|
-
| `MODEL_CHUNK`
|
|
88
|
-
| `TOOL_CALL`
|
|
89
|
-
| `MCP_TOOL_CALL`
|
|
90
|
-
| `
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
93
|
-
|
|
|
94
|
-
|
|
|
83
|
+
| Mastra Span Type | PostHog Event Type |
|
|
84
|
+
| -------------------- | ------------------ |
|
|
85
|
+
| `MODEL_GENERATION` | `$ai_generation` |
|
|
86
|
+
| `MODEL_STEP` | `$ai_generation` |
|
|
87
|
+
| `MODEL_CHUNK` | `$ai_span` |
|
|
88
|
+
| `TOOL_CALL` | `$ai_span` |
|
|
89
|
+
| `MCP_TOOL_CALL` | `$ai_span` |
|
|
90
|
+
| `PROVIDER_TOOL_CALL` | `$ai_span` |
|
|
91
|
+
| `PROCESSOR_RUN` | `$ai_span` |
|
|
92
|
+
| `AGENT_RUN` | `$ai_span` |
|
|
93
|
+
| `WORKFLOW_RUN` | `$ai_span` |
|
|
94
|
+
| All other workflows | `$ai_span` |
|
|
95
|
+
| `GENERIC` | `$ai_span` |
|
|
@@ -117,6 +117,7 @@ Mastra span types are mapped to Sentry operations:
|
|
|
117
117
|
| `MODEL_CHUNK` | _(skipped)_ |
|
|
118
118
|
| `TOOL_CALL` | `gen_ai.execute_tool` |
|
|
119
119
|
| `MCP_TOOL_CALL` | `gen_ai.execute_tool` |
|
|
120
|
+
| `PROVIDER_TOOL_CALL` | `gen_ai.execute_tool` |
|
|
120
121
|
| `WORKFLOW_RUN` | `workflow.run` |
|
|
121
122
|
| `WORKFLOW_STEP` | `workflow.step` |
|
|
122
123
|
| `WORKFLOW_CONDITIONAL` | `workflow.conditional` |
|
|
@@ -46,6 +46,7 @@ interface SpanTypeMap {
|
|
|
46
46
|
MODEL_CHUNK: ModelChunkAttributes
|
|
47
47
|
TOOL_CALL: ToolCallAttributes
|
|
48
48
|
CLIENT_TOOL_CALL: ClientToolCallAttributes
|
|
49
|
+
PROVIDER_TOOL_CALL: ProviderToolCallAttributes
|
|
49
50
|
MCP_TOOL_CALL: MCPToolCallAttributes
|
|
50
51
|
PROCESSOR_RUN: ProcessorRunAttributes
|
|
51
52
|
WORKFLOW_STEP: WorkflowStepAttributes
|
|
@@ -314,6 +315,14 @@ enum SpanType {
|
|
|
314
315
|
*/
|
|
315
316
|
CLIENT_TOOL_CALL = 'client_tool_call',
|
|
316
317
|
|
|
318
|
+
/**
|
|
319
|
+
* Provider-executed (server-side) tool span. Reconstructed from
|
|
320
|
+
* tool-call and tool-result stream chunks for tools the model
|
|
321
|
+
* provider executes (e.g. Anthropic code execution, server-side
|
|
322
|
+
* web search). Opened on tool-call chunk, closed on tool-result.
|
|
323
|
+
*/
|
|
324
|
+
PROVIDER_TOOL_CALL = 'provider_tool_call',
|
|
325
|
+
|
|
317
326
|
/** Workflow run - root span for workflow processes */
|
|
318
327
|
WORKFLOW_RUN = 'workflow_run',
|
|
319
328
|
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# StreamErrorRetryProcessor
|
|
4
4
|
|
|
5
|
-
`StreamErrorRetryProcessor` is an **error processor** that retries transient
|
|
5
|
+
`StreamErrorRetryProcessor` is an **error processor** that retries transient LLM API and stream failures. It includes built-in matching for OpenAI Responses stream errors and supports additional matchers for other provider-specific error shapes.
|
|
6
6
|
|
|
7
|
-
The processor isn't enabled by default in core. Add it to `errorProcessors` for agents that need
|
|
7
|
+
The processor isn't enabled by default in core. Add it to `errorProcessors` for agents that need bounded retry handling.
|
|
8
8
|
|
|
9
9
|
## Usage example
|
|
10
10
|
|
|
@@ -35,6 +35,43 @@ When the error is retryable, the processor returns `{ retry: true }`. It doesn't
|
|
|
35
35
|
|
|
36
36
|
When `delayMs` is set, the processor waits before signaling a retry. This is useful for transient network errors like `ECONNRESET` where immediately retrying is likely to fail again. The delay can be a fixed number of milliseconds or a function evaluated with the error args (for example, to implement exponential backoff).
|
|
37
37
|
|
|
38
|
+
### Retry limits
|
|
39
|
+
|
|
40
|
+
`maxRetries` defaults to `1` and limits this processor's retry requests. The agent also limits processor retries with `maxProcessorRetries`. When error processors are configured without an agent limit, the runtime cap is `10`.
|
|
41
|
+
|
|
42
|
+
Set both values explicitly to the same bounded value when you need a single retry budget. Keep model `maxRetries` at `0` for that call to avoid multiplying provider attempts.
|
|
43
|
+
|
|
44
|
+
### `Retry-After` handling
|
|
45
|
+
|
|
46
|
+
For retryable errors with a `Retry-After` response header, the processor reads case-insensitive delta-seconds and HTTP-date values through the error cause chain. It waits for the longer of `delayMs` and the bounded server delay.
|
|
47
|
+
|
|
48
|
+
`maxRetryAfterMs` defaults to `30_000`. It caps only provider-provided wait time. A longer explicit `delayMs` remains unchanged. Invalid or expired headers are ignored.
|
|
49
|
+
|
|
50
|
+
## Retry unknown errors
|
|
51
|
+
|
|
52
|
+
Set `retryUnknownErrors` to retry errors that don't match provider metadata, the built-in OpenAI matcher, or a custom matcher. Unknown-error retries use the processor-level `maxRetries` and `delayMs` values. Known authorization failures, including HTTP `401` and `403` responses, aren't retried:
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { Agent } from '@mastra/core/agent'
|
|
56
|
+
import { StreamErrorRetryProcessor } from '@mastra/core/processors'
|
|
57
|
+
|
|
58
|
+
export const agent = new Agent({
|
|
59
|
+
id: 'resilient-agent',
|
|
60
|
+
name: 'Resilient agent',
|
|
61
|
+
instructions: 'You are a helpful assistant.',
|
|
62
|
+
model: 'openai/gpt-5',
|
|
63
|
+
errorProcessors: [
|
|
64
|
+
new StreamErrorRetryProcessor({
|
|
65
|
+
retryUnknownErrors: true,
|
|
66
|
+
maxRetries: 2,
|
|
67
|
+
delayMs: 3000,
|
|
68
|
+
}),
|
|
69
|
+
],
|
|
70
|
+
})
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Specific matcher policies still take precedence over the unknown-error values. The option defaults to `false`, so unknown errors aren't retried unless you enable it.
|
|
74
|
+
|
|
38
75
|
## Delaying retries
|
|
39
76
|
|
|
40
77
|
Use `delayMs` with a custom matcher to retry transient network resets with a wait:
|
|
@@ -101,6 +101,16 @@ Waits for any in-flight deliveries to settle. Call this before shutdown to avoid
|
|
|
101
101
|
await pubsub.flush()
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
+
#### `clearTopic(topic)`
|
|
105
|
+
|
|
106
|
+
Deletes all retained state for a topic — cached history, persistent stream entries, and consumer groups — once no more events will be published to it. Mastra's run lifecycles (durable agents and the evented workflow engine) call this automatically when a run reaches a terminal state, so per-run topics don't accumulate on transports that retain messages.
|
|
107
|
+
|
|
108
|
+
The default implementation is a no-op: transports that retain nothing per topic (such as `EventEmitterPubSub`) have nothing to clear. Backends that persist messages, like [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams), override it. The contract is best-effort — implementations log failures rather than throwing, because callers invoke it fire-and-forget at cleanup boundaries.
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
await pubsub.clearTopic('workflow.events.v2.run-123')
|
|
112
|
+
```
|
|
113
|
+
|
|
104
114
|
### Replay methods
|
|
105
115
|
|
|
106
116
|
These methods support resuming a stream after a disconnect. The default implementations fall back to a regular `subscribe`, so backends without history support behave as live-only. [`CachingPubSub`](https://mastra.ai/reference/pubsub/caching-pubsub) overrides them to replay cached events.
|
|
@@ -92,6 +92,14 @@ const events = await pubsub.getHistory('my-topic', 0)
|
|
|
92
92
|
|
|
93
93
|
Returns: `Promise<Event[]>`
|
|
94
94
|
|
|
95
|
+
### `clearTopic(topic)`
|
|
96
|
+
|
|
97
|
+
Removes the topic's cached events and offset counter, and forwards the call to the inner pub/sub so persistent transports (such as [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams)) can delete their retained state too. Mastra's run lifecycles call this automatically when a run finishes.
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
await pubsub.clearTopic('my-topic')
|
|
101
|
+
```
|
|
102
|
+
|
|
95
103
|
## Functions
|
|
96
104
|
|
|
97
105
|
### `withCaching(pubsub, cache, options?)`
|
|
@@ -63,6 +63,8 @@ export const mastra = new Mastra({
|
|
|
63
63
|
|
|
64
64
|
**maxStreamLength** (`number`): Approximate maximum number of entries kept per stream. Set to 0 to disable trimming. (Default: `10000`)
|
|
65
65
|
|
|
66
|
+
**streamIdleTtlMs** (`number`): Idle expiry in milliseconds: a sliding TTL refreshed on every write (publish, nack retry, group re-creation). Each write resets it, so an actively-written stream never expires mid-flight; a stream left idle for the full duration is deleted by Redis automatically. Note that only writes refresh the TTL — a consumer slowly draining a backlog does not — so set it well above the longest expected gap between writes on a live topic. This is a backstop, not the primary cleanup — clearTopic handles normal end-of-lifecycle deletion; this only bounds memory for streams that never reach a clearTopic call (e.g. a crashed run). Must be a non-negative integer. Defaults to 0 (disabled). (Default: `0`)
|
|
67
|
+
|
|
66
68
|
**reclaimIntervalMs** (`number`): How often, in milliseconds, a subscription reclaims events that an earlier consumer read but never acknowledged. Set to 0 to disable. (Default: `30000`)
|
|
67
69
|
|
|
68
70
|
**reclaimIdleMs** (`number`): Minimum idle time, in milliseconds, before a pending event is eligible for reclaim. Keep this well above typical processing time to avoid double delivery. (Default: `60000`)
|
|
@@ -97,6 +99,16 @@ Waits for in-flight publishes to complete.
|
|
|
97
99
|
await pubsub.flush()
|
|
98
100
|
```
|
|
99
101
|
|
|
102
|
+
### `clearTopic(topic)`
|
|
103
|
+
|
|
104
|
+
Deletes a topic's stream and every consumer group on it, freeing the memory a finished topic would otherwise hold. Mastra's run lifecycles — durable agents and the evented workflow engine — call this automatically when a run reaches a terminal state; call it yourself only once nothing will read the topic again. It's best-effort and never throws — failures are logged at warn level. A subscriber still attached when the stream is deleted recovers on its own but misses the deleted entries.
|
|
105
|
+
|
|
106
|
+
Automatic cleanup requires `@mastra/core` and `@mastra/redis-streams` versions that both support `clearTopic`: the runtime routes the call through its caching layer, so upgrade the two packages together to get end-of-run stream deletion.
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
await pubsub.clearTopic('workflow.events.run-123')
|
|
110
|
+
```
|
|
111
|
+
|
|
100
112
|
### `close()`
|
|
101
113
|
|
|
102
114
|
Closes the Redis connections and stops all subscriptions. Call this during graceful shutdown.
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Express adapter
|
|
4
4
|
|
|
5
|
-
The `@mastra/express` package provides a server adapter for running Mastra with [Express](https://expressjs.com).
|
|
6
|
-
|
|
7
|
-
> **Info:** For general adapter concepts (constructor options, initialization flow, etc.), see [Server Adapters](https://mastra.ai/docs/server/server-adapters).
|
|
5
|
+
The `@mastra/express` package provides a server adapter for running Mastra with [Express](https://expressjs.com). For general adapter concepts (constructor options, initialization flow, etc.), see [Server Adapters](https://mastra.ai/docs/server/server-adapters).
|
|
8
6
|
|
|
9
7
|
## Installation
|
|
10
8
|
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Fastify adapter
|
|
4
4
|
|
|
5
|
-
The `@mastra/fastify` package provides a server adapter for running Mastra with [Fastify](https://fastify.dev).
|
|
6
|
-
|
|
7
|
-
> **Info:** For general adapter concepts (constructor options, initialization flow, etc.), see [Server Adapters](https://mastra.ai/docs/server/server-adapters).
|
|
5
|
+
The `@mastra/fastify` package provides a server adapter for running Mastra with [Fastify](https://fastify.dev). For general adapter concepts (constructor options, initialization flow, etc.), see [Server Adapters](https://mastra.ai/docs/server/server-adapters).
|
|
8
6
|
|
|
9
7
|
## Installation
|
|
10
8
|
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Hono adapter
|
|
4
4
|
|
|
5
|
-
The `@mastra/hono` package provides a server adapter for running Mastra with [Hono](https://hono.dev).
|
|
6
|
-
|
|
7
|
-
> **Info:** For general adapter concepts (constructor options, initialization flow, etc.), see [Server Adapters](https://mastra.ai/docs/server/server-adapters).
|
|
5
|
+
The `@mastra/hono` package provides a server adapter for running Mastra with [Hono](https://hono.dev). For general adapter concepts (constructor options, initialization flow, etc.), see [Server Adapters](https://mastra.ai/docs/server/server-adapters).
|
|
8
6
|
|
|
9
7
|
## Installation
|
|
10
8
|
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Koa adapter
|
|
4
4
|
|
|
5
|
-
The `@mastra/koa` package provides a server adapter for running Mastra with [Koa](https://koajs.com).
|
|
6
|
-
|
|
7
|
-
> **Info:** For general adapter concepts (constructor options, initialization flow, etc.), see [Server Adapters](https://mastra.ai/docs/server/server-adapters).
|
|
5
|
+
The `@mastra/koa` package provides a server adapter for running Mastra with [Koa](https://koajs.com). For general adapter concepts (constructor options, initialization flow, etc.), see [Server Adapters](https://mastra.ai/docs/server/server-adapters).
|
|
8
6
|
|
|
9
7
|
## Installation
|
|
10
8
|
|
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
The `@mastra/nestjs` package provides a NestJS module for running Mastra with the Express-based NestJS platform.
|
|
6
6
|
|
|
7
|
-
It's intentionally Express-only for v1. If Nest is bootstrapped with a different HTTP adapter, `MastraModule` throws during startup instead of attempting a partial integration.
|
|
8
|
-
|
|
9
|
-
> **Info:** For general adapter concepts, see [Server Adapters](https://mastra.ai/docs/server/server-adapters).
|
|
7
|
+
It's intentionally Express-only for v1. If Nest is bootstrapped with a different HTTP adapter, `MastraModule` throws during startup instead of attempting a partial integration. For general adapter concepts, see [Server Adapters](https://mastra.ai/docs/server/server-adapters).
|
|
10
8
|
|
|
11
9
|
## Installation
|
|
12
10
|
|
|
@@ -28,7 +28,7 @@ registerApiRoute("/items/:itemId", { ... })
|
|
|
28
28
|
|
|
29
29
|
**handler** (`Handler`): Route handler function receiving Hono Context. Use either handler or createHandler, not both.
|
|
30
30
|
|
|
31
|
-
**createHandler** (`(
|
|
31
|
+
**createHandler** (`({ mastra }: { mastra: Mastra }) => Promise<ApiRouteHandler>`): Async factory that receives the Mastra instance and returns the route handler. Runs once at server startup, so it can perform one-time setup. Use either handler or createHandler, not both.
|
|
32
32
|
|
|
33
33
|
**middleware** (`MiddlewareHandler | MiddlewareHandler[]`): Route-specific middleware functions
|
|
34
34
|
|
|
@@ -229,12 +229,13 @@ For routes that need async initialization:
|
|
|
229
229
|
```typescript
|
|
230
230
|
registerApiRoute('/dynamic', {
|
|
231
231
|
method: 'GET',
|
|
232
|
-
createHandler: async
|
|
233
|
-
// Perform async setup
|
|
232
|
+
createHandler: async ({ mastra }) => {
|
|
233
|
+
// Perform one-time async setup
|
|
234
234
|
const config = await loadConfig()
|
|
235
|
+
const agent = mastra.getAgent('weatherAgent')
|
|
235
236
|
|
|
236
237
|
return async c => {
|
|
237
|
-
return c.json({ config })
|
|
238
|
+
return c.json({ config, agent: agent.name })
|
|
238
239
|
}
|
|
239
240
|
},
|
|
240
241
|
})
|
|
@@ -15,7 +15,7 @@ Mastra templates are pre-built project structures that demonstrate specific use
|
|
|
15
15
|
|
|
16
16
|
The following templates demonstrate Gateway-first Mastra applications:
|
|
17
17
|
|
|
18
|
-
- `template-docs-expert`: Answers documentation questions with
|
|
18
|
+
- `template-docs-expert`: Answers documentation questions with Gateway web search, citations, memory, and structured responses.
|
|
19
19
|
- `template-browser-agent`: Uses AgentBrowser to browse, inspect, and interact with web pages.
|
|
20
20
|
- `template-meeting-notes`: Turns Zoom transcripts or uploaded transcripts into structured notes with decisions and action items.
|
|
21
21
|
- `template-company-knowledge`: Indexes Linear and Notion content into pgvector and answers internal knowledge questions.
|
|
@@ -601,6 +601,28 @@ mcpClient.prompts.onListChanged('myWeatherServer', () => {
|
|
|
601
601
|
})
|
|
602
602
|
```
|
|
603
603
|
|
|
604
|
+
### `tools` Property
|
|
605
|
+
|
|
606
|
+
The `MCPClient` instance has a `tools` property for subscribing to tool list change notifications. To fetch tools, use `listTools()` or `listToolsets()`.
|
|
607
|
+
|
|
608
|
+
#### `tools.onListChanged(serverName: string, handler: () => void)`
|
|
609
|
+
|
|
610
|
+
Sets a notification handler that will be called when the list of available tools changes on a specific server (for example, when the server adds or removes tools at runtime).
|
|
611
|
+
|
|
612
|
+
```typescript
|
|
613
|
+
async onListChanged(serverName: string, handler: () => void): Promise<void>
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
Example:
|
|
617
|
+
|
|
618
|
+
```typescript
|
|
619
|
+
await mcpClient.tools.onListChanged('myWeatherServer', async () => {
|
|
620
|
+
console.log('Tool list changed on myWeatherServer.')
|
|
621
|
+
// You should re-fetch the tools
|
|
622
|
+
// const tools = await mcpClient.listTools();
|
|
623
|
+
})
|
|
624
|
+
```
|
|
625
|
+
|
|
604
626
|
### `progress` Property
|
|
605
627
|
|
|
606
628
|
The `MCPClient` instance has a `progress` property for subscribing to progress notifications emitted by MCP servers while tools execute.
|
|
@@ -399,12 +399,31 @@ serve(async req => {
|
|
|
399
399
|
>
|
|
400
400
|
> The serverless mode disables session management and creates fresh server instances per request, which is necessary for stateless environments where memory doesn't persist between invocations.
|
|
401
401
|
>
|
|
402
|
-
>
|
|
402
|
+
> By default, serverless mode buffers each request into a single JSON response, so `notifications/progress` sent by a tool never reach the client. Set `serverlessStreaming: true` to handle the request with request-scoped SSE streaming instead, which delivers progress notifications before the final result:
|
|
403
|
+
>
|
|
404
|
+
> ```typescript
|
|
405
|
+
> await server.startHTTP({
|
|
406
|
+
> url,
|
|
407
|
+
> httpPath: '/mcp',
|
|
408
|
+
> req: nodeReq,
|
|
409
|
+
> res: nodeRes,
|
|
410
|
+
> options: {
|
|
411
|
+
> serverless: true,
|
|
412
|
+
> serverlessStreaming: true, // ← Stream request-scoped notifications/progress
|
|
413
|
+
> },
|
|
414
|
+
> })
|
|
415
|
+
> ```
|
|
416
|
+
>
|
|
417
|
+
> This is still stateless: no `mcp-session-id` is required or persisted. It only enables notifications scoped to the current request (such as progress). The session-dependent features below remain unavailable.
|
|
418
|
+
>
|
|
419
|
+
> **Note:** The following MCP features require session state or persistent connections and **won't work** in serverless mode (including with `serverlessStreaming: true`):
|
|
403
420
|
>
|
|
404
421
|
> - **Elicitation** - Interactive user input requests during tool execution require session management to route responses back to the correct client
|
|
405
422
|
> - **Resource subscriptions** - `resources/subscribe` and `resources/unsubscribe` need persistent connections to maintain subscription state
|
|
406
423
|
> - **Resource update notifications** - `resources.notifyUpdated()` requires active subscriptions and persistent connections to notify clients
|
|
407
424
|
> - **Prompt list change notifications** - `prompts.notifyListChanged()` requires persistent connections to push updates to clients
|
|
425
|
+
> - **Tool list change notifications** - `toolActions.notifyListChanged()` requires persistent connections to push updates to clients
|
|
426
|
+
> - **Server log notifications** - `sendLoggingMessage()` requires persistent connections to push log messages to clients
|
|
408
427
|
>
|
|
409
428
|
> These features work normally in long-lived server environments (Node.js servers, Docker containers, etc.).
|
|
410
429
|
|
|
@@ -424,6 +443,8 @@ The `StreamableHTTPServerTransportOptions` object allows you to customize the be
|
|
|
424
443
|
|
|
425
444
|
**serverless** (`boolean`): If true, runs in stateless mode without session management. Each request is handled independently with a fresh server instance. Essential for serverless environments (Cloudflare Workers, Supabase Edge Functions, Vercel Edge, etc.) where sessions cannot persist between invocations. Defaults to false.
|
|
426
445
|
|
|
446
|
+
**serverlessStreaming** (`boolean`): If true, serverless requests use request-scoped SSE streaming instead of a buffered JSON response, allowing in-request notifications/progress to reach the client before the final result. Only takes effect together with serverless: true. Defaults to false (buffered JSON responses), which preserves backward-compatible behavior. This enables only request-scoped notifications such as progress; elicitation, subscriptions, and out-of-request notifications still require session state.
|
|
447
|
+
|
|
427
448
|
**sessionIdGenerator** (`(() => string) | undefined`): A function that generates a unique session ID. This should be a cryptographically secure, globally unique string. Return undefined to disable session management.
|
|
428
449
|
|
|
429
450
|
**onsessioninitialized** (`(sessionId: string) => void`): A callback that is invoked when a new session is initialized. This is useful for tracking active MCP sessions.
|
|
@@ -776,6 +797,144 @@ await serverWithPrompts.prompts.notifyListChanged()
|
|
|
776
797
|
- Handle errors with informative messages.
|
|
777
798
|
- Document argument expectations and available versions.
|
|
778
799
|
|
|
800
|
+
## Dynamic tool management
|
|
801
|
+
|
|
802
|
+
Tools are usually provided when constructing the `MCPServer`, but you can also add or remove tools while the server is running. The server exposes these operations through the `toolActions` property. When the tool list changes, connected clients receive a `notifications/tools/list_changed` message prompting them to re-fetch the tool list.
|
|
803
|
+
|
|
804
|
+
The property is named `toolActions` because `tools()` is the method that returns the registered tool registry.
|
|
805
|
+
|
|
806
|
+
### `toolActions.add(tools)`
|
|
807
|
+
|
|
808
|
+
Registers new tools on the running server and notifies connected clients. Tools are keyed by their record key, the same as tools passed to the constructor. Adding a tool under an existing key replaces it.
|
|
809
|
+
|
|
810
|
+
```typescript
|
|
811
|
+
async server.toolActions.add(tools: ToolsInput): Promise<void>
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
Example:
|
|
815
|
+
|
|
816
|
+
```typescript
|
|
817
|
+
import { createTool } from '@mastra/core/tools'
|
|
818
|
+
import { z } from 'zod'
|
|
819
|
+
|
|
820
|
+
const searchTool = createTool({
|
|
821
|
+
id: 'search',
|
|
822
|
+
description: 'Searches the knowledge base.',
|
|
823
|
+
inputSchema: z.object({ query: z.string() }),
|
|
824
|
+
execute: async ({ query }) => ({ results: [] }),
|
|
825
|
+
})
|
|
826
|
+
|
|
827
|
+
await server.toolActions.add({ searchTool })
|
|
828
|
+
```
|
|
829
|
+
|
|
830
|
+
### `toolActions.remove(toolIds)`
|
|
831
|
+
|
|
832
|
+
Removes tools from the running server by tool ID and notifies connected clients. Unknown tool IDs are ignored. If no tools were removed, no notification is sent.
|
|
833
|
+
|
|
834
|
+
```typescript
|
|
835
|
+
async server.toolActions.remove(toolIds: string[]): Promise<void>
|
|
836
|
+
```
|
|
837
|
+
|
|
838
|
+
Example:
|
|
839
|
+
|
|
840
|
+
```typescript
|
|
841
|
+
await server.toolActions.remove(['searchTool'])
|
|
842
|
+
```
|
|
843
|
+
|
|
844
|
+
### `toolActions.notifyListChanged()`
|
|
845
|
+
|
|
846
|
+
Sends a `notifications/tools/list_changed` message to connected clients without modifying the tool registry. Call this when tool availability changes through other means (for example, authorization changes).
|
|
847
|
+
|
|
848
|
+
```typescript
|
|
849
|
+
async server.toolActions.notifyListChanged(): Promise<void>
|
|
850
|
+
```
|
|
851
|
+
|
|
852
|
+
### Mastra registry synchronization
|
|
853
|
+
|
|
854
|
+
When the server is registered with a Mastra instance, `toolActions.add()` and `toolActions.remove()` also update the Mastra instance's tool registry, matching the automatic tool registration that happens at startup. Added tools become available through `mastra.listTools()` (keyed by the tool's intrinsic `id` when present), and removed tools are deleted from the registry.
|
|
855
|
+
|
|
856
|
+
## Logging
|
|
857
|
+
|
|
858
|
+
MCP servers can send structured log messages to clients using `notifications/message`. Clients control verbosity by sending a `logging/setLevel` request; the server drops messages below the requested minimum level (following RFC 5424 severity ordering). The level is tracked per session, so different clients can request different verbosity.
|
|
859
|
+
|
|
860
|
+
### `sendLoggingMessage()`
|
|
861
|
+
|
|
862
|
+
Sends a log notification to all connected clients, honoring each client's minimum logging level.
|
|
863
|
+
|
|
864
|
+
```typescript
|
|
865
|
+
async server.sendLoggingMessage(params: {
|
|
866
|
+
level: LoggingLevel;
|
|
867
|
+
data: unknown;
|
|
868
|
+
logger?: string;
|
|
869
|
+
}): Promise<void>
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
Example:
|
|
873
|
+
|
|
874
|
+
```typescript
|
|
875
|
+
await server.sendLoggingMessage({
|
|
876
|
+
level: 'info',
|
|
877
|
+
data: { message: 'Sync completed', itemsProcessed: 42 },
|
|
878
|
+
})
|
|
879
|
+
```
|
|
880
|
+
|
|
881
|
+
### `context.mcp.log()`
|
|
882
|
+
|
|
883
|
+
Inside a tool's `execute` function, use `context.mcp.log()` to send a log message to the client that called the tool.
|
|
884
|
+
|
|
885
|
+
```typescript
|
|
886
|
+
async context.mcp.log(
|
|
887
|
+
level: LoggingLevel,
|
|
888
|
+
message: string,
|
|
889
|
+
data?: Record<string, unknown>
|
|
890
|
+
): Promise<void>
|
|
891
|
+
```
|
|
892
|
+
|
|
893
|
+
Example:
|
|
894
|
+
|
|
895
|
+
```typescript
|
|
896
|
+
execute: async ({ location }, context) => {
|
|
897
|
+
await context.mcp.log('debug', 'Fetching weather', { location })
|
|
898
|
+
const weather = await fetchWeather(location)
|
|
899
|
+
await context.mcp.log('info', 'Weather fetched')
|
|
900
|
+
return weather
|
|
901
|
+
}
|
|
902
|
+
```
|
|
903
|
+
|
|
904
|
+
## Progress notifications
|
|
905
|
+
|
|
906
|
+
Long-running tools can report progress to the calling client with `notifications/progress`. Progress is only sent when the caller requested progress tracking by including a `progressToken` in the request (the Mastra `MCPClient` does this when `enableProgressTracking` is set). When no token was sent, `context.mcp.progress()` is a no-op.
|
|
907
|
+
|
|
908
|
+
### `context.mcp.progress()`
|
|
909
|
+
|
|
910
|
+
```typescript
|
|
911
|
+
async context.mcp.progress(params: {
|
|
912
|
+
progress: number;
|
|
913
|
+
total?: number;
|
|
914
|
+
message?: string;
|
|
915
|
+
}): Promise<void>
|
|
916
|
+
```
|
|
917
|
+
|
|
918
|
+
Example:
|
|
919
|
+
|
|
920
|
+
```typescript
|
|
921
|
+
execute: async ({ items }, context) => {
|
|
922
|
+
for (const [index, item] of items.entries()) {
|
|
923
|
+
await processItem(item)
|
|
924
|
+
await context.mcp.progress({
|
|
925
|
+
progress: index + 1,
|
|
926
|
+
total: items.length,
|
|
927
|
+
message: `Processed ${item.name}`,
|
|
928
|
+
})
|
|
929
|
+
}
|
|
930
|
+
return { done: true }
|
|
931
|
+
}
|
|
932
|
+
```
|
|
933
|
+
|
|
934
|
+
## Notification delivery
|
|
935
|
+
|
|
936
|
+
Notification methods (`resources.notifyListChanged()`, `prompts.notifyListChanged()`, `toolActions.notifyListChanged()`, and `sendLoggingMessage()`) broadcast to every connected client across all transports: the stdio/SSE connection and each streamable HTTP session. `resources.notifyUpdated()` is the exception: it only notifies clients that subscribed to the resource URI via `resources/subscribe`. Subscriptions are tracked per session for streamable HTTP clients; legacy SSE clients share the main server instance and therefore share one subscription set. Clients using the stateless serverless mode can't receive notifications because each request uses a transient server instance.
|
|
937
|
+
|
|
779
938
|
## Examples
|
|
780
939
|
|
|
781
940
|
For practical examples of setting up and deploying an MCPServer, see the [Publishing an MCP Server guide](https://mastra.ai/guides/guide/publishing-mcp-server).
|
|
@@ -1402,9 +1561,7 @@ const server = new MCPServer({
|
|
|
1402
1561
|
})
|
|
1403
1562
|
```
|
|
1404
1563
|
|
|
1405
|
-
Link a tool to its app resource by setting `_meta.ui.resourceUri` on the tool to the matching `ui://` URI. The server auto-normalizes this metadata when registering tools.
|
|
1406
|
-
|
|
1407
|
-
> **Note:** Visit [MCP Apps](https://mastra.ai/docs/mcp/mcp-apps) for the full app bridge API and usage patterns.
|
|
1564
|
+
Link a tool to its app resource by setting `_meta.ui.resourceUri` on the tool to the matching `ui://` URI. The server auto-normalizes this metadata when registering tools. Visit [MCP Apps](https://mastra.ai/docs/mcp/mcp-apps) for the full app bridge API and usage patterns.
|
|
1408
1565
|
|
|
1409
1566
|
## Related information
|
|
1410
1567
|
|