Repository navigation
.NET: [BREAKING] fix(dotnet): validate declarative MCP destinations #10192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Vincent Biret (baywet)
wants to merge
4
commits into
main
Choose a base branch
from
fix/mcp-destination-validation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+659
−217
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
71fde34
fix(dotnet): validate declarative MCP destinations
baywet 5e6ed6e
fix(dotnet): validate declarative MCP handler pipelines
baywet 381b58e
fix(dotnet): reject cyclic HTTP handler pipelines
baywet 66993a1
fix(dotnet): remove unused MCP client factory constructor
baywet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
docs/decisions/0055-dotnet-declarative-mcp-allowed-hosts.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| --- | ||
| status: proposed | ||
| contact: baywet | ||
| date: 2026-11-09 | ||
| deciders: westey-m | ||
| --- | ||
|
|
||
| # Explicit allowed hosts for declarative MCP invocations | ||
|
|
||
| ## Context and Problem Statement | ||
|
|
||
| Declarative MCP actions receive their server URLs from workflow content. The application | ||
| owns destination configuration and the HTTP pipeline. The default MCP handler should apply | ||
| the same host-and-port policy as the [default HTTP handler](0049-dotnet-declarative-http-allowed-hosts.md). | ||
|
|
||
| ## Decision Drivers | ||
|
|
||
| - Require application-configured destinations before creating an HTTP client. | ||
| - Keep host normalization and port matching consistent between HTTP and MCP. | ||
| - Make destination and transport configuration explicit while preserving per-invocation session lifetime. | ||
|
|
||
| ## Considered Options | ||
|
|
||
| - Permit all destinations: preserves current behavior, but provides no application-owned destination policy. | ||
| - Require a new constructor signature: makes configuration explicit, but removes an existing API. | ||
| - Retain the existing constructor with an empty policy and add an allowlist overload: preserves binary | ||
| compatibility, but applications must migrate their configuration to continue invoking tools. | ||
|
|
||
| ## Decision Outcome | ||
|
|
||
| Chosen option: require a new constructor signature with allowed hosts and an `IHttpMessageHandlerFactory`. | ||
| Remove the constructor accepting `IHttpClientFactory` rather than retain an overload that cannot invoke tools. | ||
|
|
||
| The application supplies exact hosts or IP literals with optional ports. The list is copied, an omitted | ||
| port defaults to 443, and an empty list denies every invocation, including discovery. Matching uses the | ||
| same shared normalization as HTTP: case-insensitive IDN names, trailing DNS dots removed, and exact | ||
| effective ports, without wildcards or implicit subdomains. Workflow-supplied Host headers are rejected. | ||
|
|
||
| Both HTTP and HTTPS remain supported. Applications requiring HTTPS must enforce that additional policy. | ||
| DNS, proxy configuration, and routing remain transport responsibilities. The application supplies an | ||
| `IHttpMessageHandlerFactory`; before sending, the handler validates that each pipeline terminates in an | ||
| `HttpClientHandler`, or on .NET a `SocketsHttpHandler`, with cookies and automatic redirects disabled. | ||
| Unknown primary transports and incomplete pipelines are rejected. Redirect responses are not followed. | ||
| Application-owned delegating handlers must preserve the validated destination and bind credentials to | ||
| the intended origin. | ||
|
|
||
| The handler creates and disposes an HTTP client per invocation without disposing the factory-owned | ||
| pipeline. Client configuration callbacks registered through `IHttpClientFactory` do not apply; configure | ||
| headers and origin-bound authentication in delegating handlers. This matches the HTTP handler's ownership | ||
| and transport-validation contract while keeping MCP protocol sessions separate per invocation. | ||
|
|
||
| This removes the existing constructor. Callers must migrate to the constructor accepting their intended | ||
| destinations and a message handler factory; applications with different policies can provide an `IMcpToolHandler`. | ||
| Session creation, protocol selection, and resource disposal remain unchanged. |
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
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
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
2 changes: 1 addition & 1 deletion
2
...c/Microsoft.Agents.AI.Workflows.Declarative.Mcp/PublicAPI/net10.0/PublicAPI.Unshipped.txt
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
2 changes: 1 addition & 1 deletion
2
...rc/Microsoft.Agents.AI.Workflows.Declarative.Mcp/PublicAPI/net472/PublicAPI.Unshipped.txt
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
2 changes: 1 addition & 1 deletion
2
...rc/Microsoft.Agents.AI.Workflows.Declarative.Mcp/PublicAPI/net8.0/PublicAPI.Unshipped.txt
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
2 changes: 1 addition & 1 deletion
2
...rc/Microsoft.Agents.AI.Workflows.Declarative.Mcp/PublicAPI/net9.0/PublicAPI.Unshipped.txt
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
2 changes: 1 addition & 1 deletion
2
...soft.Agents.AI.Workflows.Declarative.Mcp/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.