Preserve MCP namespace descriptions in the tool catalog cache (#38623)

## What changed

Keep MCP namespace descriptions when publishing tool definitions to the
process-scoped catalog cache. Cached definitions now expose the server
instructions to the model before a lazily started MCP connection finishes
initializing.

## Testing

Update the cached MCP startup integration test to verify that cached namespace
descriptions retain the originating server instructions.

GitOrigin-RevId: d1b73381852fd43c6b54a7c22a599474c774dc20
This commit is contained in:
jif authored and copyberry committed 2026-08-14 18:35:13 +00:00
1 parent 478215c5c1
commit 42b5f05cef
2 files changed
+2 -4

No files matched your search

@@ -161,8 +161,6 @@ impl McpToolCatalogCacheContext {
let mut tools = tools.to_vec(); let mut tools = tools.to_vec();
for tool in &mut tools { for tool in &mut tools {
// Initialize instructions belong to one live connection and must not cross sessions.
tool.namespace_description = None;
// Tool annotations affect approval and parallelism decisions, so only the live // Tool annotations affect approval and parallelism decisions, so only the live
// connection may supply them. // connection may supply them.
tool.tool.annotations = None; tool.tool.annotations = None;
+2 -2
View File
@@ -534,7 +534,7 @@ async fn cached_mcp_startup_is_eager_for_root_and_lazy_for_subagents() -> anyhow
); );
assert_definition( assert_definition(
&unused_response, &unused_response,
&format!("Tools in the {NAMESPACE} namespace."), &format!("Use the tools from {cached_process}."),
&format!("Echo from {cached_process}."), &format!("Echo from {cached_process}."),
); );
assert_eq!( assert_eq!(
@@ -631,7 +631,7 @@ async fn cached_mcp_startup_is_eager_for_root_and_lazy_for_subagents() -> anyhow
.context("cached MCP definitions should reach inference before initialization")?; .context("cached MCP definitions should reach inference before initialization")?;
assert_definition( assert_definition(
&cached_response, &cached_response,
&format!("Tools in the {NAMESPACE} namespace."), &format!("Use the tools from {cached_process}."),
&format!("Echo from {cached_process}."), &format!("Echo from {cached_process}."),
); );
let second_pid = wait_for_new_pid(fs.as_ref(), &pid_file, Some(&eager_pid)).await?; let second_pid = wait_for_new_pid(fs.as_ref(), &pid_file, Some(&eager_pid)).await?;