Skip to main content

Module tool_cache

Module tool_cache 

Source
Expand description

ToolCache — lazily populated, refresh-on-demand tool schema store.

The cache is populated on the first call to ToolCache::get_all and reused for subsequent calls. Explicit ToolCache::refresh forces a re-fetch from the backend.

Include/exclude filters are applied at population time, so every read after the initial fetch sees only the filtered view.

§Concurrency

ToolCache uses a tokio::sync::RwLock for the cached data. Multiple concurrent readers do not block each other. A write (populate or refresh) acquires an exclusive lock. Double-checked locking prevents redundant backend fetches when multiple tasks race to populate the cache.

Structs§

ToolCache
Lazily-populated, thread-safe tool schema cache.

Traits§

ToolBackend
Abstraction over the upstream MCP client used in tests and production.