Add cache_hints constructor map for SEP-2549 caching hints (#3015)
This commit is contained in:
parent
c85836a081
commit
533c6a8226
1 changed files with 519 additions and 4 deletions
19
docs_src/caching/tutorial001.py
Normal file
19
docs_src/caching/tutorial001.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
from mcp.server import CacheHint, MCPServer
|
||||
|
||||
mcp = MCPServer(
|
||||
"Weather",
|
||||
cache_hints={
|
||||
"tools/list": CacheHint(ttl_ms=60_000, scope="public"),
|
||||
"resources/read": CacheHint(ttl_ms=5_000),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def forecast(city: str) -> str:
|
||||
return f"Sunny in {city}"
|
||||
|
||||
|
||||
@mcp.resource("config://units")
|
||||
def units() -> str:
|
||||
return "metric"
|
||||
Loading…
Reference in a new issue