Overview
Thefiles channel provides file system operations and real-time file change notifications. Operations use a request-response pattern with request IDs. File watcher events are pushed from the server without a request ID.
| Constraint | Value |
|---|---|
| Max file size | 100 MB |
| Binary encoding | Base64 |
| Path traversal | Blocked |
Ignored Paths
The file watcher ignores changes in these directories:node_modules, .git, .next, dist, build, __pycache__
File Operations
All operations are sent as client-to-server messages with arequestId. The server responds with a message of the same type and requestId.
list
List the contents of a directory.
| Field | Type | Description |
|---|---|---|
name | string | File or directory name |
type | string | "file" or "directory" |
size | integer | Size in bytes (0 for directories) |
modified | string | ISO 8601 last modified timestamp |
read
Read the contents of a file. Text files return UTF-8 content. Binary files return Base64-encoded content.
| Field | Type | Description |
|---|---|---|
content | string | File content (raw text or Base64) |
encoding | string | "utf-8" for text files, "base64" for binary files |
write
Write content to a file. Creates the file if it does not exist. Creates parent directories as needed.
| Field | Type | Required | Description |
|---|---|---|---|
path | string | Yes | File path to write |
content | string | Yes | File content |
encoding | string | No | "utf-8" (default) or "base64" for binary |
mkdir
Create a directory. Creates parent directories as needed.
delete
Delete a file or directory.
rename
Rename or move a file or directory.
| Field | Type | Required | Description |
|---|---|---|---|
oldPath | string | Yes | Current path |
newPath | string | Yes | New path |
stat
Get metadata for a file or directory.
| Field | Type | Description |
|---|---|---|
name | string | File or directory name |
type | string | "file" or "directory" |
size | integer | Size in bytes |
modified | string | ISO 8601 last modified timestamp |
permissions | string | Unix permission string |
Watcher Events
The server pushes file change events in real time. These messages have norequestId.
change
A file or directory was created, modified, or deleted.
| Field | Type | Description |
|---|---|---|
event | string | "create", "modify", or "delete" |
path | string | Affected file path |
fileType | string | "file" or "directory" |
Error Responses
If an operation fails, the server responds with the samerequestId and an error field:
Path Security
All paths are resolved relative to the workspace root. Directory traversal attempts (e.g.,../../etc/passwd) are rejected with an error. Symlinks that resolve outside the workspace root are also blocked.