@mastra/mcp-docs-server 1.2.16 → 1.2.17-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/.docs/docs/agents/code-mode.md +2 -2
  2. package/.docs/docs/agents/skills.md +1 -1
  3. package/.docs/docs/agents/using-tools.md +1 -1
  4. package/.docs/docs/harness/agent-controller.md +1 -1
  5. package/.docs/docs/mcp/overview.md +4 -5
  6. package/.docs/docs/studio/overview.md +1 -1
  7. package/.docs/docs/workspace/filesystem.md +182 -153
  8. package/.docs/docs/workspace/lsp.md +4 -5
  9. package/.docs/docs/workspace/sandbox.md +234 -141
  10. package/.docs/docs/workspace/search.md +52 -4
  11. package/.docs/docs/workspace/skills.md +62 -33
  12. package/.docs/integrations/browsers/browser-viewer.md +2 -2
  13. package/.docs/integrations/file-storage/amazon-s3.md +1 -1
  14. package/.docs/integrations/file-storage/azure-blob.md +1 -1
  15. package/.docs/integrations/file-storage/google-cloud-storage.md +1 -1
  16. package/.docs/integrations/file-storage/mesa.md +1 -1
  17. package/.docs/integrations/file-storage/vercel-files.md +1 -1
  18. package/.docs/integrations/sandboxes/apple-container.md +1 -1
  19. package/.docs/integrations/sandboxes/daytona.md +1 -1
  20. package/.docs/integrations/sandboxes/docker.md +1 -1
  21. package/.docs/integrations/sandboxes/e2b.md +1 -1
  22. package/.docs/integrations/sandboxes/modal.md +1 -1
  23. package/.docs/models/environment-variables.md +1 -0
  24. package/.docs/models/gateways/vercel.md +3 -2
  25. package/.docs/models/index.md +1 -1
  26. package/.docs/models/providers/baseten.md +2 -1
  27. package/.docs/models/providers/crossmodel.md +2 -2
  28. package/.docs/models/providers/crusoe.md +80 -0
  29. package/.docs/models/providers/deepinfra.md +3 -1
  30. package/.docs/models/providers/fireworks-ai.md +26 -20
  31. package/.docs/models/providers/huggingface.md +5 -1
  32. package/.docs/models/providers/hyper.md +1 -1
  33. package/.docs/models/providers/kilo.md +4 -4
  34. package/.docs/models/providers/llmgateway.md +3 -2
  35. package/.docs/models/providers/merge-gateway.md +5 -2
  36. package/.docs/models/providers/nano-gpt.md +6 -6
  37. package/.docs/models/providers/ofox.md +5 -1
  38. package/.docs/models/providers/opencode-go.md +2 -1
  39. package/.docs/models/providers/opencode.md +3 -1
  40. package/.docs/models/providers/requesty.md +3 -1
  41. package/.docs/models/providers/zai-coding-plan.md +3 -2
  42. package/.docs/models/providers/zhipuai-coding-plan.md +2 -1
  43. package/.docs/models/providers.md +1 -0
  44. package/.docs/reference/agent-controller/agent-controller-class.md +26 -1
  45. package/.docs/reference/browser/browser-viewer.md +1 -1
  46. package/.docs/reference/configuration.md +1 -1
  47. package/.docs/reference/core/removeWorkspace.md +1 -1
  48. package/.docs/reference/file-based-agents/workspace.md +3 -3
  49. package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +2 -0
  50. package/.docs/reference/processors/skill-search-processor.md +1 -1
  51. package/.docs/reference/tools/create-code-mode.md +1 -1
  52. package/.docs/reference/tools/create-tool.md +11 -3
  53. package/.docs/reference/tools/mcp-server.md +4 -1
  54. package/.docs/reference/workspace/local-filesystem.md +1 -1
  55. package/.docs/reference/workspace/local-sandbox.md +1 -1
  56. package/.docs/reference/workspace/workspace-class.md +52 -15
  57. package/CHANGELOG.md +14 -0
  58. package/package.json +5 -5
  59. package/.docs/docs/workspace/overview.md +0 -416
@@ -29,7 +29,7 @@ Each turn adds the full tool response to the agent's context window which can le
29
29
 
30
30
  With code mode, your tools keep running on the host with full validation, request context, and tracing. Only the model's orchestration code runs in the sandbox. Each `external_*` call is bridged back to the real tool on the host, and the function can reduce or aggregate results before returning one response to the agent.
31
31
 
32
- The function runs in a [Workspace sandbox](https://mastra.ai/docs/workspace/overview). A sandbox is required, because code mode runs model-authored code and the execution boundary must be chosen deliberately. Pass one via `sandbox`, or run the agent in a workspace that provides one. To execute on the host machine, pass `new LocalSandbox()` explicitly. This runs the function as a host `node` process with host privileges, so only use it for trusted or local development.
32
+ The function runs in a [Workspace sandbox](https://mastra.ai/docs/workspace/sandbox). A sandbox is required, because code mode runs model-authored code and the execution boundary must be chosen deliberately. Pass one via `sandbox`, or run the agent in a workspace that provides one. To execute on the host machine, pass `new LocalSandbox()` explicitly. This runs the function as a host `node` process with host privileges, so only use it for trusted or local development.
33
33
 
34
34
  Transports that bring their own execution boundary are the exception: with [`IsolatedVmCodeModeTransport`](https://mastra.ai/reference/tools/isolated-vm-transport) the program runs in an in-process V8 isolate and no sandbox is needed (see [In-process isolation](#in-process-isolation)).
35
35
 
@@ -184,4 +184,4 @@ See [Choosing a transport](https://mastra.ai/reference/tools/quickjs-transport)
184
184
  - [IsolatedVmCodeModeTransport reference](https://mastra.ai/reference/tools/isolated-vm-transport)
185
185
  - [QuickJsCodeModeTransport reference](https://mastra.ai/reference/tools/quickjs-transport)
186
186
  - [Tools](https://mastra.ai/docs/agents/using-tools)
187
- - [Workspace overview](https://mastra.ai/docs/workspace/overview)
187
+ - [Sandbox](https://mastra.ai/docs/workspace/sandbox)
@@ -4,7 +4,7 @@
4
4
 
5
5
  Skills are reusable instructions that teach agents how to perform specific tasks. They follow the [Agent Skills specification](https://agentskills.io).
6
6
 
7
- You can attach skills directly to an agent through its `skills` config, or configure them on a [workspace](https://mastra.ai/docs/workspace/overview). Attach them to the agent when the skills belong to that specific agent and you want to define them in code with no workspace required. Use a workspace when you want skills discovered from the filesystem and shared across every agent that uses it. This page covers the agent-level approach, defining skills in code and loading them from files, plus resolving them per request.
7
+ You can attach skills directly to an agent through its `skills` config, or configure them on a [workspace](https://mastra.ai/docs/workspace/skills). Attach them to the agent when the skills belong to that specific agent and you want to define them in code with no workspace required. Use a workspace when you want skills discovered from the filesystem and shared across every agent that uses it. This page covers the agent-level approach, defining skills in code and loading them from files, plus resolving them per request.
8
8
 
9
9
  ## When to use agent-level skills
10
10
 
@@ -326,7 +326,7 @@ For more phases, including `input`, `inputDelta`, `error`, `approval`, `suspend`
326
326
 
327
327
  ## Run logic around tool calls
328
328
 
329
- Use `hooks` to run custom logic before and after every tool call an agent makes. Hooks apply to all tool sources: assigned tools, memory tools, toolsets, client tools, agent and workflow tools, and [workspace tools](https://mastra.ai/docs/workspace/overview). Common uses include logging, auditing, input validation, and blocking specific calls.
329
+ Use `hooks` to run custom logic before and after every tool call an agent makes. Hooks apply to all tool sources: assigned tools, memory tools, toolsets, client tools, agent and workflow tools, and [workspace tools](https://mastra.ai/reference/workspace/workspace-class). Common uses include logging, auditing, input validation, and blocking specific calls.
330
330
 
331
331
  ```typescript
332
332
  import { Agent } from '@mastra/core/agent'
@@ -412,6 +412,6 @@ Subscriptions are isolated by Session. Events from another Session on the same c
412
412
  ## Related
413
413
 
414
414
  - [Agents](https://mastra.ai/docs/agents/overview)
415
- - [Workspace](https://mastra.ai/docs/workspace/overview)
415
+ - [Workspace](https://mastra.ai/docs/workspace/sandbox)
416
416
  - [Observational memory](https://mastra.ai/docs/memory/observational-memory)
417
417
  - [Channels](https://mastra.ai/docs/capabilities/channels)
@@ -252,7 +252,7 @@ Use an MCP App when a tool result benefits from interaction, such as a form, cal
252
252
 
253
253
  ### Define an app resource
254
254
 
255
- Return a short `content` summary for the model and place UI data in `structuredContent`. Link the tool to its app by setting `_meta.ui.resourceUri` to the same `ui://` URI used in `appResources`:
255
+ Return a short `content` summary for the model and place UI data in `structuredContent`. Link the tool to its app by setting `mcp._meta.ui.resourceUri` to the same `ui://` URI used in `appResources`:
256
256
 
257
257
  ```typescript
258
258
  import { MCPServer } from '@mastra/mcp'
@@ -266,16 +266,15 @@ export const calculatorTool = createTool({
266
266
  num1: z.number(),
267
267
  num2: z.number(),
268
268
  }),
269
+ mcp: {
270
+ _meta: { ui: { resourceUri: 'ui://calculator/main' } },
271
+ },
269
272
  execute: async ({ num1, num2 }) => ({
270
273
  content: [{ type: 'text', text: 'The result is displayed in the calculator app.' }],
271
274
  structuredContent: { result: num1 + num2 },
272
275
  }),
273
276
  })
274
277
 
275
- calculatorTool._meta = {
276
- ui: { resourceUri: 'ui://calculator/main' },
277
- }
278
-
279
278
  export const calculatorMcpServer = new MCPServer({
280
279
  id: 'calculator-app-server',
281
280
  name: 'Calculator App Server',
@@ -85,7 +85,7 @@ Run tools on their own to observe behavior and test them before assigning them t
85
85
 
86
86
  Browse the files in your agent's workspace filesystem using a built-in file browser. Switch between workspace mounts, create directories, and view file contents with syntax highlighting. Writable workspaces allow directory creation and file deletion; read-only workspaces are labeled accordingly. The Skills tab lists all discovered skills with their instructions, references, and metadata. Install community skills from [skills.sh](https://skills.sh) or remove existing ones.
87
87
 
88
- See [workspaces](https://mastra.ai/docs/workspace/overview) for configuration details.
88
+ See [workspaces](https://mastra.ai/docs/workspace/sandbox) for configuration details.
89
89
 
90
90
  ### Request context
91
91
 
@@ -2,237 +2,266 @@
2
2
 
3
3
  # Filesystem
4
4
 
5
- **Added in:** `@mastra/core@1.1.0`
5
+ Filesystems give agents persistent storage for source code, documents, datasets, and generated artifacts.
6
6
 
7
- Filesystem providers give agents the ability to read, write, and manage files. When you configure a filesystem on a workspace, agents receive tools for file operations.
7
+ Mastra supports two mutually exclusive ways to add a filesystem to a workspace:
8
8
 
9
- A filesystem provider handles all file operations for a workspace:
9
+ | Configuration | Agent access | Sandbox access |
10
+ | ------------- | ------------ | ---------------------------------------------- |
11
+ | `mounts` | File tools | Files appear as local directories through FUSE |
12
+ | `filesystem` | File tools | No access |
10
13
 
11
- - **Read** - Read file contents
12
- - **Write** - Create and update files
13
- - **List** - Browse directories with optional glob pattern filtering
14
- - **Delete** - Remove files and directories
15
- - **Stat** - Get file metadata
16
- - **Copy/Move** - Copy or move files between locations
17
- - **Grep** - Search file contents using regex patterns
14
+ Use `mounts` when a sandbox needs to run commands against the files. The agent can use file tools, while code inside the sandbox can use shell commands and libraries against the same storage.
18
15
 
19
- ## Supported providers
16
+ Use `filesystem` when the agent only needs direct file tools or the sandbox backend doesn't support mounts. The agent acts as the driver: it can read a file and pass its contents to another tool, but the file doesn't exist inside the sandbox. A command such as `cat`, `grep`, or `python script.py` can't access it unless your application passes the content as input.
20
17
 
21
- Available providers:
18
+ You can't configure both `filesystem` and `mounts` on the same workspace.
22
19
 
23
- - [`LocalFilesystem`](https://mastra.ai/reference/workspace/local-filesystem): Stores files in a directory on disk
24
- - [`S3Filesystem`](https://mastra.ai/integrations/file-storage/amazon-s3): Stores files in Amazon S3 or S3-compatible storage (R2, MinIO, Tigris)
25
- - [`GCSFilesystem`](https://mastra.ai/integrations/file-storage/google-cloud-storage): Stores files in Google Cloud Storage
26
- - [`PlatformFilesystem`](https://mastra.ai/reference/workspace/platform-filesystem): Stores files in a Mastra Platform workspace bucket
27
- - [`GoogleDriveFilesystem`](https://mastra.ai/integrations/file-storage/google-drive): Stores files inside a Google Drive folder
28
- - [`AzureBlobFilesystem`](https://mastra.ai/integrations/file-storage/azure-blob): Stores files in Azure Blob Storage
29
- - [`FilesSDKFilesystem`](https://mastra.ai/integrations/file-storage/vercel-files): Stores files in any [FilesSDK](https://files-sdk.dev) adapter (S3, R2, GCS, Azure Blob, Vercel Blob, local filesystem, and more): useful when you want one provider that can target multiple backends
30
- - [`AgentFSFilesystem`](https://mastra.ai/integrations/file-storage/agentfs): Stores files in a Turso/SQLite database via AgentFS
31
- - [`MesaFilesystem`](https://mastra.ai/integrations/file-storage/mesa): Stores files in versioned Mesa repos
32
- - [`ArchilFilesystem`](https://mastra.ai/integrations/file-storage/archil): Stores files on Archil elastic, serverless disks
20
+ ## When to use filesystems
33
21
 
34
- > **Tip:** `LocalFilesystem` is the simplest way to get started as it requires no external services. For cloud storage, use `S3Filesystem`, `GCSFilesystem`, or `AzureBlobFilesystem`. For versioned storage, use `MesaFilesystem`. For database-backed storage without external services, use `AgentFSFilesystem`.
22
+ Mount a filesystem when you want to:
35
23
 
36
- ## Basic usage
24
+ - Seed an ephemeral sandbox with source code, datasets, or project files.
25
+ - Persist files after the sandbox stops or is deleted.
26
+ - Let commands and agent file tools work against the same storage.
27
+ - Share a storage location across multiple sandbox runs.
37
28
 
38
- Create a workspace with a filesystem and assign it to an agent. The agent can then read, write, and manage files as part of its tasks:
29
+ Use a workspace-only filesystem when you want to:
39
30
 
40
- ```typescript
41
- import { Agent } from '@mastra/core/agent'
42
- import { Workspace, LocalFilesystem } from '@mastra/core/workspace'
31
+ - Give an agent access to a managed knowledge base without command execution.
32
+ - Read documents uploaded by non-technical teammates to services such as S3 or Google Drive.
33
+ - Use persistent storage with a sandbox backend that doesn't support mounts.
34
+ - Keep the storage provider separate from the sandbox execution environment.
43
35
 
44
- const workspace = new Workspace({
45
- filesystem: new LocalFilesystem({
46
- basePath: './workspace',
47
- }),
48
- })
36
+ For example, a real-estate agent could read travel-policy documents from an S3 bucket or Google Drive folder and use them while answering questions. The agent can search and read those files without needing a sandbox to execute commands against them.
49
37
 
50
- const agent = new Agent({
51
- id: 'file-agent',
52
- model: 'openai/gpt-5.6-sol',
53
- instructions: 'You are a helpful file management assistant.',
54
- workspace,
55
- })
38
+ A data agent could also download reports from Google Drive with file tools. It can pass their contents to a sandbox for analysis and presentation generation, then upload the finished presentation for the team. This works even when the sandbox backend can't mount Google Drive because the agent transfers the input and output between the filesystem and sandbox.
56
39
 
57
- // The agent now has filesystem tools available
58
- const response = await agent.generate('List all files in the workspace')
59
- ```
40
+ ## Supported filesystems
60
41
 
61
- ## Containment
42
+ ### `LocalFilesystem`
62
43
 
63
- By default, `LocalFilesystem` runs in **contained mode**, all file operations are restricted to stay within `basePath`. This prevents path traversal attacks and symlink escapes.
44
+ [`LocalFilesystem`](https://mastra.ai/reference/workspace/local-filesystem) stores files in a directory on the same machine as your Mastra application. Use it for local development or when the application already has access to the files on disk.
64
45
 
65
- In contained mode:
46
+ `LocalFilesystem` contains file-tool access within its configured `basePath` by default. You can allow specific paths outside that directory or disable containment when the application requires broader host access.
66
47
 
67
- - **Relative paths** (e.g. `src/index.ts`) resolve against `basePath`
68
- - **Absolute paths** (e.g. `/home/user/.config/file.txt`) are treated as real filesystem paths: if they fall outside `basePath` and any `allowedPaths`, a `PermissionError` is thrown
69
- - **Tilde paths** (e.g. `~/Documents`) expand to the home directory and follow the same containment rules
48
+ ### Other filesystems
70
49
 
71
- If your agent needs to access specific paths outside `basePath`, use `allowedPaths` to grant access without disabling containment entirely. Relative paths are resolved against `basePath`, and absolute paths are used as-is:
50
+ Use another filesystem when files need to persist outside the application host or already live in an external service:
72
51
 
73
- ```typescript
74
- const workspace = new Workspace({
75
- filesystem: new LocalFilesystem({
76
- basePath: './workspace',
77
- allowedPaths: ['~/.claude/skills', '../shared-data'],
78
- }),
79
- })
80
- ```
52
+ - [AgentFS](https://mastra.ai/integrations/file-storage/agentfs)
53
+ - [Amazon S3](https://mastra.ai/integrations/file-storage/amazon-s3)
54
+ - [Archil](https://mastra.ai/integrations/file-storage/archil)
55
+ - [Azure Blob](https://mastra.ai/integrations/file-storage/azure-blob)
56
+ - [Google Cloud Storage](https://mastra.ai/integrations/file-storage/google-cloud-storage)
57
+ - [Google Drive](https://mastra.ai/integrations/file-storage/google-drive)
58
+ - [Mastra Platform](https://mastra.ai/reference/workspace/platform-filesystem)
59
+ - [Mesa](https://mastra.ai/integrations/file-storage/mesa)
60
+ - [Vercel Files](https://mastra.ai/integrations/file-storage/vercel-files)
81
61
 
82
- Allowed paths can be updated at runtime using the `setAllowedPaths()` method:
62
+ Workspace-only file tools work with the full provider list. FUSE mount support depends on both the filesystem and sandbox backend, so check both references before choosing a combination.
83
63
 
84
- ```typescript
85
- // Add a path dynamically
86
- workspace.filesystem.setAllowedPaths(prev => [...prev, '/home/user/documents'])
87
- ```
64
+ ## Mounts
88
65
 
89
- This is the recommended approach for least-privilege access, the agent can only reach the specific directories you allow.
66
+ Use mounts when both the agent and sandbox commands need access to the same files.
90
67
 
91
- If your agent needs unrestricted access to the entire filesystem, disable containment:
68
+ ### Quickstart
69
+
70
+ Mount an S3 filesystem into a sandbox:
92
71
 
93
72
  ```typescript
73
+ import { Mastra } from '@mastra/core'
74
+ import { Workspace } from '@mastra/core/workspace'
75
+ import { DaytonaSandbox } from '@mastra/daytona'
76
+ import { S3Filesystem } from '@mastra/s3'
77
+
94
78
  const workspace = new Workspace({
95
- filesystem: new LocalFilesystem({
96
- basePath: './workspace',
97
- contained: false,
98
- }),
79
+ mounts: {
80
+ '/workspace': new S3Filesystem({
81
+ bucket: process.env.S3_BUCKET!,
82
+ region: process.env.S3_REGION!,
83
+ }),
84
+ },
85
+ sandbox: new DaytonaSandbox(),
99
86
  })
87
+
88
+ export const mastra = new Mastra({ workspace })
100
89
  ```
101
90
 
102
- When `contained` is `false`, absolute paths are treated as real filesystem paths with no restriction.
91
+ Existing objects in the bucket seed the sandbox at `/workspace`. Files created there persist in S3 after the sandbox stops. All agents registered with this `Mastra` instance inherit the workspace.
92
+
93
+ ### Using mounts
94
+
95
+ The agent receives file tools for mounted storage:
96
+
97
+ | Tool | Does |
98
+ | ------------ | ---------------------------------------------------------- |
99
+ | `read_file` | Reads text or binary file contents. |
100
+ | `write_file` | Creates or replaces a file. |
101
+ | `edit_file` | Applies targeted edits to a text file. |
102
+ | `list_files` | Lists files and directories, with optional glob filtering. |
103
+ | `file_stat` | Returns file metadata. |
104
+ | `mkdir` | Creates a directory. |
105
+ | `delete` | Deletes files or directories. |
106
+ | `grep` | Searches file contents with a regular expression. |
107
+
108
+ Mounted files are also available to commands inside the sandbox. In the Quickstart, `read_file('/workspace/report.md')` and `cat /workspace/report.md` read the same S3 object.
103
109
 
104
- ## Dynamic filesystem
110
+ Use `WORKSPACE_TOOLS.FILESYSTEM` to require approval, disable tools, enforce read-before-write, or change output limits. See the [Workspace filesystem tools reference](https://mastra.ai/reference/workspace/workspace-class) for configuration details.
105
111
 
106
- The `filesystem` option accepts a resolver function instead of a static instance. The resolver receives `requestContext` and returns a filesystem per request, allowing a single workspace to serve different filesystems based on the caller's identity, role, or tenant.
112
+ > **Warning:** File-tool policies only apply to file-tool calls. Restrictions such as `allowedPaths`, approval rules, or read-before-write don't constrain shell commands running inside the sandbox. A command can access any mounted path allowed by the sandbox backend and mount configuration. If the agent must not bypass file-tool policies through the shell, disable its sandbox command tools.
113
+
114
+ ### Multiple mounts
115
+
116
+ The `mounts` option creates a `CompositeFilesystem` that routes paths to storage providers by mount prefix. Supported sandbox backends expose those providers as local directories through FUSE.
107
117
 
108
118
  ```typescript
109
- import { Agent } from '@mastra/core/agent'
110
- import { Workspace, LocalFilesystem } from '@mastra/core/workspace'
119
+ import { Workspace } from '@mastra/core/workspace'
120
+ import { E2BSandbox } from '@mastra/e2b'
121
+ import { GCSFilesystem } from '@mastra/gcs'
122
+ import { S3Filesystem } from '@mastra/s3'
111
123
 
112
124
  const workspace = new Workspace({
113
- filesystem: ({ requestContext }) => {
114
- const role = requestContext.get('agent-role') || 'guest'
115
- return new LocalFilesystem({
116
- basePath: `/workspaces/${role}`,
117
- readOnly: role !== 'admin',
118
- })
125
+ mounts: {
126
+ '/data': new S3Filesystem({
127
+ bucket: 'agent-data',
128
+ region: 'us-east-1',
129
+ }),
130
+ '/reports': new GCSFilesystem({
131
+ bucket: 'agent-reports',
132
+ }),
119
133
  },
120
- })
121
-
122
- const agent = new Agent({
123
- id: 'multi-role-agent',
124
- model: 'openai/gpt-5.6-sol',
125
- workspace,
134
+ sandbox: new E2BSandbox({ id: 'analysis-sandbox' }),
126
135
  })
127
136
  ```
128
137
 
129
- Each request resolves its own filesystem for workspace tools and workspace instructions:
138
+ With this configuration:
130
139
 
131
- ```typescript
132
- import { RequestContext } from '@mastra/core/request-context'
140
+ - Existing objects under `/data` and `/reports` seed the sandbox when the mounts become available.
141
+ - Agent file tools route each path to its corresponding storage provider.
142
+ - Commands inside the sandbox access the same paths.
143
+ - New and updated files persist in the underlying buckets.
133
144
 
134
- // Admin request reads and writes from /workspaces/admin/
135
- const adminCtx = new RequestContext([['agent-role', 'admin']])
136
- await agent.generate('Write report.txt with Q4 results', { requestContext: adminCtx })
145
+ All file paths must start with a mount prefix. Listing `/` returns a virtual directory for each mount. Mount paths can't be nested, so a workspace can't mount both `/data` and `/data/archive`.
137
146
 
138
- // Viewer request reads from /workspaces/viewer/, writes are blocked
139
- const viewerCtx = new RequestContext([['agent-role', 'viewer']])
140
- await agent.generate('Read info.txt', { requestContext: viewerCtx })
141
- ```
147
+ Mount support varies by sandbox backend and filesystem provider. Check both references before choosing a combination.
142
148
 
143
- Workspace instructions use the same `requestContext`, so the agent sees the filesystem context for the resolved provider.
149
+ ### Read-only mounts
144
150
 
145
- The resolver can also be asynchronous, for example to look up configuration from a database:
151
+ Set `readOnly: true` on a filesystem provider when the sandbox and agent should only read seeded files. Mastra excludes write tools for provider objects known to be read-only, and the mount backend enforces its own write restrictions.
146
152
 
147
153
  ```typescript
148
154
  const workspace = new Workspace({
149
- filesystem: async ({ requestContext }) => {
150
- const tenantConfig = await db.getTenant(requestContext.get('tenant-id'))
151
- return new LocalFilesystem({ basePath: tenantConfig.storagePath })
155
+ mounts: {
156
+ '/policies': new S3Filesystem({
157
+ bucket: 'company-policies',
158
+ region: 'us-east-1',
159
+ readOnly: true,
160
+ }),
152
161
  },
162
+ sandbox: new DaytonaSandbox(),
153
163
  })
154
164
  ```
155
165
 
156
- > **Note:** `filesystem` and `mounts` are mutually exclusive. You can't use a resolver function together with `mounts` in the same workspace.
166
+ ### Per-user or per-thread mounts
167
+
168
+ Workspace-level `mounts` require a sandbox provider object and can't be combined with a sandbox resolver. For one sandbox and storage prefix per user or thread, create and mount the filesystem inside the sandbox resolver. See [Multi-tenant sandboxes](https://mastra.ai/docs/workspace/sandbox) for a complete example.
169
+
170
+ ## Workspace-only filesystem
157
171
 
158
- ## Read-only mode
172
+ Pass a provider to `filesystem` when only the agent needs file access. The agent receives file tools, but a sandbox configured on the same workspace can't see those files.
159
173
 
160
- To prevent agents from modifying files, enable read-only mode:
174
+ ### Quickstart
161
175
 
162
176
  ```typescript
177
+ import { LocalSandbox, Workspace } from '@mastra/core/workspace'
178
+ import { GoogleDriveFilesystem } from '@mastra/google-drive'
179
+
163
180
  const workspace = new Workspace({
164
- filesystem: new LocalFilesystem({
165
- basePath: './workspace',
166
- readOnly: true,
181
+ filesystem: new GoogleDriveFilesystem({
182
+ folderId: process.env.GOOGLE_DRIVE_FOLDER_ID!,
183
+ accessToken: process.env.GOOGLE_DRIVE_ACCESS_TOKEN!,
184
+ }),
185
+ sandbox: new LocalSandbox({
186
+ workingDirectory: './workspace',
167
187
  }),
168
188
  })
169
189
  ```
170
190
 
171
- With a static filesystem, write tools (`write_file`, `edit_file`, `delete`, `mkdir`) are excluded from the agent's toolset entirely. The agent can still read and list files.
191
+ The agent receives the same file tools listed under [Using mounts](#using-mounts), plus sandbox command tools. It can use both in one task. For the prompt "Format `draft.md` with Prettier and save it as `formatted.md`", the agent can:
192
+
193
+ 1. Read `draft.md` from Google Drive with `read_file`.
194
+ 2. Pass the returned content to `execute_command`, for example by piping it into Prettier.
195
+ 3. Write the command output to `formatted.md` with `write_file`.
172
196
 
173
- When using a [dynamic filesystem](#dynamic-filesystem), write tools are always included because `readOnly` isn't known until the resolver runs. Instead, write operations are blocked at runtime, the tool returns an error if the resolved filesystem is read-only.
197
+ The Google Drive files never appear inside the sandbox. Only the content passed to `execute_command` crosses into the execution environment, and only the returned output is written back.
174
198
 
175
- ## Mounts and `CompositeFilesystem`
199
+ ### Seed a filesystem
176
200
 
177
- When you use the `mounts` option on a workspace, Mastra creates a `CompositeFilesystem` that routes file operations to the correct provider based on path prefix.
201
+ Files already in the folder seed the workspace. You can also seed any writable provider through its API before the agent uses it:
178
202
 
179
203
  ```typescript
180
- import { Workspace } from '@mastra/core/workspace'
181
- import { S3Filesystem } from '@mastra/s3'
182
- import { GCSFilesystem } from '@mastra/gcs'
183
- import { E2BSandbox } from '@mastra/e2b'
204
+ await workspace.filesystem?.writeFile(
205
+ 'travel-policy.md',
206
+ '# Travel policy\n\nEmployees may book economy flights.',
207
+ )
208
+ ```
209
+
210
+ Filesystem operations initialize the provider on first use. Writes replace existing files by default. Pass `{ overwrite: false }` when existing content must be preserved.
211
+
212
+ ### Containment
213
+
214
+ `LocalFilesystem` uses contained mode by default. File tools can access `basePath` but can't traverse into unrelated host paths through absolute paths, `..`, or symlinks.
215
+
216
+ ```typescript
217
+ import { LocalFilesystem, Workspace } from '@mastra/core/workspace'
184
218
 
185
219
  const workspace = new Workspace({
186
- mounts: {
187
- '/data': new S3Filesystem({
188
- bucket: 'my-bucket',
189
- region: 'us-east-1',
190
- accessKeyId: process.env.AWS_ACCESS_KEY_ID,
191
- secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
192
- }),
193
- '/skills': new GCSFilesystem({
194
- bucket: 'agent-skills',
195
- }),
196
- },
197
- sandbox: new E2BSandbox({ id: 'dev-sandbox' }),
220
+ filesystem: new LocalFilesystem({
221
+ basePath: './knowledge-base',
222
+ allowedPaths: ['../shared-policies'],
223
+ }),
198
224
  })
199
225
  ```
200
226
 
201
- With this configuration:
202
-
203
- - `read_file('/data/input.csv')` reads from the S3 bucket
204
- - `write_file('/skills/guide.md', content)` writes to the GCS bucket
205
- - `list_directory('/')` returns virtual entries for `/data` and `/skills`
206
- - Commands in the sandbox can access files at `/data` and `/skills` via FUSE mounts
207
-
208
- ### Path routing
227
+ Containment still matters even though the agent accesses files through tools. It limits what those tools can expose. Prefer `allowedPaths` for specific external directories instead of setting `contained: false`.
209
228
 
210
- All file paths must start with a mount prefix because operations fail when their paths don't match a mount. Listing the root directory (`/`) returns virtual directory entries for each mount point.
229
+ ### Read-only mode
211
230
 
212
- Mount paths can't be nested, for example, you can't mount at both `/data` and `/data/sub`.
231
+ Set `readOnly: true` when the agent should use seeded content without changing it:
213
232
 
214
- ### `filesystem` vs `mounts`
233
+ ```typescript
234
+ const workspace = new Workspace({
235
+ filesystem: new LocalFilesystem({
236
+ basePath: './knowledge-base',
237
+ readOnly: true,
238
+ }),
239
+ })
240
+ ```
215
241
 
216
- `filesystem` and `mounts` are mutually exclusive options on a workspace:
242
+ For a provider object, Mastra removes write, edit, delete, and directory-creation tools. For a resolver-backed filesystem, the tools remain registered because the provider isn't known until execution. Write attempts are rejected at runtime.
217
243
 
218
- - Use **`filesystem`** when you have a single storage provider and don't need to mount it into a sandbox. The agent gets file tools that operate directly against the provider.
219
- - Use **`mounts`** when you need cloud storage accessible inside a sandbox, or when you want to combine multiple providers. The workspace creates a CompositeFilesystem for file tools and FUSE-mounts the storage into the sandbox.
244
+ ### Multi-tenant filesystems
220
245
 
221
- For local development, you typically don't need `mounts`, a `LocalFilesystem` and `LocalSandbox` pointed at the same directory gives you both file tools and command execution on the same files. See [configuration patterns](https://mastra.ai/docs/workspace/overview) for more detail.
246
+ Use a resolver when each request, user, role, or tenant needs different storage:
222
247
 
223
- ## Agent tools
248
+ ```typescript
249
+ const workspace = new Workspace({
250
+ filesystem: ({ requestContext }) => {
251
+ const tenantId = requestContext.get('tenant-id') as string
252
+ return new S3Filesystem({
253
+ bucket: process.env.S3_BUCKET!,
254
+ region: process.env.S3_REGION!,
255
+ prefix: `tenants/${tenantId}`,
256
+ })
257
+ },
258
+ })
259
+ ```
224
260
 
225
- When you configure a filesystem on a workspace, agents receive tools for reading, writing, listing, and deleting files. See [workspace class reference](https://mastra.ai/reference/workspace/workspace-class) for details.
261
+ Each tenant's prefix seeds its own workspace view. Workspace tools resolve the filesystem from the request context automatically.
226
262
 
227
263
  ## Related
228
264
 
229
- - [LocalFilesystem reference](https://mastra.ai/reference/workspace/local-filesystem)
230
- - [S3Filesystem reference](https://mastra.ai/integrations/file-storage/amazon-s3)
231
- - [GCSFilesystem reference](https://mastra.ai/integrations/file-storage/google-cloud-storage)
232
- - [GoogleDriveFilesystem reference](https://mastra.ai/integrations/file-storage/google-drive)
233
- - [AzureBlobFilesystem reference](https://mastra.ai/integrations/file-storage/azure-blob)
234
- - [FilesSDKFilesystem reference](https://mastra.ai/integrations/file-storage/vercel-files)
235
- - [AgentFSFilesystem reference](https://mastra.ai/integrations/file-storage/agentfs)
236
- - [MesaFilesystem reference](https://mastra.ai/integrations/file-storage/mesa)
237
- - [Workspace overview](https://mastra.ai/docs/workspace/overview)
238
- - [Sandbox](https://mastra.ai/docs/workspace/sandbox)
265
+ - [Sandbox](https://mastra.ai/docs/workspace/sandbox)
266
+ - [`WorkspaceFilesystem` reference](https://mastra.ai/reference/workspace/filesystem)
267
+ - [`Workspace` reference](https://mastra.ai/reference/workspace/workspace-class)
@@ -2,8 +2,6 @@
2
2
 
3
3
  # LSP inspection
4
4
 
5
- **Added in:** `@mastra/core@1.1.0`
6
-
7
5
  LSP inspection gives workspace-backed agents semantic code intelligence. When you enable LSP on a workspace, agents can inspect symbols in supported files to retrieve hover information and jump to definitions. They can also find implementations.
8
6
 
9
7
  ## When to use LSP inspection
@@ -16,7 +14,7 @@ Use LSP inspection when your agent needs semantic code understanding instead of
16
14
  - Combine semantic inspection with `view` and `search_content` for faster navigation
17
15
  - Add LSP support for additional languages by [registering custom language servers](#custom-language-servers)
18
16
 
19
- ## Basic usage
17
+ ## Quickstart
20
18
 
21
19
  Enable LSP on a workspace by setting `lsp: true`:
22
20
 
@@ -57,7 +55,7 @@ The tool returns up to three result groups:
57
55
 
58
56
  ## Tool name remapping
59
57
 
60
- Rename the tool if your agent expects a shorter name:
58
+ Use `WORKSPACE_TOOLS.LSP.LSP_INSPECT` to configure the inspection tool. Set `enabled: false` to remove it from the agent's toolset, or set `name` if the agent expects a different name:
61
59
 
62
60
  ```typescript
63
61
  import { Workspace, LocalFilesystem, WORKSPACE_TOOLS } from '@mastra/core/workspace'
@@ -75,6 +73,8 @@ const workspace = new Workspace({
75
73
 
76
74
  This changes the exposed tool name only. The configuration key stays `WORKSPACE_TOOLS.LSP.LSP_INSPECT`.
77
75
 
76
+ See [`WorkspaceToolsConfig`](https://mastra.ai/reference/workspace/workspace-class) for approval settings, dynamic policies, output limits, and hooks shared by workspace tools.
77
+
78
78
  ## LSP configuration
79
79
 
80
80
  Set `lsp` to `true` for default behavior, or provide an object to customize server startup and diagnostics:
@@ -210,7 +210,6 @@ const workspace = new Workspace({
210
210
 
211
211
  ## Related
212
212
 
213
- - [Workspace overview](https://mastra.ai/docs/workspace/overview)
214
213
  - [Filesystem](https://mastra.ai/docs/workspace/filesystem)
215
214
  - [Sandbox](https://mastra.ai/docs/workspace/sandbox)
216
215
  - [Search and indexing](https://mastra.ai/docs/workspace/search)