Skip to main content

WorkspaceExec

Trait WorkspaceExec 

Source
pub trait WorkspaceExec:
    Send
    + Sync
    + 'static {
    // Required methods
    fn scope(&self) -> WorkspaceScope;
    fn read_file(
        &self,
        path: &Path,
    ) -> impl Future<Output = Result<Vec<u8>, ToolSdkError>> + Send;
    fn write_file(
        &self,
        path: &Path,
        contents: &[u8],
    ) -> impl Future<Output = Result<(), ToolSdkError>> + Send;
    fn exec(
        &self,
        command: &str,
        args: &[&str],
    ) -> impl Future<Output = Result<ExecOutput, ToolSdkError>> + Send;
}
Expand description

Trait for accessing an agent’s workspace from within an MCP tool.

Implementations provide scoped access to the agent container’s filesystem. The sandbox enforces the granted WorkspaceScope — operations beyond the scope will return an error.

§Phase 0 Note

This trait defines the target interface. Implementations will be added in Phase 5 when DockerWorkspaceExec wraps Bollard calls behind this trait.

Required Methods§

Source

fn scope(&self) -> WorkspaceScope

The scope granted to this workspace handle.

Source

fn read_file( &self, path: &Path, ) -> impl Future<Output = Result<Vec<u8>, ToolSdkError>> + Send

Read a file from the agent’s workspace.

Returns the file contents as bytes. Requires at least WorkspaceScope::ReadOnly.

Source

fn write_file( &self, path: &Path, contents: &[u8], ) -> impl Future<Output = Result<(), ToolSdkError>> + Send

Write a file to the agent’s workspace.

Creates or overwrites the file at the given path. Requires at least WorkspaceScope::ReadWrite.

Source

fn exec( &self, command: &str, args: &[&str], ) -> impl Future<Output = Result<ExecOutput, ToolSdkError>> + Send

Execute a command in the agent’s workspace.

Returns the command’s stdout as bytes. Requires WorkspaceScope::Exec.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§