Module: MCPClient::HttpTransportBase::CacheSupport
- Includes:
- RequestAuthorization
- Included in:
- MCPClient::HttpTransportBase
- Defined in:
- lib/mcp_client/http_transport_base/cache_support.rb
Overview
MCP 2026-07-28 caching support shared by the HTTP transports: serving a stale list on transient re-fetch failures, and keeping privately scoped cache entries within their authorization context.
Defined Under Namespace
Classes: AuthorizationRecorder, HeaderProbe
Constant Summary collapse
- NOOP_APP =
Stand-in app for instantiating middleware whose request hook is run without a request (the freshness probe).
->(_env) {}
- UNKNOWN_CONTEXT =
Context that matches no cached entry: the credentials the next request would carry cannot be determined without sending it.
:unknown- PROBE_AUTHORIZATION_NEUTRAL_MIDDLEWARE =
Framework middleware that never puts an Authorization header on a request, whatever literal configuration it was installed with: the probe steps over it instead of running it (some of it overrides
calland could not be run without sending anyway). A handler that was also handed a host callback is unknown all the same (#probe_host_callback_free? is checked first).Faraday::FollowRedirects::Middlewareis on the list because the gem itself depends on it and a host that installs it should keep its private cache hits: it has no request phase, and the only header it ever touches is the Authorization it deletes on a cross-host redirect -- which can cost a hit, never leak one. %w[ Faraday::Retry::Middleware Faraday::Request::Retry Faraday::Request::Json Faraday::Request::UrlEncoded Faraday::Request::Multipart Faraday::Response::Json Faraday::Response::Logger Faraday::FollowRedirects::Middleware ].freeze
- PROBE_PURE_MIDDLEWARE =
The only middleware the probe runs: Faraday's own Authorization middleware, whose header is a pure function of the arguments it was installed with -- and only when those arguments are literal configuration it can do nothing with but read (#probe_static_value?). Host middleware is never run.
[Faraday::Request::Authorization].freeze
- PROBE_STATIC_CLASSES =
Configuration a middleware can only read: a literal, or a plain container of literals. Anything else (a proc that vends a fresh token, an object that answers
call, a holder something else can rotate) may hand a different credential to every request. [NilClass, TrueClass, FalseClass, Numeric, Symbol, String].freeze
- PROBE_STATIC_DEPTH =
How deep a container of configuration is looked into; beyond it the configuration counts as something the probe cannot read.
4- PROBE_DEFAULT_INITIALIZE_OWNERS =
Constructors that build a middleware instance and nothing else. A class with a constructor of its own can give its instances an
on_requesthook (define_singleton_method, an extended module), which a test of the class would never see -- so a class-level "no request phase" verdict only holds when Faraday's own constructor is the one that builds the instance. [Faraday::Middleware, Object, Kernel, BasicObject].freeze
- SENT_AUTHORIZATION_KEY =
Faraday env keys the AuthorizationRecorder files one exchange's record under. Both belong to that exchange and to no other, which a thread-local cannot express: a request the host's response phase nests inside this one runs on this very thread and would overwrite whatever this exchange left there.
:mcp_client_sent_authorization- RESPONSE_RECEIVED_AT_KEY =
:mcp_client_response_received_at
Constants included from RequestAuthorization
RequestAuthorization::ANONYMOUS_AUTHORIZATION, RequestAuthorization::UNRECORDED_AUTHORIZATION