FileSystem
Register the file-system tool suite to list sandbox roots, read, download, push, copy, move, and delete sandboxed files in a paired .NET app.
Install
dotnet add package Ansight.Tools.FileSystem --prerelease
Register the Suite
using Ansight;
using Ansight.Tools.FileSystem;
var options = Options.CreateBuilder()
.WithFileSystemTools(fileSystem =>
{
fileSystem.AddRoot("logs", "/absolute/path/to/logs");
})
.WithReadOnlyToolAccess()
.Build();
Registration API
WithFileSystemTools(): registers the suite with the default sandbox roots only.WithFileSystemTools(fileSystem => ...): configures additional tagged roots.AddRoot(tag, path): exposes an extra sandboxed directory under a stable root alias.
Specific Concerns
- All access is constrained to approved sandbox roots.
- The suite exposes file contents, so it is sensitive even when only read tools are enabled.
files.push_file,files.copy_file, andfiles.move_fileare write-scoped and requireWithReadWriteToolAccess(),WithAllToolAccess(), or a custom write-enabledToolGuard.files.delete_fileis delete-scoped and requiresWithAllToolAccess()or a custom delete-enabledToolGuard.files.begin_binary_downloadis the preferred path when the caller can consume binary WebSocket frames.- The app SDK does not choose the local temp file path for
files.begin_binary_download; the consuming bridge owns that path and maps it bytransferId. - The app SDK also does not read host-local paths directly. For push flows, Ansight Studio and the Ansight host MCP bridge read the host file, encode it, and call the app’s
files.push_filetool withcontentBase64. files.download_fileremains available as a JSON fallback for chunked text or base64 transfers.
Default roots:
- Android:
appData,cache,temp - iOS and Mac Catalyst:
appData,documents,cache,temp - Additional roots can be tagged with
AddRoot(tag, path)
Tool Matrix
| Name | Id | Scope | Description | Security |
|---|---|---|---|---|
List Directory | files.list_directory | Read | Lists files and folders inside the app sandbox. | Moderate |
Read File | files.read_file | Read | Reads a file from the app sandbox using a constrained path. | High |
Get File Checksum | files.get_file_checksum | Read | Computes one or more checksums for a sandboxed file without returning file contents. | Moderate |
Download File | files.download_file | Read | Downloads a sandboxed file in resumable chunks with text or base64 payloads. | High |
Begin Binary Download | files.begin_binary_download | Read | Starts a binary WebSocket download for a sandboxed file. | High |
Push File | files.push_file | Write | Writes caller-provided content into a folder inside an approved sandbox root. | High |
Copy File | files.copy_file | Write | Copies a sandboxed file to another constrained sandbox path. | High |
Move File | files.move_file | Write | Moves or renames a sandboxed file inside approved roots. | High |
Delete File | files.delete_file | Delete | Deletes a sandboxed file from an approved root. | Critical |
List Directory
Arguments:
root: optional root aliaspath: optional relative directory pathincludeHiddenrecursivemaxDepthmaxEntries
Returns:
- resolved root and directory metadata
availableRootsentriestruncatedcapturedAtUtc
Example:
{
"toolId": "files.list_directory",
"arguments": {
"root": "appData",
"path": "databases",
"recursive": true,
"maxDepth": 2,
"maxEntries": 200
}
}
Read File
Arguments:
root: optional root aliaspath: required file pathmaxBytesencoding:auto,utf8, orbase64
Returns:
- resolved file metadata
bytesReadtruncatedcontentTypeencodingtextorbase64
Example:
{
"toolId": "files.read_file",
"arguments": {
"root": "logs",
"path": "latest.log",
"maxBytes": 65536,
"encoding": "utf8"
}
}
Get File Checksum
Arguments:
root: optional root aliaspath: required file pathalgorithms: optional comma-separated list ofmd5,sha1,sha256,sha384,sha512,crc32, orall; defaults tosha256
Returns:
- resolved file metadata
fileName,fileExtension,mimeTypesizeBytes,lastModifiedUtc,versionchecksums
Example:
{
"toolId": "files.get_file_checksum",
"arguments": {
"root": "appData",
"path": "exports/session.json",
"algorithms": "sha256,crc32"
}
}
Download File
Arguments:
root: optional root aliaspath: required file pathoffsetBytesmaxBytesencoding:auto,utf8, orbase64expectedVersion
Returns:
- chunk metadata
fileName,fileExtension,mimeTypesizeBytes,lastModifiedUtc,versionhasMorenextOffsetBytesnextRequest- encoded chunk content
Example:
{
"toolId": "files.download_file",
"arguments": {
"root": "appData",
"path": "exports/session.json",
"offsetBytes": 0,
"maxBytes": 262144,
"encoding": "utf8"
}
}
Begin Binary Download
Arguments:
root: optional root aliaspath: required file pathchunkBytesdownloadId: optional caller correlation id
Returns:
- resolved file metadata
downloadIdtransferIdfileName,fileExtension,mimeTypesizeBytes,lastModifiedUtc,versiondeliveryMode = websocket_binarywireProtocol = ansight.file-transfer.v1statuschunkBytes
Example:
{
"toolId": "files.begin_binary_download",
"arguments": {
"root": "appData",
"path": "exports/archive.zip",
"chunkBytes": 65536,
"downloadId": "session-archive"
}
}
Binary Download Notes
For files.begin_binary_download, the host-side MCP bridge is expected to:
- choose the local temp file path
- call
files.begin_binary_download - map
transferIdto that file - write incoming
ASFTbinary frames until completion
Push File
files.push_file writes content into a destination folder under an approved sandbox root. Use contentBase64 for arbitrary files or text for UTF-8 text payloads. Provide exactly one content field.
Arguments:
root: optional root aliasdirectoryPath: required destination folder path relative to the rootfileName: required destination file name, not a pathcontentBase64: base64-encoded file contenttext: UTF-8 text contentoverwrite: replace an existing destination filecreateDirectory: create the destination folder when missing
Returns:
- resolved destination file metadata
sizeBytesoperationoverwrittencreatedDirectorycapturedAtUtc
Example:
{
"toolId": "files.push_file",
"arguments": {
"root": "appData",
"directoryPath": "imports",
"fileName": "config.json",
"contentBase64": "eyJkZWJ1ZyI6dHJ1ZX0=",
"overwrite": true,
"createDirectory": true
}
}
Ansight Studio and Host Push Flow
Ansight Studio exposes a host-friendly push flow for files.push_file because the app SDK cannot read files from the host computer. When you select files.push_file in Ansight Studio, the argument template uses localFilePath; Ansight Studio reads that file on the host, encodes it, and sends contentBase64 to the paired app.
Ansight Studio argument template:
{
"localFilePath": "/Users/example/Desktop/config.json",
"root": "appData",
"directoryPath": "imports",
"fileName": "config.json",
"overwrite": true,
"createDirectory": true
}
The Ansight host MCP server also exposes ansight_push_file_to_app for external MCP clients. It accepts the same host-local file fields, plus optional sessionId or appId when more than one app session is live.
Example:
{
"name": "ansight_push_file_to_app",
"arguments": {
"localFilePath": "/Users/example/Desktop/config.json",
"root": "appData",
"directoryPath": "imports",
"fileName": "config.json",
"overwrite": true,
"createDirectory": true
}
}
The paired app must have Ansight.Tools.FileSystem registered and must allow write-scoped tools.
Copy File
Arguments:
root: optional source root aliassourcePath: required source file path relative to the source rootdestinationRoot: optional destination root aliasdestinationPath: required destination file path relative to the destination rootoverwrite: replace an existing destination filecreateDirectory: create the destination folder when missing
Returns:
- resolved source and destination metadata
sizeBytesoperationoverwrittencreatedDirectorycapturedAtUtc
Example:
{
"toolId": "files.copy_file",
"arguments": {
"root": "appData",
"sourcePath": "imports/config.json",
"destinationRoot": "cache",
"destinationPath": "debug/config-copy.json",
"overwrite": true,
"createDirectory": true
}
}
Move File
Arguments:
root: optional source root aliassourcePath: required source file path relative to the source rootdestinationRoot: optional destination root aliasdestinationPath: required destination file path relative to the destination rootoverwrite: replace an existing destination filecreateDirectory: create the destination folder when missing
Returns:
- resolved source and destination metadata
sizeBytesoperationoverwrittencreatedDirectorycapturedAtUtc
Example:
{
"toolId": "files.move_file",
"arguments": {
"root": "appData",
"sourcePath": "imports/config.json",
"destinationPath": "imports/config.active.json",
"overwrite": true,
"createDirectory": false
}
}
Delete File
Arguments:
root: optional root aliaspath: required file path relative to the root
Returns:
- resolved deleted file metadata
deletedcapturedAtUtc
Example:
{
"toolId": "files.delete_file",
"arguments": {
"root": "cache",
"path": "debug/config-copy.json"
}
}