Add WithAppTool helper for MCP Apps - #1815
Open
KirschBluteX wants to merge 2 commits into
Open
Conversation
KirschBluteX
force-pushed
the
feat/with-app-tool-1607
branch
from
August 14, 2026 18:31
7fc29e4 to
f19fc75
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.
Fixes #1607
Summary
WithAppToolto register a tool and its linked HTML app resource in one callresourceUriauthoritative: require a concrete absoluteui://URI, reject URI templates, and reject conflicting_meta.ui.resourceUrivaluesCancellationTokenBehavior
If
_meta.ui.resourceUriis present, it must exactly matchresourceUri; otherwise registration throwsArgumentException. When the UI object exists without a resource URI, the helper adds the authoritative value while preserving fields such asvisibility. This guarantees that every registered tool link identifies the resource that can actually be read.The helper accepts direct UI resource URIs only. Resource templates belong to the lower-level resource APIs and are rejected here because an app tool links to one concrete UI resource.
Testing
dotnet test tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj -f net10.0 --no-restore --filter FullyQualifiedName~WithAppTool(15 passed)dotnet test tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj -f net10.0 --no-restore --filter FullyQualifiedName~McpApps(48 passed)dotnet test tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj -f net10.0 --no-build --no-restore --filter (Execution!=Manual)(2371 passed)dotnet build src/ModelContextProtocol.Extensions.Apps/ModelContextProtocol.Extensions.Apps.csproj --configuration Release --no-restore --no-incremental(4 projects, 0 warnings, 0 errors)dotnet format whitespace --verify-no-changesfor the three changed C# filesGitHub Actions currently reports
action_requiredfor this fork PR and has not started jobs; it is waiting for maintainer approval rather than reporting a test failure.