@mastra/mcp-docs-server 1.1.26-alpha.20 → 1.1.26-alpha.23
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/agents/structured-output.md +22 -0
- package/.docs/docs/memory/storage.md +1 -0
- package/.docs/guides/getting-started/next-js.md +0 -4
- package/.docs/models/gateways/openrouter.md +2 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/deepinfra.md +4 -1
- package/.docs/models/providers/fireworks-ai.md +2 -1
- package/.docs/models/providers/kilo.md +2 -1
- package/.docs/models/providers/moonshotai-cn.md +3 -2
- package/.docs/models/providers/moonshotai.md +3 -2
- package/.docs/models/providers/nano-gpt.md +8 -1
- package/.docs/models/providers/ollama-cloud.md +2 -1
- package/.docs/models/providers/opencode-go.md +1 -1
- package/.docs/models/providers/opencode.md +3 -1
- package/.docs/models/providers/zenmux.md +2 -1
- package/.docs/reference/deployer/cloudflare.md +14 -1
- package/.docs/reference/index.md +2 -0
- package/.docs/reference/storage/cloudflare-d1.md +42 -42
- package/.docs/reference/storage/redis.md +266 -0
- package/.docs/reference/tools/tavily.md +307 -0
- package/CHANGELOG.md +14 -0
- package/package.json +8 -8
|
@@ -210,6 +210,28 @@ const response = await testAgent.generate('Tell me about TypeScript.', {
|
|
|
210
210
|
})
|
|
211
211
|
```
|
|
212
212
|
|
|
213
|
+
If you want that structuring model to also see the current conversation history, set `useAgent: true` alongside `model`. Mastra will reuse the parent agent with the separate structuring model and attach read-only memory context when a thread is available.
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
const response = await testAgent.generate('Return my profile as structured data.', {
|
|
217
|
+
memory: {
|
|
218
|
+
thread: 'thread-123',
|
|
219
|
+
resource: 'user-123',
|
|
220
|
+
},
|
|
221
|
+
structuredOutput: {
|
|
222
|
+
schema: z.object({
|
|
223
|
+
favoriteColor: z.string(),
|
|
224
|
+
hometown: z.string(),
|
|
225
|
+
petName: z.string(),
|
|
226
|
+
}),
|
|
227
|
+
model: 'openai/gpt-5.4',
|
|
228
|
+
useAgent: true,
|
|
229
|
+
},
|
|
230
|
+
})
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Leave `useAgent` unset if you want the separate structuring model to work only from the current response and not inherit prior conversation memory.
|
|
234
|
+
|
|
213
235
|
### Multi-step approach with `prepareStep`
|
|
214
236
|
|
|
215
237
|
For models that don't support tools and structured outputs together, you can use `prepareStep` to handle them in separate steps.
|
|
@@ -34,6 +34,7 @@ Each provider page includes installation instructions, configuration parameters,
|
|
|
34
34
|
- [PostgreSQL](https://mastra.ai/reference/storage/postgresql)
|
|
35
35
|
- [MongoDB](https://mastra.ai/reference/storage/mongodb)
|
|
36
36
|
- [Upstash](https://mastra.ai/reference/storage/upstash)
|
|
37
|
+
- [Redis](https://mastra.ai/reference/storage/redis)
|
|
37
38
|
- [Cloudflare D1](https://mastra.ai/reference/storage/cloudflare-d1)
|
|
38
39
|
- [Cloudflare KV & Durable Objects](https://mastra.ai/reference/storage/cloudflare)
|
|
39
40
|
- [Convex](https://mastra.ai/reference/storage/convex)
|
|
@@ -4,10 +4,6 @@ In this guide, you'll build a tool-calling AI agent using Mastra, then connect i
|
|
|
4
4
|
|
|
5
5
|
You'll use [AI SDK UI](https://ai-sdk.dev/docs/ai-sdk-ui/overview) and [AI Elements](https://ai-sdk.dev/elements) to create a beautiful, interactive chat experience.
|
|
6
6
|
|
|
7
|
-

|
|
8
|
-
|
|
9
|
-
What you'll build: an agent that can call a weather tool, display the JSON result, stream a weather summary in the chat UI, and persist conversation history across reloads.
|
|
10
|
-
|
|
11
7
|
## Before you begin
|
|
12
8
|
|
|
13
9
|
- You'll need an API key from a supported [model provider](https://mastra.ai/models). If you don't have a preference, use [OpenAI](https://mastra.ai/models/providers/openai).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenRouter
|
|
2
2
|
|
|
3
|
-
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
3
|
+
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 172 models through Mastra's model router.
|
|
4
4
|
|
|
5
5
|
Learn more in the [OpenRouter documentation](https://openrouter.ai/models).
|
|
6
6
|
|
|
@@ -117,6 +117,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
117
117
|
| `moonshotai/kimi-k2-0905:exacto` |
|
|
118
118
|
| `moonshotai/kimi-k2-thinking` |
|
|
119
119
|
| `moonshotai/kimi-k2.5` |
|
|
120
|
+
| `moonshotai/kimi-k2.6` |
|
|
120
121
|
| `nousresearch/hermes-3-llama-3.1-405b:free` |
|
|
121
122
|
| `nousresearch/hermes-4-405b` |
|
|
122
123
|
| `nousresearch/hermes-4-70b` |
|
package/.docs/models/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Model Providers
|
|
2
2
|
|
|
3
|
-
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to
|
|
3
|
+
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to 3689 models from 104 providers through a single API.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Deep Infra
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 31 Deep Infra models through Mastra's model router. Authentication is handled automatically using the `DEEPINFRA_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Deep Infra documentation](https://deepinfra.com/models).
|
|
6
6
|
|
|
@@ -54,6 +54,9 @@ for await (const chunk of stream) {
|
|
|
54
54
|
| `deepinfra/openai/gpt-oss-20b` | 131K | | | | | | $0.03 | $0.14 |
|
|
55
55
|
| `deepinfra/Qwen/Qwen3-Coder-480B-A35B-Instruct` | 262K | | | | | | $0.40 | $2 |
|
|
56
56
|
| `deepinfra/Qwen/Qwen3-Coder-480B-A35B-Instruct-Turbo` | 262K | | | | | | $0.30 | $1 |
|
|
57
|
+
| `deepinfra/Qwen/Qwen3.5-35B-A3B` | 262K | | | | | | $0.20 | $0.95 |
|
|
58
|
+
| `deepinfra/Qwen/Qwen3.5-397B-A17B` | 262K | | | | | | $0.54 | $3 |
|
|
59
|
+
| `deepinfra/Qwen/Qwen3.6-35B-A3B` | 262K | | | | | | $0.20 | $1 |
|
|
57
60
|
| `deepinfra/zai-org/GLM-4.6` | 205K | | | | | | $0.43 | $2 |
|
|
58
61
|
| `deepinfra/zai-org/GLM-4.6V` | 205K | | | | | | $0.30 | $0.90 |
|
|
59
62
|
| `deepinfra/zai-org/GLM-4.7` | 203K | | | | | | $0.43 | $2 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Fireworks AI
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 18 Fireworks AI models through Mastra's model router. Authentication is handled automatically using the `FIREWORKS_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Fireworks AI documentation](https://fireworks.ai/docs/).
|
|
6
6
|
|
|
@@ -46,6 +46,7 @@ for await (const chunk of stream) {
|
|
|
46
46
|
| `fireworks-ai/accounts/fireworks/models/kimi-k2-instruct` | 128K | | | | | | $1 | $3 |
|
|
47
47
|
| `fireworks-ai/accounts/fireworks/models/kimi-k2-thinking` | 256K | | | | | | $0.60 | $3 |
|
|
48
48
|
| `fireworks-ai/accounts/fireworks/models/kimi-k2p5` | 256K | | | | | | $0.60 | $3 |
|
|
49
|
+
| `fireworks-ai/accounts/fireworks/models/kimi-k2p6` | 262K | | | | | | $0.95 | $4 |
|
|
49
50
|
| `fireworks-ai/accounts/fireworks/models/minimax-m2p1` | 200K | | | | | | $0.30 | $1 |
|
|
50
51
|
| `fireworks-ai/accounts/fireworks/models/minimax-m2p5` | 197K | | | | | | $0.30 | $1 |
|
|
51
52
|
| `fireworks-ai/accounts/fireworks/models/minimax-m2p7` | 197K | | | | | | $0.30 | $1 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Kilo Gateway
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 335 Kilo Gateway models through Mastra's model router. Authentication is handled automatically using the `KILO_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Kilo Gateway documentation](https://kilo.ai).
|
|
6
6
|
|
|
@@ -189,6 +189,7 @@ for await (const chunk of stream) {
|
|
|
189
189
|
| `kilo/moonshotai/kimi-k2-0905` | 131K | | | | | | $0.40 | $2 |
|
|
190
190
|
| `kilo/moonshotai/kimi-k2-thinking` | 131K | | | | | | $0.47 | $2 |
|
|
191
191
|
| `kilo/moonshotai/kimi-k2.5` | 262K | | | | | | $0.45 | $2 |
|
|
192
|
+
| `kilo/moonshotai/kimi-k2.6` | 262K | | | | | | $0.95 | $4 |
|
|
192
193
|
| `kilo/morph/morph-v3-fast` | 82K | | | | | | $0.80 | $1 |
|
|
193
194
|
| `kilo/morph/morph-v3-large` | 262K | | | | | | $0.90 | $2 |
|
|
194
195
|
| `kilo/nex-agi/deepseek-v3.1-nex-n1` | 131K | | | | | | $0.27 | $1 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Moonshot AI (China)
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 7 Moonshot AI (China) models through Mastra's model router. Authentication is handled automatically using the `MOONSHOT_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Moonshot AI (China) documentation](https://platform.moonshot.cn).
|
|
6
6
|
|
|
@@ -40,6 +40,7 @@ for await (const chunk of stream) {
|
|
|
40
40
|
| `moonshotai-cn/kimi-k2-thinking-turbo` | 262K | | | | | | $1 | $8 |
|
|
41
41
|
| `moonshotai-cn/kimi-k2-turbo-preview` | 262K | | | | | | $2 | $10 |
|
|
42
42
|
| `moonshotai-cn/kimi-k2.5` | 262K | | | | | | $0.60 | $3 |
|
|
43
|
+
| `moonshotai-cn/kimi-k2.6` | 262K | | | | | | $0.95 | $4 |
|
|
43
44
|
|
|
44
45
|
## Advanced configuration
|
|
45
46
|
|
|
@@ -69,7 +70,7 @@ const agent = new Agent({
|
|
|
69
70
|
model: ({ requestContext }) => {
|
|
70
71
|
const useAdvanced = requestContext.task === "complex";
|
|
71
72
|
return useAdvanced
|
|
72
|
-
? "moonshotai-cn/kimi-k2.
|
|
73
|
+
? "moonshotai-cn/kimi-k2.6"
|
|
73
74
|
: "moonshotai-cn/kimi-k2-0711-preview";
|
|
74
75
|
}
|
|
75
76
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Moonshot AI
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 7 Moonshot AI models through Mastra's model router. Authentication is handled automatically using the `MOONSHOT_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Moonshot AI documentation](https://platform.moonshot.ai).
|
|
6
6
|
|
|
@@ -40,6 +40,7 @@ for await (const chunk of stream) {
|
|
|
40
40
|
| `moonshotai/kimi-k2-thinking-turbo` | 262K | | | | | | $1 | $8 |
|
|
41
41
|
| `moonshotai/kimi-k2-turbo-preview` | 262K | | | | | | $2 | $10 |
|
|
42
42
|
| `moonshotai/kimi-k2.5` | 262K | | | | | | $0.60 | $3 |
|
|
43
|
+
| `moonshotai/kimi-k2.6` | 262K | | | | | | $0.95 | $4 |
|
|
43
44
|
|
|
44
45
|
## Advanced configuration
|
|
45
46
|
|
|
@@ -69,7 +70,7 @@ const agent = new Agent({
|
|
|
69
70
|
model: ({ requestContext }) => {
|
|
70
71
|
const useAdvanced = requestContext.task === "complex";
|
|
71
72
|
return useAdvanced
|
|
72
|
-
? "moonshotai/kimi-k2.
|
|
73
|
+
? "moonshotai/kimi-k2.6"
|
|
73
74
|
: "moonshotai/kimi-k2-0711-preview";
|
|
74
75
|
}
|
|
75
76
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# NanoGPT
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 525 NanoGPT models through Mastra's model router. Authentication is handled automatically using the `NANO_GPT_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [NanoGPT documentation](https://docs.nano-gpt.com).
|
|
6
6
|
|
|
@@ -39,6 +39,7 @@ for await (const chunk of stream) {
|
|
|
39
39
|
| `nano-gpt/aion-labs/aion-1.0-mini` | 131K | | | | | | $0.80 | $1 |
|
|
40
40
|
| `nano-gpt/aion-labs/aion-rp-llama-3.1-8b` | 33K | | | | | | $0.20 | $0.20 |
|
|
41
41
|
| `nano-gpt/Alibaba-NLP/Tongyi-DeepResearch-30B-A3B` | 128K | | | | | | $0.08 | $0.24 |
|
|
42
|
+
| `nano-gpt/alibaba/qwen3.6-flash` | 992K | | | | | | $0.19 | $1 |
|
|
42
43
|
| `nano-gpt/allenai/molmo-2-8b` | 37K | | | | | | $0.20 | $0.20 |
|
|
43
44
|
| `nano-gpt/allenai/olmo-3-32b-think` | 128K | | | | | | $0.30 | $0.45 |
|
|
44
45
|
| `nano-gpt/allenai/olmo-3.1-32b-instruct` | 66K | | | | | | $0.20 | $0.60 |
|
|
@@ -367,6 +368,8 @@ for await (const chunk of stream) {
|
|
|
367
368
|
| `nano-gpt/moonshotai/kimi-k2-thinking-turbo-original` | 256K | | | | | | $1 | $8 |
|
|
368
369
|
| `nano-gpt/moonshotai/kimi-k2.5` | 256K | | | | | | $0.30 | $2 |
|
|
369
370
|
| `nano-gpt/moonshotai/kimi-k2.5:thinking` | 256K | | | | | | $0.30 | $2 |
|
|
371
|
+
| `nano-gpt/moonshotai/kimi-k2.6` | 256K | | | | | | $0.53 | $3 |
|
|
372
|
+
| `nano-gpt/moonshotai/kimi-k2.6:thinking` | 256K | | | | | | $0.53 | $3 |
|
|
370
373
|
| `nano-gpt/NeverSleep/Llama-3-Lumimaid-70B-v0.1` | 16K | | | | | | $2 | $2 |
|
|
371
374
|
| `nano-gpt/NeverSleep/Lumimaid-v0.2-70B` | 16K | | | | | | $1 | $2 |
|
|
372
375
|
| `nano-gpt/nex-agi/deepseek-v3.1-nex-n1` | 128K | | | | | | $0.28 | $0.42 |
|
|
@@ -432,12 +435,15 @@ for await (const chunk of stream) {
|
|
|
432
435
|
| `nano-gpt/phi-4-mini-instruct` | 128K | | | | | | $0.17 | $0.68 |
|
|
433
436
|
| `nano-gpt/phi-4-multimodal-instruct` | 128K | | | | | | $0.07 | $0.11 |
|
|
434
437
|
| `nano-gpt/qvq-max` | 128K | | | | | | $1 | $5 |
|
|
438
|
+
| `nano-gpt/qwen-3.6-plus` | 992K | | | | | | $0.45 | $3 |
|
|
435
439
|
| `nano-gpt/qwen-image` | — | | | | | | — | — |
|
|
436
440
|
| `nano-gpt/qwen-long` | 10.0M | | | | | | $0.10 | $0.41 |
|
|
437
441
|
| `nano-gpt/qwen-max` | 32K | | | | | | $2 | $6 |
|
|
438
442
|
| `nano-gpt/qwen-plus` | 996K | | | | | | $0.40 | $1 |
|
|
439
443
|
| `nano-gpt/qwen-turbo` | 1.0M | | | | | | $0.05 | $0.20 |
|
|
440
444
|
| `nano-gpt/qwen/qwen3.5-397b-a17b` | 258K | | | | | | $0.60 | $4 |
|
|
445
|
+
| `nano-gpt/qwen/Qwen3.6-35B-A3B` | 262K | | | | | | $0.29 | $2 |
|
|
446
|
+
| `nano-gpt/qwen/Qwen3.6-35B-A3B:thinking` | 262K | | | | | | $0.29 | $2 |
|
|
441
447
|
| `nano-gpt/Qwen2.5-32B-EVA-v0.2` | 25K | | | | | | $0.49 | $0.49 |
|
|
442
448
|
| `nano-gpt/qwen25-vl-72b-instruct` | 32K | | | | | | $0.70 | $0.70 |
|
|
443
449
|
| `nano-gpt/qwen3-30b-a3b-instruct-2507` | 256K | | | | | | $0.20 | $0.50 |
|
|
@@ -445,6 +451,7 @@ for await (const chunk of stream) {
|
|
|
445
451
|
| `nano-gpt/qwen3-max-2026-01-23` | 256K | | | | | | $1 | $6 |
|
|
446
452
|
| `nano-gpt/qwen3-vl-235b-a22b-instruct-original` | 33K | | | | | | $0.50 | $1 |
|
|
447
453
|
| `nano-gpt/qwen3-vl-235b-a22b-thinking` | 33K | | | | | | $0.50 | $6 |
|
|
454
|
+
| `nano-gpt/qwen3.6-max-preview` | 246K | | | | | | $1 | $8 |
|
|
448
455
|
| `nano-gpt/qwq-32b` | 128K | | | | | | $0.26 | $0.30 |
|
|
449
456
|
| `nano-gpt/QwQ-32B-ArliAI-RpR-v1` | 33K | | | | | | $0.20 | $0.20 |
|
|
450
457
|
| `nano-gpt/raifle/sorcererlm-8x22b` | 16K | | | | | | $5 | $5 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Ollama Cloud
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 37 Ollama Cloud models through Mastra's model router. Authentication is handled automatically using the `OLLAMA_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Ollama Cloud documentation](https://docs.ollama.com/cloud).
|
|
6
6
|
|
|
@@ -53,6 +53,7 @@ for await (const chunk of stream) {
|
|
|
53
53
|
| `ollama-cloud/kimi-k2-thinking` | 262K | | | | | | — | — |
|
|
54
54
|
| `ollama-cloud/kimi-k2:1t` | 262K | | | | | | — | — |
|
|
55
55
|
| `ollama-cloud/kimi-k2.5` | 262K | | | | | | — | — |
|
|
56
|
+
| `ollama-cloud/kimi-k2.6:cloud` | 262K | | | | | | — | — |
|
|
56
57
|
| `ollama-cloud/minimax-m2` | 205K | | | | | | — | — |
|
|
57
58
|
| `ollama-cloud/minimax-m2.1` | 205K | | | | | | — | — |
|
|
58
59
|
| `ollama-cloud/minimax-m2.5` | 205K | | | | | | — | — |
|
|
@@ -37,7 +37,7 @@ for await (const chunk of stream) {
|
|
|
37
37
|
| `opencode-go/glm-5` | 205K | | | | | | $1 | $3 |
|
|
38
38
|
| `opencode-go/glm-5.1` | 205K | | | | | | $1 | $4 |
|
|
39
39
|
| `opencode-go/kimi-k2.5` | 262K | | | | | | $0.60 | $3 |
|
|
40
|
-
| `opencode-go/kimi-k2.6` | 262K | | | | | | $0.
|
|
40
|
+
| `opencode-go/kimi-k2.6` | 262K | | | | | | $0.32 | $1 |
|
|
41
41
|
| `opencode-go/mimo-v2-omni` | 262K | | | | | | $0.40 | $2 |
|
|
42
42
|
| `opencode-go/mimo-v2-pro` | 1.0M | | | | | | $1 | $3 |
|
|
43
43
|
| `opencode-go/minimax-m2.5` | 205K | | | | | | $0.30 | $1 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenCode Zen
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 37 OpenCode Zen models through Mastra's model router. Authentication is handled automatically using the `OPENCODE_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [OpenCode Zen documentation](https://opencode.ai/docs/zen).
|
|
6
6
|
|
|
@@ -64,8 +64,10 @@ for await (const chunk of stream) {
|
|
|
64
64
|
| `opencode/gpt-5.4-nano` | 400K | | | | | | $0.20 | $1 |
|
|
65
65
|
| `opencode/gpt-5.4-pro` | 1.1M | | | | | | $30 | $180 |
|
|
66
66
|
| `opencode/kimi-k2.5` | 262K | | | | | | $0.60 | $3 |
|
|
67
|
+
| `opencode/kimi-k2.6` | 262K | | | | | | $0.95 | $4 |
|
|
67
68
|
| `opencode/minimax-m2.5` | 205K | | | | | | $0.30 | $1 |
|
|
68
69
|
| `opencode/minimax-m2.5-free` | 205K | | | | | | — | — |
|
|
70
|
+
| `opencode/minimax-m2.7` | 205K | | | | | | $0.30 | $1 |
|
|
69
71
|
| `opencode/nemotron-3-super-free` | 205K | | | | | | — | — |
|
|
70
72
|
| `opencode/qwen3.5-plus` | 262K | | | | | | $0.20 | $1 |
|
|
71
73
|
| `opencode/qwen3.6-plus` | 262K | | | | | | $0.50 | $3 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ZenMux
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 89 ZenMux models through Mastra's model router. Authentication is handled automatically using the `ZENMUX_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [ZenMux documentation](https://docs.zenmux.ai).
|
|
6
6
|
|
|
@@ -68,6 +68,7 @@ for await (const chunk of stream) {
|
|
|
68
68
|
| `zenmux/moonshotai/kimi-k2-thinking` | 262K | | | | | | $0.60 | $3 |
|
|
69
69
|
| `zenmux/moonshotai/kimi-k2-thinking-turbo` | 262K | | | | | | $1 | $8 |
|
|
70
70
|
| `zenmux/moonshotai/kimi-k2.5` | 262K | | | | | | $0.58 | $3 |
|
|
71
|
+
| `zenmux/moonshotai/kimi-k2.6` | 262K | | | | | | $0.95 | $4 |
|
|
71
72
|
| `zenmux/openai/gpt-5` | 400K | | | | | | $1 | $10 |
|
|
72
73
|
| `zenmux/openai/gpt-5-codex` | 400K | | | | | | $1 | $10 |
|
|
73
74
|
| `zenmux/openai/gpt-5.1` | 400K | | | | | | $1 | $10 |
|
|
@@ -117,4 +117,17 @@ export const mastra = new Mastra({
|
|
|
117
117
|
],
|
|
118
118
|
},
|
|
119
119
|
})
|
|
120
|
-
```
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
> **Keep bindings inline inside new Mastra({...}):** Mastra's Babel plugin defers `new Mastra(...)` so that `env` is available when it runs. Code outside that call evaluates at module load before `env` is populated.
|
|
123
|
+
>
|
|
124
|
+
> ```typescript
|
|
125
|
+
> // ✅ Works — binding is inside new Mastra(), so it's deferred
|
|
126
|
+
> export const mastra = new Mastra({
|
|
127
|
+
> storage: new D1Store({ binding: env.DB }),
|
|
128
|
+
> })
|
|
129
|
+
>
|
|
130
|
+
> // ❌ Breaks — env.DB is undefined at module load
|
|
131
|
+
> const storage = new D1Store({ binding: env.DB })
|
|
132
|
+
> export const mastra = new Mastra({ storage })
|
|
133
|
+
> ```
|
package/.docs/reference/index.md
CHANGED
|
@@ -201,6 +201,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
201
201
|
- [MongoDB Storage](https://mastra.ai/reference/storage/mongodb)
|
|
202
202
|
- [MSSQL Storage](https://mastra.ai/reference/storage/mssql)
|
|
203
203
|
- [PostgreSQL Storage](https://mastra.ai/reference/storage/postgresql)
|
|
204
|
+
- [Redis Storage](https://mastra.ai/reference/storage/redis)
|
|
204
205
|
- [Upstash Storage](https://mastra.ai/reference/storage/upstash)
|
|
205
206
|
- [ChunkType](https://mastra.ai/reference/streaming/ChunkType)
|
|
206
207
|
- [MastraModelOutput](https://mastra.ai/reference/streaming/agents/MastraModelOutput)
|
|
@@ -217,6 +218,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
217
218
|
- [createVectorQueryTool()](https://mastra.ai/reference/tools/vector-query-tool)
|
|
218
219
|
- [MCPClient](https://mastra.ai/reference/tools/mcp-client)
|
|
219
220
|
- [MCPServer](https://mastra.ai/reference/tools/mcp-server)
|
|
221
|
+
- [Tavily Tools](https://mastra.ai/reference/tools/tavily)
|
|
220
222
|
- [Amazon S3 Vector Store](https://mastra.ai/reference/vectors/s3vectors)
|
|
221
223
|
- [Astra Vector Store](https://mastra.ai/reference/vectors/astra)
|
|
222
224
|
- [Chroma Vector Store](https://mastra.ai/reference/vectors/chroma)
|
|
@@ -34,59 +34,59 @@ bun add @mastra/cloudflare-d1@latest
|
|
|
34
34
|
|
|
35
35
|
## Usage
|
|
36
36
|
|
|
37
|
-
### Using with
|
|
37
|
+
### Using with Mastra CloudflareDeployer
|
|
38
38
|
|
|
39
|
-
|
|
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
|
-
|
|
47
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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 =
|
|
78
|
+
const mastra = new Mastra({
|
|
79
|
+
storage: new D1Store({ binding: env.DB }),
|
|
80
|
+
})
|
|
76
81
|
|
|
77
|
-
|
|
78
|
-
|
|
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 = "
|
|
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": "
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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
|
+
```
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
# Tavily tools
|
|
2
|
+
|
|
3
|
+
**Added in:** `@mastra/tavily@0.1.0-alpha.0`
|
|
4
|
+
|
|
5
|
+
The `@mastra/tavily` package wraps the [Tavily](https://app.tavily.com) API as Mastra-compatible tools. It exposes factory functions for search, extract, crawl, and map — each returning a tool created with [`createTool()`](https://mastra.ai/reference/tools/create-tool) that includes full Zod input/output schemas.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
**npm**:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @mastra/tavily @tavily/core zod
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**pnpm**:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
pnpm add @mastra/tavily @tavily/core zod
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Yarn**:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
yarn add @mastra/tavily @tavily/core zod
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Bun**:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
bun add @mastra/tavily @tavily/core zod
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Quick start
|
|
34
|
+
|
|
35
|
+
Use `createTavilyTools()` to get all four tools with shared configuration:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { createTavilyTools } from '@mastra/tavily'
|
|
39
|
+
|
|
40
|
+
const tools = createTavilyTools()
|
|
41
|
+
// Or pass an explicit API key:
|
|
42
|
+
// const tools = createTavilyTools({ apiKey: 'tvly-...' })
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Each tool can also be created individually:
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { createTavilySearchTool, createTavilyExtractTool } from '@mastra/tavily'
|
|
49
|
+
|
|
50
|
+
const searchTool = createTavilySearchTool()
|
|
51
|
+
const extractTool = createTavilyExtractTool({ apiKey: 'tvly-...' })
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
By default, all tools read `TAVILY_API_KEY` from the environment. You can pass `{ apiKey }` explicitly to override.
|
|
55
|
+
|
|
56
|
+
## Configuration
|
|
57
|
+
|
|
58
|
+
All factory functions accept `TavilyClientOptions` from `@tavily/core`:
|
|
59
|
+
|
|
60
|
+
**apiKey** (`string`): Tavily API key. Falls back to the \`TAVILY\_API\_KEY\` environment variable.
|
|
61
|
+
|
|
62
|
+
**clientSource** (`string`): Attribution string sent with each request. (Default: `'mastra'`)
|
|
63
|
+
|
|
64
|
+
**apiBaseURL** (`string`): Base URL for the Tavily API.
|
|
65
|
+
|
|
66
|
+
**proxies** (`object`): Proxy configuration passed to the underlying HTTP client.
|
|
67
|
+
|
|
68
|
+
**projectId** (`string`): Tavily project ID for request scoping.
|
|
69
|
+
|
|
70
|
+
## `createTavilyTools()`
|
|
71
|
+
|
|
72
|
+
Returns an object containing all four tools with a shared configuration.
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { createTavilyTools } from '@mastra/tavily'
|
|
76
|
+
|
|
77
|
+
const tools = createTavilyTools({ apiKey: 'tvly-...' })
|
|
78
|
+
// tools.tavilySearch, tools.tavilyExtract, tools.tavilyCrawl, tools.tavilyMap
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Returns:** `{ tavilySearch, tavilyExtract, tavilyCrawl, tavilyMap }`
|
|
82
|
+
|
|
83
|
+
## `createTavilySearchTool()`
|
|
84
|
+
|
|
85
|
+
Creates a tool that searches the web using Tavily. Returns relevant results with content snippets, optional AI-generated answers, and images.
|
|
86
|
+
|
|
87
|
+
**Tool ID:** `tavily-search`
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import { createTavilySearchTool } from '@mastra/tavily'
|
|
91
|
+
|
|
92
|
+
const searchTool = createTavilySearchTool()
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Input
|
|
96
|
+
|
|
97
|
+
**query** (`string`): The search query.
|
|
98
|
+
|
|
99
|
+
**searchDepth** (`'basic' | 'advanced' | 'fast' | 'ultra-fast'`): Search depth. Use 'basic' for standard results, 'advanced' for more thorough results, or 'fast'/'ultra-fast' for low latency.
|
|
100
|
+
|
|
101
|
+
**maxResults** (`number`): Maximum number of results to return (1-20).
|
|
102
|
+
|
|
103
|
+
**includeAnswer** (`boolean | 'basic' | 'advanced'`): Include an AI-generated answer summary.
|
|
104
|
+
|
|
105
|
+
**includeImages** (`boolean`): Include query-related images in the response.
|
|
106
|
+
|
|
107
|
+
**includeImageDescriptions** (`boolean`): Include descriptions for returned images.
|
|
108
|
+
|
|
109
|
+
**includeRawContent** (`false | 'markdown' | 'text'`): Include cleaned HTML content of each result. Pass false to disable, or 'markdown'/'text' for format.
|
|
110
|
+
|
|
111
|
+
**includeDomains** (`string[]`): Restrict results to these domains.
|
|
112
|
+
|
|
113
|
+
**excludeDomains** (`string[]`): Exclude results from these domains.
|
|
114
|
+
|
|
115
|
+
**timeRange** (`'day' | 'week' | 'month' | 'year'`): Filter results by recency.
|
|
116
|
+
|
|
117
|
+
### Output
|
|
118
|
+
|
|
119
|
+
**query** (`string`): The original search query.
|
|
120
|
+
|
|
121
|
+
**answer** (`string`): AI-generated answer summary.
|
|
122
|
+
|
|
123
|
+
**images** (`{ url: string; description?: string }[]`): Related images.
|
|
124
|
+
|
|
125
|
+
**results** (`SearchResult[]`): Array of search results.
|
|
126
|
+
|
|
127
|
+
**results.title** (`string`): Result title.
|
|
128
|
+
|
|
129
|
+
**results.url** (`string`): Result URL.
|
|
130
|
+
|
|
131
|
+
**results.content** (`string`): Content snippet.
|
|
132
|
+
|
|
133
|
+
**results.score** (`number`): Relevance score.
|
|
134
|
+
|
|
135
|
+
**results.rawContent** (`string`): Full-page content (when requested).
|
|
136
|
+
|
|
137
|
+
**responseTime** (`number`): Server response time in seconds.
|
|
138
|
+
|
|
139
|
+
## `createTavilyExtractTool()`
|
|
140
|
+
|
|
141
|
+
Creates a tool that extracts content from one or more URLs. Returns raw page content in markdown or text format with up to 20 URLs per request.
|
|
142
|
+
|
|
143
|
+
**Tool ID:** `tavily-extract`
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
import { createTavilyExtractTool } from '@mastra/tavily'
|
|
147
|
+
|
|
148
|
+
const extractTool = createTavilyExtractTool()
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Input
|
|
152
|
+
|
|
153
|
+
**urls** (`string[]`): URLs to extract content from (1-20).
|
|
154
|
+
|
|
155
|
+
**extractDepth** (`'basic' | 'advanced'`): Extraction depth. Use 'advanced' to retrieve tables and embedded content.
|
|
156
|
+
|
|
157
|
+
**query** (`string`): User intent for reranking extracted content chunks by relevance.
|
|
158
|
+
|
|
159
|
+
**includeImages** (`boolean`): Include images extracted from the pages.
|
|
160
|
+
|
|
161
|
+
**format** (`'markdown' | 'text'`): Output format for extracted content. (Default: `'markdown'`)
|
|
162
|
+
|
|
163
|
+
### Output
|
|
164
|
+
|
|
165
|
+
**results** (`ExtractResult[]`): Successfully extracted pages.
|
|
166
|
+
|
|
167
|
+
**results.url** (`string`): Page URL.
|
|
168
|
+
|
|
169
|
+
**results.rawContent** (`string`): Extracted page content.
|
|
170
|
+
|
|
171
|
+
**results.images** (`string[]`): Extracted image URLs.
|
|
172
|
+
|
|
173
|
+
**failedResults** (`FailedResult[]`): URLs that failed extraction.
|
|
174
|
+
|
|
175
|
+
**failedResults.url** (`string`): Failed URL.
|
|
176
|
+
|
|
177
|
+
**failedResults.error** (`string`): Error message.
|
|
178
|
+
|
|
179
|
+
**responseTime** (`number`): Server response time in seconds.
|
|
180
|
+
|
|
181
|
+
## `createTavilyCrawlTool()`
|
|
182
|
+
|
|
183
|
+
Creates a tool that crawls a website starting from a URL. Extracts content from discovered pages with configurable depth, breadth, and domain constraints.
|
|
184
|
+
|
|
185
|
+
**Tool ID:** `tavily-crawl`
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
import { createTavilyCrawlTool } from '@mastra/tavily'
|
|
189
|
+
|
|
190
|
+
const crawlTool = createTavilyCrawlTool()
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Input
|
|
194
|
+
|
|
195
|
+
**url** (`string`): The root URL to begin the crawl.
|
|
196
|
+
|
|
197
|
+
**maxDepth** (`number`): Maximum depth of the crawl from the base URL.
|
|
198
|
+
|
|
199
|
+
**maxBreadth** (`number`): Maximum number of links to follow per page.
|
|
200
|
+
|
|
201
|
+
**limit** (`number`): Total number of pages the crawler processes before stopping.
|
|
202
|
+
|
|
203
|
+
**instructions** (`string`): Natural language instructions for the crawler.
|
|
204
|
+
|
|
205
|
+
**selectPaths** (`string[]`): Regex patterns to select specific URL paths.
|
|
206
|
+
|
|
207
|
+
**selectDomains** (`string[]`): Regex patterns to restrict to specific domains.
|
|
208
|
+
|
|
209
|
+
**excludePaths** (`string[]`): Regex patterns to exclude specific URL paths.
|
|
210
|
+
|
|
211
|
+
**excludeDomains** (`string[]`): Regex patterns to exclude specific domains.
|
|
212
|
+
|
|
213
|
+
**allowExternal** (`boolean`): Whether to follow links to external domains.
|
|
214
|
+
|
|
215
|
+
**extractDepth** (`'basic' | 'advanced'`): Extraction depth. Use 'advanced' to retrieve tables and embedded content.
|
|
216
|
+
|
|
217
|
+
**includeImages** (`boolean`): Include images from crawled pages.
|
|
218
|
+
|
|
219
|
+
**format** (`'markdown' | 'text'`): Output format for extracted content. (Default: `'markdown'`)
|
|
220
|
+
|
|
221
|
+
### Output
|
|
222
|
+
|
|
223
|
+
**baseUrl** (`string`): The root URL that was crawled.
|
|
224
|
+
|
|
225
|
+
**results** (`CrawlResult[]`): Content extracted from discovered pages.
|
|
226
|
+
|
|
227
|
+
**results.url** (`string`): Page URL.
|
|
228
|
+
|
|
229
|
+
**results.rawContent** (`string`): Extracted page content.
|
|
230
|
+
|
|
231
|
+
**results.images** (`string[]`): Image URLs found on the page.
|
|
232
|
+
|
|
233
|
+
**responseTime** (`number`): Server response time in seconds.
|
|
234
|
+
|
|
235
|
+
## `createTavilyMapTool()`
|
|
236
|
+
|
|
237
|
+
Creates a tool that maps a website's structure starting from a URL. Discovers and returns a list of URLs without extracting page content. Use this to understand site structure before targeted extraction.
|
|
238
|
+
|
|
239
|
+
**Tool ID:** `tavily-map`
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
import { createTavilyMapTool } from '@mastra/tavily'
|
|
243
|
+
|
|
244
|
+
const mapTool = createTavilyMapTool()
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Input
|
|
248
|
+
|
|
249
|
+
**url** (`string`): The root URL to begin mapping.
|
|
250
|
+
|
|
251
|
+
**maxDepth** (`number`): Maximum depth of the mapping from the base URL.
|
|
252
|
+
|
|
253
|
+
**maxBreadth** (`number`): Maximum number of links to follow per page.
|
|
254
|
+
|
|
255
|
+
**limit** (`number`): Total number of links the mapper processes before stopping.
|
|
256
|
+
|
|
257
|
+
**instructions** (`string`): Natural language instructions for the mapper.
|
|
258
|
+
|
|
259
|
+
**selectPaths** (`string[]`): Regex patterns to select specific URL paths.
|
|
260
|
+
|
|
261
|
+
**selectDomains** (`string[]`): Regex patterns to restrict to specific domains.
|
|
262
|
+
|
|
263
|
+
**excludePaths** (`string[]`): Regex patterns to exclude specific URL paths.
|
|
264
|
+
|
|
265
|
+
**excludeDomains** (`string[]`): Regex patterns to exclude specific domains.
|
|
266
|
+
|
|
267
|
+
**allowExternal** (`boolean`): Whether to include external domain links.
|
|
268
|
+
|
|
269
|
+
### Output
|
|
270
|
+
|
|
271
|
+
**baseUrl** (`string`): The root URL that was mapped.
|
|
272
|
+
|
|
273
|
+
**results** (`string[]`): Discovered URLs.
|
|
274
|
+
|
|
275
|
+
**responseTime** (`number`): Server response time in seconds.
|
|
276
|
+
|
|
277
|
+
## Agent example
|
|
278
|
+
|
|
279
|
+
The following example demonstrates a research agent that combines search and extract:
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
import { Agent } from '@mastra/core/agent'
|
|
283
|
+
import { createTavilySearchTool, createTavilyExtractTool } from '@mastra/tavily'
|
|
284
|
+
|
|
285
|
+
const agent = new Agent({
|
|
286
|
+
id: 'web-search-agent',
|
|
287
|
+
name: 'Web Search Agent',
|
|
288
|
+
model: 'anthropic/claude-sonnet-4-6',
|
|
289
|
+
instructions:
|
|
290
|
+
'You are a web search assistant. Use search tool to find relevant pages, then use extract tool to get full content from the best results.',
|
|
291
|
+
tools: {
|
|
292
|
+
search: createTavilySearchTool(),
|
|
293
|
+
extract: createTavilyExtractTool(),
|
|
294
|
+
},
|
|
295
|
+
})
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Environment variables
|
|
299
|
+
|
|
300
|
+
| Variable | Description |
|
|
301
|
+
| ---------------- | ------------------------------------------------------------------------------------------- |
|
|
302
|
+
| `TAVILY_API_KEY` | Your Tavily API key. Used as the default when `apiKey` is not passed to a factory function. |
|
|
303
|
+
|
|
304
|
+
## Related
|
|
305
|
+
|
|
306
|
+
- [`createTool()`](https://mastra.ai/reference/tools/create-tool)
|
|
307
|
+
- [Tavily API documentation](https://docs.tavily.com)
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.1.26-alpha.23
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`a371ac5`](https://github.com/mastra-ai/mastra/commit/a371ac534aa1bb368a1acf9d8b313378dfdc787e), [`47cee3e`](https://github.com/mastra-ai/mastra/commit/47cee3e137fe39109cf7fffd2a8cf47b76dc702e), [`c80dc16`](https://github.com/mastra-ai/mastra/commit/c80dc16e113e6cc159f510ffde501ad4711b2189), [`47cee3e`](https://github.com/mastra-ai/mastra/commit/47cee3e137fe39109cf7fffd2a8cf47b76dc702e)]:
|
|
8
|
+
- @mastra/core@1.26.0-alpha.12
|
|
9
|
+
|
|
10
|
+
## 1.1.26-alpha.21
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`20f59b8`](https://github.com/mastra-ai/mastra/commit/20f59b876cf91199efbc49a0e36b391240708f08), [`e2687a7`](https://github.com/mastra-ai/mastra/commit/e2687a7408790c384563816a9a28ed06735684c9), [`8f1b280`](https://github.com/mastra-ai/mastra/commit/8f1b280b7fe6999ec654f160cb69c1a8719e7a57), [`12df98c`](https://github.com/mastra-ai/mastra/commit/12df98c4904643d9481f5c78f3bed443725b4c96)]:
|
|
15
|
+
- @mastra/core@1.26.0-alpha.11
|
|
16
|
+
|
|
3
17
|
## 1.1.26-alpha.19
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.1.26-alpha.
|
|
3
|
+
"version": "1.1.26-alpha.23",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,26 +29,26 @@
|
|
|
29
29
|
"jsdom": "^26.1.0",
|
|
30
30
|
"local-pkg": "^1.1.2",
|
|
31
31
|
"zod": "^4.3.6",
|
|
32
|
-
"@mastra/
|
|
33
|
-
"@mastra/
|
|
32
|
+
"@mastra/mcp": "^1.5.1-alpha.1",
|
|
33
|
+
"@mastra/core": "1.26.0-alpha.12"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@hono/node-server": "^1.19.11",
|
|
37
37
|
"@types/jsdom": "^21.1.7",
|
|
38
38
|
"@types/node": "22.19.15",
|
|
39
|
-
"@vitest/coverage-v8": "4.
|
|
40
|
-
"@vitest/ui": "4.
|
|
39
|
+
"@vitest/coverage-v8": "4.1.4",
|
|
40
|
+
"@vitest/ui": "4.1.4",
|
|
41
41
|
"@wong2/mcp-cli": "^1.13.0",
|
|
42
42
|
"cross-env": "^10.1.0",
|
|
43
|
-
"eslint": "^
|
|
43
|
+
"eslint": "^10.2.1",
|
|
44
44
|
"hono": "^4.12.8",
|
|
45
45
|
"tsup": "^8.5.1",
|
|
46
46
|
"tsx": "^4.21.0",
|
|
47
47
|
"typescript": "^5.9.3",
|
|
48
|
-
"vitest": "4.
|
|
48
|
+
"vitest": "4.1.4",
|
|
49
49
|
"@internal/lint": "0.0.83",
|
|
50
50
|
"@internal/types-builder": "0.0.58",
|
|
51
|
-
"@mastra/core": "1.26.0-alpha.
|
|
51
|
+
"@mastra/core": "1.26.0-alpha.12"
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://mastra.ai",
|
|
54
54
|
"repository": {
|