CU Binary Interface
Relevant source files
The following files were used as context for generating this wiki page:
The CU Binary Interface is the core bridge between the Zed editor and the cu (Container Use) command-line tool. It facilitates the Model Context Protocol (MCP) by managing the lifecycle and execution of the cu binary, which provides containerized environments for coding agents within Zed.
This interface is responsible for locating the binary on the host system, handling user-defined path overrides, and invoking the binary with the necessary arguments to establish a standard input/output (stdio) communication channel.
Sources: src/container_use_mcp.rs:1-12, README.md:1-5, extension.toml:1-5
Binary Resolution Logic
The extension employs a multi-step resolution strategy to identify the executable path of the cu binary. It prioritizes explicit user configuration before falling back to system environment discovery.
Resolution Priority
- User-Defined Path: The extension first checks the
settings.jsonfor acu_pathkey. - Cached Path: If a path was previously found and validated in the current session, it is reused.
- System PATH: The extension executes a system command to locate
cuwithin the user's environment.
The following flowchart illustrates the binary resolution and validation logic:
Execution Environment
The cu binary is executed as a child process of the Zed extension host. To function as an MCP server, it is invoked with specific arguments and environment configurations.
Command Configuration
| Element | Value / Description | Source |
|---|---|---|
| Command | Path to the cu binary | src/container_use_mcp.rs:82 |
| Arguments | ["stdio"] | src/container_use_mcp.rs:83 |
| Env Vars | Empty (Inherited from Zed) | src/container_use_mcp.rs:84 |
| Capabilities | process:exec (specifically for which) | extension.toml:10-13 |
Implementation Details
The extension implements the zed::Extension trait, specifically the context_server_command method to construct the execution instruction.
fn context_server_command(
&mut self,
context_server_id: &ContextServerId,
project: &Project,
) -> Result<Command> {
// ... setting retrieval ...
Ok(Command {
command: self.context_server_binary_path(context_server_id)?,
args: vec!["stdio".into()],
env: vec![],
})
}
Sources: src/container_use_mcp.rs:63-86, extension.toml:15-16
Configuration and Settings
The binary interface is configurable through Zed's settings mechanism. This allows users to point to non-standard installations or experimental builds of the cu tool.
Settings Schema
The extension defines a ContainerUseMcpSettings struct that is used to deserialize configuration from JSON and generate a JSON schema for Zed's settings editor.
| Field | Type | Description |
|---|---|---|
cu_path | Option<String> | Optional absolute path to the cu binary. |
Sources: src/container_use_mcp.rs:11-15, README.md:16-26
Configuration Flow
The following sequence diagram shows how settings are propagated to the binary command construction:
Summary
The CU Binary Interface provides a robust mechanism for Zed to interact with the Dagger Container Use tool. By supporting both automated path discovery via the system's which command and explicit user configuration, it ensures that the MCP server can be started reliably across different environments. The interface strictly adheres to the stdio communication mode required for the Model Context Protocol integration.
Sources: src/container_use_mcp.rs:82-85, README.md:12-14, Cargo.toml:1-14