Allow MCP servers to opt out of tool catalog caching (#33297)

## What changed

- Recognize the experimental `codex/tool-catalog-cache` server capability during MCP initialization.
- When the server advertises `cacheable: false`, clear its shared tool catalog snapshot and prevent subsequent fetches from repopulating the cache.

GitOrigin-RevId: bce98371a68881001d3ab1378fa1548575f2dadc
This commit is contained in:
jif authored and copyberry committed 2026-07-15 09:20:44 +00:00
1 parent 2e1607ee2f
commit 3307ea8b63
2 files changed
+25 -1

No files matched your search

+8 -1
View File
@@ -52,6 +52,7 @@ struct ToolCatalogCacheEntry {
struct ToolCatalogCacheState {
snapshot: Option<ToolCatalogSnapshot>,
last_accepted_generation: u64,
disabled_by_server: bool,
}
struct ToolCatalogSnapshot {
@@ -125,9 +126,15 @@ impl McpToolCatalogCacheContext {
}
}
pub(crate) fn disable(&self) {
let mut state = lock_unpoisoned(&self.entry.state);
state.disabled_by_server = true;
state.snapshot = None;
}
pub(crate) fn publish_if_newest(&self, ticket: McpToolCatalogFetchTicket, tools: &[ToolInfo]) {
let mut state = lock_unpoisoned(&self.entry.state);
if ticket.generation <= state.last_accepted_generation {
if state.disabled_by_server || ticket.generation <= state.last_accepted_generation {
return;
}