Skip to content

Commit 3e8ce76

Browse files
fix: deprecate --*.disabled CLI flags, wire up --mcp.disabled (#3482)
## Why make this change? - Closes #3376 `dab init` has both `--rest.disabled` and `--rest.enabled` (same for graphql/mcp) for the same property. This is confusing UX. Additionally, `--mcp.disabled` was defined but never wired up (no-op). ## What is this change? - **Hide** `--rest.disabled`, `--graphql.disabled`, `--mcp.disabled` from `--help` output (`Hidden = true`) - **Add `[Deprecated]` prefix** to HelpText for all three flags - **Add deprecation warning** for `--mcp.disabled` (was missing — REST and GraphQL already had them) - **Wire up `--mcp.disabled`** through `TryDetermineIfApiIsEnabled` (was previously a no-op) - **Remove** unused `TryDetermineIfMcpIsEnabled` helper - **Fix** REST+GraphQL disabled-together check to use resolved `enabled` booleans instead of raw `Disabled` flags ### Breaking change analysis - **Non-breaking**: All `--*.disabled` flags still work — they are just hidden from `--help` - **Behavior fix for MCP**: `--mcp.disabled` was previously a no-op; now it actually disables MCP - **Existing scripts**: Will continue working; deprecation warnings appear in logs ## How was this tested? - [x] Unit tests - [ ] Integration tests ## Sample Request(s) NA
1 parent 7f6ddd6 commit 3e8ce76

4 files changed

Lines changed: 49 additions & 32 deletions

File tree

src/Cli.Tests/EndToEndTests.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,11 @@ public void TestBaseRouteIsConfigurableForSWA(string authProvider, bool isExcept
12881288
[DataRow(ApiType.GraphQL, true, false, true, false, DisplayName = "Validate that GraphQL endpoint is disabled when enabled option is omitted and disabled option is included in the init command.")]
12891289
[DataRow(ApiType.GraphQL, true, true, false, false, DisplayName = "Validate that GraphQL endpoint is disabled when enabled option is set to false and disabled option is included in the init command.")]
12901290
[DataRow(ApiType.GraphQL, true, true, true, true, true, DisplayName = "Validate that config generation fails when enabled and disabled options provide conflicting values for GraphQL endpoint.")]
1291+
[DataRow(ApiType.MCP, false, false, true, true, DisplayName = "Validate that MCP endpoint is enabled when both enabled and disabled options are omitted from the init command.")]
1292+
[DataRow(ApiType.MCP, false, true, true, true, DisplayName = "Validate that MCP endpoint is enabled when enabled option is set to true and disabled option is omitted from the init command.")]
1293+
[DataRow(ApiType.MCP, true, false, true, false, DisplayName = "Validate that MCP endpoint is disabled when enabled option is omitted and disabled option is included in the init command.")]
1294+
[DataRow(ApiType.MCP, true, true, false, false, DisplayName = "Validate that MCP endpoint is disabled when enabled option is set to false and disabled option is included in the init command.")]
1295+
[DataRow(ApiType.MCP, true, true, true, true, true, DisplayName = "Validate that config generation fails when enabled and disabled options provide conflicting values for MCP endpoint.")]
12911296
public void TestEnabledDisabledFlagsForApis(
12921297
ApiType apiType,
12931298
bool includeDisabledFlag,
@@ -1333,12 +1338,22 @@ public void TestEnabledDisabledFlagsForApis(
13331338
Assert.IsNotNull(runtimeConfig.Runtime.Rest);
13341339
Assert.AreEqual(expectedEnabledFlagValueInConfig, runtimeConfig.Runtime.Rest.Enabled);
13351340
}
1336-
else
1341+
else if (apiType is ApiType.GraphQL)
13371342
{
13381343
Assert.IsNotNull(runtimeConfig.Runtime);
13391344
Assert.IsNotNull(runtimeConfig.Runtime.GraphQL);
13401345
Assert.AreEqual(expectedEnabledFlagValueInConfig, runtimeConfig.Runtime.GraphQL.Enabled);
13411346
}
1347+
else if (apiType is ApiType.MCP)
1348+
{
1349+
Assert.IsNotNull(runtimeConfig.Runtime);
1350+
Assert.IsNotNull(runtimeConfig.Runtime.Mcp);
1351+
Assert.AreEqual(expectedEnabledFlagValueInConfig, runtimeConfig.Runtime.Mcp.Enabled);
1352+
}
1353+
else
1354+
{
1355+
Assert.Fail($"Unexpected ApiType value '{apiType}' in test.");
1356+
}
13421357
}
13431358
}
13441359

src/Cli.Tests/InitTests.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,20 +196,24 @@ public void VerifyRequiredOptionsForCosmosDbNoSqlDatabase(
196196
}
197197

198198
/// <summary>
199-
/// Verify that if both REST and GraphQL is disabled, we will get error.
199+
/// Verify that if all APIs (REST, GraphQL, and MCP) are disabled, we will get an error.
200+
/// Disabling only REST and GraphQL is allowed when MCP remains enabled.
200201
/// </summary>
201-
[DataRow(CliBool.False, CliBool.False, false, DisplayName = "Both REST and GraphQL disabled.")]
202-
[DataRow(CliBool.False, CliBool.True, true, DisplayName = "REST disabled, and GraphQL enabled.")]
203-
[DataRow(CliBool.True, CliBool.False, true, DisplayName = "REST enabled, and GraphQL disabled.")]
204-
[DataRow(CliBool.True, CliBool.True, true, DisplayName = "Both REST and GraphQL are enabled.")]
202+
[DataRow(CliBool.False, CliBool.False, CliBool.False, false, DisplayName = "All three APIs disabled - failure.")]
203+
[DataRow(CliBool.False, CliBool.False, CliBool.None, true, DisplayName = "REST and GraphQL disabled, MCP defaulted to enabled - success.")]
204+
[DataRow(CliBool.False, CliBool.True, CliBool.None, true, DisplayName = "REST disabled, and GraphQL enabled.")]
205+
[DataRow(CliBool.True, CliBool.False, CliBool.None, true, DisplayName = "REST enabled, and GraphQL disabled.")]
206+
[DataRow(CliBool.True, CliBool.True, CliBool.None, true, DisplayName = "Both REST and GraphQL are enabled.")]
205207
[DataTestMethod]
206-
public void EnsureFailureWhenBothRestAndGraphQLAreDisabled(
208+
public void EnsureFailureWhenAllApisAreDisabled(
207209
CliBool restEnabled,
208210
CliBool graphQLEnabled,
211+
CliBool mcpEnabled,
209212
bool expectedResult)
210213
{
211214
bool restDisabled = restEnabled is CliBool.False ? true : false;
212215
bool graphQLDisabled = graphQLEnabled is CliBool.False ? true : false;
216+
bool mcpDisabled = mcpEnabled is CliBool.False ? true : false;
213217
InitOptions options = new(
214218
databaseType: DatabaseType.MSSQL,
215219
connectionString: "testconnectionstring",
@@ -222,8 +226,10 @@ public void EnsureFailureWhenBothRestAndGraphQLAreDisabled(
222226
authenticationProvider: EasyAuthType.AppService.ToString(),
223227
restEnabled: restEnabled,
224228
graphqlEnabled: graphQLEnabled,
229+
mcpEnabled: mcpEnabled,
225230
restDisabled: restDisabled,
226231
graphqlDisabled: graphQLDisabled,
232+
mcpDisabled: mcpDisabled,
227233
config: TEST_RUNTIME_CONFIG_FILE);
228234

229235
Assert.AreEqual(expectedResult, TryCreateRuntimeConfig(options, _runtimeConfigLoader!, _fileSystem!, out RuntimeConfig? _));

src/Cli/Commands/InitOptions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,19 @@ public InitOptions(
111111
[Option("runtime.base-route", Default = null, Required = false, HelpText = "Specifies the base route for API requests.")]
112112
public string? RuntimeBaseRoute { get; }
113113

114-
[Option("rest.disabled", Default = false, Required = false, HelpText = "Disables REST endpoint for all entities.")]
114+
[Option("rest.disabled", Default = false, Required = false, Hidden = true, HelpText = "[Deprecated] Use --rest.enabled false instead. Disables REST endpoint for all entities.")]
115115
public bool RestDisabled { get; }
116116

117117
[Option("graphql.path", Default = GraphQLRuntimeOptions.DEFAULT_PATH, Required = false, HelpText = "Specify the GraphQL endpoint's default prefix.")]
118118
public string GraphQLPath { get; }
119119

120-
[Option("graphql.disabled", Default = false, Required = false, HelpText = "Disables GraphQL endpoint for all entities.")]
120+
[Option("graphql.disabled", Default = false, Required = false, Hidden = true, HelpText = "[Deprecated] Use --graphql.enabled false instead. Disables GraphQL endpoint for all entities.")]
121121
public bool GraphQLDisabled { get; }
122122

123123
[Option("mcp.path", Default = McpRuntimeOptions.DEFAULT_PATH, Required = false, HelpText = "Specify the MCP endpoint's default prefix.")]
124124
public string McpPath { get; }
125125

126-
[Option("mcp.disabled", Default = false, Required = false, HelpText = "Disables MCP endpoint for all entities.")]
126+
[Option("mcp.disabled", Default = false, Required = false, Hidden = true, HelpText = "[Deprecated] Use --mcp.enabled false instead. Disables MCP endpoint for all entities.")]
127127
public bool McpDisabled { get; }
128128

129129
[Option("rest.enabled", Required = false, HelpText = "(Default: true) Enables REST endpoint for all entities. Supported values: true, false.")]

src/Cli/ConfigGenerator.cs

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -100,24 +100,31 @@ public static bool TryCreateRuntimeConfig(InitOptions options, FileSystemRuntime
100100

101101
HyphenatedNamingPolicy namingPolicy = new();
102102

103-
// If --rest.disabled flag is included in the init command, we log a warning to not use this flag as it will be deprecated in future versions of DAB.
103+
// If --rest.disabled flag is included in the init command, we log a warning as the flag is deprecated.
104104
if (options.RestDisabled is true)
105105
{
106-
_logger.LogWarning("The option --rest.disabled will be deprecated and support for the option will be removed in future versions of Data API builder." +
107-
" We recommend that you use the --rest.enabled option instead.");
106+
_logger.LogWarning("The option --rest.disabled is deprecated and support for the option will be removed in future versions of Data API builder." +
107+
" Use the --rest.enabled option instead.");
108108
}
109109

110-
// If --graphql.disabled flag is included in the init command, we log a warning to not use this flag as it will be deprecated in future versions of DAB.
110+
// If --graphql.disabled flag is included in the init command, we log a warning as the flag is deprecated.
111111
if (options.GraphQLDisabled is true)
112112
{
113-
_logger.LogWarning("The option --graphql.disabled will be deprecated and support for the option will be removed in future versions of Data API builder." +
114-
" We recommend that you use the --graphql.enabled option instead.");
113+
_logger.LogWarning("The option --graphql.disabled is deprecated and support for the option will be removed in future versions of Data API builder." +
114+
" Use the --graphql.enabled option instead.");
115+
}
116+
117+
// If --mcp.disabled flag is included in the init command, we log a warning as the flag is deprecated.
118+
if (options.McpDisabled is true)
119+
{
120+
_logger.LogWarning("The option --mcp.disabled is deprecated and support for the option will be removed in future versions of Data API builder." +
121+
" Use the --mcp.enabled option instead.");
115122
}
116123

117124
bool restEnabled, graphQLEnabled, mcpEnabled;
118125
if (!TryDetermineIfApiIsEnabled(options.RestDisabled, options.RestEnabled, ApiType.REST, out restEnabled) ||
119126
!TryDetermineIfApiIsEnabled(options.GraphQLDisabled, options.GraphQLEnabled, ApiType.GraphQL, out graphQLEnabled) ||
120-
!TryDetermineIfMcpIsEnabled(options.McpEnabled, out mcpEnabled))
127+
!TryDetermineIfApiIsEnabled(options.McpDisabled, options.McpEnabled, ApiType.MCP, out mcpEnabled))
121128
{
122129
return false;
123130
}
@@ -237,9 +244,9 @@ public static bool TryCreateRuntimeConfig(InitOptions options, FileSystemRuntime
237244
}
238245
}
239246

240-
if (options.RestDisabled && options.GraphQLDisabled)
247+
if (!restEnabled && !graphQLEnabled && !mcpEnabled)
241248
{
242-
_logger.LogError("Both Rest and GraphQL cannot be disabled together.");
249+
_logger.LogError("At least one of REST, GraphQL, or MCP must be enabled.");
243250
return false;
244251
}
245252

@@ -297,12 +304,12 @@ public static bool TryCreateRuntimeConfig(InitOptions options, FileSystemRuntime
297304

298305
/// <summary>
299306
/// Helper method to determine if the api is enabled or not based on the enabled/disabled options in the dab init command.
300-
/// The method also validates that there is no mismatch in semantics of enabling/disabling the REST/GraphQL API(s)
307+
/// The method also validates that there is no mismatch in semantics of enabling/disabling the REST/GraphQL/MCP API(s)
301308
/// based on the values supplied in the enabled/disabled options for the API in the init command.
302309
/// </summary>
303310
/// <param name="apiDisabledOptionValue">Value of disabled option as in the init command. If the option is omitted in the command, default value is assigned.</param>
304311
/// <param name="apiEnabledOptionValue">Value of enabled option as in the init command. If the option is omitted in the command, default value is assigned.</param>
305-
/// <param name="apiType">ApiType - REST/GraphQL.</param>
312+
/// <param name="apiType">ApiType - REST/GraphQL/MCP.</param>
306313
/// <param name="isApiEnabled">Boolean value indicating whether the API endpoint is enabled or not.</param>
307314
private static bool TryDetermineIfApiIsEnabled(bool apiDisabledOptionValue, CliBool apiEnabledOptionValue, ApiType apiType, out bool isApiEnabled)
308315
{
@@ -334,17 +341,6 @@ private static bool TryDetermineIfApiIsEnabled(bool apiDisabledOptionValue, CliB
334341
return true;
335342
}
336343

337-
/// <summary>
338-
/// Helper method to determine if the mcp api is enabled or not based on the enabled/disabled options in the dab init command.
339-
/// </summary>
340-
/// <param name="mcpEnabledOptionValue">True, if MCP is enabled</param>
341-
/// <param name="isMcpEnabled">Out param isMcpEnabled</param>
342-
/// <returns>True if MCP is enabled</returns>
343-
private static bool TryDetermineIfMcpIsEnabled(CliBool mcpEnabledOptionValue, out bool isMcpEnabled)
344-
{
345-
return TryDetermineIfApiIsEnabled(false, mcpEnabledOptionValue, ApiType.MCP, out isMcpEnabled);
346-
}
347-
348344
/// <summary>
349345
/// Helper method to determine if the multiple create operation is enabled or not based on the inputs from dab init command.
350346
/// </summary>

0 commit comments

Comments
 (0)