@mastra/mcp-docs-server 1.1.32-alpha.0 → 1.1.32-alpha.2
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/processors.md +8 -0
- package/.docs/docs/agents/supervisor-agents.md +16 -0
- package/.docs/docs/observability/tracing/overview.md +22 -0
- package/.docs/docs/workspace/filesystem.md +2 -0
- package/.docs/models/gateways/azure-openai.md +53 -14
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/berget.md +2 -1
- package/.docs/models/providers/cortecs.md +1 -1
- package/.docs/reference/core/mastra-class.md +2 -0
- package/.docs/reference/harness/harness-class.md +33 -0
- package/.docs/reference/index.md +1 -0
- package/.docs/reference/processors/skill-search-processor.md +19 -0
- package/.docs/reference/processors/tool-call-filter.md +23 -0
- package/.docs/reference/storage/clickhouse.md +21 -1
- package/.docs/reference/vectors/mongodb.md +0 -2
- package/.docs/reference/workspace/google-drive-filesystem.md +185 -0
- package/CHANGELOG.md +14 -0
- package/package.json +5 -5
|
@@ -367,6 +367,14 @@ See the [`TokenLimiterProcessor` reference](https://mastra.ai/reference/processo
|
|
|
367
367
|
|
|
368
368
|
Removes tool calls and results from messages sent to the LLM, saving tokens on verbose tool interactions. Optionally exclude only specific tools. This filter only affects the LLM input, filtered messages are still saved to memory.
|
|
369
369
|
|
|
370
|
+
By default, `ToolCallFilter` filters the initial input before the agent loop starts. Use `filterAfterToolSteps` to also filter during each loop step while preserving recent tool-producing steps.
|
|
371
|
+
|
|
372
|
+
```typescript
|
|
373
|
+
new ToolCallFilter({
|
|
374
|
+
filterAfterToolSteps: 2,
|
|
375
|
+
})
|
|
376
|
+
```
|
|
377
|
+
|
|
370
378
|
See the [`ToolCallFilter` reference](https://mastra.ai/reference/processors/tool-call-filter) for configuration options and the [Memory Processors](https://mastra.ai/docs/memory/memory-processors) page for pre-memory filtering.
|
|
371
379
|
|
|
372
380
|
### `ToolSearchProcessor`
|
|
@@ -167,6 +167,22 @@ const stream = await supervisor.stream('Research AI trends', {
|
|
|
167
167
|
|
|
168
168
|
The callback receives `messages` (the full conversation history), `primitiveId` (the subagent ID), and `prompt` (the delegation prompt). Return the filtered array of messages.
|
|
169
169
|
|
|
170
|
+
## Subagent result context
|
|
171
|
+
|
|
172
|
+
When a subagent completes, the supervisor model receives the subagent's text response in later iterations. Nested tool calls and subagent metadata, such as thread and resource IDs, are not added to the supervisor model context.
|
|
173
|
+
|
|
174
|
+
Application code and UI integrations can still inspect the raw delegation result, including `subAgentToolResults`, from the tool result payload. This keeps debugging and display data available without sending nested tool arguments or outputs back into the supervisor's next model call.
|
|
175
|
+
|
|
176
|
+
Set `includeSubAgentToolResultsInModelContext` to include the full subagent result, including nested tool results and subagent metadata, in the supervisor model context.
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
await supervisor.generate('Research AI trends', {
|
|
180
|
+
delegation: {
|
|
181
|
+
includeSubAgentToolResultsInModelContext: true,
|
|
182
|
+
},
|
|
183
|
+
})
|
|
184
|
+
```
|
|
185
|
+
|
|
170
186
|
## Iteration monitoring
|
|
171
187
|
|
|
172
188
|
`onIterationComplete` is called after each iteration of the supervisor loop. Use it to log progress, inject feedback, or stop execution early.
|
|
@@ -341,6 +341,28 @@ execute: async (inputData, context) => {
|
|
|
341
341
|
|
|
342
342
|
Metadata set here will be shown in all configured exporters.
|
|
343
343
|
|
|
344
|
+
### Tagging traces with the deployment environment
|
|
345
|
+
|
|
346
|
+
Set the top-level `environment` field on Mastra to automatically attach the deployment environment to all observability signals without passing `tracingOptions.metadata.environment` on each call.
|
|
347
|
+
|
|
348
|
+
```ts
|
|
349
|
+
export const mastra = new Mastra({
|
|
350
|
+
environment: 'production',
|
|
351
|
+
observability: new Observability({
|
|
352
|
+
configs: {
|
|
353
|
+
default: {
|
|
354
|
+
serviceName: 'my-service',
|
|
355
|
+
exporters: [new DefaultExporter()],
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
}),
|
|
359
|
+
})
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
If `environment` is not set, Mastra falls back to `process.env.NODE_ENV`. If neither is set, the field is left undefined rather than guessed.
|
|
363
|
+
|
|
364
|
+
Per-call `tracingOptions.metadata.environment` always takes precedence, so individual calls can still override the value when needed.
|
|
365
|
+
|
|
344
366
|
### Automatic Metadata from `RequestContext`
|
|
345
367
|
|
|
346
368
|
Instead of manually adding metadata to each span, you can configure Mastra to automatically extract values from RequestContext and attach them as metadata to all spans in a trace. This is useful for consistently tracking user identifiers, environment information, feature flags, or any request-scoped data across your entire trace.
|
|
@@ -21,6 +21,7 @@ Available providers:
|
|
|
21
21
|
- [`LocalFilesystem`](https://mastra.ai/reference/workspace/local-filesystem): Stores files in a directory on disk
|
|
22
22
|
- [`S3Filesystem`](https://mastra.ai/reference/workspace/s3-filesystem): Stores files in Amazon S3 or S3-compatible storage (R2, MinIO, Tigris)
|
|
23
23
|
- [`GCSFilesystem`](https://mastra.ai/reference/workspace/gcs-filesystem): Stores files in Google Cloud Storage
|
|
24
|
+
- [`GoogleDriveFilesystem`](https://mastra.ai/reference/workspace/google-drive-filesystem): Stores files inside a Google Drive folder
|
|
24
25
|
- [`AzureBlobFilesystem`](https://mastra.ai/reference/workspace/azure-blob-filesystem): Stores files in Azure Blob Storage
|
|
25
26
|
- [`AgentFSFilesystem`](https://mastra.ai/reference/workspace/agentfs-filesystem): Stores files in a Turso/SQLite database via AgentFS
|
|
26
27
|
|
|
@@ -220,6 +221,7 @@ When you configure a filesystem on a workspace, agents receive tools for reading
|
|
|
220
221
|
- [LocalFilesystem reference](https://mastra.ai/reference/workspace/local-filesystem)
|
|
221
222
|
- [S3Filesystem reference](https://mastra.ai/reference/workspace/s3-filesystem)
|
|
222
223
|
- [GCSFilesystem reference](https://mastra.ai/reference/workspace/gcs-filesystem)
|
|
224
|
+
- [GoogleDriveFilesystem reference](https://mastra.ai/reference/workspace/google-drive-filesystem)
|
|
223
225
|
- [AzureBlobFilesystem reference](https://mastra.ai/reference/workspace/azure-blob-filesystem)
|
|
224
226
|
- [AgentFSFilesystem reference](https://mastra.ai/reference/workspace/agentfs-filesystem)
|
|
225
227
|
- [Workspace overview](https://mastra.ai/docs/workspace/overview)
|
|
@@ -92,6 +92,41 @@ export const mastra = new Mastra({
|
|
|
92
92
|
|
|
93
93
|
The Service Principal requires "Cognitive Services User" role. See [Azure documentation](https://learn.microsoft.com/en-us/entra/identity-platform/howto-create-service-principal-portal).
|
|
94
94
|
|
|
95
|
+
### Microsoft Entra ID authentication
|
|
96
|
+
|
|
97
|
+
Use Microsoft Entra ID authentication when API keys are disabled for your Azure OpenAI resource. Pass any Azure SDK-compatible credential, such as `DefaultAzureCredential` from `@azure/identity`.
|
|
98
|
+
|
|
99
|
+
Install `@azure/identity` in your Mastra project if you use `DefaultAzureCredential`.
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
103
|
+
import { Mastra } from "@mastra/core";
|
|
104
|
+
import { AzureOpenAIGateway } from "@mastra/core/llm";
|
|
105
|
+
|
|
106
|
+
export const mastra = new Mastra({
|
|
107
|
+
gateways: [
|
|
108
|
+
new AzureOpenAIGateway({
|
|
109
|
+
resourceName: "my-openai-resource",
|
|
110
|
+
authentication: {
|
|
111
|
+
type: "entraId",
|
|
112
|
+
credential: new DefaultAzureCredential(),
|
|
113
|
+
},
|
|
114
|
+
deployments: ["gpt-4-prod", "gpt-35-turbo-dev"],
|
|
115
|
+
}),
|
|
116
|
+
],
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The identity needs permission to call Azure OpenAI, such as the `Cognitive Services OpenAI User` role.
|
|
121
|
+
|
|
122
|
+
For a specific managed identity, pass `ManagedIdentityCredential` instead.
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
import { ManagedIdentityCredential } from "@azure/identity";
|
|
126
|
+
|
|
127
|
+
const credential = new ManagedIdentityCredential("client-id");
|
|
128
|
+
```
|
|
129
|
+
|
|
95
130
|
### Manual Deployment Names
|
|
96
131
|
|
|
97
132
|
Provide resource name and API key only. Specify deployment names when creating agents. No IDE autocomplete.
|
|
@@ -112,17 +147,21 @@ export const mastra = new Mastra({
|
|
|
112
147
|
|
|
113
148
|
## Configuration Reference
|
|
114
149
|
|
|
115
|
-
| Option | Type
|
|
116
|
-
| --------------------------- |
|
|
117
|
-
| `resourceName` | `string`
|
|
118
|
-
| `apiKey` | `string`
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
122
|
-
| `
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
125
|
-
| `management
|
|
126
|
-
| `management.
|
|
127
|
-
|
|
128
|
-
|
|
150
|
+
| Option | Type | Required | Description |
|
|
151
|
+
| --------------------------- | ----------------- | -------- | --------------------------------------------------------------------- |
|
|
152
|
+
| `resourceName` | `string` | Yes | Azure OpenAI resource name |
|
|
153
|
+
| `apiKey` | `string` | Yes\* | API key from "Keys and Endpoint" |
|
|
154
|
+
| `authentication` | `object` | No | Microsoft Entra ID authentication |
|
|
155
|
+
| `authentication.type` | `"entraId"` | Yes\* | Authentication mode |
|
|
156
|
+
| `authentication.credential` | `TokenCredential` | Yes\* | Azure SDK-compatible credential for `entraId` authentication mode |
|
|
157
|
+
| `authentication.scope` | `string` | No | Token scope (default: `https://cognitiveservices.azure.com/.default`) |
|
|
158
|
+
| `apiVersion` | `string` | No | API version (default: `2024-04-01-preview`) |
|
|
159
|
+
| `deployments` | `string[]` | No | Deployment names for static mode |
|
|
160
|
+
| `management` | `object` | No | Management API credentials |
|
|
161
|
+
| `management.tenantId` | `string` | Yes\* | Azure AD tenant ID |
|
|
162
|
+
| `management.clientId` | `string` | Yes\* | Service Principal client ID |
|
|
163
|
+
| `management.clientSecret` | `string` | Yes\* | Service Principal secret |
|
|
164
|
+
| `management.subscriptionId` | `string` | Yes\* | Azure subscription ID |
|
|
165
|
+
| `management.resourceGroup` | `string` | Yes\* | Resource group name |
|
|
166
|
+
|
|
167
|
+
\* Provide either `apiKey` or `authentication.type: "entraId"`. Management fields are required if `management` is provided.
|
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 3779 models from 106 providers through a single API.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Berget.AI
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 6 Berget.AI models through Mastra's model router. Authentication is handled automatically using the `BERGET_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Berget.AI documentation](https://api.berget.ai).
|
|
6
6
|
|
|
@@ -36,6 +36,7 @@ for await (const chunk of stream) {
|
|
|
36
36
|
| ------------------------------------------------------ | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
37
37
|
| `berget/google/gemma-4-31B-it` | 128K | | | | | | $0.28 | $0.55 |
|
|
38
38
|
| `berget/meta-llama/Llama-3.3-70B-Instruct` | 128K | | | | | | $0.99 | $0.99 |
|
|
39
|
+
| `berget/mistralai/Mistral-Medium-3.5-128B` | 262K | | | | | | $2 | $6 |
|
|
39
40
|
| `berget/mistralai/Mistral-Small-3.2-24B-Instruct-2506` | 32K | | | | | | $0.33 | $0.33 |
|
|
40
41
|
| `berget/openai/gpt-oss-120b` | 128K | | | | | | $0.44 | $0.99 |
|
|
41
42
|
| `berget/zai-org/GLM-4.7` | 128K | | | | | | $0.77 | $3 |
|
|
@@ -62,7 +62,7 @@ for await (const chunk of stream) {
|
|
|
62
62
|
| `cortecs/minimax-m2` | 400K | | | | | | $0.39 | $2 |
|
|
63
63
|
| `cortecs/minimax-m2.1` | 196K | | | | | | $0.34 | $1 |
|
|
64
64
|
| `cortecs/minimax-m2.5` | 197K | | | | | | $0.32 | $1 |
|
|
65
|
-
| `cortecs/minimax-
|
|
65
|
+
| `cortecs/minimax-m2.7` | 203K | | | | | | $0.47 | $1 |
|
|
66
66
|
| `cortecs/nova-pro-v1` | 300K | | | | | | $1 | $4 |
|
|
67
67
|
| `cortecs/qwen3-32b` | 16K | | | | | | $0.10 | $0.33 |
|
|
68
68
|
| `cortecs/qwen3-coder-480b-a35b-instruct` | 262K | | | | | | $0.44 | $2 |
|
|
@@ -49,6 +49,8 @@ Visit the [Configuration reference](https://mastra.ai/reference/configuration) f
|
|
|
49
49
|
|
|
50
50
|
**observability** (`ObservabilityEntrypoint`): Observability configuration for tracing and monitoring
|
|
51
51
|
|
|
52
|
+
**environment** (`string`): Deployment environment name (e.g. \`production\`, \`staging\`, \`development\`). When set, automatically attached to all observability signals so they can be filtered by environment without passing \`tracingOptions.metadata.environment\` on each call. Falls back to \`process.env.NODE\_ENV\` when unset; left undefined if neither is set. Per-call \`tracingOptions.metadata.environment\` always takes precedence.
|
|
53
|
+
|
|
52
54
|
**deployer** (`MastraDeployer`): An instance of a MastraDeployer for managing deployments.
|
|
53
55
|
|
|
54
56
|
**server** (`ServerConfig`): Server configuration including port, host, timeout, API routes, middleware, CORS settings, and build options for Swagger UI, API request logging, and OpenAPI docs.
|
|
@@ -152,6 +152,14 @@ Return a read-only snapshot of the current harness state.
|
|
|
152
152
|
const state = harness.getState()
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
+
#### `getDisplayState()`
|
|
156
|
+
|
|
157
|
+
Return the current `HarnessDisplayState` snapshot for UI rendering.
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
const displayState = harness.getDisplayState()
|
|
161
|
+
```
|
|
162
|
+
|
|
155
163
|
#### `setState(updates)`
|
|
156
164
|
|
|
157
165
|
Update the harness state. Validates against `stateSchema` if provided, and emits a `state_changed` event with the new state and changed keys.
|
|
@@ -722,10 +730,35 @@ Forked mode trades isolation for context inheritance. If the subagent should run
|
|
|
722
730
|
|
|
723
731
|
### Events
|
|
724
732
|
|
|
733
|
+
#### `subscribeDisplayState(listener, options?)`
|
|
734
|
+
|
|
735
|
+
Register a listener for coalesced display state snapshots. Use this method for UI, Server-Sent Events (SSE), terminal UI (TUI), and bridge rendering paths that only need the latest `HarnessDisplayState`. Use [`subscribe`](#subscribelistener) when you need the raw event log.
|
|
736
|
+
|
|
737
|
+
```typescript
|
|
738
|
+
const unsubscribe = harness.subscribeDisplayState(displayState => {
|
|
739
|
+
render(displayState)
|
|
740
|
+
})
|
|
741
|
+
|
|
742
|
+
// Optional tuning:
|
|
743
|
+
harness.subscribeDisplayState(render, {
|
|
744
|
+
windowMs: 250,
|
|
745
|
+
maxWaitMs: 500,
|
|
746
|
+
})
|
|
747
|
+
|
|
748
|
+
// Later:
|
|
749
|
+
unsubscribe()
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
Returns: `() => void`
|
|
753
|
+
|
|
754
|
+
`subscribeDisplayState()` does not call the listener immediately. Call [`getDisplayState`](#getdisplaystate) first if the UI needs an initial render before the next harness event.
|
|
755
|
+
|
|
725
756
|
#### `subscribe(listener)`
|
|
726
757
|
|
|
727
758
|
Register an event listener. Returns an unsubscribe function.
|
|
728
759
|
|
|
760
|
+
Use this method for audit logs, debugging, analytics, deterministic replay, or consumers that need every raw event. For display rendering, prefer [`subscribeDisplayState`](#subscribedisplaystatelistener-options) so high-frequency events such as `message_update`, `tool_update`, and `tool_input_delta` are coalesced into the latest display state snapshot.
|
|
761
|
+
|
|
729
762
|
```typescript
|
|
730
763
|
const unsubscribe = harness.subscribe(event => {
|
|
731
764
|
switch (event.type) {
|
package/.docs/reference/index.md
CHANGED
|
@@ -296,6 +296,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
296
296
|
- [DockerSandbox](https://mastra.ai/reference/workspace/docker-sandbox)
|
|
297
297
|
- [E2BSandbox](https://mastra.ai/reference/workspace/e2b-sandbox)
|
|
298
298
|
- [GCSFilesystem](https://mastra.ai/reference/workspace/gcs-filesystem)
|
|
299
|
+
- [GoogleDriveFilesystem](https://mastra.ai/reference/workspace/google-drive-filesystem)
|
|
299
300
|
- [LocalFilesystem](https://mastra.ai/reference/workspace/local-filesystem)
|
|
300
301
|
- [LocalSandbox](https://mastra.ai/reference/workspace/local-sandbox)
|
|
301
302
|
- [ModalSandbox](https://mastra.ai/reference/workspace/modal-sandbox)
|
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
The `SkillSearchProcessor` is an **input processor** that enables on-demand skill discovery and loading. Instead of injecting all skill metadata into the system prompt upfront (like `SkillsProcessor`), it gives the agent two meta-tools (`search_skills` and `load_skill`) that let it find and load skills on demand. This reduces context token usage when workspaces have many skills.
|
|
4
4
|
|
|
5
|
+
By default, when you attach only `SkillSearchProcessor` to an agent with a skill-enabled `Workspace`, the agent treats skills as on-demand:
|
|
6
|
+
|
|
7
|
+
- The default eager `SkillsProcessor` is not auto-added.
|
|
8
|
+
- `search_skills` and `load_skill` are exposed for discovery and instruction loading.
|
|
9
|
+
- Overlapping `skill` and `skill_search` tools are hidden.
|
|
10
|
+
- `skill_read` remains available so the agent can read supporting skill files such as references, scripts, and assets.
|
|
11
|
+
|
|
12
|
+
If you explicitly configure `SkillsProcessor` alongside `SkillSearchProcessor`, the agent preserves the eager `skill` and `skill_search` tools as an opt-in path.
|
|
13
|
+
|
|
5
14
|
## Usage example
|
|
6
15
|
|
|
7
16
|
```typescript
|
|
@@ -36,6 +45,8 @@ const skillSearch = new SkillSearchProcessor({
|
|
|
36
45
|
|
|
37
46
|
**name** (`string`): Processor display name set to 'Skill Search Processor'
|
|
38
47
|
|
|
48
|
+
**providesSkillDiscovery** (`'on-demand'`): Signals to the agent that this processor owns skill discovery and instruction loading.
|
|
49
|
+
|
|
39
50
|
**processInputStep** (`(args: ProcessInputStepArgs) => Promise<ProcessInputStepResult>`): Processes each step to inject search/load meta-tools and any previously loaded skill instructions as system messages.
|
|
40
51
|
|
|
41
52
|
## Extended usage example
|
|
@@ -77,6 +88,14 @@ The agent workflow is:
|
|
|
77
88
|
4. The skill's instructions appear as system messages on the next turn
|
|
78
89
|
5. Agent follows the loaded skill's instructions
|
|
79
90
|
|
|
91
|
+
## Workspace file tools
|
|
92
|
+
|
|
93
|
+
`SkillSearchProcessor` loads skill instructions into the conversation. It does not block workspace file tools from reading files.
|
|
94
|
+
|
|
95
|
+
Use `skill_read` for supporting files that belong to a loaded skill, such as files under `references/`, `scripts/`, or `assets/`.
|
|
96
|
+
|
|
97
|
+
Reserve workspace file tools such as `mastra_workspace_read_file` for explicit file inspection or editing workflows. During normal task execution, the agent does not need to read the same `SKILL.md` file after `load_skill` succeeds.
|
|
98
|
+
|
|
80
99
|
## Compared to SkillsProcessor
|
|
81
100
|
|
|
82
101
|
| | SkillsProcessor | SkillSearchProcessor |
|
|
@@ -14,6 +14,11 @@ const filterAll = new ToolCallFilter()
|
|
|
14
14
|
const filterSpecific = new ToolCallFilter({
|
|
15
15
|
exclude: ['searchDatabase', 'sendEmail'],
|
|
16
16
|
})
|
|
17
|
+
|
|
18
|
+
// Enable filtering during agent loops and keep the two most recent tool-producing steps
|
|
19
|
+
const filterAfterRecentTools = new ToolCallFilter({
|
|
20
|
+
filterAfterToolSteps: 2,
|
|
21
|
+
})
|
|
17
22
|
```
|
|
18
23
|
|
|
19
24
|
## Constructor parameters
|
|
@@ -22,6 +27,8 @@ const filterSpecific = new ToolCallFilter({
|
|
|
22
27
|
|
|
23
28
|
**options.exclude** (`string[]`): List of specific tool names to exclude. If not provided or undefined, all tool calls are excluded
|
|
24
29
|
|
|
30
|
+
**options.filterAfterToolSteps** (`number`): Enables filtering during agent loops and preserves tool calls and results from this many recent tool-producing steps. If undefined, step filtering is disabled
|
|
31
|
+
|
|
25
32
|
## Returns
|
|
26
33
|
|
|
27
34
|
**id** (`string`): Processor identifier set to 'tool-call-filter'
|
|
@@ -30,6 +37,22 @@ const filterSpecific = new ToolCallFilter({
|
|
|
30
37
|
|
|
31
38
|
**processInput** (`(args: { messages: MastraDBMessage[]; messageList: MessageList; abort: (reason?: string) => never; requestContext?: RequestContext }) => Promise<MessageList | MastraDBMessage[]>`): Processes input messages to filter out tool calls and their results based on configuration
|
|
32
39
|
|
|
40
|
+
**processInputStep** (`(args: ProcessInputStepArgs) => Promise<ProcessInputStepResult>`): Processes agent loop step input when filterAfterToolSteps is configured. Returns no changes when step filtering is disabled
|
|
41
|
+
|
|
42
|
+
## Step filtering
|
|
43
|
+
|
|
44
|
+
By default, `ToolCallFilter` filters only the initial input before the agent loop starts. Set `filterAfterToolSteps` to also filter during each loop step.
|
|
45
|
+
|
|
46
|
+
`filterAfterToolSteps` counts tool-producing steps. For example, `filterAfterToolSteps: 2` keeps tool calls and results from the two most recent tool-producing steps and filters older tool calls and results. Non-tool text remains in context.
|
|
47
|
+
|
|
48
|
+
Set `filterAfterToolSteps: 0` to filter all previous tool calls and results on each step.
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
const filter = new ToolCallFilter({
|
|
52
|
+
filterAfterToolSteps: 2,
|
|
53
|
+
})
|
|
54
|
+
```
|
|
55
|
+
|
|
33
56
|
## Extended usage example
|
|
34
57
|
|
|
35
58
|
```typescript
|
|
@@ -101,7 +101,27 @@ New projects should use `ObservabilityStorageClickhouseVNext` instead.
|
|
|
101
101
|
|
|
102
102
|
### ClickHouse for every domain
|
|
103
103
|
|
|
104
|
-
`
|
|
104
|
+
`ClickhouseStoreVNext` backs the `memory`, `workflows`, and `observability` domains with ClickHouse and uses the vNext observability adapter automatically. Use it when you want ClickHouse to back the entire application without wiring a composite store manually.
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import { Mastra } from '@mastra/core'
|
|
108
|
+
import { ClickhouseStoreVNext } from '@mastra/clickhouse'
|
|
109
|
+
|
|
110
|
+
export const mastra = new Mastra({
|
|
111
|
+
storage: new ClickhouseStoreVNext({
|
|
112
|
+
id: 'clickhouse-storage',
|
|
113
|
+
url: process.env.CLICKHOUSE_URL!,
|
|
114
|
+
username: process.env.CLICKHOUSE_USERNAME!,
|
|
115
|
+
password: process.env.CLICKHOUSE_PASSWORD!,
|
|
116
|
+
}),
|
|
117
|
+
})
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`ClickhouseStoreVNext` accepts the same configuration as `ClickhouseStore` and reuses the same ClickHouse client across every domain.
|
|
121
|
+
|
|
122
|
+
#### Manual composition
|
|
123
|
+
|
|
124
|
+
`ClickhouseStore` is the long-standing class that backs every domain with the legacy observability adapter. New projects should prefer `ClickhouseStoreVNext`. If you need to customize the composite (for example, to override one domain with a different backend), build it manually:
|
|
105
125
|
|
|
106
126
|
```typescript
|
|
107
127
|
import { Mastra } from '@mastra/core'
|
|
@@ -107,8 +107,6 @@ Searches for similar vectors with optional metadata filtering.
|
|
|
107
107
|
|
|
108
108
|
**includeVector** (`boolean`): Whether to include vector data in results (Default: `false`)
|
|
109
109
|
|
|
110
|
-
**minScore** (`number`): Minimum similarity score threshold (Default: `0`)
|
|
111
|
-
|
|
112
110
|
### `describeIndex()`
|
|
113
111
|
|
|
114
112
|
Returns information about the index (collection).
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# GoogleDriveFilesystem
|
|
2
|
+
|
|
3
|
+
Stores files in a single Google Drive folder. Each directory maps to a Drive folder under the configured root, and paths use POSIX semantics (for example `/notes/todo.txt`).
|
|
4
|
+
|
|
5
|
+
> **Info:** For interface details, see [WorkspaceFilesystem Interface](https://mastra.ai/reference/workspace/filesystem).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
**npm**:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @mastra/google-drive
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**pnpm**:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @mastra/google-drive
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Yarn**:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
yarn add @mastra/google-drive
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Bun**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
bun add @mastra/google-drive
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
Add a `GoogleDriveFilesystem` to a workspace and assign it to an agent:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { Agent } from '@mastra/core/agent'
|
|
39
|
+
import { Workspace } from '@mastra/core/workspace'
|
|
40
|
+
import { GoogleDriveFilesystem } from '@mastra/google-drive'
|
|
41
|
+
|
|
42
|
+
const workspace = new Workspace({
|
|
43
|
+
filesystem: new GoogleDriveFilesystem({
|
|
44
|
+
folderId: process.env.GOOGLE_DRIVE_FOLDER_ID!,
|
|
45
|
+
accessToken: process.env.GOOGLE_DRIVE_ACCESS_TOKEN!,
|
|
46
|
+
}),
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const agent = new Agent({
|
|
50
|
+
id: 'drive-agent',
|
|
51
|
+
name: 'Drive Agent',
|
|
52
|
+
model: 'openai/gpt-4o-mini',
|
|
53
|
+
workspace,
|
|
54
|
+
})
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Authentication
|
|
58
|
+
|
|
59
|
+
Supply one of the following authentication options:
|
|
60
|
+
|
|
61
|
+
- **`accessToken`**: A pre-obtained OAuth access token. Use the `https://www.googleapis.com/auth/drive` scope so the token can see folders shared with the authenticated identity.
|
|
62
|
+
- **`getAccessToken`**: A callback that returns a token. Useful when tokens are refreshed externally.
|
|
63
|
+
- **`serviceAccount`**: A Google service account. Share the target folder with the service account email.
|
|
64
|
+
|
|
65
|
+
#### Service account
|
|
66
|
+
|
|
67
|
+
Service account auth is the recommended option for backend agents. There is no user consent flow and no token refresh handling. You only need **two values** from the service account JSON key file: `client_email` and `private_key`.
|
|
68
|
+
|
|
69
|
+
##### Set up the service account
|
|
70
|
+
|
|
71
|
+
1. Open the [Google Cloud Console](https://console.cloud.google.com/) and select or create a project.
|
|
72
|
+
2. Go to **APIs & Services > Library**, search for **Google Drive API**, and select **Enable**.
|
|
73
|
+
3. Go to **APIs & Services > Credentials**, select **Create credentials > Service account**, and complete the form. The role can be left blank — Drive permissions are granted by sharing folders, not by IAM roles.
|
|
74
|
+
4. Open the new service account, go to the **Keys** tab, and select **Add key > Create new key > JSON**. The browser downloads a JSON key file.
|
|
75
|
+
5. Copy the `client_email` value from the JSON file. This is the address you share Drive folders with.
|
|
76
|
+
|
|
77
|
+
##### Share the Drive folder with the service account
|
|
78
|
+
|
|
79
|
+
The service account is its own Google identity. It cannot see anything in Drive until you share with it explicitly.
|
|
80
|
+
|
|
81
|
+
1. Open the target folder in [Google Drive](https://drive.google.com/).
|
|
82
|
+
2. Select **Share**.
|
|
83
|
+
3. Paste the service account's `client_email` address.
|
|
84
|
+
4. Set the role to **Editor** (for read and write) or **Viewer** (for read-only access). Select **Send**.
|
|
85
|
+
5. Copy the folder ID from the URL. It is the segment after `/folders/` in `https://drive.google.com/drive/folders/<folderId>`.
|
|
86
|
+
|
|
87
|
+
> **Warning:** Service accounts cannot create files in standard "My Drive" folders. A service account has no personal Drive storage quota, so any file it creates needs to be owned by a quota-bearing entity. If you only share a personal Drive folder, read operations work but writes fail with a quota error.
|
|
88
|
+
>
|
|
89
|
+
> For write access, place the folder inside a **shared drive** (formerly Team Drive) and add the service account as a member of that shared drive. Shared drives provide the storage quota that service-account-created files need.
|
|
90
|
+
>
|
|
91
|
+
> Read-only workloads against a personal Drive folder do not have this restriction.
|
|
92
|
+
|
|
93
|
+
##### Configure the filesystem
|
|
94
|
+
|
|
95
|
+
Copy `client_email` and `private_key` from the JSON file into your environment:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
GOOGLE_DRIVE_FOLDER_ID=1AbCdEfGhIjKlMnOpQrStUvWxYz
|
|
99
|
+
GOOGLE_DRIVE_CLIENT_EMAIL=my-bot@my-project.iam.gserviceaccount.com
|
|
100
|
+
# Wrap the value in quotes — the key contains newlines that must be preserved.
|
|
101
|
+
GOOGLE_DRIVE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkq...\n-----END PRIVATE KEY-----\n"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
import { GoogleDriveFilesystem } from '@mastra/google-drive'
|
|
106
|
+
|
|
107
|
+
const filesystem = new GoogleDriveFilesystem({
|
|
108
|
+
folderId: process.env.GOOGLE_DRIVE_FOLDER_ID!,
|
|
109
|
+
serviceAccount: {
|
|
110
|
+
clientEmail: process.env.GOOGLE_DRIVE_CLIENT_EMAIL!,
|
|
111
|
+
privateKey: process.env.GOOGLE_DRIVE_PRIVATE_KEY!,
|
|
112
|
+
},
|
|
113
|
+
})
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
You do **not** need to copy the entire JSON file or pass other fields like `project_id`, `client_id`, `private_key_id`, or `token_uri`. They are not used. Only `clientEmail` and `privateKey` are required. `privateKeyId`, `scopes`, and `subject` are optional. `scopes` defaults to `['https://www.googleapis.com/auth/drive']`, which is the scope required for the service account to see folders shared with it. The narrower `drive.file` scope only grants access to files the application created itself, so a folder shared with the service account would return `404 Not Found`.
|
|
117
|
+
|
|
118
|
+
`GoogleDriveFilesystem` automatically normalizes the `privateKey` string before signing. It strips surrounding quotes (including escaped quotes from JSON-wrapped values), converts literal `\n` sequences to real newlines, normalizes `\r\n` line endings, and removes a trailing comma. The key works regardless of how your `.env` loader handles the value.
|
|
119
|
+
|
|
120
|
+
##### Troubleshoot
|
|
121
|
+
|
|
122
|
+
- **`404 File not found: <folderId>`**: The service account does not have access to the folder. Confirm the folder is shared with the exact `client_email` address and that the folder ID matches the URL.
|
|
123
|
+
- **`storageQuotaExceeded` on write**: The folder is in a personal "My Drive". Move the folder to a shared drive and add the service account as a member.
|
|
124
|
+
- **`error:1E08010C:DECODER routines::unsupported`**: The `privateKey` value is malformed. Confirm the value contains the full PEM block and that newlines are preserved (literal `\n` is fine).
|
|
125
|
+
|
|
126
|
+
### Read-only mode
|
|
127
|
+
|
|
128
|
+
Pass `readOnly: true` to block write operations (`writeFile`, `appendFile`, `deleteFile`, `copyFile`, `moveFile`, `mkdir`, `rmdir`).
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
const filesystem = new GoogleDriveFilesystem({
|
|
132
|
+
folderId,
|
|
133
|
+
accessToken,
|
|
134
|
+
readOnly: true,
|
|
135
|
+
})
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Constructor parameters
|
|
139
|
+
|
|
140
|
+
**folderId** (`string`): ID of the Google Drive folder that acts as the workspace root. All paths are resolved inside this folder.
|
|
141
|
+
|
|
142
|
+
**accessToken** (`string`): OAuth access token with access to the folder.
|
|
143
|
+
|
|
144
|
+
**getAccessToken** (`() => string | Promise<string>`): Callback that returns a fresh OAuth access token. Called on every request that needs authorization.
|
|
145
|
+
|
|
146
|
+
**serviceAccount** (`{ clientEmail: string; privateKey: string; privateKeyId?: string; scopes?: string[]; subject?: string }`): Service account credentials used to mint access tokens via the OAuth 2.0 JWT flow.
|
|
147
|
+
|
|
148
|
+
**id** (`string`): Unique identifier for this filesystem instance (Default: `` `google-drive:${folderId}` ``)
|
|
149
|
+
|
|
150
|
+
**readOnly** (`boolean`): When true, all write operations are blocked. (Default: `false`)
|
|
151
|
+
|
|
152
|
+
**instructions** (`InstructionsOption`): Override the default instructions returned to tool descriptions.
|
|
153
|
+
|
|
154
|
+
## Properties
|
|
155
|
+
|
|
156
|
+
**id** (`string`): Filesystem instance identifier
|
|
157
|
+
|
|
158
|
+
**name** (`string`): Provider name ('GoogleDriveFilesystem')
|
|
159
|
+
|
|
160
|
+
**provider** (`string`): Provider identifier ('google-drive')
|
|
161
|
+
|
|
162
|
+
**readOnly** (`boolean | undefined`): Whether the filesystem is in read-only mode
|
|
163
|
+
|
|
164
|
+
## Methods
|
|
165
|
+
|
|
166
|
+
GoogleDriveFilesystem implements the [WorkspaceFilesystem interface](https://mastra.ai/reference/workspace/filesystem), providing all standard filesystem methods:
|
|
167
|
+
|
|
168
|
+
- `readFile(path, options?)` - Download file contents
|
|
169
|
+
- `writeFile(path, content, options?)` - Upload or overwrite a file
|
|
170
|
+
- `appendFile(path, content)` - Append content by reading and re-uploading the file
|
|
171
|
+
- `deleteFile(path, options?)` - Delete a file
|
|
172
|
+
- `copyFile(src, dest, options?)` - Copy a file using the Drive `files.copy` API
|
|
173
|
+
- `moveFile(src, dest, options?)` - Move a file between folders by swapping parents
|
|
174
|
+
- `mkdir(path, options?)` - Create a folder
|
|
175
|
+
- `rmdir(path, options?)` - Remove a folder
|
|
176
|
+
- `readdir(path, options?)` - List folder contents (supports `recursive` and `extension` filtering)
|
|
177
|
+
- `stat(path)` - Return Drive metadata for a file or folder
|
|
178
|
+
- `exists(path)` - Check if a file or folder exists
|
|
179
|
+
|
|
180
|
+
## Notes
|
|
181
|
+
|
|
182
|
+
- Google Drive allows multiple files with the same name in a folder. `GoogleDriveFilesystem` resolves paths by picking the first match, so keep names unique within each folder when you rely on path-based lookup.
|
|
183
|
+
- `writeFile` creates parent folders automatically when `recursive` is unset (the default) or `true`. Set `recursive: false` to require the parent folder to already exist.
|
|
184
|
+
- `expectedMtime` on `WriteOptions` is honored — when the stored `modifiedTime` differs, the write is rejected with `StaleFileError` to support optimistic concurrency.
|
|
185
|
+
- The provider only exercises Drive REST endpoints (`https://www.googleapis.com/drive/v3` and `https://www.googleapis.com/upload/drive/v3`) through the built-in `fetch`; no additional dependencies are required.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.1.32-alpha.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`e109607`](https://github.com/mastra-ai/mastra/commit/e10960749251e34d46b480a20648c490fd30381b)]:
|
|
8
|
+
- @mastra/core@1.31.0-alpha.1
|
|
9
|
+
|
|
10
|
+
## 1.1.32-alpha.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`1723e09`](https://github.com/mastra-ai/mastra/commit/1723e099829892419ddbfe49287acfeac2522724), [`629f9e9`](https://github.com/mastra-ai/mastra/commit/629f9e9a7e56aa8f129515a3923c5813298790c7), [`25168fb`](https://github.com/mastra-ai/mastra/commit/25168fb9c1de9db7f8171df4f58ceb842c53aa29), [`ab34b5a`](https://github.com/mastra-ai/mastra/commit/ab34b5a2191b8e4353df1dbf7b9155e7d6628d79), [`5fb6c2a`](https://github.com/mastra-ai/mastra/commit/5fb6c2a95c1843cc231704b91354311fc1f34a71), [`394f0cf`](https://github.com/mastra-ai/mastra/commit/394f0cfc31e6b4d801219fdef2e9cc69e5bc8682), [`3d7f709`](https://github.com/mastra-ai/mastra/commit/3d7f709b615e588050bb6283c4ee5cfe2978cbde), [`48a42f1`](https://github.com/mastra-ai/mastra/commit/48a42f114a4006a95e0b7a1b5ad1a24815a175c2), [`2c83efc`](https://github.com/mastra-ai/mastra/commit/2c83efc4482b3efe50830e3b8b4ba9a8d219edff), [`282a10c`](https://github.com/mastra-ai/mastra/commit/282a10c9446e9922afe80e10e3770481c8ac8a28)]:
|
|
15
|
+
- @mastra/core@1.31.0-alpha.0
|
|
16
|
+
|
|
3
17
|
## 1.1.31
|
|
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.32-alpha.
|
|
3
|
+
"version": "1.1.32-alpha.2",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
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/core": "1.31.0-alpha.1",
|
|
33
|
+
"@mastra/mcp": "^1.6.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@hono/node-server": "^1.19.11",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"tsx": "^4.21.0",
|
|
47
47
|
"typescript": "^6.0.3",
|
|
48
48
|
"vitest": "4.1.5",
|
|
49
|
-
"@internal/types-builder": "0.0.64",
|
|
50
49
|
"@internal/lint": "0.0.89",
|
|
51
|
-
"@
|
|
50
|
+
"@internal/types-builder": "0.0.64",
|
|
51
|
+
"@mastra/core": "1.31.0-alpha.1"
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://mastra.ai",
|
|
54
54
|
"repository": {
|