Building from Source
Relevant source files
The following files were used as context for generating this wiki page:
Building the Container Use MCP extension from source involves compiling the Rust-based Zed extension and ensuring the underlying cu (Container Use) binary is correctly built and available on the system. The extension serves as a bridge between the Zed editor and the cu binary, which provides containerized environments for AI coding agents.
Sources: README.md:1-5, extension.toml:1-4
Extension Compilation and Structure
The extension is developed in Rust and compiled as a dynamic library (cdylib). It utilizes the zed_extension_api to interface with the Zed editor.
Project Metadata
The project is configured using Cargo.toml and extension.toml.
| Field | Value | Source |
|---|---|---|
| Name | container_use_mcp | Cargo.toml:2 |
| Version | 0.0.1 | Cargo.toml:3 |
| License | Apache-2.0 | Cargo.toml:6 |
| Crate Type | cdylib | Cargo.toml:10 |
| API Dependency | zed_extension_api 0.5.0 | Cargo.toml:15 |
Core Logic
The primary logic resides in src/container_use_mcp.rs, which defines the ContainerUseMcpExtension struct and implements the zed::Extension trait. This implementation handles binary discovery and command execution.
Sources: src/container_use_mcp.rs:1-122, Cargo.toml:9-15
Dependency: The cu Binary
The extension requires the cu binary from the Container Use repository. Because this project is in active development, users are instructed to build the cu binary from source manually.
Binary Discovery Flow
The extension follows a specific sequence to locate the cu executable required to run the MCP server.
The discovery logic checks user settings first, then falls back to searching the system PATH.
Sources: src/container_use_mcp.rs:25-52, README.md:12-25
Build Requirements and Environment
To successfully build and run the extension from source, the following environment capabilities and dependencies must be met:
Capabilities
The extension requires the ability to execute system processes to find dependencies.
- Process Execution: The extension specifically needs to execute the
whichcommand with thecuargument to locate the binary.
Sources: extension.toml:11-14, src/container_use_mcp.rs:35-37
Implementation Detail: Settings Schema
The extension uses schemars and serde to define and validate configuration settings during the build and runtime phases.
#[derive(Debug, Deserialize, JsonSchema)]
struct ContainerUseMcpSettings {
/// Path to the cu binary (optional - will download if not provided)
cu_path: Option<String>,
}
Sources: src/container_use_mcp.rs:10-14
Component Interaction
The following sequence diagram illustrates how the Zed extension interacts with the local environment to initialize the MCP server.
Agent Configuration
Once the binary and extension are built, a specific ruleset is required for AI agents to correctly utilize the containerized environment. This is achieved by downloading an agent rules file into the project root.
curl -o .rules https://raw.githubusercontent.com/dagger/container-use/main/rules/agent.md
Sources: README.md:31-35, configuration/installation_instructions.md:1
Building this extension from source requires a Rust toolchain to compile the cdylib and the manual installation of the cu binary. The system relies on standard Unix utilities like which and curl for discovery and rule configuration respectively.