@mastra/mcp-docs-server 1.2.19-alpha.4 → 1.2.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/channels.md +28 -1
- package/.docs/docs/deployment/cloud-providers.md +1 -0
- package/.docs/docs/deployment/mastra-server.md +19 -0
- package/.docs/docs/deployment/overview.md +1 -0
- package/.docs/docs/deployment/workers.md +2 -2
- package/.docs/docs/harness/durable-agents.md +1 -1
- package/.docs/docs/mastra-platform/api.md +54 -0
- package/.docs/docs/mastra-platform/deploy.md +101 -0
- package/.docs/docs/mastra-platform/observability.md +3 -1
- package/.docs/docs/mastra-platform/server.md +6 -11
- package/.docs/docs/mastra-platform/studio.md +8 -10
- package/.docs/docs/memory/semantic-recall.md +19 -0
- package/.docs/docs/observability/feedback.md +14 -0
- package/.docs/docs/observability/integrations/exporters/mastra-storage.md +19 -14
- package/.docs/docs/observability/metrics/overview.md +31 -44
- package/.docs/docs/sandbox/overview.md +43 -0
- package/.docs/docs/server/middleware.md +30 -0
- package/.docs/docs/server/server-adapters.md +109 -34
- package/.docs/docs/storage.md +2 -0
- package/.docs/docs/subagents.md +6 -6
- package/.docs/integrations/channels/github.md +56 -9
- package/.docs/integrations/channels/imessage.md +150 -8
- package/.docs/integrations/databases/elasticsearch.md +156 -0
- package/.docs/integrations/databases/libsql.md +16 -0
- package/.docs/integrations/databases/mongodb.md +1 -1
- package/.docs/integrations/databases/postgresql.md +26 -0
- package/.docs/integrations/databases/valkey.md +99 -0
- package/.docs/integrations/deploy/kubernetes-helm.md +332 -0
- package/.docs/integrations/deploy/kubernetes.md +1 -1
- package/.docs/integrations/deploy/render.md +47 -61
- package/.docs/integrations/sandboxes/daytona.md +52 -0
- package/.docs/integrations/sandboxes/e2b-desktop.md +128 -0
- package/.docs/integrations/sandboxes/e2b.md +6 -0
- package/.docs/integrations/sandboxes/vercel.md +2 -2
- package/.docs/integrations/tools/parallel.md +240 -0
- package/.docs/integrations.md +5 -0
- package/.docs/models/environment-variables.md +9 -0
- package/.docs/models/gateways/netlify.md +12 -5
- package/.docs/models/gateways/openrouter.md +5 -10
- package/.docs/models/gateways/vercel.md +5 -5
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/agentrouter.md +17 -34
- package/.docs/models/providers/agnes.md +75 -0
- package/.docs/models/providers/aixy.md +73 -0
- package/.docs/models/providers/aki-io.md +14 -13
- package/.docs/models/providers/chutes.md +2 -2
- package/.docs/models/providers/cline-pass.md +4 -2
- package/.docs/models/providers/crof.md +3 -8
- package/.docs/models/providers/deepseek.md +4 -6
- package/.docs/models/providers/edenai.md +14 -14
- package/.docs/models/providers/evroc.md +3 -2
- package/.docs/models/providers/gmicloud.md +6 -4
- package/.docs/models/providers/huggingface.md +2 -1
- package/.docs/models/providers/hyper.md +5 -5
- package/.docs/models/providers/inceptron.md +2 -2
- package/.docs/models/providers/iteracompute.md +73 -0
- package/.docs/models/providers/kilo.md +26 -27
- package/.docs/models/providers/llmgateway-providers.md +18 -9
- package/.docs/models/providers/llmgateway.md +3 -5
- package/.docs/models/providers/llmtech.md +73 -0
- package/.docs/models/providers/nano-gpt.md +22 -13
- package/.docs/models/providers/neosmith.md +104 -0
- package/.docs/models/providers/nvidia.md +3 -1
- package/.docs/models/providers/ofox.md +2 -1
- package/.docs/models/providers/openai.md +2 -2
- package/.docs/models/providers/opencode-go.md +3 -2
- package/.docs/models/providers/opper.md +112 -0
- package/.docs/models/providers/pendra.md +78 -0
- package/.docs/models/providers/requesty.md +1 -1
- package/.docs/models/providers/standardcompute.md +73 -0
- package/.docs/models/providers/vivgrid.md +2 -1
- package/.docs/models/providers/wandb.md +2 -1
- package/.docs/models/providers/zai.md +2 -1
- package/.docs/models/providers.md +9 -0
- package/.docs/reference/agents/channels.md +1 -1
- package/.docs/reference/ai-sdk/handle-chat-stream.md +11 -0
- package/.docs/reference/ai-sdk/with-sse-heartbeat.md +47 -0
- package/.docs/reference/cli/mastra.md +10 -4
- package/.docs/reference/client-js/observability.md +1 -1
- package/.docs/reference/index.md +5 -0
- package/.docs/reference/observability/feedback.md +4 -0
- package/.docs/reference/observability/metrics/automatic-metrics.md +1 -1
- package/.docs/reference/observability/metrics/queries.md +462 -0
- package/.docs/reference/pubsub/valkey-streams.md +84 -0
- package/.docs/reference/rag/vector-databases.md +4 -4
- package/.docs/reference/server/elysia-adapter.md +184 -0
- package/.docs/reference/server/express-adapter.md +6 -8
- package/.docs/reference/server/hono-adapter.md +19 -6
- package/.docs/reference/storage/turso.md +88 -0
- package/.docs/reference/streaming/ChunkType.md +29 -1
- package/.docs/reference/streaming/agents/stream.md +1 -3
- package/.docs/reference/tools/mcp-client.md +41 -9
- package/.docs/reference/vectors/mongodb.md +11 -11
- package/.docs/reference/vectors/pg.md +2 -0
- package/.docs/reference/workspace/local-sandbox.md +2 -0
- package/.docs/reference/workspace/platform-sandbox.md +3 -1
- package/.docs/reference/workspace/sandbox.md +143 -3
- package/CHANGELOG.md +81 -0
- package/package.json +6 -6
- package/.docs/docs/observability/metrics/querying.md +0 -314
|
@@ -10,6 +10,8 @@ The `WorkspaceSandbox` interface defines how workspaces execute commands and man
|
|
|
10
10
|
|
|
11
11
|
**processes** (`SandboxProcessManager`): Background process manager. If not implemented, process management tools won't be available. See SandboxProcessManager reference.
|
|
12
12
|
|
|
13
|
+
**computer** (`SandboxComputer`): Computer-use (desktop) capability. If not implemented, computer tools won't be available. See Computer capability.
|
|
14
|
+
|
|
13
15
|
## Methods
|
|
14
16
|
|
|
15
17
|
### `start()`
|
|
@@ -17,10 +19,78 @@ The `WorkspaceSandbox` interface defines how workspaces execute commands and man
|
|
|
17
19
|
Starts the sandbox and is called automatically by `workspace.init()` or the first `executeCommand()` call.
|
|
18
20
|
|
|
19
21
|
```typescript
|
|
20
|
-
await sandbox.start()
|
|
22
|
+
const result = await sandbox.start()
|
|
23
|
+
// { outcome: 'created' } — a fresh VM was created
|
|
24
|
+
// { outcome: 'connected' } — reconnected to an existing VM
|
|
25
|
+
// undefined — the provider does not report
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Returns:** `void | Promise<SandboxStartResult | void>`
|
|
29
|
+
|
|
30
|
+
A sandbox constructed with a known `id` resolves that id on `start()`: reconnect or resume the sandbox if it exists, create it if not (get-or-create). Providers that support this report a `SandboxStartResult`:
|
|
31
|
+
|
|
32
|
+
**outcome** (`'created' | 'connected'`): 'created' when a brand-new sandbox VM (or working directory) was provisioned; 'connected' when the call reconnected to or resumed an existing one.
|
|
33
|
+
|
|
34
|
+
Providers that predate the contract return `void`, which the base class treats as unknown.
|
|
35
|
+
|
|
36
|
+
Provider implementations plug into the start lifecycle at one of three rungs; the best available wins, and the base class always owns coalescing, status management, the `onStart` hook, and mount processing:
|
|
37
|
+
|
|
38
|
+
1. **Acquisition primitives**: implement protected `find()` (side-effect-free lookup by logical id, returning a provider-native handle or `undefined`), `connect(handle)` (wake/resume/adopt), and `create()` (provision fresh) without overriding `start()`. The base orchestrates find → connect → `{ outcome: 'connected' }`, else create → `{ outcome: 'created' }`. The outcome is derived structurally from which branch ran. Used by `E2BSandbox`, `DaytonaSandbox`, and `LocalSandbox`.
|
|
39
|
+
2. **`start()` override returning `SandboxStartResult`**: for providers whose API is a fused get-or-create where decomposition would add round-trips (`PlatformSandbox`, `RailwaySandbox`).
|
|
40
|
+
3. **`start()` override returning `void`**: legacy providers, where the outcome is unknown.
|
|
41
|
+
|
|
42
|
+
Concurrent `start()` calls on one instance coalesce onto a single in-flight attempt, and joined callers share that attempt's result (all observe `outcome: 'created'` when the shared attempt created the VM). The in-flight slot is cleared when the attempt settles, so a failed start can be retried. While the sandbox is already `running`, `start()` resolves `{ outcome: 'connected' }` without re-invoking the provider.
|
|
43
|
+
|
|
44
|
+
The result is also forwarded to the `onStart` lifecycle hook as `{ sandbox, outcome }`.
|
|
45
|
+
|
|
46
|
+
### `onStart` (constructor option)
|
|
47
|
+
|
|
48
|
+
`onStart` runs inside the start lifecycle, after the sandbox reaches `running` status and before pending mounts are processed. It fires on every start regardless of trigger, whether an explicit call, a lazy `ensureRunning()` from a command, or a revival after the provider replaced the VM. That makes it the seam for once-per-VM setup: branch on `outcome` and probe or run whatever the environment needs.
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
new E2BSandbox({
|
|
52
|
+
id: sessionId,
|
|
53
|
+
onStart: async ({ sandbox, outcome }) => {
|
|
54
|
+
if (outcome === 'created') {
|
|
55
|
+
// Fresh VM: run the full setup.
|
|
56
|
+
await runSetup(sandbox)
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
// Reconnected: probe, and self-heal if setup never completed.
|
|
60
|
+
const probe = await sandbox.executeCommand('test -d ~/repo/.git')
|
|
61
|
+
if (probe.exitCode !== 0) await runSetup(sandbox)
|
|
62
|
+
},
|
|
63
|
+
})
|
|
21
64
|
```
|
|
22
65
|
|
|
23
|
-
|
|
66
|
+
Semantics:
|
|
67
|
+
|
|
68
|
+
- A thrown error is fatal: `start()` rejects with the hook's error and the sandbox is marked `error`, so a caller never observes a running sandbox whose setup hook failed. Nothing is latched, and the next `start()` (including the one triggered by the next lazy command) retries the hook. `onStop` and `onDestroy` remain non-fatal observers, because teardown proceeds best-effort.
|
|
69
|
+
- `outcome` distinguishes the branches: `'created'` means this start provisioned a fresh VM (run setup), `'connected'` means it reconnected or resumed (setup normally already ran, so probe when the hook must self-heal a crash between create and setup-complete). `undefined` means the provider doesn't report.
|
|
70
|
+
- Keep setup work idempotent. A hook re-runs whenever a probe decides it should, and a checkpoint-recovered fresh VM reports `outcome: 'created'`.
|
|
71
|
+
- The sandbox status flips to `running` before the hook executes (the hook runs commands through the sandbox's own command path), so commands issued concurrently through `ensureRunning()` can interleave with it. Callers awaiting the original `start()` always observe a sandbox whose hook finished.
|
|
72
|
+
- The hook runs before pending filesystem mounts are processed, so it can't rely on mounted paths.
|
|
73
|
+
|
|
74
|
+
### `setOnStart(update)`
|
|
75
|
+
|
|
76
|
+
Attaches a start hook after construction, for runtimes that receive a sandbox they didn't build. Without it, every host that constructs a sandbox has to accept a hook and pass it to the provider constructor, and a host that forgets leaves setup unrun with no error.
|
|
77
|
+
|
|
78
|
+
The updater receives the hook currently installed, either the `onStart` constructor option or one a previous call left behind, and returns the hook to install. Composing this way means a caller never discards a hook it didn't know about:
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
sandbox.setOnStart?.(previous => async args => {
|
|
82
|
+
await previous?.(args) // whatever prepared the sandbox runs first
|
|
83
|
+
await mySetup(args)
|
|
84
|
+
})
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Semantics:
|
|
88
|
+
|
|
89
|
+
- Errors stay fatal, exactly as with the constructor option. Because each hook awaits the next, a throw stops the ones sequenced after it.
|
|
90
|
+
- The caller chooses the order. Await `previous` first when your hook needs the workspace it prepares, or last when yours is the one preparing it.
|
|
91
|
+
- Ignoring `previous` replaces the installed hook. That's supported, and it's how a caller takes over setup a runtime installed.
|
|
92
|
+
- Each call wraps the current hook, so attach once per sandbox instance. Attaching on a path that runs per request stacks duplicate work on every start.
|
|
93
|
+
- Only starts that begin after the call see the new hook.
|
|
24
94
|
|
|
25
95
|
### `stop()`
|
|
26
96
|
|
|
@@ -69,12 +139,40 @@ const result = await sandbox.executeCommand('npm', ['install', 'lodash'])
|
|
|
69
139
|
|
|
70
140
|
**options.cwd** (`string`): Working directory for the command
|
|
71
141
|
|
|
72
|
-
**options.env** (`Record<string, string>`): Additional environment variables
|
|
142
|
+
**options.env** (`Record<string, string>`): Additional environment variables for this command. These take precedence over the sandbox environment for this command execution only.
|
|
73
143
|
|
|
74
144
|
**options.onStdout** (`(data: string) => void`): Callback for stdout streaming
|
|
75
145
|
|
|
76
146
|
**options.onStderr** (`(data: string) => void`): Callback for stderr streaming
|
|
77
147
|
|
|
148
|
+
### `setEnv(update)`
|
|
149
|
+
|
|
150
|
+
Update the sandbox's runtime environment. These values are merged into every command the sandbox runs, including `executeCommand()` and `processes.spawn()`, so credentials installed or rotated after the sandbox was created reach every subsequent command. Optional, so check for support or use optional chaining.
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
sandbox.setEnv?.(env => ({ ...env, GH_TOKEN: token }))
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
The updater receives a copy of the current environment and returns the replacement, so a single call can set, unset, or batch-update variables. Removing a key removes it from the sandbox's runtime environment only, so values the provider supplies on its own still apply. Seed the initial values with the `env` constructor option.
|
|
157
|
+
|
|
158
|
+
The runtime environment applies to commands executed through the sandbox rather than to the VM's own environment, so it's never written into the VM and survives provider pause and resume. When a command runs, provider defaults are applied first, the sandbox's runtime environment overrides them, and the per-call `env` option on `executeCommand()` wins over both.
|
|
159
|
+
|
|
160
|
+
**Parameters:**
|
|
161
|
+
|
|
162
|
+
**update** (`(env: Record<string, string | undefined>) => Record<string, string | undefined>`): Receives a copy of the sandbox's current runtime environment and returns the replacement.
|
|
163
|
+
|
|
164
|
+
**Returns:** `void`
|
|
165
|
+
|
|
166
|
+
### `getEnv()`
|
|
167
|
+
|
|
168
|
+
Returns a copy of the sandbox's current runtime environment. Mutating the returned object doesn't change the sandbox, so use `setEnv()` for updates.
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
const token = sandbox.getEnv().GH_TOKEN
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Returns:** `Record<string, string | undefined>`
|
|
175
|
+
|
|
78
176
|
### `getInfo()`
|
|
79
177
|
|
|
80
178
|
Get sandbox status and resource information.
|
|
@@ -99,6 +197,48 @@ const instructions = sandbox.getInstructions?.()
|
|
|
99
197
|
|
|
100
198
|
**Returns:** `string`
|
|
101
199
|
|
|
200
|
+
## Computer capability
|
|
201
|
+
|
|
202
|
+
Sandboxes with a controllable desktop environment implement the optional `SandboxComputer` interface on the `computer` property. When present on a statically configured sandbox, the workspace tools factory registers the `mastra_workspace_computer_*` tools automatically. See [Computer-use tools](https://mastra.ai/docs/sandbox/overview).
|
|
203
|
+
|
|
204
|
+
Coordinates are pixels from the top-left corner of the display. Providers normalize their SDK semantics (key names, scroll units) onto this surface and expose richer native APIs through their own accessors.
|
|
205
|
+
|
|
206
|
+
**screenshot()** (`() => Promise<{ data: Uint8Array; mediaType: "image/png" }>`): Capture the current display as a PNG image.
|
|
207
|
+
|
|
208
|
+
**leftClick(x, y)** (`(x: number, y: number) => Promise<void>`): Left-click at the given coordinates.
|
|
209
|
+
|
|
210
|
+
**rightClick(x, y)** (`(x: number, y: number) => Promise<void>`): Right-click at the given coordinates.
|
|
211
|
+
|
|
212
|
+
**doubleClick(x, y)** (`(x: number, y: number) => Promise<void>`): Double-click (left button) at the given coordinates.
|
|
213
|
+
|
|
214
|
+
**moveMouse(x, y)** (`(x: number, y: number) => Promise<void>`): Move the cursor without clicking.
|
|
215
|
+
|
|
216
|
+
**drag(from, to)** (`(from: ComputerPosition, to: ComputerPosition) => Promise<void>`): Press the left button at from, drag to to, and release.
|
|
217
|
+
|
|
218
|
+
**scroll(direction, amount)** (`(direction: 'up' | 'down', amount: number) => Promise<void>`): Scroll the display by the given amount of ticks.
|
|
219
|
+
|
|
220
|
+
**type(text)** (`(text: string) => Promise<void>`): Type text into the focused element.
|
|
221
|
+
|
|
222
|
+
**press(key)** (`(key: string | string[]) => Promise<void>`): Press a key or key combination. A string presses one key (for example 'Enter'); an array presses a chord (for example \['ctrl', 's']).
|
|
223
|
+
|
|
224
|
+
**getScreenSize()** (`() => Promise<{ width: number; height: number }>`): Get the display dimensions.
|
|
225
|
+
|
|
226
|
+
**getCursorPosition()** (`() => Promise<{ x: number; y: number }>`): Get the current cursor position.
|
|
227
|
+
|
|
228
|
+
**streamUrl()** (`() => Promise<string | null>`): Get a URL for a live view of the desktop, such as noVNC, or null when unavailable. Optional, not all providers expose a viewer.
|
|
229
|
+
|
|
230
|
+
Use the `supportsComputer()` type guard to check for the capability:
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
import { supportsComputer } from '@mastra/core/workspace'
|
|
234
|
+
|
|
235
|
+
if (supportsComputer(sandbox)) {
|
|
236
|
+
const { data } = await sandbox.computer.screenshot()
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
`DaytonaSandbox` and `E2BDesktopSandbox` implement this capability. See the [Daytona](https://mastra.ai/integrations/sandboxes/daytona) and [E2B Desktop](https://mastra.ai/integrations/sandboxes/e2b-desktop) integration pages.
|
|
241
|
+
|
|
102
242
|
## Related
|
|
103
243
|
|
|
104
244
|
- [SandboxProcessManager reference](https://mastra.ai/reference/workspace/process-manager)
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,86 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.2.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`79f04a7`](https://github.com/mastra-ai/mastra/commit/79f04a7f6c6829da541139f638f2f1d267916e08), [`65edab1`](https://github.com/mastra-ai/mastra/commit/65edab1c233d17b8f163bad12fca410d0e6f16b1), [`1e47b75`](https://github.com/mastra-ai/mastra/commit/1e47b7520cab4cfaa8daed52f17e2e6d14ff7539), [`ab20a38`](https://github.com/mastra-ai/mastra/commit/ab20a38d0275f8d85e0f3833bd87ef487bcc609f), [`fd4d5fe`](https://github.com/mastra-ai/mastra/commit/fd4d5fe4f943699b85db5e74404f190d5a6b8c2a), [`ae8790c`](https://github.com/mastra-ai/mastra/commit/ae8790c4bfaa088d2ab279d1dcc06f326b9fd109), [`2c85f42`](https://github.com/mastra-ai/mastra/commit/2c85f428e04ccd63ea31a7ec80b5b327afdad555), [`11bbeb9`](https://github.com/mastra-ai/mastra/commit/11bbeb9b108ef2264e05acefc6dafb9cbb342921), [`48ef1f1`](https://github.com/mastra-ai/mastra/commit/48ef1f1d24eedafbb07f64e659a81b52b67b8bf6), [`aa3a85d`](https://github.com/mastra-ai/mastra/commit/aa3a85daf094c683bb97efdf4b6a696d2e474af5), [`d29d06f`](https://github.com/mastra-ai/mastra/commit/d29d06fe00bbd35b4571150ea04c59d2ed783c71), [`dfb7efa`](https://github.com/mastra-ai/mastra/commit/dfb7efa19e348b5a788be2d954362cbae12379d6), [`e6516df`](https://github.com/mastra-ai/mastra/commit/e6516dfcdae4f4ac0e7971d84359a81385ee602f), [`1a485f3`](https://github.com/mastra-ai/mastra/commit/1a485f3538f5ec64d58bd8b5e1e99de0c695c87b), [`0d37487`](https://github.com/mastra-ai/mastra/commit/0d37487d9f349388a3f1cef6a536cf9dcc4b6273), [`8661d7d`](https://github.com/mastra-ai/mastra/commit/8661d7d7179f0a024456aabdd8679bcecd09ac28), [`dbbfeb8`](https://github.com/mastra-ai/mastra/commit/dbbfeb85ec949dc9ebc0755e1ad262e4f5eba8db), [`575e343`](https://github.com/mastra-ai/mastra/commit/575e343900451021d96110916497d334af7bc252), [`0b2a3d1`](https://github.com/mastra-ai/mastra/commit/0b2a3d1783875c5b97b7b36ab3d03d7360e0dde7), [`6bb5d71`](https://github.com/mastra-ai/mastra/commit/6bb5d7193fe9166b219f0fccae17db7a5ae86e65), [`3cc9d00`](https://github.com/mastra-ai/mastra/commit/3cc9d00b2b4333e0377a5e9df5eff92c17ce7630), [`cacb839`](https://github.com/mastra-ai/mastra/commit/cacb8392d9e74189b56d857290b0615f98a2683d), [`57de7d6`](https://github.com/mastra-ai/mastra/commit/57de7d644ba7146edb4e9e6111ec4fa98c3a59e9), [`c8e4cea`](https://github.com/mastra-ai/mastra/commit/c8e4ceac9a390d78c8327dff3cdb2861dd71957f), [`ed01e9a`](https://github.com/mastra-ai/mastra/commit/ed01e9a807514a904374bf687a7b8f18750f6f78), [`b47b26e`](https://github.com/mastra-ai/mastra/commit/b47b26e6fe95cb8a3482be2c5e52de157fe59d0b), [`0d37487`](https://github.com/mastra-ai/mastra/commit/0d37487d9f349388a3f1cef6a536cf9dcc4b6273), [`733a537`](https://github.com/mastra-ai/mastra/commit/733a537489a858b5880b2e98809334fba895a221), [`e8e299c`](https://github.com/mastra-ai/mastra/commit/e8e299cc6abdfc39947e2fec25803493015d3882), [`edfc548`](https://github.com/mastra-ai/mastra/commit/edfc548886bc7bae17b681f8b6b41a47eb32bcd2), [`b05f486`](https://github.com/mastra-ai/mastra/commit/b05f48612984d5fe2447ea2d6cdd5c604d285b97), [`a8a4871`](https://github.com/mastra-ai/mastra/commit/a8a4871215f51da95c47129602157ce5372f634a), [`eb9ecaa`](https://github.com/mastra-ai/mastra/commit/eb9ecaa89c36e889749e3b825cfc507ce7f7980b), [`4ff3ee2`](https://github.com/mastra-ai/mastra/commit/4ff3ee2bff7ed07528b4817f8f49639031c72a4d), [`9207dfa`](https://github.com/mastra-ai/mastra/commit/9207dfab8062e5fc68b751684797ff86fe0b4e70), [`5165cdc`](https://github.com/mastra-ai/mastra/commit/5165cdcdcf50e144bb8113278535196cc9b07065), [`e737014`](https://github.com/mastra-ai/mastra/commit/e737014e0fc7035759762bb5b48baef1d6c0f6a7), [`6bb5d71`](https://github.com/mastra-ai/mastra/commit/6bb5d7193fe9166b219f0fccae17db7a5ae86e65), [`f591643`](https://github.com/mastra-ai/mastra/commit/f591643becdf0be9bddce6ba1748e64bc30d77f1), [`63796ba`](https://github.com/mastra-ai/mastra/commit/63796ba0fda60253be17535e68f6bbbf1e6ffa09), [`b1ad324`](https://github.com/mastra-ai/mastra/commit/b1ad324d657f3544b0701332aef7eb10e9a36258), [`61c566d`](https://github.com/mastra-ai/mastra/commit/61c566dd2f2cde2b23ed8f139924e530d4202214), [`c24754c`](https://github.com/mastra-ai/mastra/commit/c24754c1fb6fe144e5051e536e98c8a18b0214ac), [`12c61d2`](https://github.com/mastra-ai/mastra/commit/12c61d280c8cb208bc3c8dbcbe5dcc60cf9d1cd0), [`c46eb09`](https://github.com/mastra-ai/mastra/commit/c46eb09ce4987509af57a0ac582c61241a6dd2f1), [`9ee8120`](https://github.com/mastra-ai/mastra/commit/9ee8120ce17f76b9f617489e05a283353742690a), [`d975e92`](https://github.com/mastra-ai/mastra/commit/d975e924d4936f46c386bd3dee39c671720289f6), [`45dd6ee`](https://github.com/mastra-ai/mastra/commit/45dd6ee089bd7df0d0c98a10098e483fd388e04a), [`4e9a228`](https://github.com/mastra-ai/mastra/commit/4e9a2283d5fd6ed1b70a2751eb3dc2cbf82ada20), [`d6ce34a`](https://github.com/mastra-ai/mastra/commit/d6ce34aeceb06ddf3d595a1eed5cc74f481a46a1), [`f95f468`](https://github.com/mastra-ai/mastra/commit/f95f468cf1e7c2b924a13826494f98b8f2ccd581), [`30ed33e`](https://github.com/mastra-ai/mastra/commit/30ed33ee14084a26019aba15fceadda6d6ddefaf), [`04a815f`](https://github.com/mastra-ai/mastra/commit/04a815fc8971d29e97fcdcc5008a1eb472fc00ff), [`1cfa878`](https://github.com/mastra-ai/mastra/commit/1cfa8784d8da0dfaa0317e5048bc48b6084a5ea5), [`997cf5b`](https://github.com/mastra-ai/mastra/commit/997cf5bb3fc600b30aa20e048b663e48e0e1305a), [`9a12ef3`](https://github.com/mastra-ai/mastra/commit/9a12ef3fccf3f4186db0f294f4ee1f02cf4d8db2), [`32d3583`](https://github.com/mastra-ai/mastra/commit/32d358332cb8ac2306b83b73cf3536e74dbd435e), [`7960688`](https://github.com/mastra-ai/mastra/commit/7960688828e04eaf3106e34f7758fa580257eef6), [`91ad69d`](https://github.com/mastra-ai/mastra/commit/91ad69d64994c89199b0c55399e64ed91c61df2f), [`c4e2364`](https://github.com/mastra-ai/mastra/commit/c4e2364742bc37beebfa995db2d42efce6cfc7b8), [`8dc408d`](https://github.com/mastra-ai/mastra/commit/8dc408d34438f9e13297f792c11a5cfd6cf952e1), [`c92def1`](https://github.com/mastra-ai/mastra/commit/c92def10a13c822972c96f0a4ca6ffc1f4258aed), [`63041eb`](https://github.com/mastra-ai/mastra/commit/63041eb4c50b520a0a80e03d4cd6ea99f67715a0), [`c118318`](https://github.com/mastra-ai/mastra/commit/c1183181c9804303db4b511c2e2648f8b714712b), [`c5eaec5`](https://github.com/mastra-ai/mastra/commit/c5eaec5a860d80d0e3805e67db0414b87ac8cbed), [`fc07c64`](https://github.com/mastra-ai/mastra/commit/fc07c6465043e08e99193a6751a01c56ffc2e7a1), [`cced745`](https://github.com/mastra-ai/mastra/commit/cced745a056ec2225c5bc702e32d848847aa8b65), [`542dee2`](https://github.com/mastra-ai/mastra/commit/542dee254167f974ff8cbbbfc0ce10f9a2616a7b), [`3c19dce`](https://github.com/mastra-ai/mastra/commit/3c19dcef8e73062a80627a4927eae3ec11145afd), [`aca2869`](https://github.com/mastra-ai/mastra/commit/aca2869b2031982f3c4a2f52525c9be7cf123ef8), [`a58483c`](https://github.com/mastra-ai/mastra/commit/a58483cff1a9d41fce7c931843f48cb0ac450f64), [`a58483c`](https://github.com/mastra-ai/mastra/commit/a58483cff1a9d41fce7c931843f48cb0ac450f64), [`e6f8450`](https://github.com/mastra-ai/mastra/commit/e6f845074d478527026b18d85031b23353e1d0a4), [`895e9df`](https://github.com/mastra-ai/mastra/commit/895e9dfc17d6f34299eca64e317ded9e5f5e5ef8), [`e66b2ba`](https://github.com/mastra-ai/mastra/commit/e66b2ba100db63eaeab6e21e1ea34b113f2ec781), [`3e8727e`](https://github.com/mastra-ai/mastra/commit/3e8727e11ec1a5d733acedb5c872896394be18c1)]:
|
|
8
|
+
- @mastra/core@1.62.0
|
|
9
|
+
- @mastra/mcp@1.17.2
|
|
10
|
+
|
|
11
|
+
## 1.2.19-alpha.19
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`48ef1f1`](https://github.com/mastra-ai/mastra/commit/48ef1f1d24eedafbb07f64e659a81b52b67b8bf6), [`63796ba`](https://github.com/mastra-ai/mastra/commit/63796ba0fda60253be17535e68f6bbbf1e6ffa09), [`3c19dce`](https://github.com/mastra-ai/mastra/commit/3c19dcef8e73062a80627a4927eae3ec11145afd)]:
|
|
16
|
+
- @mastra/core@1.62.0-alpha.12
|
|
17
|
+
|
|
18
|
+
## 1.2.19-alpha.18
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [[`4ff3ee2`](https://github.com/mastra-ai/mastra/commit/4ff3ee2bff7ed07528b4817f8f49639031c72a4d), [`c24754c`](https://github.com/mastra-ai/mastra/commit/c24754c1fb6fe144e5051e536e98c8a18b0214ac), [`45dd6ee`](https://github.com/mastra-ai/mastra/commit/45dd6ee089bd7df0d0c98a10098e483fd388e04a), [`32d3583`](https://github.com/mastra-ai/mastra/commit/32d358332cb8ac2306b83b73cf3536e74dbd435e), [`aca2869`](https://github.com/mastra-ai/mastra/commit/aca2869b2031982f3c4a2f52525c9be7cf123ef8)]:
|
|
23
|
+
- @mastra/core@1.62.0-alpha.11
|
|
24
|
+
|
|
25
|
+
## 1.2.19-alpha.16
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [[`b05f486`](https://github.com/mastra-ai/mastra/commit/b05f48612984d5fe2447ea2d6cdd5c604d285b97), [`7960688`](https://github.com/mastra-ai/mastra/commit/7960688828e04eaf3106e34f7758fa580257eef6)]:
|
|
30
|
+
- @mastra/core@1.62.0-alpha.10
|
|
31
|
+
|
|
32
|
+
## 1.2.19-alpha.15
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [[`eb9ecaa`](https://github.com/mastra-ai/mastra/commit/eb9ecaa89c36e889749e3b825cfc507ce7f7980b), [`3e8727e`](https://github.com/mastra-ai/mastra/commit/3e8727e11ec1a5d733acedb5c872896394be18c1)]:
|
|
37
|
+
- @mastra/core@1.62.0-alpha.9
|
|
38
|
+
|
|
39
|
+
## 1.2.19-alpha.14
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Updated dependencies [[`aa3a85d`](https://github.com/mastra-ai/mastra/commit/aa3a85daf094c683bb97efdf4b6a696d2e474af5), [`d29d06f`](https://github.com/mastra-ai/mastra/commit/d29d06fe00bbd35b4571150ea04c59d2ed783c71), [`e6516df`](https://github.com/mastra-ai/mastra/commit/e6516dfcdae4f4ac0e7971d84359a81385ee602f), [`0b2a3d1`](https://github.com/mastra-ai/mastra/commit/0b2a3d1783875c5b97b7b36ab3d03d7360e0dde7), [`6bb5d71`](https://github.com/mastra-ai/mastra/commit/6bb5d7193fe9166b219f0fccae17db7a5ae86e65), [`57de7d6`](https://github.com/mastra-ai/mastra/commit/57de7d644ba7146edb4e9e6111ec4fa98c3a59e9), [`e8e299c`](https://github.com/mastra-ai/mastra/commit/e8e299cc6abdfc39947e2fec25803493015d3882), [`edfc548`](https://github.com/mastra-ai/mastra/commit/edfc548886bc7bae17b681f8b6b41a47eb32bcd2), [`a8a4871`](https://github.com/mastra-ai/mastra/commit/a8a4871215f51da95c47129602157ce5372f634a), [`5165cdc`](https://github.com/mastra-ai/mastra/commit/5165cdcdcf50e144bb8113278535196cc9b07065), [`6bb5d71`](https://github.com/mastra-ai/mastra/commit/6bb5d7193fe9166b219f0fccae17db7a5ae86e65), [`9ee8120`](https://github.com/mastra-ai/mastra/commit/9ee8120ce17f76b9f617489e05a283353742690a), [`d975e92`](https://github.com/mastra-ai/mastra/commit/d975e924d4936f46c386bd3dee39c671720289f6), [`1cfa878`](https://github.com/mastra-ai/mastra/commit/1cfa8784d8da0dfaa0317e5048bc48b6084a5ea5), [`c118318`](https://github.com/mastra-ai/mastra/commit/c1183181c9804303db4b511c2e2648f8b714712b), [`fc07c64`](https://github.com/mastra-ai/mastra/commit/fc07c6465043e08e99193a6751a01c56ffc2e7a1), [`542dee2`](https://github.com/mastra-ai/mastra/commit/542dee254167f974ff8cbbbfc0ce10f9a2616a7b), [`a58483c`](https://github.com/mastra-ai/mastra/commit/a58483cff1a9d41fce7c931843f48cb0ac450f64), [`a58483c`](https://github.com/mastra-ai/mastra/commit/a58483cff1a9d41fce7c931843f48cb0ac450f64), [`895e9df`](https://github.com/mastra-ai/mastra/commit/895e9dfc17d6f34299eca64e317ded9e5f5e5ef8)]:
|
|
44
|
+
- @mastra/core@1.62.0-alpha.8
|
|
45
|
+
|
|
46
|
+
## 1.2.19-alpha.13
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- Updated dependencies [[`ae8790c`](https://github.com/mastra-ai/mastra/commit/ae8790c4bfaa088d2ab279d1dcc06f326b9fd109), [`dfb7efa`](https://github.com/mastra-ai/mastra/commit/dfb7efa19e348b5a788be2d954362cbae12379d6), [`04a815f`](https://github.com/mastra-ai/mastra/commit/04a815fc8971d29e97fcdcc5008a1eb472fc00ff), [`cced745`](https://github.com/mastra-ai/mastra/commit/cced745a056ec2225c5bc702e32d848847aa8b65)]:
|
|
51
|
+
- @mastra/core@1.62.0-alpha.7
|
|
52
|
+
- @mastra/mcp@1.17.2-alpha.2
|
|
53
|
+
|
|
54
|
+
## 1.2.19-alpha.11
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- Updated dependencies [[`c8e4cea`](https://github.com/mastra-ai/mastra/commit/c8e4ceac9a390d78c8327dff3cdb2861dd71957f), [`ed01e9a`](https://github.com/mastra-ai/mastra/commit/ed01e9a807514a904374bf687a7b8f18750f6f78), [`4e9a228`](https://github.com/mastra-ai/mastra/commit/4e9a2283d5fd6ed1b70a2751eb3dc2cbf82ada20), [`997cf5b`](https://github.com/mastra-ai/mastra/commit/997cf5bb3fc600b30aa20e048b663e48e0e1305a), [`63041eb`](https://github.com/mastra-ai/mastra/commit/63041eb4c50b520a0a80e03d4cd6ea99f67715a0)]:
|
|
59
|
+
- @mastra/core@1.62.0-alpha.6
|
|
60
|
+
- @mastra/mcp@1.17.2-alpha.1
|
|
61
|
+
|
|
62
|
+
## 1.2.19-alpha.9
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- Updated dependencies [[`65edab1`](https://github.com/mastra-ai/mastra/commit/65edab1c233d17b8f163bad12fca410d0e6f16b1), [`ab20a38`](https://github.com/mastra-ai/mastra/commit/ab20a38d0275f8d85e0f3833bd87ef487bcc609f), [`dbbfeb8`](https://github.com/mastra-ai/mastra/commit/dbbfeb85ec949dc9ebc0755e1ad262e4f5eba8db), [`3cc9d00`](https://github.com/mastra-ai/mastra/commit/3cc9d00b2b4333e0377a5e9df5eff92c17ce7630), [`733a537`](https://github.com/mastra-ai/mastra/commit/733a537489a858b5880b2e98809334fba895a221), [`9207dfa`](https://github.com/mastra-ai/mastra/commit/9207dfab8062e5fc68b751684797ff86fe0b4e70), [`12c61d2`](https://github.com/mastra-ai/mastra/commit/12c61d280c8cb208bc3c8dbcbe5dcc60cf9d1cd0), [`9a12ef3`](https://github.com/mastra-ai/mastra/commit/9a12ef3fccf3f4186db0f294f4ee1f02cf4d8db2)]:
|
|
67
|
+
- @mastra/core@1.62.0-alpha.5
|
|
68
|
+
|
|
69
|
+
## 1.2.19-alpha.7
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- Updated dependencies [[`79f04a7`](https://github.com/mastra-ai/mastra/commit/79f04a7f6c6829da541139f638f2f1d267916e08), [`fd4d5fe`](https://github.com/mastra-ai/mastra/commit/fd4d5fe4f943699b85db5e74404f190d5a6b8c2a), [`f591643`](https://github.com/mastra-ai/mastra/commit/f591643becdf0be9bddce6ba1748e64bc30d77f1), [`b1ad324`](https://github.com/mastra-ai/mastra/commit/b1ad324d657f3544b0701332aef7eb10e9a36258), [`61c566d`](https://github.com/mastra-ai/mastra/commit/61c566dd2f2cde2b23ed8f139924e530d4202214)]:
|
|
74
|
+
- @mastra/core@1.62.0-alpha.4
|
|
75
|
+
|
|
76
|
+
## 1.2.19-alpha.5
|
|
77
|
+
|
|
78
|
+
### Patch Changes
|
|
79
|
+
|
|
80
|
+
- Updated dependencies [[`2c85f42`](https://github.com/mastra-ai/mastra/commit/2c85f428e04ccd63ea31a7ec80b5b327afdad555), [`11bbeb9`](https://github.com/mastra-ai/mastra/commit/11bbeb9b108ef2264e05acefc6dafb9cbb342921), [`1a485f3`](https://github.com/mastra-ai/mastra/commit/1a485f3538f5ec64d58bd8b5e1e99de0c695c87b), [`0d37487`](https://github.com/mastra-ai/mastra/commit/0d37487d9f349388a3f1cef6a536cf9dcc4b6273), [`8661d7d`](https://github.com/mastra-ai/mastra/commit/8661d7d7179f0a024456aabdd8679bcecd09ac28), [`575e343`](https://github.com/mastra-ai/mastra/commit/575e343900451021d96110916497d334af7bc252), [`cacb839`](https://github.com/mastra-ai/mastra/commit/cacb8392d9e74189b56d857290b0615f98a2683d), [`b47b26e`](https://github.com/mastra-ai/mastra/commit/b47b26e6fe95cb8a3482be2c5e52de157fe59d0b), [`0d37487`](https://github.com/mastra-ai/mastra/commit/0d37487d9f349388a3f1cef6a536cf9dcc4b6273), [`c46eb09`](https://github.com/mastra-ai/mastra/commit/c46eb09ce4987509af57a0ac582c61241a6dd2f1), [`30ed33e`](https://github.com/mastra-ai/mastra/commit/30ed33ee14084a26019aba15fceadda6d6ddefaf), [`91ad69d`](https://github.com/mastra-ai/mastra/commit/91ad69d64994c89199b0c55399e64ed91c61df2f), [`c4e2364`](https://github.com/mastra-ai/mastra/commit/c4e2364742bc37beebfa995db2d42efce6cfc7b8), [`8dc408d`](https://github.com/mastra-ai/mastra/commit/8dc408d34438f9e13297f792c11a5cfd6cf952e1), [`c92def1`](https://github.com/mastra-ai/mastra/commit/c92def10a13c822972c96f0a4ca6ffc1f4258aed), [`c5eaec5`](https://github.com/mastra-ai/mastra/commit/c5eaec5a860d80d0e3805e67db0414b87ac8cbed), [`e66b2ba`](https://github.com/mastra-ai/mastra/commit/e66b2ba100db63eaeab6e21e1ea34b113f2ec781)]:
|
|
81
|
+
- @mastra/core@1.62.0-alpha.3
|
|
82
|
+
- @mastra/mcp@1.17.2-alpha.0
|
|
83
|
+
|
|
3
84
|
## 1.2.19-alpha.4
|
|
4
85
|
|
|
5
86
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.2.19
|
|
3
|
+
"version": "1.2.19",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"jsdom": "^26.1.0",
|
|
29
29
|
"local-pkg": "^1.1.2",
|
|
30
30
|
"zod": "^4.4.3",
|
|
31
|
-
"@mastra/core": "1.62.0
|
|
32
|
-
"@mastra/mcp": "^1.17.
|
|
31
|
+
"@mastra/core": "1.62.0",
|
|
32
|
+
"@mastra/mcp": "^1.17.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@hono/node-server": "^2.0.0",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"tsx": "^4.23.1",
|
|
46
46
|
"typescript": "^6.0.3",
|
|
47
47
|
"vitest": "4.1.10",
|
|
48
|
-
"@internal/lint": "0.0.
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
48
|
+
"@internal/lint": "0.0.126",
|
|
49
|
+
"@mastra/core": "1.62.0",
|
|
50
|
+
"@internal/types-builder": "0.0.101"
|
|
51
51
|
},
|
|
52
52
|
"homepage": "https://mastra.ai",
|
|
53
53
|
"repository": {
|
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
-
|
|
3
|
-
# Querying metrics
|
|
4
|
-
|
|
5
|
-
Mastra exposes the same five OLAP queries (`getMetricAggregate`, `getMetricBreakdown`, `getMetricTimeSeries`, `getMetricPercentiles`, and discovery helpers) through three surfaces: an in-process store accessor and the runtime HTTP API, plus the `mastra api metric` CLI. All three accept the same Zod-validated input shapes, so you can move from a one-off CLI investigation to a programmatic dashboard tool without re-learning the API.
|
|
6
|
-
|
|
7
|
-
**For AI agents:** Run `npx mastra api metric aggregate '{"name":"mastra_agent_duration_ms","aggregation":"avg"}'` to query average agent latency directly instead of writing a temporary script. Querying local metrics requires a running Mastra server with an OLAP-capable observability store; start the local server with `npx mastra dev`, or pass the reachable server's base URL with `--url`. Run `npx mastra api metric aggregate --schema` before constructing a different query. Install Mastra's skill with `npx skills add mastra-ai/skills --skill mastra` for complete API CLI discovery, targeting, schema, authentication, and error-handling guidance.
|
|
8
|
-
|
|
9
|
-
## When to use this
|
|
10
|
-
|
|
11
|
-
- Build a custom dashboard or KPI tile alongside Studio.
|
|
12
|
-
- Power a scheduled alert that fires when token cost or latency crosses a threshold.
|
|
13
|
-
- Give an agent a tool that reads its own performance metrics and explains them in chat.
|
|
14
|
-
- Run one-off investigations from a terminal with `mastra api metric ...`.
|
|
15
|
-
|
|
16
|
-
For setup of the observability store itself, see the [Metrics overview](https://mastra.ai/docs/observability/metrics/overview). For the list of metric names you can query, see the [Automatic metrics reference](https://mastra.ai/reference/observability/metrics/automatic-metrics).
|
|
17
|
-
|
|
18
|
-
> **Note:** Metric queries are served by the observability domain, which requires an OLAP-capable store (DuckDB locally, ClickHouse in production). See [Metrics overview](https://mastra.ai/docs/observability/metrics/overview) for setup. If the observability store isn't configured, `getStore('observability')` returns `null`.
|
|
19
|
-
|
|
20
|
-
## Surfaces
|
|
21
|
-
|
|
22
|
-
### In-process
|
|
23
|
-
|
|
24
|
-
Inside a tool, server route, or workflow step, get the observability store from the Mastra storage:
|
|
25
|
-
|
|
26
|
-
```typescript
|
|
27
|
-
import { createTool } from '@mastra/core/tools'
|
|
28
|
-
import { z } from 'zod'
|
|
29
|
-
|
|
30
|
-
export const agentLatencyTool = createTool({
|
|
31
|
-
id: 'agentLatency',
|
|
32
|
-
description: 'Average agent latency over the last hour.',
|
|
33
|
-
inputSchema: z.object({}),
|
|
34
|
-
execute: async (_input, context) => {
|
|
35
|
-
const observability = await context.mastra!.getStorage()!.getStore('observability')
|
|
36
|
-
if (!observability) {
|
|
37
|
-
throw new Error('Observability domain is not configured (requires DuckDB or ClickHouse)')
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const result = await observability.getMetricAggregate({
|
|
41
|
-
name: ['mastra_agent_duration_ms'],
|
|
42
|
-
aggregation: 'avg',
|
|
43
|
-
filters: {
|
|
44
|
-
timestamp: { start: new Date(Date.now() - 60 * 60 * 1000) },
|
|
45
|
-
},
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
return { averageMs: result.value }
|
|
49
|
-
},
|
|
50
|
-
})
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
`getStore('observability')` returns `null` when the configured backend doesn't support OLAP queries.
|
|
54
|
-
|
|
55
|
-
### HTTP
|
|
56
|
-
|
|
57
|
-
The `mastra dev` server (and any deployed Mastra runtime) exposes the same queries under `/api/observability/metrics/*`. Aggregate, breakdown, time series, and percentile endpoints take a JSON body with `POST`. Discovery endpoints use `GET` with query parameters.
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
curl -sS -X POST http://localhost:4111/api/observability/metrics/aggregate \
|
|
61
|
-
-H "content-type: application/json" \
|
|
62
|
-
-d '{"name":["mastra_agent_duration_ms"],"aggregation":"avg"}'
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
Available routes:
|
|
66
|
-
|
|
67
|
-
- `POST /api/observability/metrics/aggregate`
|
|
68
|
-
- `POST /api/observability/metrics/breakdown`
|
|
69
|
-
- `POST /api/observability/metrics/timeseries`
|
|
70
|
-
- `POST /api/observability/metrics/percentiles`
|
|
71
|
-
- `GET /api/observability/metrics` (raw rows, paginated)
|
|
72
|
-
- `GET /api/observability/discovery/metric-names`
|
|
73
|
-
- `GET /api/observability/discovery/metric-label-keys`
|
|
74
|
-
- `GET /api/observability/discovery/metric-label-values`
|
|
75
|
-
|
|
76
|
-
The `@mastra/client-js` SDK wraps the same routes as `mastraClient.getMetricAggregate(...)`, `getMetricBreakdown(...)`, and so on.
|
|
77
|
-
|
|
78
|
-
### CLI
|
|
79
|
-
|
|
80
|
-
`mastra api metric ...` calls the same endpoints with a single JSON argument, so an agent or shell script can fetch metrics without writing any code:
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
|
-
mastra api metric aggregate \
|
|
84
|
-
'{"name":["mastra_agent_duration_ms"],"aggregation":"avg"}' \
|
|
85
|
-
--url http://localhost:4111
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
By default the CLI targets hosted Mastra observability (`https://observability.mastra.ai`). Pass `--url http://localhost:4111` to query a local `mastra dev` server. See [`mastra api metric aggregate`](https://mastra.ai/reference/cli/mastra) and the surrounding entries for the full command list.
|
|
89
|
-
|
|
90
|
-
## Queries
|
|
91
|
-
|
|
92
|
-
### `getMetricAggregate`
|
|
93
|
-
|
|
94
|
-
Returns a single scalar, the building block for KPI cards.
|
|
95
|
-
|
|
96
|
-
Inputs:
|
|
97
|
-
|
|
98
|
-
- `name`: Array of one or more metric names.
|
|
99
|
-
- `aggregation`: One of `'sum' | 'avg' | 'min' | 'max' | 'count' | 'count_distinct' | 'last'`.
|
|
100
|
-
- `filters`: Optional [filter object](#filtering).
|
|
101
|
-
- `comparePeriod`: Optional `'previous_period' | 'previous_day' | 'previous_week'` for period-over-period comparison.
|
|
102
|
-
|
|
103
|
-
Response:
|
|
104
|
-
|
|
105
|
-
- `value`, `previousValue`, `changePercent`.
|
|
106
|
-
- `estimatedCost`, `costUnit`, `previousEstimatedCost`, `costChangePercent` for token metrics.
|
|
107
|
-
|
|
108
|
-
```typescript
|
|
109
|
-
const observability = await mastra.getStorage()!.getStore('observability')
|
|
110
|
-
|
|
111
|
-
const cost = await observability!.getMetricAggregate({
|
|
112
|
-
name: ['mastra_model_total_input_tokens', 'mastra_model_total_output_tokens'],
|
|
113
|
-
aggregation: 'sum',
|
|
114
|
-
comparePeriod: 'previous_day',
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
console.log(cost.value, cost.estimatedCost, cost.costUnit, cost.changePercent)
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
### `getMetricBreakdown`
|
|
121
|
-
|
|
122
|
-
Groups rows by one or more dimensions and aggregates each group, the building block for top-N tables (e.g. "tokens by agent").
|
|
123
|
-
|
|
124
|
-
Inputs:
|
|
125
|
-
|
|
126
|
-
- `name`: Array of metric names.
|
|
127
|
-
- `groupBy`: Array of fields to group by (for example `['entityName']`).
|
|
128
|
-
- `aggregation`: Same enum as above.
|
|
129
|
-
- `limit`: Server-side top-K cap. Required for high-cardinality `groupBy`.
|
|
130
|
-
- `orderDirection`: `'ASC' | 'DESC'` (defaults to `DESC`).
|
|
131
|
-
- `filters`: Optional.
|
|
132
|
-
|
|
133
|
-
Response: `groups[]`, each with `dimensions` (record of group keys to values), `value`, and `estimatedCost`.
|
|
134
|
-
|
|
135
|
-
```typescript
|
|
136
|
-
const byAgent = await observability!.getMetricBreakdown({
|
|
137
|
-
name: ['mastra_model_total_input_tokens'],
|
|
138
|
-
groupBy: ['entityName'],
|
|
139
|
-
aggregation: 'sum',
|
|
140
|
-
limit: 10,
|
|
141
|
-
orderDirection: 'DESC',
|
|
142
|
-
})
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### `getMetricTimeSeries`
|
|
146
|
-
|
|
147
|
-
Buckets values by a fixed interval, the building block for line and bar charts.
|
|
148
|
-
|
|
149
|
-
Inputs:
|
|
150
|
-
|
|
151
|
-
- `name`: Array of metric names.
|
|
152
|
-
- `interval`: One of `'1m' | '5m' | '15m' | '1h' | '1d'`.
|
|
153
|
-
- `aggregation`: Same enum.
|
|
154
|
-
- `groupBy`: Optional. When omitted, multiple metric names are summed into one series. Use one call per metric to keep them separate.
|
|
155
|
-
- `filters`: Optional.
|
|
156
|
-
|
|
157
|
-
Response: `series[]`, each with `name`, `costUnit`, and `points[]` of `{ timestamp, value, estimatedCost }`.
|
|
158
|
-
|
|
159
|
-
```typescript
|
|
160
|
-
const inputTokens = await observability!.getMetricTimeSeries({
|
|
161
|
-
name: ['mastra_model_total_input_tokens'],
|
|
162
|
-
aggregation: 'sum',
|
|
163
|
-
interval: '1h',
|
|
164
|
-
filters: {
|
|
165
|
-
timestamp: { start: new Date(Date.now() - 24 * 60 * 60 * 1000) },
|
|
166
|
-
},
|
|
167
|
-
})
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
### `getMetricPercentiles`
|
|
171
|
-
|
|
172
|
-
Returns percentile values bucketed by time, the building block for latency charts.
|
|
173
|
-
|
|
174
|
-
Inputs:
|
|
175
|
-
|
|
176
|
-
- `name`: Single metric name (string, not array).
|
|
177
|
-
- `percentiles`: Array of numbers between `0` and `1`, for example `[0.5, 0.95, 0.99]`.
|
|
178
|
-
- `interval`: Same enum as `getMetricTimeSeries`.
|
|
179
|
-
- `filters`: Optional.
|
|
180
|
-
|
|
181
|
-
Response: `series[]`, each with `percentile` and `points[]` of `{ timestamp, value }`.
|
|
182
|
-
|
|
183
|
-
```typescript
|
|
184
|
-
const latency = await observability!.getMetricPercentiles({
|
|
185
|
-
name: 'mastra_agent_duration_ms',
|
|
186
|
-
percentiles: [0.5, 0.95],
|
|
187
|
-
interval: '1h',
|
|
188
|
-
})
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### Discovery
|
|
192
|
-
|
|
193
|
-
Use these endpoints to populate dropdowns or to give an agent the menu of values it can filter by. All discovery routes are `GET` and live under `/api/observability/discovery/`.
|
|
194
|
-
|
|
195
|
-
**Metric-specific** (also exposed as `mastra api metric` subcommands):
|
|
196
|
-
|
|
197
|
-
| Method | Args | Path suffix | CLI |
|
|
198
|
-
| ---------------------- | ------------------------------------------- | --------------------- | -------------------------------- |
|
|
199
|
-
| `getMetricNames` | `{ prefix?, limit? }` | `metric-names` | `mastra api metric names` |
|
|
200
|
-
| `getMetricLabelKeys` | `{ metricName }` | `metric-label-keys` | `mastra api metric label-keys` |
|
|
201
|
-
| `getMetricLabelValues` | `{ metricName, labelKey, prefix?, limit? }` | `metric-label-values` | `mastra api metric label-values` |
|
|
202
|
-
|
|
203
|
-
**Shared with traces and logs** (HTTP-only, no dedicated CLI subcommand):
|
|
204
|
-
|
|
205
|
-
| Method | Args | Path suffix |
|
|
206
|
-
| ----------------- | ----------------- | --------------- |
|
|
207
|
-
| `getEntityTypes` | `{}` | `entity-types` |
|
|
208
|
-
| `getEntityNames` | `{ entityType? }` | `entity-names` |
|
|
209
|
-
| `getServiceNames` | `{}` | `service-names` |
|
|
210
|
-
| `getEnvironments` | `{}` | `environments` |
|
|
211
|
-
| `getTags` | `{ entityType? }` | `tags` |
|
|
212
|
-
|
|
213
|
-
## Filtering
|
|
214
|
-
|
|
215
|
-
Every query accepts the same `filters` object. The most useful fields:
|
|
216
|
-
|
|
217
|
-
- `name`: Restrict to specific metric names. (Top-level `name` already does this for aggregate/breakdown/timeseries. Use `filters.name` when you want to mix multiple metrics under a single query.)
|
|
218
|
-
- `timestamp`: `{ start, end, startExclusive, endExclusive }`. Both bounds are optional. Omit `end` for "until now".
|
|
219
|
-
- `provider`, `model`, `costUnit`: For token and cost metrics.
|
|
220
|
-
- `labels`: Exact key-value match on metric labels, for example `{ status: 'error' }` for duration metrics.
|
|
221
|
-
- Correlation fields: `entityType`, `entityName`, `parentEntityName`, `rootEntityName`, `userId`, `organizationId`, `resourceId`, `runId`, `sessionId`, `threadId`, `requestId`, `executionSource`, `environment`, `serviceName`, `experimentId`, `tags`.
|
|
222
|
-
|
|
223
|
-
The same `filters` shape works across all three surfaces:
|
|
224
|
-
|
|
225
|
-
```typescript
|
|
226
|
-
// In-process
|
|
227
|
-
await observability!.getMetricAggregate({
|
|
228
|
-
name: ['mastra_tool_duration_ms'],
|
|
229
|
-
aggregation: 'avg',
|
|
230
|
-
filters: { entityName: 'weatherTool', labels: { status: 'error' } },
|
|
231
|
-
})
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
```bash
|
|
235
|
-
# CLI
|
|
236
|
-
mastra api metric aggregate \
|
|
237
|
-
'{"name":["mastra_tool_duration_ms"],"aggregation":"avg","filters":{"entityName":"weatherTool","labels":{"status":"error"}}}' \
|
|
238
|
-
--url http://localhost:4111
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
```bash
|
|
242
|
-
# HTTP
|
|
243
|
-
curl -sS -X POST http://localhost:4111/api/observability/metrics/aggregate \
|
|
244
|
-
-H "content-type: application/json" \
|
|
245
|
-
-d '{"name":["mastra_tool_duration_ms"],"aggregation":"avg","filters":{"entityName":"weatherTool","labels":{"status":"error"}}}'
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
### Always provide a time range
|
|
249
|
-
|
|
250
|
-
`filters.timestamp` is optional, but you should treat it as required for any query that runs against a production store. Observability tables are typically partitioned (or chunked, for TimescaleDB) by event time. When you supply `timestamp.start` (and ideally `end`), the backend can prune to the partitions that overlap the range, usually one or two. Without a time range, the planner has to scan every partition, which can be hundreds of segments over a year of retention and is the most common cause of slow OLAP queries on Postgres-backed stores.
|
|
251
|
-
|
|
252
|
-
A safe default for ad-hoc queries is the last 24 hours; alerts and dashboards should match their actual evaluation window:
|
|
253
|
-
|
|
254
|
-
```typescript
|
|
255
|
-
await observability!.getMetricAggregate({
|
|
256
|
-
name: ['mastra_agent_duration_ms'],
|
|
257
|
-
aggregation: 'p95',
|
|
258
|
-
filters: {
|
|
259
|
-
timestamp: { start: new Date(Date.now() - 24 * 60 * 60 * 1000) },
|
|
260
|
-
},
|
|
261
|
-
})
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
This guidance applies to all backends (ClickHouse, Postgres v-next, DuckDB), but matters most for Postgres v-next where each missing time bound translates directly into one extra partition scan.
|
|
265
|
-
|
|
266
|
-
## Example: build a custom KPI tile
|
|
267
|
-
|
|
268
|
-
The following tool returns input-token volume and estimated cost for the last hour. An agent or a dashboard can call it as `structuredContent` without re-implementing the query.
|
|
269
|
-
|
|
270
|
-
```typescript
|
|
271
|
-
import { createTool } from '@mastra/core/tools'
|
|
272
|
-
import { z } from 'zod'
|
|
273
|
-
|
|
274
|
-
export const tokenKpiTool = createTool({
|
|
275
|
-
id: 'tokenKpi',
|
|
276
|
-
description: 'Returns input-token volume and estimated cost for the last hour.',
|
|
277
|
-
inputSchema: z.object({}),
|
|
278
|
-
outputSchema: z.object({
|
|
279
|
-
inputTokens: z.number().nullable(),
|
|
280
|
-
estimatedCost: z.number().nullable(),
|
|
281
|
-
costUnit: z.string().nullable(),
|
|
282
|
-
changePercent: z.number().nullable(),
|
|
283
|
-
}),
|
|
284
|
-
execute: async (_input, context) => {
|
|
285
|
-
const observability = await context.mastra!.getStorage()!.getStore('observability')
|
|
286
|
-
if (!observability) {
|
|
287
|
-
throw new Error('Observability domain is not configured (requires DuckDB or ClickHouse)')
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const result = await observability.getMetricAggregate({
|
|
291
|
-
name: ['mastra_model_total_input_tokens'],
|
|
292
|
-
aggregation: 'sum',
|
|
293
|
-
filters: {
|
|
294
|
-
timestamp: { start: new Date(Date.now() - 60 * 60 * 1000) },
|
|
295
|
-
},
|
|
296
|
-
comparePeriod: 'previous_period',
|
|
297
|
-
})
|
|
298
|
-
|
|
299
|
-
return {
|
|
300
|
-
inputTokens: result.value,
|
|
301
|
-
estimatedCost: result.estimatedCost ?? null,
|
|
302
|
-
costUnit: result.costUnit ?? null,
|
|
303
|
-
changePercent: result.changePercent ?? null,
|
|
304
|
-
}
|
|
305
|
-
},
|
|
306
|
-
})
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
## Related
|
|
310
|
-
|
|
311
|
-
- [Metrics overview](https://mastra.ai/docs/observability/metrics/overview)
|
|
312
|
-
- [Automatic metrics reference](https://mastra.ai/reference/observability/metrics/automatic-metrics)
|
|
313
|
-
- [CLI: `mastra api metric ...`](https://mastra.ai/reference/cli/mastra)
|
|
314
|
-
- [Studio observability](https://mastra.ai/docs/studio/observability)
|