fix: emit cache hints from handler macros (#1120)
This commit is contained in:
parent
f8f9607d0b
commit
07bcda2973
1 changed files with 120 additions and 6 deletions
|
|
@ -66,15 +66,19 @@ pub fn tool_handler(attr: TokenStream, input: TokenStream) -> syn::Result<TokenS
|
|||
async fn list_tools(
|
||||
&self,
|
||||
_request: Option<rmcp::model::PaginatedRequestParams>,
|
||||
_context: rmcp::service::RequestContext<rmcp::RoleServer>,
|
||||
context: rmcp::service::RequestContext<rmcp::RoleServer>,
|
||||
) -> Result<rmcp::model::ListToolsResult, rmcp::ErrorData> {
|
||||
let supports_cache_hints = context.protocol_version().is_some_and(|version| {
|
||||
version >= rmcp::model::ProtocolVersion::V_2026_07_28
|
||||
});
|
||||
Ok(rmcp::model::ListToolsResult{
|
||||
result_type: Some(rmcp::model::ResultType::COMPLETE),
|
||||
tools: #router.list_all(),
|
||||
meta: #result_meta,
|
||||
next_cursor: None,
|
||||
ttl_ms: None,
|
||||
cache_scope: None,
|
||||
ttl_ms: supports_cache_hints.then_some(0),
|
||||
cache_scope: supports_cache_hints
|
||||
.then_some(rmcp::model::CacheScope::Public),
|
||||
})
|
||||
}
|
||||
})?;
|
||||
|
|
|
|||
Loading…
Reference in a new issue