Start required cached MCP servers lazily for subagents (#38217)

## Why

Subagents can reuse cached MCP tool definitions without opening another server
connection immediately, but marking a server as required previously forced eager
startup even when its cached tools were available.

## What changed

- Allow required MCP servers with usable cached tools to remain dormant under
  the lazy startup policy.
- Treat those cached tools as satisfying required-server validation and tool
  catalog capture until the server is needed.
- Preserve eager startup for required servers without cached tools and start a
  dormant server when one of its tools is called.

## Testing

Extend the cached HTTP MCP subagent test to cover both optional and required
servers, verifying that the required server stays dormant until its cached tool
is called.

GitOrigin-RevId: 48ea20b9ae447eef27461caee2320ea78465bb6a
This commit is contained in:
jif authored and copyberry committed 2026-08-12 16:50:23 +00:00
1 parent 91d6f48992
commit 7093e8c480
5 files changed
+13 -5

No files matched your search

@@ -493,7 +493,6 @@ impl McpConnectionSet {
catalog_item_limit,
);
let defer_startup = allow_deferred_startup
&& !configured_config.required
&& !tool_plugin_provenance.is_selected_plugin_mcp_server(&server_name)
&& async_managed_client
.tool_catalog_cache_context