Skip to content

[release/13.4] Filter resources with resource.excludeFromMcp from CLI MCP tools - #18150

Merged
Jose Perez Rodriguez (joperezr) merged 6 commits into
release/13.4from
backport/pr-18106-to-release/13.4
Jun 12, 2026
Merged

[release/13.4] Filter resources with resource.excludeFromMcp from CLI MCP tools#18150
Jose Perez Rodriguez (joperezr) merged 6 commits into
release/13.4from
backport/pr-18106-to-release/13.4

Conversation

@aspire-repo-bot

@aspire-repo-botaspire-repo-botBot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Backport of #18106 to release/13.4

/cc James Newton-King (@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

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.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 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/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 18150

Or

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

@github-actions

Copy link
Copy Markdown
Contributor

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.
GitHub was asked to rerun all failed jobs for that attempt, and the rerun is being tracked in the rerun attempt.
The job links below point to the failed attempt jobs that matched the retry-safe transient failure rules.

@github-actions

Copy link
Copy Markdown
Contributor

CLI E2E Tests unknown — 112 passed, 0 failed, 2 unknown (commit d46acb1)

View all recordings
-TestDetail
AddPackageInteractiveWhileAppHostRunningDetachedRecording · Job · CLI logs
AddPackageWhileAppHostRunningDetachedRecording · Job · CLI logs
AgentCommands_AllHelpOutputs_AreCorrectRecording · Job · CLI logs
AgentInitCommand_DefaultSelection_InstallsDefaultSkillsRecording · Job · CLI logs
AgentInitCommand_MigratesDeprecatedConfigRecording · Job · CLI logs
AgentInitCommand_NonInteractive_BundleOnlySkillsBeyondCliCatalog_AreInstallableRecording · Job · CLI logs
AgentMcpListResources_ExcludesResourceMarkedWithExcludeFromMcpRecording · Job · CLI logs
AgentMcpListStructuredLogsReturnsLogsFromStarterAppRecording · Job · CLI logs
AgentMcpListStructuredLogsReturnsLogsFromStarterApp_DevLocalhostRecording · Job · CLI logs
AgentMcpListStructuredLogsReturnsLogsFromStarterApp_IsolatedRecording · Job · CLI logs
AllPublishMethodsBuildDockerImagesRecording · Job · CLI logs
AspireAddAndStartWorkAgainstLegacyAppHostTsRecording · Job · CLI logs
AspireAddPackageVersionToDirectoryPackagesPropsRecording · Job · CLI logs
AspireInitSingleFileAppHostRunsViaDotnetRunAppHostRecording · Job · CLI logs
AspireInitWithExistingAppHostDirRecreatesMissingNuGetConfigAndPreservesFilesRecording · Job · CLI logs
AspireInitWithSolutionFileGeneratesAppHostThatBuildsAgainstChannelHiveRecording · Job · CLI logs
AspireStartUpdatesStaleTypeScriptAppHostPathRecording · Job · CLI logs
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesPropsRecording · Job · CLI logs
AspireUpdateRemovesOrphanAppHostPackageVersionWhenSdkAlreadyCurrentRecording · Job · CLI logs
Banner_DisplayedOnFirstRunRecording · Job · CLI logs
Banner_DisplayedWithExplicitFlagRecording · Job · CLI logs
Banner_NotDisplayedWithNoLogoFlagRecording · Job · CLI logs
CertificatesClean_RemovesCertificatesRecording · Job · CLI logs
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificateRecording · Job · CLI logs
CertificatesTrust_WithUntrustedCert_TrustsCertificateRecording · Job · CLI logs
ConfigSetGet_CreatesNestedJsonFormatRecording · Job · CLI logs
CreateAndRunAspireStarterProjectRecording · Job · CLI logs
CreateAndRunAspireStarterProjectWithBundleRecording · Job · CLI logs
CreateAndRunEmptyAppHostProjectRecording · Job · CLI logs
CreateAndRunJavaEmptyAppHostProjectRecording · Job · CLI logs
CreateAndRunJsReactProjectRecording · Job · CLI logs
CreateAndRunPolyglotAppHostWithDevLocalhostUrlsRecording · Job · CLI logs
CreateAndRunPythonReactProjectRecording · Job · CLI logs
CreateAndRunTypeScriptEmptyAppHostProjectRecording · Job · CLI logs
CreateAndRunTypeScriptStarterProjectRecording · Job · CLI logs
CreateJavaAppHostWithViteAppRecording · Job · CLI logs
CreateTypeScriptAppHostWithViteApp_AllowsGuestAppPackageManagerToDifferRecording · Job · CLI logs
CreateTypeScriptAppHostWithViteApp_UsesConfiguredToolchainRecording · Job · CLI logs
DashboardRunWithAgentMcpListTracesReturnsNoTracesRecording · Job · CLI logs
DashboardRunWithAgentMcpListTracesReturnsNoTraces_DevLocalhostRecording · Job · CLI logs
DashboardRunWithOtelTracesReturnsNoTracesRecording · Job · CLI logs
DashboardRunWithOtelTracesReturnsNoTraces_DevLocalhostRecording · Job · CLI logs
DeployK8sBasicApiServiceRecording · Job · CLI logs
DeployK8sWithExternalHelmChartRecording · Job · CLI logs
DeployK8sWithGarnetRecording · Job · CLI logs
DeployK8sWithMongoDBRecording · Job · CLI logs
DeployK8sWithMySqlRecording · Job · CLI logs
DeployK8sWithPostgresRecording · Job · CLI logs
DeployK8sWithRabbitMQRecording · Job · CLI logs
DeployK8sWithRedisRecording · Job · CLI logs
DeployK8sWithSqlServerRecording · Job · CLI logs
DeployK8sWithValkeyRecording · Job · CLI logs
DeployTypeScriptAppToKubernetesRecording · Job · CLI logs
DescribeCommandResolvesReplicaNamesRecording · Job · CLI logs
DescribeCommandShowsRunningResourcesRecording · Job · CLI logs
DetachFormatJsonProducesValidJsonRecording · Job · CLI logs
DetachFormatJsonProducesValidJsonWhenRestartingExistingInstanceRecording · Job · CLI logs
DoPublishAndDeployListStepsWorkRecording · Job · CLI logs
DocsCommand_RendersInteractiveMarkdownFromLocalSourceRecording · Job · CLI logs
DoctorCommand_DetectsDeprecatedAgentConfigRecording · Job · CLI logs
DoctorCommand_TypeScriptAppHostReportsMissingConfiguredToolchainRecording · Job · CLI logs
DoctorCommand_WithSslCertDir_ShowsTrustedRecording · Job · CLI logs
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrustedRecording · Job · CLI logs
GatewayWithoutExternalEndpoint_FailsPublishWithGuidanceRecording · Job · CLI logs
GeneratedAspireDevScript_StartsWatchMode_WithConfiguredToolchainRecording · Job · CLI logs
GlobalMigration_HandlesCommentsAndTrailingCommasRecording · Job · CLI logs
GlobalMigration_HandlesMalformedLegacyJsonRecording · Job · CLI logs
GlobalMigration_PreservesAllValueTypesRecording · Job · CLI logs
GlobalMigration_SkipsWhenNewConfigExistsRecording · Job · CLI logs
GlobalSettings_MigratedFromLegacyFormatRecording · Job · CLI logs
IngressWithoutExternalEndpoint_FailsPublishWithGuidanceRecording · Job · CLI logs
InitTypeScriptAppHost_AugmentsExistingViteRepoInWorkspaceSubdirectoryRecording · Job · CLI logs
InteractiveCSharpInitCreatesExpectedFilesRecording · Job · CLI logs
InvalidAppHostPathWithComments_IsHealedOnRunRecording · Job · CLI logs
JavaScriptHostingApisRunFromTypeScriptAppHostRecording · Job · CLI logs
LatestCliCanStartStableChannelAppHostRecording · Job · CLI logs
LatestCliCanStartStableChannelTypeScriptAppHostRecording · Job · CLI logs
LegacySettingsMigration_AdjustsRelativeAppHostPathRecording · Job · CLI logs
LogsCommandShowsResourceLogsRecording · Job · CLI logs
OtelLogsReturnsStructuredLogsFromStarterAppRecording · Job · CLI logs
OtelLogsReturnsStructuredLogsFromStarterAppIsolatedRecording · Job · CLI logs
PersistentContainersPreserveDataAcrossAppHostRunsRecording · Job · CLI logs
PsCommandListsRunningAppHostRecording · Job · CLI logs
PsFormatJsonOutputsOnlyJsonToStdoutRecording · Job · CLI logs
PublishJavaScriptPatternsGeneratesExpectedDockerComposeArtifactsRecording · Job · CLI logs
PublishWithConfigureEnvFileUpdatesEnvOutputRecording · Job · CLI logs
PublishWithDockerComposeServiceCallbackSucceedsRecording · Job · CLI logs
PublishWithoutOutputPathUsesAppHostDirectoryDefaultRecording · Job · CLI logs
ResourceCommand_FailedExecution_DisplaysAppHostLogPathAndLogContainsEntriesRecording · Job · CLI logs
ResourceCommand_SetAndDeleteParameterUpdatesDescribeOutputRecording · Job · CLI logs
RestoreGeneratesSdkFilesRecording · Job · CLI logs
RestoreGeneratesSdkFiles_WithConfiguredToolchainRecording · Job · CLI logs
RestoreRefreshesGeneratedSdkAfterAddingIntegrationRecording · Job · CLI logs
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypesRecording · Job · CLI logs
RunFromParentDirectory_UsesExistingConfigNearAppHostRecording · Job · CLI logs
RunReportsSyntaxErrorsForDotNetAppHostRecording · Job · CLI logs
RunReportsSyntaxErrorsForTypeScriptAppHostRecording · Job · CLI logs
SecretCrudOnDotNetAppHostRecording · Job · CLI logs
SecretCrudOnTypeScriptAppHostRecording · Job · CLI logs
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannelsRecording · Job · CLI logs
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssetsRecording · Job · CLI logs
StartReportsSyntaxErrorsForDotNetAppHostRecording · Job · CLI logs
StartReportsSyntaxErrorsForTypeScriptAppHostRecording · Job · CLI logs
StopAllAppHostsFromAppHostDirectoryRecording · Job · CLI logs
StopJavaPolyglotAppHostUsingApphostDirectoryRecording · Job · CLI logs
StopNonInteractiveSingleAppHostRecording · Job · CLI logs
StopTypeScriptPolyglotAppHostUsingApphostDirectoryRecording · Job · CLI logs
StopWithNoRunningAppHostExitsSuccessfullyRecording · Job · CLI logs
TypeScriptAppHostRunDoesNotDeadlockWhenLazyOptionsInvokeAsyncCallbackRecording · Job · CLI logs
UnAwaitedChainsCompileWithAutoResolvePromisesRecording · Job · CLI logs
UpdateProjectChannelToStable_CSharpEmptyAppHost_PreservesAspireConfigChannelRecording · Job · CLI logs
UpdateProjectChannelToStable_CSharpSingleFileInit_PreservesAspireConfigChannelRecording · Job · CLI logs
UpdateProjectChannelToStable_TypeScriptSingleFileInit_PreservesAspireConfigChannelRecording · Job · CLI logs
UpdateProjectChannelToStable_TypeScript_PreviewsStablePackagesAndPreservesChannelRecording · Job · CLI logs

📹 Recordings uploaded automatically from CI run #27402121786

@joperezr
Jose Perez Rodriguez (joperezr) merged commit ccc566c into release/13.4Jun 12, 2026
620 of 624 checks passed
@joperezr
Jose Perez Rodriguez (joperezr) deleted the backport/pr-18106-to-release/13.4 branch June 12, 2026 17:57
@github-actionsgithub-actionsBot added this to the 13.4.x milestone Jun 12, 2026
@microsoft-github-policy-servicemicrosoft-github-policy-serviceBot removed this from the 13.4.x milestone Jun 12, 2026
@aspire-repo-bot

Copy link
Copy Markdown
ContributorAuthor

✅ No documentation update needed.

Decision path: docs_required → already documented by name

Triggered signals (2): cli_command_file_changed, mcp_tool_file_changed.

This PR is a backport of #18106 to release/13.4, fixing a regression (introduced in 13.2) where resources annotated with ExcludeFromMcp() were not being filtered from MCP tool results. No new flags, options, APIs, or tools were added — the fix restores already-documented behavior.

Per-signal documentation evidence (all in src/frontend/src/content/docs/get-started/aspire-mcp-server.mdx):

  • cli_command_file_changed (AgentMcpCommand.cs): The "Exclude resources from MCP" section already states: "By default, all resources, console logs, and telemetry are accessible through the MCP server. You can exclude specific resources and their associated telemetry by annotating them with ExcludeFromMcp():" (line 126). The method ExcludeFromMcp() appears verbatim in code examples at lines 134 and 151, and in the Enterprise considerations list at line 209.

  • mcp_tool_file_changed (ListResourcesTool.cs, ListConsoleLogsTool.cs, ExecuteResourceCommandTool.cs, ListStructuredLogsTool.cs, ListTracesTool.cs, ListTraceStructuredLogsTool.cs, McpToolHelpers.cs): All modified tools are listed by name in the Tools table: list_resources (line 108), list_console_logs (line 109), list_structured_logs (line 110), list_traces (line 111), list_trace_structured_logs (line 112), execute_resource_command (line 113). The filtering behavior for excluded resources is described in the same "Exclude resources from MCP" section.

This was referenced Jul 7, 2026
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 13, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@joperezr@JamesNK