@mastra/mcp-docs-server 1.3.7-alpha.5 → 1.3.7-alpha.7
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/harness/agent-controller.md +18 -0
- package/.docs/docs/mastra-platform/api.md +88 -0
- package/.docs/docs/mastra-platform/observability.md +2 -0
- package/.docs/docs/server/request-context.md +5 -5
- package/.docs/reference/agent-controller/agent-controller-class.md +1 -1
- package/.docs/reference/agent-controller/session.md +49 -5
- package/package.json +5 -5
|
@@ -133,6 +133,24 @@ const session = await controller.createSession({
|
|
|
133
133
|
|
|
134
134
|
Use [`session.thread.create()`](https://mastra.ai/reference/agent-controller/session) and [`session.thread.switch()`](https://mastra.ai/reference/agent-controller/session) to move one live Session between conversations.
|
|
135
135
|
|
|
136
|
+
### Transfer thread ownership
|
|
137
|
+
|
|
138
|
+
Each new thread stores its durable owner in `metadata.ownerId` and its original creator in `metadata.createdBy`. Both default to the Session host's `ownerId`. `createdBy` doesn't change when ownership transfers.
|
|
139
|
+
|
|
140
|
+
Read the active thread's owner and transfer it through `session.thread`:
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
const currentOwnerId = await session.thread.getOwner()
|
|
144
|
+
|
|
145
|
+
await session.thread.transferOwnership({
|
|
146
|
+
toOwnerId: 'user-456',
|
|
147
|
+
})
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Transfers are serialized within one process. Hosts that require a durable cross-process compare-and-set should commit it in their own storage first, then call `transferOwnership()` to mirror the owner onto the active thread.
|
|
151
|
+
|
|
152
|
+
Every run snapshots the thread owner when it starts. Tools and other dynamic runtime code can read that value from `AgentControllerRequestContext.threadOwnerId`. If ownership changes during a run, the active run keeps the old snapshot and the next run receives the new owner. `context.session.ownerId` remains the identity of the process-local Session host.
|
|
153
|
+
|
|
136
154
|
### List stored messages from the client
|
|
137
155
|
|
|
138
156
|
Use the Agent Controller client to page through a thread's stored messages. Passing an options object returns the messages with pagination metadata:
|
|
@@ -179,6 +179,94 @@ The API returns `401` for invalid credentials, `403` for organization authorizat
|
|
|
179
179
|
|
|
180
180
|
Hosted observability doesn't provide a feedback creation route. Export feedback from the application as described in [Export feedback to Mastra Platform](https://mastra.ai/docs/observability/feedback).
|
|
181
181
|
|
|
182
|
+
## Metrics API
|
|
183
|
+
|
|
184
|
+
The Metrics API queries metrics exported to Mastra Platform Observability. Because the API is unversioned, backwards compatibility isn't guaranteed. Rate limits, retention, and ingestion-to-query freshness aren't published contracts.
|
|
185
|
+
|
|
186
|
+
The endpoints share their query parameters, request bodies, and response types with the Mastra runtime metric routes. See the [metric queries reference](https://mastra.ai/reference/observability/metrics/queries) for the full contract, including [shared filters](https://mastra.ai/reference/observability/metrics/queries), [analytics methods](https://mastra.ai/reference/observability/metrics/queries), and [metric discovery](https://mastra.ai/reference/observability/metrics/queries).
|
|
187
|
+
|
|
188
|
+
Use the root URL for your environment's data-residency region:
|
|
189
|
+
|
|
190
|
+
| Region | Root URL |
|
|
191
|
+
| -------------- | ------------------------------------------------------ |
|
|
192
|
+
| United States | `https://observability.mastra.ai/api/observability` |
|
|
193
|
+
| European Union | `https://observability.eu.mastra.ai/api/observability` |
|
|
194
|
+
|
|
195
|
+
Telemetry stays in its residency region. Querying the other region returns no records for the environment. See [Observability co-location](https://mastra.ai/docs/mastra-platform/regions) for the environment-to-region mapping.
|
|
196
|
+
|
|
197
|
+
### Authentication and project scope
|
|
198
|
+
|
|
199
|
+
Every request requires a platform access token. Create one in [Mastra Platform](https://projects.mastra.ai), or use the token written to `.env` during Platform setup.
|
|
200
|
+
|
|
201
|
+
Include `X-Mastra-Project-Id` to limit results to one project. If you omit it, the query covers metrics in every project available to the token's organization.
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
curl -sS "https://observability.mastra.ai/api/observability/discovery/metric-names?prefix=mastra_model_" \
|
|
205
|
+
-H "Authorization: Bearer $MASTRA_PLATFORM_ACCESS_TOKEN" \
|
|
206
|
+
-H "X-Mastra-Project-Id: $MASTRA_PROJECT_ID" | jq
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Use an organization-scoped Platform access token. Gateway inference keys such as `mk_*` keys aren't accepted. Queries remain constrained to the token's organization even when you supply a project ID.
|
|
210
|
+
|
|
211
|
+
### Endpoints
|
|
212
|
+
|
|
213
|
+
| Method | Endpoint | Description |
|
|
214
|
+
| ------ | -------------------------------- | --------------------------------------- |
|
|
215
|
+
| GET | `/metrics` | List raw metric records |
|
|
216
|
+
| POST | `/metrics/aggregate` | Return one aggregate value |
|
|
217
|
+
| POST | `/metrics/breakdown` | Group metrics by dimensions |
|
|
218
|
+
| POST | `/metrics/timeseries` | Bucket metrics by interval |
|
|
219
|
+
| POST | `/metrics/percentiles` | Return percentile series for one metric |
|
|
220
|
+
| GET | `/discovery/metric-names` | List metric names |
|
|
221
|
+
| GET | `/discovery/metric-label-keys` | List label keys for a metric |
|
|
222
|
+
| GET | `/discovery/metric-label-values` | List values for a metric label key |
|
|
223
|
+
|
|
224
|
+
The list and discovery endpoints take their arguments as query parameters. See [`listMetrics(args)`](https://mastra.ai/reference/observability/metrics/queries) and [metric discovery](https://mastra.ai/reference/observability/metrics/queries) in the metric queries reference for the parameters each one accepts.
|
|
225
|
+
|
|
226
|
+
Analytics endpoints accept the same JSON request bodies and return types as the [metric queries reference](https://mastra.ai/reference/observability/metrics/queries), including `name`, `aggregation`, `filters`, `groupBy`, `interval`, `percentiles`, `comparePeriod`, `limit`, `orderDirection`, and `distinctColumn`.
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
curl -sS "https://observability.mastra.ai/api/observability/metrics/aggregate" \
|
|
230
|
+
-X POST \
|
|
231
|
+
-H "Authorization: Bearer $MASTRA_PLATFORM_ACCESS_TOKEN" \
|
|
232
|
+
-H "X-Mastra-Project-Id: $MASTRA_PROJECT_ID" \
|
|
233
|
+
-H "Content-Type: application/json" \
|
|
234
|
+
--data '{"name":["mastra_model_total_input_tokens","mastra_model_total_output_tokens"],"aggregation":"sum","filters":{"timestamp":{"start":"2026-09-13T00:00:00Z","end":"2026-10-13T00:00:00Z"}},"comparePeriod":"previous_period"}' | jq
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
`filters.timestamp` is optional. If you omit `start` and `end`, the query covers all retained data. `comparePeriod` requires both `start` and `end`. Without them, the previous-period fields are `null`.
|
|
238
|
+
|
|
239
|
+
The API returns `401` for invalid credentials, `403` for organization authorization failures, and `400` for malformed query arguments or JSON bodies.
|
|
240
|
+
|
|
241
|
+
#### `MastraClient`
|
|
242
|
+
|
|
243
|
+
`MastraClient` from `@mastra/client-js` exposes the analytics and discovery methods. Set `baseUrl` to the region's host without the `/api/observability` path:
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
import { MastraClient } from '@mastra/client-js'
|
|
247
|
+
|
|
248
|
+
const mastraClient = new MastraClient({
|
|
249
|
+
baseUrl: 'https://observability.mastra.ai',
|
|
250
|
+
headers: {
|
|
251
|
+
Authorization: `Bearer ${process.env.MASTRA_PLATFORM_ACCESS_TOKEN}`,
|
|
252
|
+
'X-Mastra-Project-Id': process.env.MASTRA_PROJECT_ID!,
|
|
253
|
+
},
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
const result = await mastraClient.getMetricAggregate({
|
|
257
|
+
name: ['mastra_model_total_input_tokens', 'mastra_model_total_output_tokens'],
|
|
258
|
+
aggregation: 'sum',
|
|
259
|
+
})
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
#### CLI
|
|
263
|
+
|
|
264
|
+
The [`mastra api metric`](https://mastra.ai/reference/cli/mastra) commands target the United States endpoint by default. Pass `--url` to query the European Union region:
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
mastra api --url https://observability.eu.mastra.ai metric aggregate '<json>'
|
|
268
|
+
```
|
|
269
|
+
|
|
182
270
|
## Gateway proxy endpoints
|
|
183
271
|
|
|
184
272
|
Visit the [Gateway documentation](https://gateway.mastra.ai/docs) for more details.
|
|
@@ -168,6 +168,8 @@ The CLI can infer platform credentials from your project environment. See the [`
|
|
|
168
168
|
|
|
169
169
|
You can query exported feedback over HTTP. See the [Feedback API](https://mastra.ai/docs/mastra-platform/api) for its current status, regional endpoints, authentication, project scoping, and supported query parameters such as `traceId` and `environment`.
|
|
170
170
|
|
|
171
|
+
You can query exported metrics over HTTP, with `MastraClient`, or with `mastra api metric`. See the [Metrics API](https://mastra.ai/docs/mastra-platform/api) for regional endpoints, authentication, project scoping, and supported endpoints.
|
|
172
|
+
|
|
171
173
|
## Import existing traces
|
|
172
174
|
|
|
173
175
|
Use `mastra traces import` to move existing trace history from a supported observability provider into an existing Mastra Platform project. The command reads and validates complete traces at the source, converts them into Mastra spans, then uses a shared workflow for preparation, upload, resume, and verification.
|
|
@@ -284,11 +284,11 @@ requestContext.set(MASTRA_RESOURCE_ID_KEY, user.id)
|
|
|
284
284
|
requestContext.set(MASTRA_THREAD_ID_KEY, threadId)
|
|
285
285
|
```
|
|
286
286
|
|
|
287
|
-
| Key | Purpose
|
|
288
|
-
| --------------------------- |
|
|
289
|
-
| `MASTRA_RESOURCE_ID_KEY` | Forces all memory operations to use this resource ID. The server validates that accessed threads belong to this resource and returns 403 if not.
|
|
290
|
-
| `MASTRA_THREAD_ID_KEY` | Forces thread operations to use this thread ID, overriding client-provided values
|
|
291
|
-
| `MASTRA_MESSAGE_AUTHOR_KEY` | Names who sent a user message as `{ id, name?, avatarUrl? }`. Agent-controller sessions
|
|
287
|
+
| Key | Purpose |
|
|
288
|
+
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
289
|
+
| `MASTRA_RESOURCE_ID_KEY` | Forces all memory operations to use this resource ID. The server validates that accessed threads belong to this resource and returns 403 if not. |
|
|
290
|
+
| `MASTRA_THREAD_ID_KEY` | Forces thread operations to use this thread ID, overriding client-provided values |
|
|
291
|
+
| `MASTRA_MESSAGE_AUTHOR_KEY` | Names who sent a user message as `{ id, name?, avatarUrl? }`. Agent-controller sessions persist it at `content.metadata.signal.author` and mirror it to `providerMetadata.mastra.author` for compatibility, so a thread shared by several people can show who wrote what. |
|
|
292
292
|
|
|
293
293
|
These keys are used to implement user isolation in multi-tenant applications. See [Authorization middleware](https://mastra.ai/docs/server/middleware) for usage examples.
|
|
294
294
|
|
|
@@ -194,7 +194,7 @@ The same `resourceId` and `scope` return the same `Session` instance. A differen
|
|
|
194
194
|
|
|
195
195
|
**id** (`string`): Stable session identifier. Defaults to the controller id.
|
|
196
196
|
|
|
197
|
-
**ownerId** (`string`): Stable
|
|
197
|
+
**ownerId** (`string`): Stable identity of the process-local Session host. Defaults to id. New threads use it as their initial owner, but later transfers do not change this value.
|
|
198
198
|
|
|
199
199
|
**tags** (`Record<string, string>`): Tags copied to threads created by the session.
|
|
200
200
|
|
|
@@ -92,20 +92,25 @@ Returns: `() => void`
|
|
|
92
92
|
|
|
93
93
|
### Messages and run control
|
|
94
94
|
|
|
95
|
-
#### `sendMessage({ content, files?, requestContext? })`
|
|
95
|
+
#### `sendMessage({ content, files?, requestContext?, author? })`
|
|
96
96
|
|
|
97
|
-
Send a user message. The session creates a thread first when no thread is active.
|
|
97
|
+
Send a user message. The session creates a thread first when no thread is active. Pass `author` when the host has authenticated the sender.
|
|
98
98
|
|
|
99
99
|
```typescript
|
|
100
100
|
await session.sendMessage({
|
|
101
101
|
content: 'Summarize this file.',
|
|
102
102
|
files: [{ data: fileContents, mediaType: 'text/plain', filename: 'notes.txt' }],
|
|
103
|
+
author: { id: 'user-123' },
|
|
103
104
|
})
|
|
104
105
|
```
|
|
105
106
|
|
|
106
|
-
When `requestContext` carries `MASTRA_MESSAGE_AUTHOR_KEY`, the
|
|
107
|
+
The author persists under `content.metadata.signal.author`. Read it with `getMessageAuthor(message)` from `@mastra/core/agent`. When `requestContext` carries `MASTRA_MESSAGE_AUTHOR_KEY`, the session uses that value if `author` is omitted. See [Reserved keys](https://mastra.ai/docs/server/request-context).
|
|
107
108
|
|
|
108
|
-
#### `
|
|
109
|
+
#### `queueMessage({ content, files?, requestContext?, author? })`
|
|
110
|
+
|
|
111
|
+
Queue a message for the next run, or send it immediately while the session is idle. Author metadata persists with the queued message.
|
|
112
|
+
|
|
113
|
+
#### `steer({ content, requestContext?, author? })`
|
|
109
114
|
|
|
110
115
|
Queue steering content into an active run.
|
|
111
116
|
|
|
@@ -295,7 +300,9 @@ To change the resource ID, use [`controller.setResourceId()`](https://mastra.ai/
|
|
|
295
300
|
|
|
296
301
|
## Thread
|
|
297
302
|
|
|
298
|
-
`session.thread` owns the active thread binding and resource-scoped thread operations. Stored threads and messages can survive controller recreation when storage is configured. Conversation settings such as mode, model, thinking level, token usage,
|
|
303
|
+
`session.thread` owns the active thread binding and resource-scoped thread operations. Stored threads and messages can survive controller recreation when storage is configured. Conversation settings such as mode, model, thinking level, token usage, pending runs, and ownership are restored from the active thread when the session creates or switches threads. The live session and its event bus don't persist.
|
|
304
|
+
|
|
305
|
+
New threads store the Session host's `ownerId` in the reserved `metadata.ownerId` and `metadata.createdBy` fields. Clones use the cloning Session host for both fields. Existing threads without `metadata.ownerId` read as owned by the current Session host without writing a backfill.
|
|
299
306
|
|
|
300
307
|
### `session.thread.create({ title?, id?, requestContext? })`
|
|
301
308
|
|
|
@@ -369,6 +376,43 @@ Return the active thread ID, creating and binding a new thread when none is boun
|
|
|
369
376
|
const threadId = await session.thread.ensureId()
|
|
370
377
|
```
|
|
371
378
|
|
|
379
|
+
### `session.thread.getOwner({ threadId? })`
|
|
380
|
+
|
|
381
|
+
Return a thread's durable owner. Omit `threadId` to read the active thread. The method returns `undefined` when no thread is selected. An owner-less legacy thread returns the Session host's `ownerId` without writing a backfill.
|
|
382
|
+
|
|
383
|
+
```typescript
|
|
384
|
+
const ownerId = await session.thread.getOwner()
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
Returns: `Promise<string | undefined>`
|
|
388
|
+
|
|
389
|
+
### `session.thread.transferOwnership({ toOwnerId })`
|
|
390
|
+
|
|
391
|
+
Store `toOwnerId` in the active thread's `metadata.ownerId` and emit `thread_owner_changed`. The original `metadata.createdBy` value doesn't change.
|
|
392
|
+
|
|
393
|
+
```typescript
|
|
394
|
+
await session.thread.transferOwnership({
|
|
395
|
+
toOwnerId: 'user-456',
|
|
396
|
+
})
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
Returns: `Promise<void>`
|
|
400
|
+
|
|
401
|
+
Transfers are serialized within one process. Storage-backed applications that require a durable cross-process compare-and-set should perform it in their own store first, then call this method to mirror the result.
|
|
402
|
+
|
|
403
|
+
A successful change emits:
|
|
404
|
+
|
|
405
|
+
```typescript
|
|
406
|
+
const event = {
|
|
407
|
+
type: 'thread_owner_changed',
|
|
408
|
+
threadId: 'thread-7',
|
|
409
|
+
fromOwnerId: 'user-123',
|
|
410
|
+
toOwnerId: 'user-456',
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
Runs snapshot ownership when they start. Within agent tools and dynamic runtime functions, `AgentControllerRequestContext.threadOwnerId` remains unchanged for the run's lifetime. A transfer becomes visible on the next run. `AgentControllerRequestContext.session.ownerId` continues to identify the process-local Session host.
|
|
415
|
+
|
|
372
416
|
### `session.thread.list(options?)`
|
|
373
417
|
|
|
374
418
|
List threads from storage. By default only threads for the current resource are returned, and transient forked subagent threads are hidden.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.3.7-alpha.
|
|
3
|
+
"version": "1.3.7-alpha.7",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@mastra/mcp-legacy": "npm:@mastra/mcp@^1.18.0",
|
|
27
27
|
"local-pkg": "^1.1.2",
|
|
28
28
|
"zod": "^4.6.4",
|
|
29
|
-
"@mastra/core": "1.77.0-alpha.
|
|
29
|
+
"@mastra/core": "1.77.0-alpha.3",
|
|
30
30
|
"@mastra/mcp": "^2.4.0-alpha.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"tsx": "^4.23.1",
|
|
44
44
|
"typescript": "^7.0.2",
|
|
45
45
|
"vitest": "4.1.11",
|
|
46
|
-
"@internal/
|
|
47
|
-
"@mastra/core": "1.77.0-alpha.
|
|
48
|
-
"@internal/
|
|
46
|
+
"@internal/types-builder": "0.0.117",
|
|
47
|
+
"@mastra/core": "1.77.0-alpha.3",
|
|
48
|
+
"@internal/lint": "0.0.142"
|
|
49
49
|
},
|
|
50
50
|
"homepage": "https://mastra.ai",
|
|
51
51
|
"repository": {
|