@mastra/mcp-docs-server 0.0.0-studio-deploy-20260404184540 → 0.0.0-studio-cli-20260504022012
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/adding-voice.md +18 -17
- package/.docs/docs/agents/background-tasks.md +242 -0
- package/.docs/docs/agents/channels.md +2 -1
- package/.docs/docs/agents/overview.md +4 -0
- package/.docs/docs/agents/processors.md +177 -5
- package/.docs/docs/agents/structured-output.md +66 -1
- package/.docs/docs/agents/supervisor-agents.md +65 -0
- package/.docs/docs/agents/using-tools.md +73 -0
- package/.docs/docs/browser/agent-browser.md +78 -0
- package/.docs/docs/browser/browser-viewer.md +144 -0
- package/.docs/docs/browser/overview.md +168 -0
- package/.docs/docs/browser/stagehand.md +129 -0
- package/.docs/docs/deployment/cloud-providers.md +5 -1
- package/.docs/docs/deployment/mastra-server.md +4 -4
- package/.docs/docs/deployment/monorepo.md +3 -3
- package/.docs/docs/deployment/overview.md +11 -8
- package/.docs/docs/editor/overview.md +290 -0
- package/.docs/docs/editor/prompts.md +134 -0
- package/.docs/docs/editor/tools.md +152 -0
- package/.docs/docs/evals/custom-scorers.md +63 -3
- package/.docs/docs/evals/datasets/overview.md +1 -1
- package/.docs/docs/index.md +2 -2
- package/.docs/docs/mastra-platform/configuration.md +36 -0
- package/.docs/docs/mastra-platform/overview.md +78 -0
- package/.docs/docs/mcp/overview.md +17 -0
- package/.docs/docs/memory/memory-processors.md +3 -3
- package/.docs/docs/memory/message-history.md +8 -2
- package/.docs/docs/memory/observational-memory.md +65 -8
- package/.docs/docs/memory/storage.md +1 -2
- package/.docs/docs/memory/working-memory.md +2 -2
- package/.docs/docs/observability/logging.md +1 -1
- package/.docs/docs/observability/metrics/overview.md +2 -2
- package/.docs/docs/observability/overview.md +1 -1
- package/.docs/docs/observability/tracing/bridges/datadog.md +217 -0
- package/.docs/docs/observability/tracing/bridges/otel.md +2 -2
- package/.docs/docs/observability/tracing/exporters/arthur.md +163 -0
- package/.docs/docs/observability/tracing/exporters/cloud.md +135 -63
- package/.docs/docs/observability/tracing/exporters/datadog.md +3 -1
- package/.docs/docs/observability/tracing/exporters/default.md +5 -5
- package/.docs/docs/observability/tracing/exporters/laminar.md +22 -14
- package/.docs/docs/observability/tracing/exporters/langfuse.md +50 -33
- package/.docs/docs/observability/tracing/overview.md +87 -20
- package/.docs/docs/server/custom-adapters.md +5 -5
- package/.docs/docs/server/custom-api-routes.md +3 -3
- package/.docs/docs/server/middleware.md +46 -42
- package/.docs/docs/server/request-context.md +13 -2
- package/.docs/docs/server/server-adapters.md +91 -8
- package/.docs/docs/streaming/background-task-streaming.md +80 -0
- package/.docs/docs/streaming/overview.md +3 -0
- package/.docs/docs/studio/deployment.md +24 -6
- package/.docs/docs/studio/observability.md +1 -1
- package/.docs/docs/studio/overview.md +4 -4
- package/.docs/docs/voice/overview.md +74 -5
- package/.docs/docs/voice/speech-to-speech.md +45 -1
- package/.docs/docs/voice/speech-to-text.md +7 -7
- package/.docs/docs/voice/text-to-speech.md +10 -10
- package/.docs/docs/workflows/agents-and-tools.md +1 -1
- package/.docs/docs/workflows/overview.md +105 -4
- package/.docs/docs/workflows/scheduled-workflows.md +181 -0
- package/.docs/docs/workspace/filesystem.md +64 -6
- package/.docs/docs/workspace/lsp.md +76 -4
- package/.docs/docs/workspace/overview.md +27 -8
- package/.docs/docs/workspace/sandbox.md +3 -1
- package/.docs/docs/workspace/search.md +41 -2
- package/.docs/docs/workspace/skills.md +19 -19
- package/.docs/guides/agent-frameworks/ai-sdk.md +4 -4
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +56 -9
- package/.docs/guides/build-your-ui/assistant-ui.md +1 -1
- package/.docs/guides/deployment/mastra-platform.md +191 -0
- package/.docs/guides/deployment/netlify.md +16 -1
- package/.docs/guides/getting-started/nestjs.md +238 -0
- package/.docs/guides/getting-started/next-js.md +0 -4
- package/.docs/guides/guide/code-review-bot.md +2 -2
- package/.docs/guides/guide/dev-assistant.md +4 -4
- package/.docs/{docs/mcp → guides/guide}/publishing-mcp-server.md +21 -1
- package/.docs/guides/guide/slack-assistant.md +191 -0
- package/.docs/guides/migrations/mastra-cloud.md +368 -0
- package/.docs/guides/migrations/upgrade-to-v1/tracing.md +1 -1
- package/.docs/models/embeddings.md +3 -3
- package/.docs/models/gateways/azure-openai.md +74 -35
- package/.docs/models/gateways/mastra.md +64 -0
- package/.docs/models/gateways/netlify.md +7 -3
- package/.docs/models/gateways/openrouter.md +28 -12
- package/.docs/models/gateways/vercel.md +16 -1
- package/.docs/models/gateways.md +1 -0
- package/.docs/models/index.md +43 -8
- package/.docs/models/providers/302ai.md +37 -4
- package/.docs/models/providers/abliteration-ai.md +71 -0
- package/.docs/models/providers/alibaba-cn.md +7 -2
- package/.docs/models/providers/alibaba-coding-plan-cn.md +3 -2
- package/.docs/models/providers/alibaba-coding-plan.md +3 -2
- package/.docs/models/providers/alibaba.md +8 -1
- package/.docs/models/providers/anthropic.md +18 -5
- package/.docs/models/providers/baseten.md +3 -1
- package/.docs/models/providers/berget.md +10 -12
- package/.docs/models/providers/chutes.md +4 -2
- package/.docs/models/providers/cloudflare-workers-ai.md +14 -48
- package/.docs/models/providers/cortecs.md +22 -2
- package/.docs/models/providers/deepinfra.md +8 -2
- package/.docs/models/providers/deepseek.md +6 -4
- package/.docs/models/providers/digitalocean.md +133 -0
- package/.docs/models/providers/fireworks-ai.md +6 -1
- package/.docs/models/providers/firmware.md +12 -10
- package/.docs/models/providers/friendli.md +6 -7
- package/.docs/models/providers/google.md +8 -4
- package/.docs/models/providers/helicone.md +1 -2
- package/.docs/models/providers/hpc-ai.md +73 -0
- package/.docs/models/providers/huggingface.md +6 -2
- package/.docs/models/providers/inception.md +9 -11
- package/.docs/models/providers/kilo.md +359 -339
- package/.docs/models/providers/kimi-for-coding.md +2 -1
- package/.docs/models/providers/llmgateway.md +67 -77
- package/.docs/models/providers/mistral.md +3 -2
- package/.docs/models/providers/mixlayer.md +75 -0
- 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 -2
- package/.docs/models/providers/neuralwatt.md +84 -0
- package/.docs/models/providers/novita-ai.md +19 -4
- package/.docs/models/providers/nvidia.md +8 -1
- package/.docs/models/providers/ollama-cloud.md +7 -2
- package/.docs/models/providers/openai.md +7 -2
- package/.docs/models/providers/opencode-go.md +21 -13
- package/.docs/models/providers/opencode.md +11 -4
- package/.docs/models/providers/ovhcloud.md +6 -8
- package/.docs/models/providers/poe.md +10 -15
- package/.docs/models/providers/regolo-ai.md +83 -0
- package/.docs/models/providers/siliconflow-cn.md +5 -2
- package/.docs/models/providers/siliconflow.md +6 -3
- package/.docs/models/providers/stepfun.md +8 -7
- package/.docs/models/providers/synthetic.md +5 -2
- package/.docs/models/providers/tencent-token-plan.md +71 -0
- package/.docs/models/providers/tencent-tokenhub.md +71 -0
- package/.docs/models/providers/togetherai.md +8 -7
- package/.docs/models/providers/vivgrid.md +7 -3
- package/.docs/models/providers/vultr.md +7 -6
- package/.docs/models/providers/wafer.ai.md +73 -0
- package/.docs/models/providers/wandb.md +3 -2
- package/.docs/models/providers/xai.md +6 -1
- package/.docs/models/providers/xiaomi-token-plan-ams.md +9 -7
- package/.docs/models/providers/xiaomi-token-plan-cn.md +9 -7
- package/.docs/models/providers/xiaomi-token-plan-sgp.md +9 -7
- package/.docs/models/providers/xiaomi.md +4 -2
- package/.docs/models/providers/zai-coding-plan.md +11 -19
- package/.docs/models/providers/zai.md +2 -1
- package/.docs/models/providers/zenmux.md +13 -5
- package/.docs/models/providers/zhipuai-coding-plan.md +11 -21
- package/.docs/models/providers/zhipuai.md +2 -1
- package/.docs/models/providers.md +8 -0
- package/.docs/reference/agents/agent.md +1 -1
- package/.docs/reference/agents/channels.md +3 -3
- package/.docs/reference/agents/generate.md +88 -6
- package/.docs/reference/agents/generateLegacy.md +1 -1
- package/.docs/reference/ai-sdk/chat-route.md +2 -0
- package/.docs/reference/ai-sdk/handle-chat-stream.md +19 -0
- package/.docs/reference/ai-sdk/handle-network-stream.md +2 -0
- package/.docs/reference/ai-sdk/network-route.md +2 -0
- package/.docs/reference/ai-sdk/to-ai-sdk-messages.md +95 -0
- package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +15 -0
- package/.docs/reference/browser/agent-browser.md +375 -0
- package/.docs/reference/browser/browser-viewer.md +228 -0
- package/.docs/reference/browser/mastra-browser.md +286 -0
- package/.docs/reference/browser/stagehand-browser.md +286 -0
- package/.docs/reference/cli/mastra.md +703 -0
- package/.docs/reference/client-js/agents.md +166 -0
- package/.docs/reference/client-js/mastra-client.md +23 -0
- package/.docs/reference/client-js/observability.md +2 -2
- package/.docs/reference/client-js/workflows.md +62 -1
- package/.docs/reference/configuration.md +67 -1
- package/.docs/reference/core/addGateway.md +5 -5
- package/.docs/reference/core/getEditor.md +35 -0
- package/.docs/reference/core/getGateway.md +5 -5
- package/.docs/reference/core/getGatewayById.md +5 -5
- package/.docs/reference/core/getMCPServer.md +2 -2
- package/.docs/reference/core/getMCPServerById.md +2 -2
- package/.docs/reference/core/getScorer.md +3 -3
- package/.docs/reference/core/getScorerById.md +3 -3
- package/.docs/reference/core/listGateways.md +5 -5
- package/.docs/reference/core/listMCPServers.md +2 -2
- package/.docs/reference/core/listScorers.md +3 -3
- package/.docs/reference/core/mastra-class.md +11 -1
- package/.docs/reference/core/mastra-model-gateway.md +5 -5
- package/.docs/reference/datasets/create.md +4 -4
- package/.docs/reference/datasets/startExperiment.md +28 -2
- package/.docs/reference/datasets/update.md +4 -4
- package/.docs/reference/deployer/cloudflare.md +14 -1
- package/.docs/reference/deployer/netlify.md +50 -2
- package/.docs/reference/editor/mastra-editor.md +168 -0
- package/.docs/reference/editor/tool-provider.md +85 -0
- package/.docs/reference/evals/context-precision.md +3 -3
- package/.docs/reference/evals/context-relevance.md +3 -3
- package/.docs/reference/evals/create-scorer.md +5 -3
- package/.docs/reference/evals/filter-run.md +117 -0
- package/.docs/reference/evals/mastra-scorer.md +4 -4
- package/.docs/reference/evals/noise-sensitivity.md +6 -6
- package/.docs/reference/evals/prompt-alignment.md +12 -12
- package/.docs/reference/evals/run-evals.md +6 -6
- package/.docs/reference/evals/scorer-utils.md +3 -3
- package/.docs/reference/evals/trajectory-accuracy.md +3 -3
- package/.docs/reference/harness/harness-class.md +152 -53
- package/.docs/reference/index.md +25 -0
- package/.docs/reference/logging/pino-logger.md +0 -2
- package/.docs/reference/mastra-platform/api.md +108 -0
- package/.docs/reference/memory/clone-utilities.md +4 -2
- package/.docs/reference/memory/cloneThread.md +4 -2
- package/.docs/reference/memory/observational-memory.md +4 -0
- package/.docs/reference/observability/metrics/automatic-metrics.md +3 -3
- package/.docs/reference/observability/tracing/bridges/datadog.md +211 -0
- package/.docs/reference/observability/tracing/bridges/otel.md +3 -3
- package/.docs/reference/observability/tracing/configuration.md +18 -11
- package/.docs/reference/observability/tracing/exporters/arthur.md +122 -0
- package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +102 -21
- package/.docs/reference/observability/tracing/exporters/console-exporter.md +8 -8
- package/.docs/reference/observability/tracing/exporters/datadog.md +3 -1
- package/.docs/reference/observability/tracing/exporters/default-exporter.md +8 -8
- package/.docs/reference/observability/tracing/exporters/langfuse.md +25 -32
- package/.docs/reference/observability/tracing/exporters/otel.md +3 -3
- package/.docs/reference/observability/tracing/instances.md +7 -7
- package/.docs/reference/observability/tracing/interfaces.md +23 -6
- package/.docs/reference/observability/tracing/span-filtering.md +95 -0
- package/.docs/reference/observability/tracing/spans.md +6 -6
- package/.docs/reference/processors/prefill-error-handler.md +70 -0
- package/.docs/reference/processors/processor-interface.md +400 -40
- package/.docs/reference/processors/skill-search-processor.md +20 -1
- package/.docs/reference/processors/stream-error-retry-processor.md +54 -0
- package/.docs/reference/processors/tool-call-filter.md +23 -0
- package/.docs/reference/server/create-route.md +3 -3
- package/.docs/reference/server/express-adapter.md +4 -4
- package/.docs/reference/server/fastify-adapter.md +4 -4
- package/.docs/reference/server/hono-adapter.md +4 -4
- package/.docs/reference/server/koa-adapter.md +4 -4
- package/.docs/reference/server/mastra-server.md +3 -3
- package/.docs/reference/server/nestjs-adapter.md +169 -0
- package/.docs/reference/server/register-api-route.md +4 -4
- package/.docs/reference/server/routes.md +11 -10
- package/.docs/reference/storage/clickhouse.md +300 -0
- package/.docs/reference/storage/cloudflare-d1.md +42 -42
- package/.docs/reference/storage/composite.md +5 -3
- package/.docs/reference/storage/duckdb.md +150 -0
- package/.docs/reference/storage/overview.md +1 -1
- package/.docs/reference/storage/redis.md +266 -0
- package/.docs/reference/streaming/ChunkType.md +143 -3
- package/.docs/reference/streaming/agents/MastraModelOutput.md +2 -2
- package/.docs/reference/streaming/agents/stream.md +10 -2
- package/.docs/reference/streaming/agents/streamUntilIdle.md +94 -0
- package/.docs/reference/streaming/workflows/resumeStream.md +2 -0
- package/.docs/reference/templates/overview.md +88 -14
- package/.docs/reference/tools/create-tool.md +107 -5
- package/.docs/reference/tools/mcp-client.md +45 -0
- package/.docs/reference/tools/mcp-server.md +1 -3
- package/.docs/reference/tools/perplexity.md +155 -0
- package/.docs/reference/tools/tavily.md +307 -0
- package/.docs/reference/vectors/mongodb.md +0 -2
- package/.docs/reference/voice/aws-nova-sonic.md +247 -0
- package/.docs/reference/voice/cloudflare.md +3 -3
- package/.docs/reference/voice/sarvam.md +29 -23
- package/.docs/reference/voice/voice.connect.md +4 -4
- package/.docs/reference/voice/voice.listen.md +3 -3
- package/.docs/reference/workflows/run-methods/resume.md +24 -0
- package/.docs/reference/workflows/run-methods/startAsync.md +1 -1
- package/.docs/reference/workflows/step.md +88 -7
- package/.docs/reference/workflows/workflow-methods/foreach.md +14 -1
- package/.docs/reference/workflows/workflow.md +88 -4
- package/.docs/reference/workspace/azure-blob-filesystem.md +219 -0
- package/.docs/reference/workspace/docker-sandbox.md +196 -0
- package/.docs/reference/workspace/gcs-filesystem.md +1 -0
- package/.docs/reference/workspace/google-drive-filesystem.md +185 -0
- package/.docs/reference/workspace/modal-sandbox.md +168 -0
- package/.docs/reference/workspace/process-manager.md +1 -1
- package/.docs/reference/workspace/s3-filesystem.md +80 -5
- package/.docs/reference/workspace/vercel.md +1 -1
- package/.docs/reference/workspace/workspace-class.md +37 -6
- package/CHANGELOG.md +486 -4
- package/dist/stdio.js.map +1 -1
- package/dist/utils.d.ts +1 -4
- package/dist/utils.d.ts.map +1 -1
- package/package.json +11 -11
- package/.docs/docs/mastra-cloud/deployment.md +0 -77
- package/.docs/docs/mastra-cloud/observability.md +0 -38
- package/.docs/docs/mastra-cloud/overview.md +0 -23
- package/.docs/docs/mastra-cloud/setup.md +0 -42
|
@@ -4,10 +4,10 @@ This reference provides comprehensive information about Mastra templates, includ
|
|
|
4
4
|
|
|
5
5
|
Mastra templates are pre-built project structures that demonstrate specific use cases and patterns. They provide:
|
|
6
6
|
|
|
7
|
-
- **Working examples
|
|
8
|
-
- **Best practices
|
|
9
|
-
- **Educational resources
|
|
10
|
-
- **Quickstarts
|
|
7
|
+
- **Working examples**: Complete, functional Mastra applications
|
|
8
|
+
- **Best practices**: Proper project structure and coding conventions
|
|
9
|
+
- **Educational resources**: Learn Mastra patterns through real implementations
|
|
10
|
+
- **Quickstarts**: Bootstrap projects faster than building from scratch
|
|
11
11
|
|
|
12
12
|
## Using templates
|
|
13
13
|
|
|
@@ -15,10 +15,30 @@ Mastra templates are pre-built project structures that demonstrate specific use
|
|
|
15
15
|
|
|
16
16
|
Install a template using the `create-mastra` command:
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
**npm**:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
19
21
|
npx create-mastra@latest --template template-name
|
|
20
22
|
```
|
|
21
23
|
|
|
24
|
+
**pnpm**:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
pnpm dlx create-mastra@latest --template template-name
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Yarn**:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
yarn dlx create-mastra@latest --template template-name
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Bun**:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
bun x create-mastra@latest --template template-name
|
|
40
|
+
```
|
|
41
|
+
|
|
22
42
|
This creates a complete project with all necessary code and configuration.
|
|
23
43
|
|
|
24
44
|
### Setup Process
|
|
@@ -41,20 +61,74 @@ After installation:
|
|
|
41
61
|
|
|
42
62
|
3. **Install dependencies** (if not done automatically):
|
|
43
63
|
|
|
44
|
-
|
|
64
|
+
**npm**:
|
|
65
|
+
|
|
66
|
+
```sh
|
|
45
67
|
npm install
|
|
46
68
|
```
|
|
47
69
|
|
|
70
|
+
**pnpm**:
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
pnpm install
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Yarn**:
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
yarn install
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Bun**:
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
bun install
|
|
86
|
+
```
|
|
87
|
+
|
|
48
88
|
4. **Start development server**:
|
|
49
89
|
|
|
50
|
-
|
|
90
|
+
**npm**:
|
|
91
|
+
|
|
92
|
+
```sh
|
|
51
93
|
npm run dev
|
|
52
94
|
```
|
|
53
95
|
|
|
54
|
-
|
|
96
|
+
**pnpm**:
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
pnpm run dev
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Yarn**:
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
yarn dev
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Bun**:
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
bun run dev
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Template structure
|
|
55
115
|
|
|
56
116
|
All templates follow this standardized structure:
|
|
57
117
|
|
|
118
|
+
```text
|
|
119
|
+
your-template/
|
|
120
|
+
├── src/
|
|
121
|
+
│ └── mastra/
|
|
122
|
+
│ ├── agents/ # Agent definitions
|
|
123
|
+
│ ├── tools/ # Tool definitions
|
|
124
|
+
│ ├── workflows/ # Workflow definitions
|
|
125
|
+
│ └── index.ts # Main Mastra config
|
|
126
|
+
├── .env.example # Required environment variables
|
|
127
|
+
├── package.json
|
|
128
|
+
├── tsconfig.json
|
|
129
|
+
└── README.md
|
|
130
|
+
```
|
|
131
|
+
|
|
58
132
|
## Creating templates
|
|
59
133
|
|
|
60
134
|
### Requirements
|
|
@@ -127,12 +201,12 @@ const agent = new Agent({
|
|
|
127
201
|
|
|
128
202
|
Templates must be:
|
|
129
203
|
|
|
130
|
-
- **Single projects
|
|
131
|
-
- **Framework-free
|
|
132
|
-
- **Mastra-focused
|
|
133
|
-
- **Mergeable
|
|
134
|
-
- **Node.js compatible
|
|
135
|
-
- **ESM modules
|
|
204
|
+
- **Single projects**: Not monorepos with multiple applications
|
|
205
|
+
- **Framework-free**: No Next.js, Express, or other web framework boilerplate
|
|
206
|
+
- **Mastra-focused**: Demonstrate Mastra functionality without additional layers
|
|
207
|
+
- **Mergeable**: Structure code for seamless integration into existing projects
|
|
208
|
+
- **Node.js compatible**: Support Node.js v22.13.0 and later
|
|
209
|
+
- **ESM modules**: Use ES modules (`"type": "module"` in package.json)
|
|
136
210
|
|
|
137
211
|
### Documentation Requirements
|
|
138
212
|
|
|
@@ -27,6 +27,106 @@ export const tool = createTool({
|
|
|
27
27
|
})
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
## Define schemas
|
|
31
|
+
|
|
32
|
+
You can define the tool's `inputSchema` and `outputSchema` with any library that supports [Standard JSON Schema](https://standardschema.dev/json-schema). This includes libraries like [Zod](https://zod.dev/), [Valibot](https://valibot.dev/), and [ArkType](https://arktype.io/).
|
|
33
|
+
|
|
34
|
+
**Zod**:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { createTool } from '@mastra/core/tools'
|
|
38
|
+
import { z } from 'zod'
|
|
39
|
+
|
|
40
|
+
export const weatherTool = createTool({
|
|
41
|
+
id: 'weather-tool',
|
|
42
|
+
description: 'Fetches weather for a location',
|
|
43
|
+
inputSchema: z.object({
|
|
44
|
+
location: z.string(),
|
|
45
|
+
}),
|
|
46
|
+
outputSchema: z.object({
|
|
47
|
+
weather: z.string(),
|
|
48
|
+
}),
|
|
49
|
+
execute: async inputData => {
|
|
50
|
+
// Fetch weather data
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Valibot**:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { createTool } from '@mastra/core/tools'
|
|
59
|
+
import * as v from 'valibot'
|
|
60
|
+
import { toStandardJsonSchema } from '@valibot/to-json-schema'
|
|
61
|
+
|
|
62
|
+
export const weatherTool = createTool({
|
|
63
|
+
id: 'weather-tool',
|
|
64
|
+
description: 'Fetches weather for a location',
|
|
65
|
+
inputSchema: toStandardJsonSchema(
|
|
66
|
+
v.object({
|
|
67
|
+
location: v.string(),
|
|
68
|
+
}),
|
|
69
|
+
),
|
|
70
|
+
outputSchema: toStandardJsonSchema(
|
|
71
|
+
v.object({
|
|
72
|
+
weather: v.string(),
|
|
73
|
+
}),
|
|
74
|
+
),
|
|
75
|
+
execute: async inputData => {
|
|
76
|
+
// Fetch weather data
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**ArkType**:
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { createTool } from '@mastra/core/tools'
|
|
85
|
+
import { type } from 'arktype'
|
|
86
|
+
|
|
87
|
+
export const weatherTool = createTool({
|
|
88
|
+
id: 'weather-tool',
|
|
89
|
+
description: 'Fetches weather for a location',
|
|
90
|
+
inputSchema: type({
|
|
91
|
+
location: 'string',
|
|
92
|
+
}),
|
|
93
|
+
outputSchema: type({
|
|
94
|
+
weather: 'string',
|
|
95
|
+
}),
|
|
96
|
+
execute: async inputData => {
|
|
97
|
+
// Fetch weather data
|
|
98
|
+
},
|
|
99
|
+
})
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Example with strict tool inputs
|
|
103
|
+
|
|
104
|
+
Set `strict: true` when you want Mastra to ask supported model providers to generate tool arguments that exactly match the tool schema.
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import { createTool } from '@mastra/core/tools'
|
|
108
|
+
import { z } from 'zod'
|
|
109
|
+
|
|
110
|
+
export const weatherTool = createTool({
|
|
111
|
+
id: 'get-weather',
|
|
112
|
+
description: 'Get weather for a city',
|
|
113
|
+
strict: true,
|
|
114
|
+
inputSchema: z.object({
|
|
115
|
+
city: z.string(),
|
|
116
|
+
units: z.enum(['metric', 'imperial']),
|
|
117
|
+
}),
|
|
118
|
+
execute: async ({ city, units }) => {
|
|
119
|
+
return {
|
|
120
|
+
city,
|
|
121
|
+
units,
|
|
122
|
+
forecast: 'sunny',
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
})
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Mastra forwards `strict: true` to model adapters that support strict tool calling. On adapters that do not support strict tool calling, Mastra ignores this option.
|
|
129
|
+
|
|
30
130
|
## Example with `toModelOutput`
|
|
31
131
|
|
|
32
132
|
Use `toModelOutput` when your tool should return rich internal data to your app, but the model should receive either a simplified value or multimodal content.
|
|
@@ -116,21 +216,23 @@ export const weatherTool = createTool({
|
|
|
116
216
|
|
|
117
217
|
**description** (`string`): A description of what the tool does. This is used by the agent to decide when to use the tool.
|
|
118
218
|
|
|
119
|
-
**inputSchema** (`
|
|
219
|
+
**inputSchema** (`StandardJSONSchemaV1`): A Standard JSON Schema defining the expected input parameters for the tool's \`execute\` function.
|
|
220
|
+
|
|
221
|
+
**outputSchema** (`StandardJSONSchemaV1`): A Standard JSON Schema defining the expected output structure of the tool's \`execute\` function.
|
|
120
222
|
|
|
121
|
-
**
|
|
223
|
+
**strict** (`boolean`): When true, Mastra enables strict tool input generation on model adapters that support it. This helps supported providers return arguments that match the tool schema more closely.
|
|
122
224
|
|
|
123
225
|
**toModelOutput** (`(output: TSchemaOut) => unknown`): Optional function that transforms the tool's \`execute\` output before it is sent back to the model. Use this to return \`text\`, \`json\`, or \`content\`-shaped outputs (including multimodal parts like images/files) to the model while still keeping the full raw output in your application code.
|
|
124
226
|
|
|
125
|
-
**suspendSchema** (`
|
|
227
|
+
**suspendSchema** (`StandardJSONSchemaV1`): A Standard JSON Schema defining the structure of the payload passed to \`suspend()\`. This payload is returned to the client when the tool suspends execution.
|
|
126
228
|
|
|
127
|
-
**resumeSchema** (`
|
|
229
|
+
**resumeSchema** (`StandardJSONSchemaV1`): A Standard JSON Schema defining the expected structure of \`resumeData\` when the tool is resumed. Used by the agent to extract data from user messages when \`autoResumeSuspendedTools\` is enabled.
|
|
128
230
|
|
|
129
231
|
**requireApproval** (`boolean`): When true, the tool requires explicit approval before execution. The agent will emit a \`tool-call-approval\` chunk and pause until approved or declined.
|
|
130
232
|
|
|
131
233
|
**mcp** (`MCPToolProperties`): MCP-specific properties for tools exposed via Model Context Protocol. Includes \`annotations\` (tool behavior hints like \`title\`, \`readOnlyHint\`, \`destructiveHint\`, \`idempotentHint\`, \`openWorldHint\`) and \`\_meta\` (arbitrary metadata passed through to MCP clients).
|
|
132
234
|
|
|
133
|
-
**requestContextSchema** (`
|
|
235
|
+
**requestContextSchema** (`StandardJSONSchemaV1`): A Standard JSON Schema for validating request context values. When provided, the context is validated before execute() runs, returning an error object if validation fails.
|
|
134
236
|
|
|
135
237
|
**execute** (`function`): The function that contains the tool's logic. It receives two parameters: the validated input data (first parameter) and an optional execution context object (second parameter) containing \`requestContext\`, \`tracingContext\`, \`abortSignal\`, and other execution metadata.
|
|
136
238
|
|
|
@@ -53,6 +53,51 @@ Each server in the `servers` map is configured using the `MastraMCPServerDefinit
|
|
|
53
53
|
|
|
54
54
|
**enableServerLogs** (`boolean`): Whether to enable logging for this server. (Default: `true`)
|
|
55
55
|
|
|
56
|
+
**requireToolApproval** (`boolean | (params: RequireToolApprovalContext) => boolean | Promise<boolean>`): Require human approval before executing tools from this server. When set to \`true\`, all tools require approval. When set to a function, the function is called with the tool name, arguments, and request context to dynamically decide whether approval is needed.
|
|
57
|
+
|
|
58
|
+
## Tool approval
|
|
59
|
+
|
|
60
|
+
Use `requireToolApproval` on a server definition to require human approval before any tool from that server is executed. This works with the existing [human-in-the-loop](https://mastra.ai/docs/workflows/human-in-the-loop) approval flow.
|
|
61
|
+
|
|
62
|
+
### Require approval for all tools
|
|
63
|
+
|
|
64
|
+
Set `requireToolApproval` to `true` to require approval for every tool on the server:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
const mcp = new MCPClient({
|
|
68
|
+
servers: {
|
|
69
|
+
github: {
|
|
70
|
+
url: new URL('http://localhost:3000/mcp'),
|
|
71
|
+
requireToolApproval: true,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
})
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Dynamic approval with a function
|
|
78
|
+
|
|
79
|
+
Pass a function to decide per-call whether approval is needed. The function receives the tool name, the arguments the model passed, and any request context from the incoming request:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
const mcp = new MCPClient({
|
|
83
|
+
servers: {
|
|
84
|
+
github: {
|
|
85
|
+
url: new URL('http://localhost:3000/mcp'),
|
|
86
|
+
requireToolApproval: ({ toolName, args, requestContext }) => {
|
|
87
|
+
// Read-only tools don't need approval
|
|
88
|
+
if (toolName === 'list_repos') return false
|
|
89
|
+
// Destructive tools with force flag always need approval
|
|
90
|
+
if (toolName === 'delete_repo') return args.force === true
|
|
91
|
+
// Non-admin users need approval for everything else
|
|
92
|
+
return requestContext?.userRole !== 'admin'
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
})
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The function can also be async. It receives `requestContext` from the incoming request, which you can use for auth checks or other per-request logic.
|
|
100
|
+
|
|
56
101
|
## Methods
|
|
57
102
|
|
|
58
103
|
### `listTools()`
|
|
@@ -768,11 +768,9 @@ await serverWithPrompts.prompts.notifyListChanged()
|
|
|
768
768
|
- Handle errors with informative messages.
|
|
769
769
|
- Document argument expectations and available versions.
|
|
770
770
|
|
|
771
|
-
***
|
|
772
|
-
|
|
773
771
|
## Examples
|
|
774
772
|
|
|
775
|
-
For practical examples of setting up and deploying an MCPServer, see the [Publishing an MCP Server guide](https://mastra.ai/
|
|
773
|
+
For practical examples of setting up and deploying an MCPServer, see the [Publishing an MCP Server guide](https://mastra.ai/guides/guide/publishing-mcp-server).
|
|
776
774
|
|
|
777
775
|
The example at the beginning of this page also demonstrates how to instantiate `MCPServer` with both tools and agents.
|
|
778
776
|
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Perplexity tools
|
|
2
|
+
|
|
3
|
+
Added in: `@mastra/perplexity@0.1.0-alpha.0`
|
|
4
|
+
|
|
5
|
+
The `@mastra/perplexity` package wraps the [Perplexity Search API](https://docs.perplexity.ai/docs/search/quickstart) as a Mastra-compatible tool. It exposes a factory function that returns a tool created with [`createTool()`](https://mastra.ai/reference/tools/create-tool) and full Zod input/output schemas.
|
|
6
|
+
|
|
7
|
+
For chat completions or agentic workflows powered by Perplexity, use Mastra's built-in [Perplexity model provider](https://mastra.ai/models/providers/perplexity) or [Perplexity Agent provider](https://mastra.ai/models/providers/perplexity-agent). Those are separate from this Search tool.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Install the package alongside Zod:
|
|
12
|
+
|
|
13
|
+
**npm**:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install @mastra/perplexity zod
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**pnpm**:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
pnpm add @mastra/perplexity zod
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Yarn**:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
yarn add @mastra/perplexity zod
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Bun**:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
bun add @mastra/perplexity zod
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage example
|
|
38
|
+
|
|
39
|
+
The following example creates the search tool with the default configuration. By default, the tool reads `PERPLEXITY_API_KEY` (with `PPLX_API_KEY` as a fallback) from the environment. Pass `{ apiKey }` explicitly to override.
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { createPerplexitySearchTool } from '@mastra/perplexity'
|
|
43
|
+
|
|
44
|
+
const searchTool = createPerplexitySearchTool()
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
To pass an API key explicitly:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { createPerplexitySearchTool } from '@mastra/perplexity'
|
|
51
|
+
|
|
52
|
+
const searchTool = createPerplexitySearchTool({ apiKey: 'pplx-...' })
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Configuration
|
|
56
|
+
|
|
57
|
+
All factory functions accept a `PerplexityClientOptions` object:
|
|
58
|
+
|
|
59
|
+
**apiKey** (`string`): Perplexity API key. Falls back to the \`PERPLEXITY\_API\_KEY\` then \`PPLX\_API\_KEY\` environment variables.
|
|
60
|
+
|
|
61
|
+
**baseUrl** (`string`): Override the API base URL. (Default: `'https://api.perplexity.ai'`)
|
|
62
|
+
|
|
63
|
+
**fetch** (`typeof fetch`): Custom \`fetch\` implementation. Useful for tests, retries, or instrumentation.
|
|
64
|
+
|
|
65
|
+
## Methods
|
|
66
|
+
|
|
67
|
+
### Factory functions
|
|
68
|
+
|
|
69
|
+
#### `createPerplexityTools(config?)`
|
|
70
|
+
|
|
71
|
+
Returns an object containing all Perplexity tools that share the supplied configuration.
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { createPerplexityTools } from '@mastra/perplexity'
|
|
75
|
+
|
|
76
|
+
const tools = createPerplexityTools({ apiKey: 'pplx-...' })
|
|
77
|
+
// tools.perplexitySearch
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Returns: `{ perplexitySearch }`
|
|
81
|
+
|
|
82
|
+
#### `createPerplexitySearchTool(config?)`
|
|
83
|
+
|
|
84
|
+
Creates a tool that searches the web using the Perplexity Search API. Returns ranked results with titles, URLs, snippets, and optional publication dates.
|
|
85
|
+
|
|
86
|
+
The tool is registered with the ID `perplexity-search`.
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { createPerplexitySearchTool } from '@mastra/perplexity'
|
|
90
|
+
|
|
91
|
+
const searchTool = createPerplexitySearchTool()
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
##### Input
|
|
95
|
+
|
|
96
|
+
**query** (`string`): The search query.
|
|
97
|
+
|
|
98
|
+
**maxResults** (`number`): Maximum number of results to return (1-20).
|
|
99
|
+
|
|
100
|
+
**searchDomainFilter** (`string[]`): Restrict (or exclude) results by domain. Prefix a domain with \`-\` to exclude it (for example, \`-pinterest.com\`). Do not mix allow- and deny-list entries in the same call.
|
|
101
|
+
|
|
102
|
+
**searchRecencyFilter** (`'hour' | 'day' | 'week' | 'month' | 'year'`): Only return results from within the given recency window.
|
|
103
|
+
|
|
104
|
+
**searchAfterDateFilter** (`string`): Only return results published on or after this date. Format: m/d/yyyy.
|
|
105
|
+
|
|
106
|
+
**searchBeforeDateFilter** (`string`): Only return results published on or before this date. Format: m/d/yyyy.
|
|
107
|
+
|
|
108
|
+
##### Output
|
|
109
|
+
|
|
110
|
+
**query** (`string`): The original search query.
|
|
111
|
+
|
|
112
|
+
**results** (`SearchResult[]`): Array of search results.
|
|
113
|
+
|
|
114
|
+
**results.title** (`string`): Result title.
|
|
115
|
+
|
|
116
|
+
**results.url** (`string`): Result URL.
|
|
117
|
+
|
|
118
|
+
**results.snippet** (`string`): Content snippet.
|
|
119
|
+
|
|
120
|
+
**results.date** (`string`): Publication date when available.
|
|
121
|
+
|
|
122
|
+
## Agent example
|
|
123
|
+
|
|
124
|
+
The following example registers the search tool on an agent so it can fetch fresh web results before answering.
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
import { Agent } from '@mastra/core/agent'
|
|
128
|
+
import { createPerplexitySearchTool } from '@mastra/perplexity'
|
|
129
|
+
|
|
130
|
+
const agent = new Agent({
|
|
131
|
+
id: 'research-agent',
|
|
132
|
+
name: 'Research Agent',
|
|
133
|
+
model: 'anthropic/claude-sonnet-4-6',
|
|
134
|
+
instructions:
|
|
135
|
+
'You are a research assistant. Use the perplexity-search tool to find up-to-date information from the web before answering.',
|
|
136
|
+
tools: {
|
|
137
|
+
search: createPerplexitySearchTool(),
|
|
138
|
+
},
|
|
139
|
+
})
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Environment variables
|
|
143
|
+
|
|
144
|
+
| Variable | Description |
|
|
145
|
+
| -------------------- | ----------------------------------------------------------------------------------------------- |
|
|
146
|
+
| `PERPLEXITY_API_KEY` | Your Perplexity API key. Used as the default when `apiKey` is not passed to a factory function. |
|
|
147
|
+
| `PPLX_API_KEY` | Fallback used when `PERPLEXITY_API_KEY` is unset. |
|
|
148
|
+
|
|
149
|
+
## Related
|
|
150
|
+
|
|
151
|
+
- [`createTool()`](https://mastra.ai/reference/tools/create-tool)
|
|
152
|
+
- [Perplexity Search quickstart](https://docs.perplexity.ai/docs/search/quickstart)
|
|
153
|
+
- [Perplexity Agent quickstart](https://docs.perplexity.ai/docs/agent/quickstart)
|
|
154
|
+
- [Perplexity model provider](https://mastra.ai/models/providers/perplexity)
|
|
155
|
+
- [Perplexity Agent provider](https://mastra.ai/models/providers/perplexity-agent)
|