using System.Text.Json; namespace LehrerApp.Desktop.Services; internal class McpSettingsConfig { public bool Enabled { get; set; } } /// /// Opt-in-Schalter für den lokalen MCP-Server (siehe Planungsdokument, Phase 1). Anders als /// braucht Phase 1 kein Login/Token — die Named Pipe selbst ist die /// Vertrauensgrenze (lokaler Prozess, gleiche Windows-Session bzw. Unix-Dateirechte), siehe /// Begründung im Planungsdokument. /// public class McpSettingsService { private readonly string _configPath; private McpSettingsConfig _config; public bool Enabled => _config.Enabled; public McpSettingsService(string appDataPath) { _configPath = Path.Combine(appDataPath, "mcp-settings.json"); _config = Load(); } public void SetEnabled(bool enabled) { _config.Enabled = enabled; Save(); } private void Save() => File.WriteAllText(_configPath, JsonSerializer.Serialize(_config)); private McpSettingsConfig Load() { try { if (File.Exists(_configPath)) return JsonSerializer.Deserialize(File.ReadAllText(_configPath)) ?? new McpSettingsConfig(); } catch { /* beschädigte Konfiguration -> Standardwert */ } return new McpSettingsConfig(); } }