From c8991857b02650d72b5220c4e62838b42f432c04 Mon Sep 17 00:00:00 2001 From: Shyju Krishnankutty Date: Wed, 18 Mar 2026 14:26:34 -0700 Subject: [PATCH] Cleanup --- .../BuiltInFunctionExecutor.cs | 6 +++-- .../FunctionMetadataFactory.cs | 27 +++++++++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/BuiltInFunctionExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/BuiltInFunctionExecutor.cs index 98c6cfd688..64ec846eb8 100644 --- a/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/BuiltInFunctionExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/BuiltInFunctionExecutor.cs @@ -174,8 +174,10 @@ internal sealed class BuiltInFunctionExecutor : IFunctionExecutor throw new InvalidOperationException($"MCP tool invocation context binding is missing for the invocation {context.InvocationId}."); } - context.GetInvocationResult().Value = - await BuiltInFunctions.RunWorkflowMcpToolAsync(mcpToolInvocationContext, durableTaskClient, context); + context.GetInvocationResult().Value = await BuiltInFunctions.RunWorkflowMcpToolAsync( + mcpToolInvocationContext, + durableTaskClient, + context); return; } diff --git a/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/FunctionMetadataFactory.cs b/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/FunctionMetadataFactory.cs index ce1f2f54db..43dd53be18 100644 --- a/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/FunctionMetadataFactory.cs +++ b/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/FunctionMetadataFactory.cs @@ -105,17 +105,34 @@ internal static class FunctionMetadataFactory /// The name of the workflow to expose as an MCP tool. /// An optional description for the MCP tool. If null, a default description is generated. /// A configured for an MCP tool trigger. - internal static DefaultFunctionMetadata CreateWorkflowMcpToolTrigger(string workflowName, string? description) + internal static DefaultFunctionMetadata CreateWorkflowMcpToolTrigger( + string workflowName, + string? description) { + var functionName = $"{BuiltInFunctions.McpToolPrefix}{workflowName}"; + var toolDescription = description ?? $"Run the {workflowName} workflow"; + + const string ToolProperties = + """[{\"propertyName\":\"input\",\"propertyType\":\"string\",\"description\":\"The input to the workflow.\",\"isRequired\":true,\"isArray\":false}]"""; + + var TriggerBinding = + $$"""{"name":"context","type":"mcpToolTrigger","direction":"In","toolName":"{{workflowName}}","description":"{{toolDescription}}","toolProperties":"{{ToolProperties}}"}"""; + + const string InputBinding = + """{"name":"input","type":"mcpToolProperty","direction":"In","propertyName":"input","description":"The input to the workflow","isRequired":true,"dataType":"String","propertyType":"string"}"""; + + const string ClientBinding = + """{"name":"client","type":"durableClient","direction":"In"}"""; + return new DefaultFunctionMetadata { - Name = $"{BuiltInFunctions.McpToolPrefix}{workflowName}", + Name = functionName, Language = "dotnet-isolated", RawBindings = [ - $$"""{"name":"context","type":"mcpToolTrigger","direction":"In","toolName":"{{workflowName}}","description":"{{description ?? $"Run the {workflowName} workflow"}}","toolProperties":"[{\"propertyName\":\"input\",\"propertyType\":\"string\",\"description\":\"The input to the workflow.\",\"isRequired\":true,\"isArray\":false}]"}""", - """{"name":"input","type":"mcpToolProperty","direction":"In","propertyName":"input","description":"The input to the workflow","isRequired":true,"dataType":"String","propertyType":"string"}""", - """{"name":"client","type":"durableClient","direction":"In"}""" + TriggerBinding, + InputBinding, + ClientBinding ], EntryPoint = BuiltInFunctions.RunWorkflowMcpToolFunctionEntryPoint, ScriptFile = BuiltInFunctions.ScriptFile,