DAIMONMCP sandbox, kernel-isolated
by Linux kernel policy or Kubernetes Pods
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) -> ReadResult

Read a file from the sandbox filesystem. Supports UTF-8 text, images, and office/PDF documents converted to Markdown. Content larger than MCP_READ_INLINE_OUTPUT_MAX_CHARS returns an error unless you pass limit. Later Reads of the same converted bytes reuse a cached conversion.

ParameterTypeDefaultDescription
file_pathstrPath to the file.
offsetint | NoneNoneStarting line for text and converted documents.
limitint | NoneNoneMax lines to read. Required when the file or converted Markdown exceeds the inline size limit.
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