Context Server Registration
Relevant source files
The following files were used as context for generating this wiki page:
Context Server Registration is the mechanism by which the container-use-mcp extension identifies, configures, and launches the Model Context Protocol (MCP) server within the Zed editor environment. The primary goal of this registration process is to provide coding agents with access to containerized environments using the cu (Container Use) binary.
The registration lifecycle involves defining metadata in the extension manifest, implementing the zed::Extension trait to handle server commands and configurations, and resolving the executable path for the cu binary either through environment PATH resolution or user-defined settings.
Sources: extension.toml:1-14, src/container_use_mcp.rs:1-12, README.md:1-5
Extension Metadata and Capabilities
The registration begins with the extension.toml file, which defines the extension's identity and its required capabilities. The extension specifically requests process:exec permissions to execute the which command, which is necessary for automatic binary discovery.
Manifest Configuration
| Field | Value | Description |
|---|---|---|
id | mcp-server-container-use | Unique identifier for the extension. |
name | Container Use MCP Server | Human-readable name of the server. |
context_servers | container-use-mcp | The internal key used to reference this server. |
Sources: extension.toml:1-14
Execution Logic and Binary Discovery
The registration logic is implemented in the ContainerUseMcpExtension struct. When Zed attempts to start the context server, it invokes context_server_command, which triggers a multi-stage discovery process for the cu binary.
Binary Resolution Flow
The extension first checks for a user-provided path in settings. If not found, it attempts to locate the cu binary in the system's PATH.
Sources: src/container_use_mcp.rs:25-54
Data Structures
The extension uses specific Rust structures to handle settings and state:
ContainerUseMcpSettings: A deserializable struct used to capture thecu_pathfrom Zed'ssettings.json.ContainerUseMcpExtension: Maintains acached_binary_pathto avoid repeated disk or process lookups.
Sources: src/container_use_mcp.rs:12-20
Context Server Configuration
The registration process provides Zed with the necessary UI components and schemas to manage the server via the context_server_configuration method. This includes installation instructions, default settings, and a JSON schema for settings validation.
Configuration Components
| Component | Source/Origin | Purpose |
|---|---|---|
installation_instructions | configuration/installation_instructions.md | Guides the user on setting up .rules for agents. |
settings_schema | schemars::schema_for! | Provides autocomplete and validation for cu_path in Zed settings. |
default_settings | configuration/default_settings.jsonc | Provides the baseline configuration for the extension. |
Sources: src/container_use_mcp.rs:73-89, configuration/installation_instructions.md:1-1
Server Instantiation
The final step of registration is the creation of a Command object that Zed uses to spawn the MCP server process. The server is always launched with the stdio argument to facilitate communication with the editor.
Ok(Command {
command: self.context_server_binary_path(context_server_id)?,
args: vec!["stdio".into()],
env: vec![],
})
Sources: src/container_use_mcp.rs:66-70
Summary
Context Server Registration in container-use-mcp bridges the Zed extension API with the local cu binary. By leveraging zed_extension_api, the project ensures that the MCP server is correctly discovered, configured through user settings, and executed with the appropriate standard I/O parameters to enable containerized agent workflows.