🎉 ai-infra v1.0 is here — Production-ready AI/LLM infrastructure
What's new
nfrax logonfrax

Infrastructure that just works. Ship products, not boilerplate.

Frameworks

  • svc-infra
  • ai-infra
  • fin-infra
  • robo-infra

Resources

  • Getting Started
  • What's New
  • Contributing

Community

  • GitHub

© 2026 nfrax. All rights reserved.

nfrax logonfrax
Start HereWhat's New
GitHub
ai-infra / API Reference

CachingInterceptor

from ai_infra.mcp import CachingInterceptor
View source
ai_infra.mcp

Cache tool call results for a configurable TTL. Caches based on tool name, arguments, and server name. Useful for expensive operations with deterministic results.

Attributes

ttl_seconds: Time-to-live for cache entries (default: 300).

python
cache = CachingInterceptor(ttl_seconds=60)
    mcp = MCPClient([config], interceptors=[cache])
Constructor
CachingInterceptor(ttl_seconds: int = 300, _cache: dict[str, tuple[CallToolResult, float]] = dict()) -> None
ParameterTypeDefaultDescription
ttl_secondsint300—
_cachedict[str, tuple[CallToolResult, float]]dict()—

Methods

On This Page

Constructorclearinvalidate