@mastra/mcp-docs-server 1.1.26-alpha.8 → 1.1.26

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.
Files changed (56) hide show
  1. package/.docs/docs/agents/structured-output.md +22 -0
  2. package/.docs/docs/agents/supervisor-agents.md +18 -0
  3. package/.docs/docs/editor/overview.md +69 -0
  4. package/.docs/docs/memory/storage.md +1 -0
  5. package/.docs/docs/observability/tracing/exporters/langfuse.md +31 -0
  6. package/.docs/guides/deployment/netlify.md +16 -1
  7. package/.docs/guides/getting-started/next-js.md +0 -4
  8. package/.docs/guides/migrations/mastra-cloud.md +2 -2
  9. package/.docs/models/gateways/netlify.md +2 -3
  10. package/.docs/models/gateways/openrouter.md +3 -1
  11. package/.docs/models/index.md +1 -1
  12. package/.docs/models/providers/302ai.md +32 -1
  13. package/.docs/models/providers/berget.md +9 -12
  14. package/.docs/models/providers/cloudflare-workers-ai.md +2 -1
  15. package/.docs/models/providers/cortecs.md +2 -1
  16. package/.docs/models/providers/deepinfra.md +4 -1
  17. package/.docs/models/providers/digitalocean.md +116 -0
  18. package/.docs/models/providers/fireworks-ai.md +2 -1
  19. package/.docs/models/providers/helicone.md +1 -2
  20. package/.docs/models/providers/huggingface.md +2 -1
  21. package/.docs/models/providers/kilo.md +2 -1
  22. package/.docs/models/providers/kimi-for-coding.md +2 -1
  23. package/.docs/models/providers/llmgateway.md +59 -77
  24. package/.docs/models/providers/moonshotai-cn.md +3 -2
  25. package/.docs/models/providers/moonshotai.md +3 -2
  26. package/.docs/models/providers/nano-gpt.md +8 -1
  27. package/.docs/models/providers/nvidia.md +2 -1
  28. package/.docs/models/providers/ollama-cloud.md +2 -1
  29. package/.docs/models/providers/openai.md +1 -2
  30. package/.docs/models/providers/opencode-go.md +2 -1
  31. package/.docs/models/providers/opencode.md +4 -1
  32. package/.docs/models/providers/ovhcloud.md +4 -7
  33. package/.docs/models/providers/poe.md +2 -1
  34. package/.docs/models/providers/tencent-token-plan.md +71 -0
  35. package/.docs/models/providers/tencent-tokenhub.md +71 -0
  36. package/.docs/models/providers/wafer.ai.md +72 -0
  37. package/.docs/models/providers/zenmux.md +2 -1
  38. package/.docs/models/providers.md +4 -0
  39. package/.docs/reference/agents/generate.md +8 -0
  40. package/.docs/reference/client-js/workflows.md +12 -0
  41. package/.docs/reference/core/mastra-class.md +9 -1
  42. package/.docs/reference/deployer/cloudflare.md +14 -1
  43. package/.docs/reference/deployer/netlify.md +50 -2
  44. package/.docs/reference/harness/harness-class.md +72 -49
  45. package/.docs/reference/index.md +2 -0
  46. package/.docs/reference/observability/tracing/exporters/langfuse.md +2 -0
  47. package/.docs/reference/processors/prefill-error-handler.md +5 -5
  48. package/.docs/reference/storage/cloudflare-d1.md +42 -42
  49. package/.docs/reference/storage/redis.md +266 -0
  50. package/.docs/reference/streaming/agents/stream.md +8 -0
  51. package/.docs/reference/streaming/workflows/resumeStream.md +2 -0
  52. package/.docs/reference/tools/tavily.md +307 -0
  53. package/.docs/reference/workflows/run-methods/resume.md +24 -0
  54. package/.docs/reference/workflows/workflow-methods/foreach.md +14 -1
  55. package/CHANGELOG.md +71 -0
  56. package/package.json +10 -10
@@ -34,59 +34,59 @@ bun add @mastra/cloudflare-d1@latest
34
34
 
35
35
  ## Usage
36
36
 
37
- ### Using with Cloudflare Workers
37
+ ### Using with Mastra CloudflareDeployer
38
38
 
39
- When using D1Store in a Cloudflare Worker, you need to access the D1 binding from the worker's `env` parameter at runtime. The `D1Database` in your type definition is only for TypeScript type checking—the actual binding is provided by the Workers runtime.
39
+ The standard way to use D1Store with Mastra on Cloudflare is with `CloudflareDeployer`. Import `env` from `cloudflare:workers` and initialize `D1Store` inline inside `new Mastra({...})`.
40
40
 
41
41
  ```typescript
42
+ import { env } from 'cloudflare:workers'
42
43
  import { D1Store } from '@mastra/cloudflare-d1'
43
44
  import { Mastra } from '@mastra/core'
44
45
  import { CloudflareDeployer } from '@mastra/deployer-cloudflare'
45
46
 
46
- type Env = {
47
- D1Database: D1Database // TypeScript type definition
48
- }
47
+ export const mastra = new Mastra({
48
+ storage: new D1Store({ binding: env.DB }),
49
+ deployer: new CloudflareDeployer({
50
+ name: 'my-worker',
51
+ d1_databases: [
52
+ {
53
+ binding: 'DB',
54
+ database_name: 'your-database-name',
55
+ database_id: 'your-database-id',
56
+ },
57
+ ],
58
+ }),
59
+ })
60
+ ```
61
+
62
+ > **Note:** When using `import { env } from 'cloudflare:workers'`, `D1Store` must be initialized inline inside `new Mastra({...})` — not extracted to a module-level variable. Alternatively, initialize `D1Store` inside the `fetch` handler after `env` is available. See [CloudflareDeployer reference](https://mastra.ai/reference/deployer/cloudflare) for details.
49
63
 
50
- // Factory function to create Mastra with D1 binding
51
- function createMastra(env: Env) {
52
- const storage = new D1Store({
53
- binding: env.D1Database, // ✅ Access the actual binding from env
54
- tablePrefix: 'dev_', // Optional: isolate tables per environment
55
- })
56
-
57
- return new Mastra({
58
- storage,
59
- deployer: new CloudflareDeployer({
60
- name: 'my-worker',
61
- d1_databases: [
62
- {
63
- binding: 'D1Database', // Must match the property name in Env type
64
- database_name: 'your-database-name',
65
- database_id: 'your-database-id',
66
- },
67
- ],
68
- }),
69
- })
64
+ ### Using in a Cloudflare Worker without HTTP routes
65
+
66
+ If you want to call Mastra directly in a Worker — for example, to run an agent or trigger a workflow — without serving HTTP routes, you don't need `CloudflareDeployer`. Access the D1 binding from the worker's `env` parameter and call Mastra programmatically.
67
+
68
+ ```typescript
69
+ import { D1Store } from '@mastra/cloudflare-d1'
70
+ import { Mastra } from '@mastra/core'
71
+
72
+ type Env = {
73
+ DB: D1Database
70
74
  }
71
75
 
72
- // Cloudflare Worker export
73
76
  export default {
74
77
  async fetch(request: Request, env: Env, ctx: ExecutionContext) {
75
- const mastra = createMastra(env)
78
+ const mastra = new Mastra({
79
+ storage: new D1Store({ binding: env.DB }),
80
+ })
76
81
 
77
- // Your handler logic here
78
- return new Response('Hello from Mastra with D1!')
82
+ const agent = mastra.getAgent('my-agent')
83
+ const result = await agent.generate('Hello')
84
+
85
+ return Response.json({ text: result.text })
79
86
  },
80
87
  }
81
88
  ```
82
89
 
83
- > **Important: Understanding D1 Bindings:** In the `Env` type definition, `D1Database: D1Database` serves two purposes:
84
- >
85
- > - The **property name** (`D1Database`) must match the `binding` name in your `wrangler.toml`
86
- > - The **type** (`: D1Database`) is from `@cloudflare/workers-types` for TypeScript type checking
87
- >
88
- > At runtime, Cloudflare Workers provides the actual D1 database instance via `env.D1Database`. You can't use `D1Database` directly outside of the worker's context.
89
-
90
90
  ### Using with REST API
91
91
 
92
92
  For non-Workers environments (Node.js, serverless functions, etc.), use the REST API approach:
@@ -108,7 +108,7 @@ Add the D1 database binding to your `wrangler.toml`:
108
108
 
109
109
  ```toml
110
110
  [[d1_databases]]
111
- binding = "D1Database" # Must match the property name in your Env type
111
+ binding = "DB"
112
112
  database_name = "your-database-name"
113
113
  database_id = "your-database-id"
114
114
  ```
@@ -119,7 +119,7 @@ Or in `wrangler.jsonc`:
119
119
  {
120
120
  "d1_databases": [
121
121
  {
122
- "binding": "D1Database",
122
+ "binding": "DB",
123
123
  "database_name": "your-database-name",
124
124
  "database_id": "your-database-id",
125
125
  },
@@ -158,14 +158,14 @@ import { Mastra } from '@mastra/core'
158
158
  import { D1Store } from '@mastra/cloudflare-d1'
159
159
 
160
160
  type Env = {
161
- D1Database: D1Database
161
+ DB: D1Database
162
162
  }
163
163
 
164
164
  // In a Cloudflare Worker
165
165
  export default {
166
166
  async fetch(request: Request, env: Env, ctx: ExecutionContext) {
167
167
  const storage = new D1Store({
168
- binding: env.D1Database, // ✅ Use env.D1Database
168
+ binding: env.DB,
169
169
  })
170
170
 
171
171
  const mastra = new Mastra({
@@ -184,7 +184,7 @@ If you're using storage directly without Mastra, you must call `init()` explicit
184
184
  import { D1Store } from '@mastra/cloudflare-d1'
185
185
 
186
186
  type Env = {
187
- D1Database: D1Database
187
+ DB: D1Database
188
188
  }
189
189
 
190
190
  // In a Cloudflare Worker
@@ -192,7 +192,7 @@ export default {
192
192
  async fetch(request: Request, env: Env, ctx: ExecutionContext) {
193
193
  const storage = new D1Store({
194
194
  id: 'd1-storage',
195
- binding: env.D1Database, // ✅ Use env.D1Database
195
+ binding: env.DB,
196
196
  })
197
197
 
198
198
  // Required when using storage directly
@@ -0,0 +1,266 @@
1
+ # Redis Storage
2
+
3
+ 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.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @mastra/redis
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Using Connection String
14
+
15
+ ```typescript
16
+ import { RedisStore } from '@mastra/redis'
17
+
18
+ const storage = new RedisStore({
19
+ id: 'redis-storage',
20
+ connectionString: 'redis://localhost:6379',
21
+ })
22
+
23
+ await storage.init()
24
+ ```
25
+
26
+ ### Using Host/Port Configuration
27
+
28
+ ```typescript
29
+ import { RedisStore } from '@mastra/redis'
30
+
31
+ const storage = new RedisStore({
32
+ id: 'redis-storage',
33
+ host: 'localhost',
34
+ port: 6379,
35
+ password: 'your-password',
36
+ db: 0,
37
+ })
38
+
39
+ await storage.init()
40
+ ```
41
+
42
+ ### Using Pre-configured Client
43
+
44
+ For advanced configurations like Sentinel or Cluster, you can pass a pre-configured redis client:
45
+
46
+ ```typescript
47
+ import { RedisStore } from '@mastra/redis'
48
+ import { createClient } from 'redis'
49
+
50
+ const client = createClient({
51
+ url: 'redis://localhost:6379',
52
+ socket: {
53
+ reconnectStrategy: retries => Math.min(retries * 50, 2000),
54
+ },
55
+ })
56
+
57
+ // Connect the client before passing to RedisStore
58
+ await client.connect()
59
+
60
+ const storage = new RedisStore({
61
+ id: 'redis-storage',
62
+ client,
63
+ })
64
+ ```
65
+
66
+ ## Parameters
67
+
68
+ **id** (`string`): Unique identifier for the storage instance
69
+
70
+ **connectionString** (`string`): Redis connection URL (e.g., \`redis\://localhost:6379\` or \`redis\://:password\@localhost:6379\`)
71
+
72
+ **host** (`string`): Redis host address
73
+
74
+ **port** (`number`): Redis port number (Default: `6379`)
75
+
76
+ **password** (`string`): Redis password for authentication
77
+
78
+ **db** (`number`): Redis database number (Default: `0`)
79
+
80
+ **client** (`RedisClient`): Pre-configured redis client (from the \`redis\` package) for advanced setups
81
+
82
+ > **Note:** You must provide either `connectionString`, `host`, or `client`. These options are mutually exclusive.
83
+
84
+ ## Additional Notes
85
+
86
+ ### Key Structure
87
+
88
+ The Redis storage implementation uses the following key patterns:
89
+
90
+ - Threads: `mastra_threads:id:{threadId}`
91
+ - Messages: `mastra_messages:threadId:{threadId}:id:{messageId}`
92
+ - Message index: `msg-idx:{messageId}` (for fast lookups)
93
+ - Thread messages sorted set: `thread:{threadId}:messages`
94
+ - Workflow snapshots: `mastra_workflow_snapshot:namespace:{ns}:workflow_name:{name}:run_id:{id}`
95
+ - Scores: `mastra_scorers:id:{scoreId}`
96
+ - Resources: `mastra_resources:{resourceId}`
97
+
98
+ ### Redis Sentinel
99
+
100
+ For high-availability deployments using Redis Sentinel, create a custom client:
101
+
102
+ ```typescript
103
+ import { RedisStore } from '@mastra/redis'
104
+ import { createClient } from 'redis'
105
+
106
+ const client = createClient({
107
+ url: 'redis://sentinel-host:26379',
108
+ // Configure sentinel options as needed for your setup
109
+ })
110
+
111
+ await client.connect()
112
+
113
+ const storage = new RedisStore({
114
+ id: 'redis-sentinel-storage',
115
+ client,
116
+ })
117
+ ```
118
+
119
+ ### Redis Cluster
120
+
121
+ For Redis Cluster deployments, use the cluster client:
122
+
123
+ ```typescript
124
+ import { RedisStore } from '@mastra/redis'
125
+ import { createCluster } from 'redis'
126
+
127
+ const cluster = createCluster({
128
+ rootNodes: [
129
+ { url: 'redis://node-1:6379' },
130
+ { url: 'redis://node-2:6379' },
131
+ { url: 'redis://node-3:6379' },
132
+ ],
133
+ })
134
+
135
+ await cluster.connect()
136
+
137
+ const storage = new RedisStore({
138
+ id: 'redis-cluster-storage',
139
+ client: cluster,
140
+ })
141
+ ```
142
+
143
+ ### Accessing the Underlying Client
144
+
145
+ You can access the underlying redis client for custom operations:
146
+
147
+ ```typescript
148
+ const storage = new RedisStore({
149
+ id: 'redis-storage',
150
+ connectionString: 'redis://localhost:6379',
151
+ })
152
+
153
+ await storage.init()
154
+
155
+ const client = storage.getClient()
156
+
157
+ // Custom Redis operations
158
+ await client.set('custom-key', 'value')
159
+ const value = await client.get('custom-key')
160
+ ```
161
+
162
+ ### Closing Connections
163
+
164
+ When shutting down your application, close the Redis connection:
165
+
166
+ ```typescript
167
+ await storage.close()
168
+ ```
169
+
170
+ ## Usage Example
171
+
172
+ ### Adding memory to an agent
173
+
174
+ ```typescript
175
+ import { Memory } from '@mastra/memory'
176
+ import { Agent } from '@mastra/core/agent'
177
+ import { RedisStore } from '@mastra/redis'
178
+
179
+ export const redisAgent = new Agent({
180
+ id: 'redis-agent',
181
+ name: 'Redis Agent',
182
+ instructions:
183
+ 'You are an AI agent with the ability to automatically recall memories from previous interactions.',
184
+ model: 'openai/gpt-4o',
185
+ memory: new Memory({
186
+ storage: new RedisStore({
187
+ id: 'redis-agent-storage',
188
+ connectionString: process.env.REDIS_URL!,
189
+ }),
190
+ options: {
191
+ lastMessages: 10,
192
+ },
193
+ }),
194
+ })
195
+ ```
196
+
197
+ ### Using the agent
198
+
199
+ ```typescript
200
+ import 'dotenv/config'
201
+
202
+ import { mastra } from './mastra'
203
+
204
+ const threadId = '123'
205
+ const resourceId = 'user-456'
206
+
207
+ const agent = mastra.getAgent('redisAgent')
208
+
209
+ const message = await agent.stream('My name is Mastra', {
210
+ memory: {
211
+ thread: threadId,
212
+ resource: resourceId,
213
+ },
214
+ })
215
+
216
+ await message.textStream.pipeTo(new WritableStream())
217
+
218
+ const stream = await agent.stream("What's my name?", {
219
+ memory: {
220
+ thread: threadId,
221
+ resource: resourceId,
222
+ },
223
+ memoryOptions: {
224
+ lastMessages: 5,
225
+ },
226
+ })
227
+
228
+ for await (const chunk of stream.textStream) {
229
+ process.stdout.write(chunk)
230
+ }
231
+ ```
232
+
233
+ ### Using with Mastra instance
234
+
235
+ ```typescript
236
+ import { Mastra } from '@mastra/core'
237
+ import { RedisStore } from '@mastra/redis'
238
+
239
+ const storage = new RedisStore({
240
+ id: 'mastra-storage',
241
+ host: 'localhost',
242
+ port: 6379,
243
+ })
244
+
245
+ const mastra = new Mastra({
246
+ storage, // init() called automatically
247
+ })
248
+ ```
249
+
250
+ If using storage directly without Mastra, call `init()` explicitly:
251
+
252
+ ```typescript
253
+ import { RedisStore } from '@mastra/redis'
254
+
255
+ const storage = new RedisStore({
256
+ id: 'redis-storage',
257
+ host: 'localhost',
258
+ port: 6379,
259
+ })
260
+
261
+ await storage.init()
262
+
263
+ // Access domain-specific stores via getStore()
264
+ const memoryStore = await storage.getStore('memory')
265
+ const thread = await memoryStore?.getThreadById({ threadId: '...' })
266
+ ```
@@ -206,6 +206,14 @@ const stream = await agent.stream('message for agent')
206
206
 
207
207
  **options.tracingOptions.tags** (`string[]`): Tags to apply to this trace. String labels for categorizing and filtering traces.
208
208
 
209
+ **options.versions** (`VersionOverrides`): Per-invocation version overrides for sub-agent delegation. Merged on top of Mastra instance-level versions and propagated automatically through sub-agent calls via requestContext. Requires the editor package. See \[Sub-agent versioning]\(/docs/editor/overview#sub-agent-versioning).
210
+
211
+ **options.versions.agents** (`Record<string, VersionSelector>`): A map of agent IDs to their version selectors.
212
+
213
+ **options.versions.agents.versionId** (`string`): Target a specific version by ID.
214
+
215
+ **options.versions.agents.status** (`'draft' | 'published'`): Target the latest version with this publication status.
216
+
209
217
  ## Returns
210
218
 
211
219
  **stream** (`MastraModelOutput<Output>`): Returns a MastraModelOutput instance that provides access to the streaming output.
@@ -32,6 +32,8 @@ if (result!.status === 'suspended') {
32
32
 
33
33
  **step** (`Step<string, any, any, any, any, TEngineType>`): The step to resume execution from
34
34
 
35
+ **forEachIndex** (`number`): Target a specific iteration of a suspended \`.foreach()\` step. Pass the zero-based index of the iteration to resume; other iterations remain suspended. Omit to resume all suspended iterations of the step with the same \`resumeData\`.
36
+
35
37
  **tracingOptions** (`TracingOptions`): Options for Tracing configuration.
36
38
 
37
39
  **tracingOptions.metadata** (`Record<string, any>`): Metadata to add to the root trace span. Useful for adding custom attributes like user IDs, session IDs, or feature flags.