fn main() { tauri_build::build(); // 从 tauri.conf.json 读取 identifier,注入编译时常量 MCP_APP_IDENTIFIER。 // CLI 模式(mcp-server)无 tauri app handle,无法通过 app.path().app_data_dir() 获取 // 真实路径;此常量让 default_db_path 自动拼出 Tauri 实际使用的 APPDATA/{identifier}/ 路径, // 保证 MCP server 与 GUI 应用读写同一数据库,无需手动传 --db。 let conf_path = std::path::Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()) .join("tauri.conf.json"); if let Ok(content) = std::fs::read_to_string(&conf_path) { if let Some(identifier) = content .lines() .find(|l| l.contains("\"identifier\"")) .and_then(|l| l.split(':').nth(1)) .map(|s| s.trim().trim_matches(',').trim_matches('"')) { println!("cargo:rustc-env=MCP_APP_IDENTIFIER={}", identifier); } } }