Zed Settings JSON Integration
Relevant source files
The following files were used as context for generating this wiki page:
The Zed Settings JSON Integration for the Container Use MCP extension allows users to configure the execution environment for containerized coding agents directly within the Zed editor's configuration system. This integration primarily focuses on defining the location of the cu (Container Use) binary, which is essential for establishing the Model Context Protocol (MCP) connection between Zed and the containerized environment.
This system leverages the zed_extension_api to parse user-defined settings from Zed's settings.json and apply them to the extension's execution logic. By default, the extension attempts to discover the cu binary via the system's PATH, but the JSON integration provides a mechanism for overrides and custom installations.
Sources: README.md:15-32, src/container_use_mcp.rs:11-14, src/container_use_mcp.rs:69-72
Configuration Data Model
The integration relies on a structured data model to deserialize JSON configuration into Rust types. The primary structure used is ContainerUseMcpSettings, which defines the available configuration keys for the extension.
| Field | Type | Description |
|---|---|---|
cu_path | Option<String> | The absolute path to the cu binary. If omitted, the extension searches the system PATH. |
Sources: src/container_use_mcp.rs:11-14
Schema Generation
To provide auto-completion and validation within Zed's settings.json, the extension generates a JSON schema from the Rust struct using the schemars crate. This schema is registered during the extension's configuration phase.
Sources: src/container_use_mcp.rs:11, src/container_use_mcp.rs:90-93, Cargo.toml:16
Settings Resolution Logic
The extension follows a specific hierarchy when determining which binary path to use. It prioritized user-defined settings in settings.json over automatic discovery.
The logic ensures that manual configuration takes precedence, but provides a fallback to the system environment.
Sources: src/container_use_mcp.rs:27-51, src/container_use_mcp.rs:71-82
The context_server_command Flow
When Zed requests a command to start the MCP server, the extension performs the following steps:
- Retrieves
ContextServerSettingsfor the "container-use-mcp" server. - Deserializes the settings into the
ContainerUseMcpSettingsstruct. - If a
cu_pathis provided, it updates the internalcached_binary_path. - Calls
context_server_binary_pathto resolve the final executable string.
Sources: src/container_use_mcp.rs:69-82
Integration with Zed API
The extension implements the zed::Extension trait, which provides hooks for configuration and command generation.
Configuration Registration
The context_server_configuration method informs Zed about the extension's settings structure and documentation.
Execution Environment
The resolved configuration results in a Command object that Zed uses to launch the MCP server. The command is always executed with the stdio argument to facilitate communication.
| Component | Value | Source |
|---|---|---|
| Binary | Resolved cu_path or which cu | src/container_use_mcp.rs:71 |
| Arguments | ["stdio"] | src/container_use_mcp.rs:80 |
| Environment | Empty vec![] | src/container_use_mcp.rs:81 |
Sources: src/container_use_mcp.rs:78-82, extension.toml:13-16
Implementation Example
Users configure the integration by adding the server ID container-use-mcp to their context_servers block in Zed.
{
"context_servers": {
"container-use-mcp": {
"settings": {
"cu_path": "/usr/local/bin/cu"
}
}
}
}
Sources: README.md:20-28, extension.toml:18-19
Summary
The Zed Settings JSON Integration provides a robust way to bridge the editor's configuration with the cu binary required for containerized agent operations. By combining static schema generation with dynamic path resolution (checking user settings, then cache, then the system PATH), the system ensures the Container Use MCP server can be reliably instantiated across various user environments.