Skip to content

Commit 8aacf67

Browse files
fix: q mcp add subcommand failing when mcp.json is not found (#2561)
1 parent 8c692aa commit 8aacf67

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

crates/chat-cli/src/cli/mcp.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ impl AddArgs {
152152
Some(Scope::Workspace) => directories::chat_legacy_workspace_mcp_config(os)?,
153153
_ => directories::chat_legacy_global_mcp_config(os)?,
154154
};
155+
if !legacy_mcp_config_path.exists() {
156+
// Create an empty config file that won't fail to deserialize.
157+
os.fs.write(&legacy_mcp_config_path, "{ \"mcpServers\": {} }").await?;
158+
}
155159
let mut mcp_servers = McpServerConfig::load_from_file(os, &legacy_mcp_config_path).await?;
156160

157161
if mcp_servers.mcp_servers.contains_key(&self.name) && !self.force {

0 commit comments

Comments
 (0)