Add ExcludeFromMcp() resource extension#12515
Merged
Conversation
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12515Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12515" |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds functionality to opt out resources from AI features in the Aspire Dashboard. The implementation introduces a new AIOptOut property that allows resources to exclude their data (console logs and telemetry) from AI tools and assistants.
Key changes:
- Introduced
AIOptOutAnnotationandWithOptOutAI()extension method for marking resources - Added filtering logic in MCP tools to exclude opted-out resources from AI data retrieval
- Created
IsResourceAIOptOut()helper method andTryConvertToBool()utility for property checking
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Aspire.Hosting/ApplicationModel/AIOptOutAnnotation.cs | New annotation class to mark resources for AI opt-out |
| src/Aspire.Hosting/ResourceBuilderExtensions.cs | Added WithOptOutAI() extension method for resource configuration |
| src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs | Publishes AI opt-out property to dashboard when annotation is present |
| src/Shared/Model/KnownProperties.cs | Defined AIOptOut property constant |
| src/Aspire.Dashboard/Utils/ValueExtensions.cs | Added TryConvertToBool() helper method for boolean conversion |
| src/Aspire.Dashboard/Model/Assistant/AIHelpers.cs | Added IsResourceAIOptOut() helper to check resource opt-out status |
| src/Aspire.Dashboard/Mcp/AspireTelemetryMcpTools.cs | Filters traces and logs from opted-out resources |
| src/Aspire.Dashboard/Mcp/AspireResourceMcpTools.cs | Filters resources and prevents access to console logs for opted-out resources |
| tests/Aspire.Dashboard.Tests/Mcp/AspireTelemetryMcpToolsTests.cs | Test coverage for opt-out filtering in telemetry tools |
| tests/Aspire.Dashboard.Tests/Mcp/AspireResourceMcpToolsTests.cs | Test coverage for opt-out filtering in resource tools |
f4d364c to
cd3aaa5
Compare
WithExcludeFromMcp() resource extension
bb5ebe8 to
fc6b815
Compare
WithExcludeFromMcp() resource extensionExcludeFromMcp() resource extension
fc6b815 to
cf667e6
Compare
davidfowl
approved these changes
Oct 31, 2025
Member
Author
|
/backport to release/13.0 |
Contributor
|
Started backporting to release/13.0: https://github.com/dotnet/aspire/actions/runs/18987184161 |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
This PR adds a way for resources to opt-out of being included in AI results. When opted out, a resource won't be returned with
list_resources, won't be a target ofexecute_resource_command, and no telemetry/consoles logs will be returned for it.For example, adding
frontendBuilder.WithOptOutAI()will exclude the frontend resource from all AI results.Fixes #12504
Checklist
<remarks />and<code />elements on your triple slash comments?doc-ideatemplatebreaking-changetemplatediagnostictemplate