DAIMONMCP sandbox, kernel-isolated
by Linux nsjail
Python SDK

Files

Read, write, edit, glob, grep, and transfer files inside the sandbox.

All methods return typed result objects.

FilesAPI.read

async files.read(file_path, *, offset=None, limit=None, pages=None) -> ReadResult

Read a file from the sandbox filesystem. Supports text, image, and multi-page content.

ParameterTypeDefaultDescription
file_pathstrPath to the file.
offsetint | NoneNoneStarting line for text files.
limitint | NoneNoneMax lines to read.
pagesstr | NoneNonePage range for PDFs (e.g. '1-5').
read = await client.files.read("/tmp/demo.txt")
print(read.file.content)
print(read.file.num_lines)

FilesAPI.write

async files.write(file_path, content) -> WriteResult

Write content to a file. Creates the file if it does not exist.

written = await client.files.write("/tmp/demo.txt", "hello\n")
print(written.file_path)

FilesAPI.edit

async files.edit(file_path, *, old_string, new_string, replace_all=False) -> EditResult

Edit a file by replacing text. Returns a structured patch.

ParameterTypeDefaultDescription
file_pathstrPath to the file.
old_stringstrText to replace.
new_stringstrReplacement text.
replace_allboolFalseReplace all occurrences.

FilesAPI.glob

async files.glob(pattern, *, path=None) -> GlobResult
glob = await client.files.glob("**/*.rs", path=runtime.base_workdir)
print(glob.search_path, glob.num_files)

FilesAPI.grep

async files.grep(pattern, *, path=None, glob=None, output_mode=None, ...) -> GrepResult

Search file contents with regex. Supports the full Grep tool parameter set.

ParameterTypeDefaultDescription
patternstrRegex pattern to search for.
pathstr | NoneNoneRoot directory to search.
globstr | NoneNoneFile filter glob (e.g. '*.py').
output_modestr | NoneNone'content', 'files_with_matches', or 'count'.
grep = await client.files.grep("TODO", path=runtime.base_workdir)
print(grep.num_matches)

File transfer

Upload and download raw bytes through the SDK-only HTTP endpoint (/sdk/file). Meant for SDK and GUI integrations.

async files.upload_bytes(file_path, data) -> FileTransferResult

blob = await client.files.upload_bytes(
    "artifacts/report.pdf",
    pdf_bytes,
)
print(blob.file_path, blob.bytes_written, blob.created)

async files.download_bytes(file_path) -> bytes

data = await client.files.download_bytes("artifacts/report.pdf")
print(len(data))

async files.upload_file(local_path, remote_path) -> FileTransferResult

Upload a local file to the sandbox.

async files.download_file(remote_path, local_path) -> Path

Download a remote file to the local filesystem.

On this page