MCP · Lesson 82 of 120
Caching Hints
Ttl for lists.
Clients often ask for the same lists again and again. A server can say how long a reply stays fresh. Then the client can reuse it, instead of asking again.

- Same lists again
- How long it's fresh
- Reuse it
A caching hint
Cache hints maps a method to a hint. Here, the tool list stays fresh for one minute, and can be shared between users. The client sees the hint on the result. Run it. A time to live of sixty thousand milliseconds, with public scope.
cache_hints.pypython
import asyncio
from mcp import Client
from mcp.server.caching import CacheHint
from mcp.server.mcpserver import MCPServer
mcp = MCPServer("northwind", cache_hints={"tools/list": CacheHint(ttl_ms=60_000, scope="public")})
@mcp.tool()
def order_status(order_id: int) -> str:
"""Look up an order."""
return "shipped"
async def main():
async with Client(mcp) as client:
page = await client.list_tools()
print("ttl:", page.ttl_ms, "ms | scope:", page.cache_scope)
asyncio.run(main())Output
ttl: 60000 ms | scope: public
Scopes
Public means any user may share the cached reply. Private means it's only reused for the same user. Use private when replies depend on who's asking. A time to live of zero means don't reuse it.
| key | value |
|---|---|
| public | shared by all |
| private | same user only |
| Per-user data | private |
| ttl 0 | always fresh |
Summary
Caching hints tell clients how long lists stay fresh, and who may share them. Next, roots.
Key takeaways- cache_hints
- ttl_ms
- scope
Next up: Roots — where the client allows