feat!: implement SEP-2549 cache hints (#889)

implements https://github.com/modelcontextprotocol/rust-sdk/issues/875

Co-authored-by: Jack Amadeo <jackamadeo@squareup.com>
This commit is contained in:
Michael Neale 2026-07-10 10:54:18 -07:00 • committed by GitHub
commit d8331d9442
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 403 additions and 7 deletions

View file

@ -150,6 +150,21 @@
"format": "const",
"const": "boolean"
},
"CacheScope": {
"description": "Scope describing who may cache cacheable list/read results (SEP-2549).\n\nDefaults to [`CacheScope::Public`] when absent from the wire.",
"oneOf": [
{
"description": "Any client or intermediary may cache and serve the response to any user.",
"type": "string",
"const": "public"
},
{
"description": "Only the requesting user's client may cache the response.",
"type": "string",
"const": "private"
}
]
},
"CallToolResult": {
"description": "The result of a tool call operation.\n\nContains the content returned by the tool execution and an optional\nflag indicating whether the operation resulted in an error.",
"type": "object",
@ -1515,6 +1530,17 @@
],
"additionalProperties": true
},
"cacheScope": {
"description": "Scope describing who may cache this result (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"anyOf": [
{
"$ref": "#/definitions/CacheScope"
},
{
"type": "null"
}
]
},
"nextCursor": {
"type": [
"string",
@ -1535,6 +1561,15 @@
}
],
"default": "complete"
},
"ttlMs": {
"description": "Time, in milliseconds, that this result may be treated as fresh (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0
}
},
"required": [
@ -1551,6 +1586,17 @@
],
"additionalProperties": true
},
"cacheScope": {
"description": "Scope describing who may cache this result (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"anyOf": [
{
"$ref": "#/definitions/CacheScope"
},
{
"type": "null"
}
]
},
"nextCursor": {
"type": [
"string",
@ -1571,6 +1617,15 @@
}
],
"default": "complete"
},
"ttlMs": {
"description": "Time, in milliseconds, that this result may be treated as fresh (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0
}
},
"required": [
@ -1587,6 +1642,17 @@
],
"additionalProperties": true
},
"cacheScope": {
"description": "Scope describing who may cache this result (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"anyOf": [
{
"$ref": "#/definitions/CacheScope"
},
{
"type": "null"
}
]
},
"nextCursor": {
"type": [
"string",
@ -1607,6 +1673,15 @@
}
],
"default": "complete"
},
"ttlMs": {
"description": "Time, in milliseconds, that this result may be treated as fresh (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0
}
},
"required": [
@ -1655,6 +1730,17 @@
],
"additionalProperties": true
},
"cacheScope": {
"description": "Scope describing who may cache this result (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"anyOf": [
{
"$ref": "#/definitions/CacheScope"
},
{
"type": "null"
}
]
},
"nextCursor": {
"type": [
"string",
@ -1675,6 +1761,15 @@
"items": {
"$ref": "#/definitions/Tool"
}
},
"ttlMs": {
"description": "Time, in milliseconds, that this result may be treated as fresh (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0
}
},
"required": [
@ -2214,6 +2309,17 @@
],
"additionalProperties": true
},
"cacheScope": {
"description": "Scope describing who may cache this result (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"anyOf": [
{
"$ref": "#/definitions/CacheScope"
},
{
"type": "null"
}
]
},
"contents": {
"description": "The actual content of the resource",
"type": "array",
@ -2221,7 +2327,7 @@
"$ref": "#/definitions/ResourceContents"
}
},
"result_type": {
"resultType": {
"description": "Result type discriminator. Absent values deserialize as `\"complete\"`.",
"allOf": [
{
@ -2229,6 +2335,15 @@
}
],
"default": "complete"
},
"ttlMs": {
"description": "Time, in milliseconds, that this result may be treated as fresh (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0
}
},
"required": [

View file

@ -150,6 +150,21 @@
"format": "const",
"const": "boolean"
},
"CacheScope": {
"description": "Scope describing who may cache cacheable list/read results (SEP-2549).\n\nDefaults to [`CacheScope::Public`] when absent from the wire.",
"oneOf": [
{
"description": "Any client or intermediary may cache and serve the response to any user.",
"type": "string",
"const": "public"
},
{
"description": "Only the requesting user's client may cache the response.",
"type": "string",
"const": "private"
}
]
},
"CallToolResult": {
"description": "The result of a tool call operation.\n\nContains the content returned by the tool execution and an optional\nflag indicating whether the operation resulted in an error.",
"type": "object",
@ -1515,6 +1530,17 @@
],
"additionalProperties": true
},
"cacheScope": {
"description": "Scope describing who may cache this result (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"anyOf": [
{
"$ref": "#/definitions/CacheScope"
},
{
"type": "null"
}
]
},
"nextCursor": {
"type": [
"string",
@ -1535,6 +1561,15 @@
}
],
"default": "complete"
},
"ttlMs": {
"description": "Time, in milliseconds, that this result may be treated as fresh (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0
}
},
"required": [
@ -1551,6 +1586,17 @@
],
"additionalProperties": true
},
"cacheScope": {
"description": "Scope describing who may cache this result (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"anyOf": [
{
"$ref": "#/definitions/CacheScope"
},
{
"type": "null"
}
]
},
"nextCursor": {
"type": [
"string",
@ -1571,6 +1617,15 @@
}
],
"default": "complete"
},
"ttlMs": {
"description": "Time, in milliseconds, that this result may be treated as fresh (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0
}
},
"required": [
@ -1587,6 +1642,17 @@
],
"additionalProperties": true
},
"cacheScope": {
"description": "Scope describing who may cache this result (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"anyOf": [
{
"$ref": "#/definitions/CacheScope"
},
{
"type": "null"
}
]
},
"nextCursor": {
"type": [
"string",
@ -1607,6 +1673,15 @@
}
],
"default": "complete"
},
"ttlMs": {
"description": "Time, in milliseconds, that this result may be treated as fresh (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0
}
},
"required": [
@ -1655,6 +1730,17 @@
],
"additionalProperties": true
},
"cacheScope": {
"description": "Scope describing who may cache this result (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"anyOf": [
{
"$ref": "#/definitions/CacheScope"
},
{
"type": "null"
}
]
},
"nextCursor": {
"type": [
"string",
@ -1675,6 +1761,15 @@
"items": {
"$ref": "#/definitions/Tool"
}
},
"ttlMs": {
"description": "Time, in milliseconds, that this result may be treated as fresh (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0
}
},
"required": [
@ -2214,6 +2309,17 @@
],
"additionalProperties": true
},
"cacheScope": {
"description": "Scope describing who may cache this result (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"anyOf": [
{
"$ref": "#/definitions/CacheScope"
},
{
"type": "null"
}
]
},
"contents": {
"description": "The actual content of the resource",
"type": "array",
@ -2221,7 +2327,7 @@
"$ref": "#/definitions/ResourceContents"
}
},
"result_type": {
"resultType": {
"description": "Result type discriminator. Absent values deserialize as `\"complete\"`.",
"allOf": [
{
@ -2229,6 +2335,15 @@
}
],
"default": "complete"
},
"ttlMs": {
"description": "Time, in milliseconds, that this result may be treated as fresh (SEP-2549).\nRequired by spec version 2026-07-28, but optional here to maintain compatibility\nwith older spec versions.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0
}
},
"required": [