@mastra/mcp-docs-server 1.3.7-alpha.9 → 1.3.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.
@@ -318,14 +318,14 @@ export const mastra = new Mastra({
318
318
 
319
319
  ### Subscribe to all task events
320
320
 
321
- Calling `stream()` with no filter returns a stream of every task event in the system. On connection, the stream emits a snapshot of all currently running tasks, then forwards live events as they happen.
321
+ Pass `allResources: true` to receive every task event in the system, across all resources. On connection, the stream emits a snapshot of all currently running tasks, then forwards live events as they happen.
322
322
 
323
323
  ```typescript
324
324
  const bgManager = mastra.backgroundTaskManager;
325
325
  if (!bgManager) throw new Error('Background tasks are not enabled');
326
326
 
327
327
  const controller = new AbortController();
328
- const stream = bgManager.stream({ abortSignal: controller.signal });
328
+ const stream = bgManager.stream({ allResources: true, abortSignal: controller.signal });
329
329
 
330
330
  for await (const chunk of stream) {
331
331
  switch (chunk.type) {
@@ -344,6 +344,8 @@ for await (const chunk of stream) {
344
344
 
345
345
  The stream stays open until the caller's `AbortSignal` fires. Always pass an `abortSignal` so you can disconnect cleanly.
346
346
 
347
+ > **Warning:** `allResources: true` delivers task arguments and results for every user. Use it only in trusted server-side code, never to serve a single user's request. Without `resourceId` or `allResources`, `stream()` only delivers tasks that have no `resourceId`. Agent tasks dispatched with memory always have a `resourceId`, so they won't appear in that stream.
348
+
347
349
  ### Filter the stream
348
350
 
349
351
  Pass any combination of filter options to narrow the events you receive. Filters apply to both the initial snapshot and the live event subscription.
@@ -357,14 +359,15 @@ const stream = bgManager.stream({
357
359
  })
358
360
  ```
359
361
 
360
- | Filter | Description |
361
- | ------------- | --------------------------------------------------- |
362
- | `agentId` | Only events from tasks dispatched by this agent |
363
- | `runId` | Only events from this specific agent run |
364
- | `threadId` | Only events from tasks scoped to this memory thread |
365
- | `resourceId` | Only events from tasks scoped to this resource |
366
- | `taskId` | Only events for a single task |
367
- | `abortSignal` | Closes the stream when the signal aborts |
362
+ | Filter | Description |
363
+ | -------------- | --------------------------------------------------------------------------------------------- |
364
+ | `agentId` | Only events from tasks dispatched by this agent |
365
+ | `runId` | Only events from this specific agent run |
366
+ | `threadId` | Only events from tasks scoped to this memory thread |
367
+ | `resourceId` | Only events from tasks scoped to this resource |
368
+ | `taskId` | Only events for a single task |
369
+ | `allResources` | Include tasks from every resource when `resourceId` is omitted. Trusted server-side code only |
370
+ | `abortSignal` | Closes the stream when the signal aborts |
368
371
 
369
372
  ### Look up task state directly
370
373
 
@@ -374,10 +374,13 @@ Enforcement of the claim depends on the workflows store. When the store supports
374
374
  - `@mastra/convex`
375
375
  - `@mastra/mongodb`, on a replica set or sharded cluster
376
376
  - `@mastra/dynamodb`
377
+ - `@mastra/redis`
378
+ - `@mastra/upstash`
379
+ - `@mastra/valkey`
377
380
 
378
381
  On Convex, run fencing runs in the Mastra server functions you deploy. Redeploy your Convex functions after upgrading `@mastra/convex`. Until you do, durable agent runs fail with an error asking you to redeploy, while other writes keep working.
379
382
 
380
- Stores that support run fencing keep one claim record per run, plus one memory fence record per run with memory. Stores with retention support prune them with the `workflows.runOwnership` and `memory.runFences` [retention keys](https://mastra.ai/reference/storage/retention). A run's first generation comes from the store's clock, so a run that reuses a `runId` after its records were pruned still outranks the fences and stream events of its earlier executions.
383
+ Stores that support run fencing keep one claim record per run, plus one memory fence record per run with memory. Stores with retention support prune them with the `workflows.runOwnership` and `memory.runFences` [retention keys](https://mastra.ai/reference/storage/retention). Redis, Upstash, and Valkey expire them on their own instead: a claim 7 days after its last claim, renewal, or release, and a fence 7 days after it's retired. A run's first generation comes from the store's clock, so a run that reuses a `runId` after its records were pruned still outranks the fences and stream events of its earlier executions.
381
384
 
382
385
  With any other workflows store, the claim is a lease on the [PubSub](https://mastra.ai/docs/server/pubsub) backend. The lease keeps two executions from claiming the run at once, but writes from an execution that lost the run aren't rejected. A run taken over while its previous execution was still live can end with that execution's output. When an execution loses its lease and no other execution has taken the run, the run stays held for up to 15 more seconds. Until then, `recover()` without `force` throws `DURABLE_AGENT_RUN_ACTIVE` with `retryAt` set to when the hold is sure to have ended. Mastra logs a warning when it recovers runs against a workflows or memory store without run fencing.
383
386
 
@@ -151,6 +151,37 @@ const response = await memoryAgent.generate("What's my favorite color?", {
151
151
 
152
152
  To list all threads for a resource, or retrieve a specific thread, [use the memory API directly](https://mastra.ai/docs/memory/message-history).
153
153
 
154
+ ### Identify memory with scopes
155
+
156
+ Instead of a `memory` object, you can pass `scopes`: the addresses a run acts as, written as `<type>:<value>`. Memory reads the resource from a `resource:` scope and the thread from a `thread:` scope. Other scopes, such as `org:acme`, are passed to tools and processors.
157
+
158
+ ```typescript
159
+ const response = await memoryAgent.generate('Remember my favorite color is blue.', {
160
+ scopes: ['org:acme', 'resource:user-123', 'thread:conversation-123'],
161
+ })
162
+ ```
163
+
164
+ Scopes can also come from the agent and from the request context. Mastra combines all three sources:
165
+
166
+ ```typescript
167
+ export const memoryAgent = new Agent({
168
+ id: 'memory-agent',
169
+ name: 'Memory Agent',
170
+ scopes: ({ requestContext }) => {
171
+ // Set by your auth middleware. Request bodies can fill unreserved keys.
172
+ const orgId = requestContext.get('org-id')
173
+ return orgId ? [`org:${orgId}`] : []
174
+ },
175
+ memory: new Memory(),
176
+ })
177
+ ```
178
+
179
+ The resolver's inputs must come from the server, not the client: a request body can set any request context key that isn't reserved. Trusted server middleware can also set scopes directly with the `MASTRA_SCOPES_KEY` request context key. Visit [Request Context](https://mastra.ai/docs/server/request-context) for details. Clients can't send scopes in a request body.
180
+
181
+ You can mix scopes with `memory.resource`, `memory.thread`, or the resource and thread request context keys, as long as they agree. If a `resource:` or `thread:` scope names a different value than another source, the call throws an error.
182
+
183
+ Tools, processors, and subagents receive the run's other scopes, but not its `resource:` and `thread:` scopes. Each nested agent call picks its own resource and thread.
184
+
154
185
  ## Observational Memory
155
186
 
156
187
  Long conversations can fill the context window with raw message history and reduce agent performance. [Observational Memory](https://mastra.ai/docs/memory/observational-memory) uses background agents to compress older messages into observations. This reduces the context used by message history while retaining information for later turns.
@@ -284,11 +284,35 @@ 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 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. |
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_SCOPES_KEY` | Sets the [scopes](https://mastra.ai/docs/memory/overview) the agent run acts as, as an array of `<type>:<value>` strings. Combined with the agent's `scopes` and per-call `scopes`. A `resource:` or `thread:` scope that conflicts with another resource or thread value returns a 400 error. |
292
+ | `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. |
293
+
294
+ Server ownership checks read only `MASTRA_RESOURCE_ID_KEY` and `MASTRA_THREAD_ID_KEY`. If your middleware sets identity through `MASTRA_SCOPES_KEY` and you want those checks, set `MASTRA_RESOURCE_ID_KEY` too:
295
+
296
+ ```typescript
297
+ import {
298
+ MASTRA_RESOURCE_ID_KEY,
299
+ MASTRA_THREAD_ID_KEY,
300
+ MASTRA_SCOPES_KEY,
301
+ } from '@mastra/core/request-context'
302
+
303
+ requestContext.set(MASTRA_SCOPES_KEY, [`org:${user.orgId}`, `resource:${user.id}`])
304
+ requestContext.set(MASTRA_RESOURCE_ID_KEY, user.id)
305
+ ```
306
+
307
+ The same applies to a `thread:` scope: it sets the run's thread identity, but only `MASTRA_THREAD_ID_KEY` drives the server's thread checks, so set both when middleware pins the thread:
308
+
309
+ ```typescript
310
+ requestContext.set(MASTRA_SCOPES_KEY, [`resource:${user.id}`, `thread:${threadId}`])
311
+ requestContext.set(MASTRA_RESOURCE_ID_KEY, user.id)
312
+ requestContext.set(MASTRA_THREAD_ID_KEY, threadId)
313
+ ```
314
+
315
+ Scopes from the request context and per-call `scopes` need a `@mastra/server` release that reserves them. Older servers pass these values from request bodies through to the agent, so while one is registered, agents throw an `AGENT_SCOPES_SERVER_OUTDATED` error instead of using them. The agent's own `scopes` option still applies.
292
316
 
293
317
  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
318
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  # Redis
6
6
 
7
- The Redis storage implementation provides a high-performance storage solution using direct Redis connections via [`node-redis`](https://github.com/redis/node-redis) (the official Redis client for Node.js). It supports standalone Redis, and through custom client configuration, Redis Sentinel and Cluster deployments.
7
+ The Redis storage implementation provides a high-performance storage solution using direct Redis connections via [`node-redis`](https://github.com/redis/node-redis) (the official Redis client for Node.js). It supports standalone Redis and, through a custom client, Redis Sentinel. Redis Cluster isn't supported.
8
8
 
9
9
  ## Installation
10
10
 
@@ -45,7 +45,7 @@ await storage.init()
45
45
 
46
46
  ### Using Pre-configured Client
47
47
 
48
- For advanced configurations like Sentinel or Cluster, you can pass a pre-configured Redis client:
48
+ For advanced configurations such as Sentinel, you can pass a pre-configured Redis client:
49
49
 
50
50
  ```typescript
51
51
  import { RedisStore } from '@mastra/redis'
@@ -122,27 +122,7 @@ const storage = new RedisStore({
122
122
 
123
123
  ### Redis Cluster
124
124
 
125
- For Redis Cluster deployments, use the cluster client:
126
-
127
- ```typescript
128
- import { RedisStore } from '@mastra/redis'
129
- import { createCluster } from 'redis'
130
-
131
- const cluster = createCluster({
132
- rootNodes: [
133
- { url: 'redis://node-1:6379' },
134
- { url: 'redis://node-2:6379' },
135
- { url: 'redis://node-3:6379' },
136
- ],
137
- })
138
-
139
- await cluster.connect()
140
-
141
- const storage = new RedisStore({
142
- id: 'redis-cluster-storage',
143
- client: cluster,
144
- })
145
- ```
125
+ Redis Cluster isn't supported. `RedisStore` accepts only a standalone client from `createClient()`, and several operations read or write keys that hash to different slots, which Redis Cluster rejects with a `CROSSSLOT` error.
146
126
 
147
127
  ### Accessing the Underlying Client
148
128
 
@@ -66,6 +66,8 @@ const storage = new ValkeyStore({
66
66
 
67
67
  For an existing `GlideClient`, connect it before passing it to `ValkeyStore`. The caller remains responsible for closing injected clients.
68
68
 
69
+ `ValkeyStore` needs a standalone Valkey server. Valkey Cluster and `GlideClusterClient` aren't supported.
70
+
69
71
  ## Constructor parameters
70
72
 
71
73
  **id** (`string`): Unique identifier for the storage instance.
@@ -587,6 +587,8 @@ Returns an `AgentThreadSubscription` object with these members:
587
587
 
588
588
  **scorers** (`MastraScorers | ({ requestContext: RequestContext }) => MastraScorers | Promise<MastraScorers>`): Scoring configuration for runtime evaluation and telemetry. Can be static or dynamically provided.
589
589
 
590
+ **scopes** (`string[] | ({ requestContext: RequestContext }) => string[] | Promise<string[]>`): Scopes every run of this agent acts as, written as \<type>:\<value>. Combined with per-call scopes and the mastra\_\_scopes request context key.
591
+
590
592
  **memory** (`MastraMemory | ({ requestContext: RequestContext }) => MastraMemory | Promise<MastraMemory>`): Memory module used for storing and retrieving stateful context.
591
593
 
592
594
  **notifications** (`object`): Notification delivery configuration for durable notification signals.
@@ -128,6 +128,8 @@ const result = await agent.generate('message for agent')
128
128
 
129
129
  **options.output** (`Zod schema | JsonSchema7`): \*\*Deprecated.\*\* Use structuredOutput without a model to achieve the same thing. Defines the expected structure of the output. Can be a JSON Schema object or a Zod schema.
130
130
 
131
+ **options.scopes** (`string[]`): Scopes the run acts as, written as \<type>:\<value> (for example org:acme, resource:user-123, thread:conversation-123). Memory reads its resource and thread from resource: and thread: scopes. Other scopes are passed to tools and processors. Combined with the agent's scopes and the mastra\_\_scopes request context key. Throws if a resource: or thread: scope conflicts with another resource or thread value.
132
+
131
133
  **options.memory** (`object`): Memory configuration for conversation persistence and retrieval.
132
134
 
133
135
  **options.memory.thread** (`string | { id: string; metadata?: Record<string, any>, title?: string }`): Thread identifier for conversation continuity. Can be a string ID or an object with ID and optional metadata/title.
@@ -2006,15 +2006,24 @@ Prints help message and exits.
2006
2006
 
2007
2007
  ## Telemetry
2008
2008
 
2009
- By default, Mastra collects anonymous information about your project like your OS, Mastra version or Node.js version. You can read the [source code](https://github.com/mastra-ai/mastra/blob/main/packages/cli/src/analytics/index.ts) to check what's collected.
2009
+ By default, Mastra collects telemetry about your project, including your OS, Mastra version, and Node.js version. Server events also include the project identifiers described below. You can read the [CLI telemetry source code](https://github.com/mastra-ai/mastra/blob/main/packages/cli/src/analytics/index.ts) to check what's collected by the CLI.
2010
2010
 
2011
- When a server started with `mastra dev` or `mastra start` has observability metrics enabled, Mastra also sends anonymous, aggregated model usage at startup: input and output token counts per provider and model, plus the command (`dev` or `start`) and `NODE_ENV`. No prompts, responses, or other message content is ever sent. You can read the [source code](https://github.com/mastra-ai/mastra/blob/main/packages/core/src/telemetry/usage-telemetry.ts) to check what's collected.
2011
+ When a server started with `mastra dev` or `mastra start` has observability metrics enabled, Mastra sends aggregated model usage at startup: input and output token counts per provider and model, plus the command (`dev` or `start`) and `NODE_ENV`. No prompts, responses, or other message content is sent. You can read the [model usage telemetry source code](https://github.com/mastra-ai/mastra/blob/main/packages/core/src/telemetry/usage-telemetry.ts) to check what's collected.
2012
2012
 
2013
- At server startup, Mastra also sends an anonymous project-surface snapshot: counts of registered agents, agent controllers, workflows, tools, processors, vector stores, scorers, workspaces, MCP servers, gateways, and channels, plus booleans for memory, voice, editor, and observability usage and the coarse storage backend category. It doesn't send names or identifiers. You can read the [source code](https://github.com/mastra-ai/mastra/blob/main/packages/core/src/telemetry/feature-telemetry.ts) to check what's collected.
2013
+ At server startup, Mastra sends a project-surface snapshot with component counts, feature flags, and the coarse storage backend category, but no component names or component identifiers. You can read the [feature telemetry source code](https://github.com/mastra-ai/mastra/blob/main/packages/core/src/telemetry/feature-telemetry.ts) to check what's collected.
2014
+
2015
+ The server events `mastra_feature_usage` and `mastra_model_token_usage` include:
2016
+
2017
+ - `project_id`: The first 16 hexadecimal characters of the SHA-256 hash of `MASTRA_PROJECT_ROOT`, or the current working directory when unset. This identifier also keys the local model-usage cursor.
2018
+ - `project_id2`: An optional identifier for correlation across machines and deployments. If the trimmed `MASTRA_PROJECT_ID` value has UUID format, the value is sent **unhashed**, prefixed with `mp_`. Search for `mp_<platform-project-id>` to find that project's telemetry. Names, slugs, and other non-UUID values aren't sent as Platform identifiers.
2019
+
2020
+ When no UUID-shaped Platform ID is available, `project_id2` uses the first 16 hexadecimal characters of the SHA-256 hash of the normalized Git `origin` remote. Normalization keeps the lowercase host and repository path, excluding the scheme, credentials, port, query, fragment, trailing slashes, and `.git` suffix. Equivalent SSH and HTTPS remotes produce the same identifier. Remotes with the same host and path share an identifier even if different ports or SSH users refer to different repositories. Local filesystem remotes aren't used. Git discovery runs asynchronously and is cached for the process, including when unavailable. If neither source is available, `project_id2` is omitted.
2021
+
2022
+ These server events aren't anonymous: a Platform ID links them to that project, and a known repository URL can be normalized and hashed to match Git-derived events. Hashing the Git identity avoids sending the raw repository URL or credentials, but doesn't prevent correlation with public or otherwise known repositories.
2014
2023
 
2015
2024
  The Studio UI also collects anonymous browser-side usage analytics, such as page views and UI interactions. You can read the [source code](https://github.com/mastra-ai/mastra/blob/main/packages/playground/src/lib/analytics.tsx) to check what's collected. Setting `MASTRA_TELEMETRY_DISABLED` disables this too: the value is injected into the served page, so it applies to `mastra dev` and self-hosted builds alike.
2016
2025
 
2017
- You can opt out of all CLI and usage analytics by setting an environment variable:
2026
+ You can opt out of CLI, server, and Studio usage analytics by setting this environment variable before starting Mastra. When disabled, server telemetry doesn't look up the Git remote or send either project identifier:
2018
2027
 
2019
2028
  ```bash
2020
2029
  MASTRA_TELEMETRY_DISABLED=1
@@ -122,6 +122,8 @@ const stream = await agent.stream('message for agent')
122
122
 
123
123
  **options.output** (`Zod schema | JsonSchema7`): \*\*Deprecated.\*\* Use structuredOutput without a model to achieve the same thing. Defines the expected structure of the output. Can be a JSON Schema object or a Zod schema.
124
124
 
125
+ **options.scopes** (`string[]`): Scopes the run acts as, written as \<type>:\<value> (for example org:acme, resource:user-123, thread:conversation-123). Memory reads its resource and thread from resource: and thread: scopes. Other scopes are passed to tools and processors. Combined with the agent's scopes and the mastra\_\_scopes request context key. Throws if a resource: or thread: scope conflicts with another resource or thread value.
126
+
125
127
  **options.memory** (`object`): Configuration for memory. This is the preferred way to manage memory.
126
128
 
127
129
  **options.memory.thread** (`string | { id: string; metadata?: Record<string, any>, title?: string }`): The conversation thread, as a string ID or an object with an id and optional metadata.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mcp-docs-server",
3
- "version": "1.3.7-alpha.9",
3
+ "version": "1.3.8-alpha.0",
4
4
  "description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -26,8 +26,8 @@
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/mcp": "^2.4.0-alpha.0",
30
- "@mastra/core": "1.77.0-alpha.4"
29
+ "@mastra/core": "1.78.0-alpha.0",
30
+ "@mastra/mcp": "^2.4.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@hono/node-server": "^2.0.0",
@@ -43,9 +43,9 @@
43
43
  "tsx": "^4.23.1",
44
44
  "typescript": "^7.0.2",
45
45
  "vitest": "4.1.11",
46
- "@internal/lint": "0.0.142",
47
- "@internal/types-builder": "0.0.117",
48
- "@mastra/core": "1.77.0-alpha.4"
46
+ "@internal/types-builder": "0.0.118",
47
+ "@internal/lint": "0.0.143",
48
+ "@mastra/core": "1.78.0-alpha.0"
49
49
  },
50
50
  "homepage": "https://mastra.ai",
51
51
  "repository": {