Refactor McpFunctionMetadataTransformer using Builder pattern with pluggable steps#216
Open
liliankasem wants to merge 1 commit intomainfrom
Open
Refactor McpFunctionMetadataTransformer using Builder pattern with pluggable steps#216liliankasem wants to merge 1 commit intomainfrom
liliankasem wants to merge 1 commit intomainfrom
Conversation
5 tasks
aishwaryabh
reviewed
Mar 27, 2026
...t.Azure.Functions.Worker.Extensions.Mcp/Configuration/McpBindingBuilder/McpBuilderContext.cs
Outdated
Show resolved
Hide resolved
aishwaryabh
previously approved these changes
Mar 27, 2026
5 tasks
…uggable steps Decomposes the monolithic McpFunctionMetadataTransformer into a fluent McpBindingBuilder with pluggable extension method steps. Each transformation concern lives in its own file and can be added or removed without modifying the builder itself. New builder steps: - AddToolProperties: resolves tool properties from options/attributes - AddPromptArguments: resolves prompt arguments from options/attributes - AddMetadata: applies fluent + attributed metadata for tool/resource/prompt - AddAppUiMetadata: merges MCP App UI metadata and emits synthetic functions - PatchPropertyBindings: patches mcpToolProperty bindings with type info Also extracts MetadataMerger as a standalone utility class. Rebased on top of main, incorporating prompt support (#210/#211), MCP Apps fluent API (#226), and instrumentation changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
09cf354 to
34ffdcc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Decomposes the monolithic
McpFunctionMetadataTransformerinto a fluentMcpBindingBuilderwith pluggable extension method steps. Each transformation concern lives in its own file and can be added or removed without modifying the builder itself.Motivation
The transformer had grown to ~210 lines mixing parsing, tool property resolution, metadata enrichment, and property binding patching in a single class. This refactor improves:
Changes
New:
McpBindingBuilder/McpBindingBuilder.csHasBindings,Build(), binding parsing. Never needs to change.McpBuilderContext.csMcpParsedBinding.csMetadataMerger.csNew:
McpBindingBuilder/Steps/AddToolPropertiesExtension.csAddMetadataExtension.cs[McpMetadata]attribute metadata onto trigger bindingsPatchPropertyBindingsExtension.csmcpToolPropertybindings with type info from resolved propertiesModified:
McpFunctionMetadataTransformer.csReduced from ~210 lines to ~40 lines. Now a thin loop:
How to add a new step
Create a single file with an extension method — no other files change: