Skip to content

Commit f721916

Browse files
authored
Set FUNCTIONS_WORKER_RUNTIME to custom if EnableMcpCustomHandlerPreview is set (#4703)
1 parent 2f6a2d6 commit f721916

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/Cli/func/Actions/HostActions/StartHostAction.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using Microsoft.AspNetCore.Hosting;
1919
using Microsoft.Azure.WebJobs.Extensions.Http;
2020
using Microsoft.Azure.WebJobs.Script;
21+
using Microsoft.Azure.WebJobs.Script.Config;
2122
using Microsoft.Azure.WebJobs.Script.Configuration;
2223
using Microsoft.Azure.WebJobs.Script.Description;
2324
using Microsoft.Azure.WebJobs.Script.WebHost;
@@ -367,6 +368,11 @@ private void UpdateEnvironmentVariables(IDictionary<string, string> secrets)
367368
Environment.SetEnvironmentVariable($"AzureFunctionsJobHost__functions__{i}", EnabledFunctions[i]);
368369
}
369370
}
371+
372+
if (FeatureFlags.IsEnabled(Constants.EnableMcpCustomHandlerFeatureFlag, SystemEnvironment.Instance))
373+
{
374+
Environment.SetEnvironmentVariable(Constants.FunctionsWorkerRuntime, Constants.Languages.Custom);
375+
}
370376
}
371377

372378
/// <summary>

src/Cli/func/Common/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ internal static partial class Constants
9595
public const string Dotnet = "dotnet";
9696
public const string InProcDotNet8EnabledSetting = "FUNCTIONS_INPROC_NET8_ENABLED";
9797
public const string AzureDevSessionsRemoteHostName = "AzureDevSessionsRemoteHostName";
98+
public const string EnableMcpCustomHandlerFeatureFlag = "EnableMcpCustomHandlerPreview";
9899

99100
// forwardedHttpUrl sample format: https://n12abc3t-<port>.asse.devtunnels.ms/
100101
public const string AzureDevSessionsPortSuffixPlaceholder = "<port>";

src/Cli/func/ConfigurationProfiles/McpCustomHandlerConfigurationProfile.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ internal class McpCustomHandlerConfigurationProfile : IConfigurationProfile
1212
{
1313
// This feature flag enables MCP (Model Context Protocol) support for custom handlers
1414
// This flag is not required locally, but is required when deploying to Azure environments.
15-
private const string McpFeatureFlag = "EnableMcpCustomHandlerPreview";
16-
1715
public string Name { get; } = "mcp-custom-handler";
1816

1917
public async Task ApplyAsync(WorkerRuntime workerRuntime, bool force = false)
@@ -102,19 +100,19 @@ internal async Task ApplyLocalSettingsAsync(WorkerRuntime workerRuntime, bool fo
102100
.Where(f => !string.IsNullOrWhiteSpace(f))
103101
.ToList();
104102

105-
if (!flags.Contains(McpFeatureFlag, StringComparer.OrdinalIgnoreCase))
103+
if (!flags.Contains(Constants.EnableMcpCustomHandlerFeatureFlag, StringComparer.OrdinalIgnoreCase))
106104
{
107-
flags.Add(McpFeatureFlag);
105+
flags.Add(Constants.EnableMcpCustomHandlerFeatureFlag);
108106
values[Constants.AzureWebJobsFeatureFlags] = string.Join(",", flags);
109107
updatedFeatureFlag = true;
110108

111109
if (!hasFlagsKey)
112110
{
113-
SetupProgressLogger.Ok(Constants.LocalSettingsJsonFileName, $"Added feature flag '{McpFeatureFlag}'");
111+
SetupProgressLogger.Ok(Constants.LocalSettingsJsonFileName, $"Added feature flag '{Constants.EnableMcpCustomHandlerFeatureFlag}'");
114112
}
115113
else
116114
{
117-
SetupProgressLogger.Ok(Constants.LocalSettingsJsonFileName, $"Appended feature flag '{McpFeatureFlag}'");
115+
SetupProgressLogger.Ok(Constants.LocalSettingsJsonFileName, $"Appended feature flag '{Constants.EnableMcpCustomHandlerFeatureFlag}'");
118116
}
119117
}
120118

0 commit comments

Comments
 (0)