mm.tech
factory stable TypeScript

MCP Cache Kit

Leak-safe caching for the Model Context Protocol

Implements MCP spec SEP-2549 (ttlMs + cacheScope): set the cache fields correctly server-side, and never share a private result across tenants or users client-side. Closes the cross-tenant cache-leak class with helpers and types. 66 tests, MIT, TypeScript.

What it solves

The MCP release candidate of 2026-07-28 added cache hints to list results and resource reads, modelled on HTTP cache control: a time to live and a cache scope. It is new enough that almost nothing supports it properly, and a generic cache that stores results somehow and ignores the scope is a real security trap. A result marked private, cached and then served to a different user, is a cross-user data leak.

How it works

Three pieces. On the server side a helper sets the fields correctly. On the client or proxy side a cache honours the time to live and refuses to serve a private result across authorization contexts. In between sits a guard that answers whether a given result may be cached for a given scope, and says why. It is deliberately conservative: anything it cannot prove safe is treated as uncacheable, and it tolerates missing or malformed fields rather than guessing.

When to use it

Use it if you are writing a gateway, a proxy or a client that caches MCP results at all. Zero runtime dependencies, strict TypeScript, both module systems, Node 20 or newer, and the MCP SDK is only an optional peer because the helpers also work on plain result objects.

When not to use it

The spec it models is a release candidate, so field names and semantics may still shift before the final version. That is a reason to pin a version and reread the release notes, not a reason to hand-roll the caching instead, but it is worth knowing before you build a product on top of it.

Stars

★ 0

installs

↓ 404

Clones (14d)

⊟ 26

Language

TypeScript

Updated

2026-08-21

Install

npx -y mcp-cache-kit

Related repos