Expose deferred MCP servers in resource listings (#60423)

## Why

Aggregate resource listings omitted dormant MCP servers, leaving callers without their names for explicit queries.

## What changed

Include a sorted `deferredServers` list in aggregate `list_mcp_resources` and `list_mcp_resource_templates` results alongside resources from ready servers. Apply the listing filters to deferred servers and omit the field when empty. Discovery leaves dormant servers unstarted; callers can query them by passing `server` explicitly.

## Testing

Extend the resource discovery scenario for direct calls and Code Mode to verify deferred server names, confirm discovery leaves the server unstarted, and then list and read resources by server name.

GitOrigin-RevId: f95b8beb64bb1329f4ae3245e8c375614fcb3360
This commit is contained in:
Charlie Marsh
2026-11-09 17:58:16 +00:00
committed by copyberry
parent 4f9e7171a1
commit 27fcd7cbed
11 changed files with 171 additions and 84 deletions
+4 -3
View File
@@ -31,6 +31,7 @@ use serde_json::Value as JsonValue;
use crate::McpConfig;
use crate::McpServerPermissions;
use crate::binding_clients::McpBindingClients;
use crate::binding_clients::McpResourceListing;
use crate::client_tool_catalog::ToolCatalogSnapshot;
use crate::connection_manager::McpConnectionSet;
use crate::rmcp_client::ManagedClient;
@@ -52,7 +53,7 @@ impl McpBinding {
pub fn empty(config: Arc<McpConfig>) -> Self {
Self::new(
Arc::new(McpConnectionSet::empty(config.prefix_mcp_tool_names)),
Arc::new(McpBindingClients::new(HashMap::new())),
Arc::new(McpBindingClients::default()),
config,
/*plugins_available*/ false,
Vec::new(),
@@ -130,7 +131,7 @@ impl McpBinding {
pub async fn list_all_resources(
&self,
include_server: impl Fn(&str) -> bool,
) -> HashMap<String, Vec<Resource>> {
) -> McpResourceListing<Resource> {
self.clients.list_all_resources(include_server).await
}
@@ -154,7 +155,7 @@ impl McpBinding {
pub async fn list_all_resource_templates(
&self,
include_server: impl Fn(&str) -> bool,
) -> HashMap<String, Vec<ResourceTemplate>> {
) -> McpResourceListing<ResourceTemplate> {
self.clients
.list_all_resource_templates(|server| {
include_server(server) && !self.connections.skips_resource_template_listing(server)