Skip to content

Conversation

@JamesNK
Copy link
Member

@JamesNK JamesNK commented Oct 30, 2025

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 of execute_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

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

@github-actions
Copy link
Contributor

github-actions bot commented Oct 30, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12515

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12515"

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AIOptOutAnnotation and WithOptOutAI() extension method for marking resources
  • Added filtering logic in MCP tools to exclude opted-out resources from AI data retrieval
  • Created IsResourceAIOptOut() helper method and TryConvertToBool() 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

@JamesNK JamesNK force-pushed the jamesnk/dashboardmcp-optout branch from f4d364c to cd3aaa5 Compare October 31, 2025 03:11
@JamesNK JamesNK changed the title Add AI opt-out annotation Add MCP opt-out annotation Oct 31, 2025
@JamesNK JamesNK changed the title Add MCP opt-out annotation Add WithExcludeFromMcp() resource extension Oct 31, 2025
@JamesNK JamesNK force-pushed the jamesnk/dashboardmcp-optout branch from bb5ebe8 to fc6b815 Compare October 31, 2025 03:39
@JamesNK JamesNK changed the title Add WithExcludeFromMcp() resource extension Add ExcludeFromMcp() resource extension Oct 31, 2025
@JamesNK JamesNK force-pushed the jamesnk/dashboardmcp-optout branch from fc6b815 to cf667e6 Compare October 31, 2025 07:22
@JamesNK JamesNK added this to the 13.0 milestone Oct 31, 2025
@JamesNK JamesNK merged commit 2255035 into main Oct 31, 2025
581 of 585 checks passed
@JamesNK JamesNK deleted the jamesnk/dashboardmcp-optout branch October 31, 2025 23:01
@JamesNK
Copy link
Member Author

JamesNK commented Oct 31, 2025

/backport to release/13.0

@dotnet-policy-service dotnet-policy-service bot modified the milestones: 13.0, 13.1 Oct 31, 2025
@github-actions
Copy link
Contributor

Started backporting to release/13.0: https://github.com/dotnet/aspire/actions/runs/18987184161

@github-actions github-actions bot locked and limited conversation to collaborators Dec 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Per-resource MCP configuration

4 participants