[release/13.4] Filter resources with resource.excludeFromMcp from CLI MCP tools#18150
Conversation
Resources marked with the resource.excludeFromMcp property are now excluded from all MCP tool results: - ListResourcesTool filters them from resource listings - ListConsoleLogsTool and ExecuteResourceCommandTool reject requests targeting excluded resources - ListStructuredLogsTool, ListTracesTool, and ListTraceStructuredLogsTool filter out telemetry from excluded resources - McpResourceToolRefreshService skips excluded resources Added McpToolHelpers with IsExcludedFromMcp, CheckResourceExcludedAsync, GetExcludedResourceNamesAsync, and GetResourceNotAvailableMessage helpers. Includes comprehensive unit tests covering all filtering scenarios.
- Add two tests for ListTraceStructuredLogsTool filtering:
- FiltersExcludedResourceLogs: verifies excluded resource logs are
removed from trace-scoped structured log results
- ReturnsAllLogs_WhenNoResourcesExcluded: verifies no filtering when
no resources are excluded
- Add doesNotContainMarker parameter to CallAgentMcpToolAsync helper
- Add AgentMcpExcludeFromMcpTests E2E test that verifies list_resources
excludes resources marked with ExcludeFromMcp()
Add overloads of CheckResourceExcludedAsync and GetExcludedResourceNamesAsync that accept IAppHostAuxiliaryBackchannel directly. Update ListConsoleLogsTool and ExecuteResourceCommandTool to use the connection they already obtained, eliminating a redundant GetSelectedConnectionAsync + GetResourceSnapshotsAsync call per request.
The test was timing out because the Redis container's health check never passed in the Docker-in-Docker CI environment, causing webfrontend (which has WaitFor(cache)) to stay stuck in Waiting state. Redis is irrelevant to this test — it only verifies ExcludeFromMcp() filtering. Disabling Redis removes the container dependency.
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 18150Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 18150" |
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
|
❓ CLI E2E Tests unknown — 112 passed, 0 failed, 2 unknown (commit View all recordings
📹 Recordings uploaded automatically from CI run #27402121786 |
|
✅ No documentation update needed. Decision path: Triggered signals (2): This PR is a backport of #18106 to Per-signal documentation evidence (all in
|
Backport of #18106 to release/13.4
/cc @JamesNK
Customer Impact
ExcludeFromMcp()no longer works. A customer would use it with a resource and expect the resource to be excluded from MCP calls. However the annotation doesn't work. The resource data is available from MCP and its tools are callable from MCP.Testing
Unit tests, end-to-end tests
Risk
Low
Regression?
Yes, introduced in 13.2 #14337