diff --git a/src/DynamoCore/Configuration/PreferenceSettings.cs b/src/DynamoCore/Configuration/PreferenceSettings.cs index 08fe38e99c2..bc57748cc24 100644 --- a/src/DynamoCore/Configuration/PreferenceSettings.cs +++ b/src/DynamoCore/Configuration/PreferenceSettings.cs @@ -76,6 +76,7 @@ private readonly static Lazy private bool isEnablePersistExtensionsEnabled; private bool isAutoSyncDocumentBrowser = true; private bool isStaticSplashScreenEnabled; + private bool isMcpServerEnabledOnStartup; private bool isTimeStampIncludedInExportFilePath; private bool isCreatedFromValidFile = true; private string backupLocation; @@ -825,6 +826,24 @@ public bool EnableStaticSplashScreen } } + /// + /// This defines whether the Dynamo MCP (Model Context Protocol) server starts + /// automatically when Dynamo launches. When false, the server stays off until the + /// user enables it from the MCP extension's Extensions-menu toggle (DYN-9355). + /// + public bool EnableMcpServerOnStartup + { + get + { + return isMcpServerEnabledOnStartup; + } + set + { + isMcpServerEnabledOnStartup = value; + RaisePropertyChanged(nameof(EnableMcpServerOnStartup)); + } + } + /// /// This defines if the user is agree to the ML Automcomplete Terms of Use /// @@ -1100,6 +1119,7 @@ public PreferenceSettings() HideAutocompleteMethodOptions = false; EnableNotificationCenter = true; isStaticSplashScreenEnabled = true; + isMcpServerEnabledOnStartup = false; isTimeStampIncludedInExportFilePath = true; DefaultPythonEngine = string.Empty; ViewExtensionSettings = new List(); diff --git a/src/DynamoCore/PublicAPI.Unshipped.txt b/src/DynamoCore/PublicAPI.Unshipped.txt index fd19c94b62b..ae3bcd415be 100644 --- a/src/DynamoCore/PublicAPI.Unshipped.txt +++ b/src/DynamoCore/PublicAPI.Unshipped.txt @@ -1,3 +1,5 @@ +Dynamo.Configuration.PreferenceSettings.EnableMcpServerOnStartup.get -> bool +Dynamo.Configuration.PreferenceSettings.EnableMcpServerOnStartup.set -> void Dynamo.Graph.Nodes.IValueSchemaProvider Dynamo.Graph.Nodes.IValueSchemaProvider.IsListValue.get -> bool Dynamo.Graph.Nodes.IValueSchemaProvider.ValueTypeId.get -> string diff --git a/src/DynamoCoreWpf/Properties/Resources.Designer.cs b/src/DynamoCoreWpf/Properties/Resources.Designer.cs index 03f501a0c71..29ee279075e 100644 --- a/src/DynamoCoreWpf/Properties/Resources.Designer.cs +++ b/src/DynamoCoreWpf/Properties/Resources.Designer.cs @@ -8390,6 +8390,24 @@ public static string PreferencesViewEnablePersistExtensions { return ResourceManager.GetString("PreferencesViewEnablePersistExtensions", resourceCulture); } } + + /// + /// Looks up a localized string similar to Start the MCP server when Dynamo launches. + /// + public static string PreferencesViewEnableMcpServerOnStartup { + get { + return ResourceManager.GetString("PreferencesViewEnableMcpServerOnStartup", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to When enabled, the Dynamo MCP server starts automatically with Dynamo. When disabled, you can still turn it on at any time from the Extensions menu without restarting Dynamo. + /// + public static string PreferencesViewEnableMcpServerOnStartupTooltip { + get { + return ResourceManager.GetString("PreferencesViewEnableMcpServerOnStartupTooltip", resourceCulture); + } + } /// /// Looks up a localized string similar to Enable T-Spline nodes. diff --git a/src/DynamoCoreWpf/Properties/Resources.en-US.resx b/src/DynamoCoreWpf/Properties/Resources.en-US.resx index 14958c67a51..6552a8e1cfd 100644 --- a/src/DynamoCoreWpf/Properties/Resources.en-US.resx +++ b/src/DynamoCoreWpf/Properties/Resources.en-US.resx @@ -740,6 +740,14 @@ Don't worry, you'll have the option to save your work. Experimental Preferences | Features | Experimental + + Start the MCP server when Dynamo launches + Preferences | Features | Experimental + + + When enabled, the Dynamo MCP server starts automatically with Dynamo. When disabled, you can still turn it on at any time from the Extensions menu without restarting Dynamo. + Preferences | Features | Experimental + _Settings Setting menu diff --git a/src/DynamoCoreWpf/Properties/Resources.resx b/src/DynamoCoreWpf/Properties/Resources.resx index 5f1aae9c455..532fca8c339 100644 --- a/src/DynamoCoreWpf/Properties/Resources.resx +++ b/src/DynamoCoreWpf/Properties/Resources.resx @@ -600,6 +600,14 @@ Experimental Preferences | Features | Experimental + + Start the MCP server when Dynamo launches + Preferences | Features | Experimental + + + When enabled, the Dynamo MCP server starts automatically with Dynamo. When disabled, you can still turn it on at any time from the Extensions menu without restarting Dynamo. + Preferences | Features | Experimental + Enable T-Spline nodes Preferences | Features | Experimental | Enable T-Spline nodes diff --git a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs index d5f50cac3b0..ac226dbb9c9 100644 --- a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs @@ -401,6 +401,24 @@ public bool StaticSplashScreenEnabled } } + /// + /// Controls the IsChecked property in the "start MCP server on launch" toggle button. + /// When enabled, the Dynamo MCP server starts automatically with Dynamo; otherwise it + /// stays off until enabled from the MCP extension's Extensions-menu toggle (DYN-9355). + /// + public bool McpServerEnabledOnStartup + { + get + { + return preferenceSettings.EnableMcpServerOnStartup; + } + set + { + preferenceSettings.EnableMcpServerOnStartup = value; + RaisePropertyChanged(nameof(McpServerEnabledOnStartup)); + } + } + /// /// Controls the IsChecked property in the selecting to include timestamp for export path section /// @@ -1287,9 +1305,9 @@ public bool IsExperimentalExpanderVisible { get { - // Hide for now since panel nodes are OOTB and no other experimental features - // Keep infrastructure for future experimental features - return false; + // Visible now that the Experimental section hosts the MCP server startup + // toggle (DYN-9355). Previously hidden when the section had no features. + return true; } } diff --git a/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml b/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml index 246c0329346..3d410facf32 100644 --- a/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml +++ b/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml @@ -1100,7 +1100,30 @@ - + + + + diff --git a/test/DynamoCoreTests/Configuration/PreferenceSettingsTests.cs b/test/DynamoCoreTests/Configuration/PreferenceSettingsTests.cs index ab659c59255..6e79068321a 100644 --- a/test/DynamoCoreTests/Configuration/PreferenceSettingsTests.cs +++ b/test/DynamoCoreTests/Configuration/PreferenceSettingsTests.cs @@ -427,6 +427,32 @@ public void TestImportCopySettings() Assert.IsTrue(checkEquality.SamePropertyValues.Count == checkEquality.Properties.Count); } + [Test] + [Category("UnitTests")] + public void WhenSettingsAreNewThenMcpServerOnStartupDefaultsToFalse() + { + // The MCP server must stay off unless the user opts in (DYN-9355). + var settings = new PreferenceSettings(); + + Assert.IsFalse(settings.EnableMcpServerOnStartup); + } + + [Test] + [Category("UnitTests")] + public void WhenMcpServerOnStartupIsEnabledThenItPersistsAcrossSaveAndLoad() + { + // Use a unique file under the per-test TempFolder, which UnitTestBase cleans up on teardown. + string tempPath = GetNewFileNameOnTempPath("xml"); + + var settings = new PreferenceSettings(); + settings.EnableMcpServerOnStartup = true; + + settings.Save(tempPath); + var loadedSettings = PreferenceSettings.Load(tempPath); + + Assert.IsTrue(loadedSettings.EnableMcpServerOnStartup); + } + [Test] [Category("UnitTests")] public void TestTaintedFile() diff --git a/test/settings/DynamoSettings-NewSettings.xml b/test/settings/DynamoSettings-NewSettings.xml index 6d0b1938a2e..079694ae326 100644 --- a/test/settings/DynamoSettings-NewSettings.xml +++ b/test/settings/DynamoSettings-NewSettings.xml @@ -87,6 +87,7 @@ false false false + true false false true