#include #include #include #include constexpr auto* TAG = "McpSettings"; #include #include #include namespace tt::settings::mcp { static std::string getSettingsFilePath() { return getUserDataPath() + "/settings/mcp.properties"; } constexpr auto* KEY_MCP_ENABLED = "mcpEnabled"; bool load(McpSettings& settings) { auto settings_path = getSettingsFilePath(); if (!file::isFile(settings_path)) { return false; } std::map map; if (!file::loadPropertiesFile(settings_path, map)) { return false; } auto mcp_enabled = map.find(KEY_MCP_ENABLED); settings.mcpEnabled = (mcp_enabled != map.end()) ? (mcp_enabled->second == "1" || mcp_enabled->second == "true") : false; return true; } McpSettings getDefault() { return McpSettings{ .mcpEnabled = false }; } McpSettings loadOrGetDefault() { McpSettings settings; if (!load(settings)) { settings = getDefault(); if (!save(settings)) { LOG_W(TAG, "Failed to save default MCP settings"); } } return settings; } bool save(const McpSettings& settings) { std::map map; map[KEY_MCP_ENABLED] = settings.mcpEnabled ? "true" : "false"; auto settings_path = getSettingsFilePath(); if (!file::findOrCreateParentDirectory(settings_path, 0755)) { LOG_E(TAG, "Failed to create parent dir for %s", settings_path.c_str()); return false; } if (!file::savePropertiesFile(settings_path, map)) { LOG_E(TAG, "Failed to save MCP settings to %s", settings_path.c_str()); return false; } return true; } } // namespace