From 848d10583bf1c4436e0abdee0bebc79637a8f0c9 Mon Sep 17 00:00:00 2001 From: Joseph Southwell Date: Wed, 21 May 2025 10:36:27 -0500 Subject: [PATCH] Updated create_mcp_configuration_file to create the parent directory --- src/ui/app.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ui/app.rs b/src/ui/app.rs index fd69953..2bfb7af 100644 --- a/src/ui/app.rs +++ b/src/ui/app.rs @@ -504,8 +504,15 @@ fn find_root_project(mut path: &Path, projects: &[ProjectDescription]) -> Option } fn create_mcp_configuration_file(path: &Path, contents: String) -> anyhow::Result<()> { - let config_path = PathBuf::from(path).join(".cursor/mcp.json"); - std::fs::create_dir_all(&config_path)?; - std::fs::write(config_path, contents)?; + let config_dir = PathBuf::from(path).join(".cursor"); + let config_path = config_dir.join("mcp.json"); + if let Err(e) = std::fs::create_dir_all(&config_dir) { + tracing::error!("Failed to create directory {:?}. Error: {}", config_dir, e); + return Err(e.into()); + } + if let Err(e) = std::fs::write(&config_path, &contents) { + tracing::error!("Failed to write mcp.json at {:?} with contents: {}. Error: {}", config_path, contents, e); + return Err(e.into()); + } Ok(()) }