#include #include #include #include #include #include #include namespace tt::settings::mcp { static const auto LOGGER = Logger("McpSettings"); 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)) { LOGGER.warn("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)) { LOGGER.error("Failed to create parent dir for {}", settings_path); return false; } if (!file::savePropertiesFile(settings_path, map)) { LOGGER.error("Failed to save MCP settings to {}", settings_path); return false; } return true; } } // namespace