feat(server): add annotation to tool macro (#184)

skip serializing the tool annotations if none, fixes mcp inspector
This commit is contained in:
Abhay Agarwal 2025-05-18 01:04:58 -07:00 • committed by GitHub
commit 68ddea3ad5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -37,11 +37,13 @@ pub struct Tool {
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct ToolAnnotations {
/// A human-readable title for the tool.
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
/// If true, the tool does not modify its environment.
///
/// Default: false
#[serde(skip_serializing_if = "Option::is_none")]
pub read_only_hint: Option<bool>,
/// If true, the tool may perform destructive updates to its environment.
@ -51,6 +53,7 @@ pub struct ToolAnnotations {
///
/// Default: true
/// A human-readable description of the tool's purpose.
#[serde(skip_serializing_if = "Option::is_none")]
pub destructive_hint: Option<bool>,
/// If true, calling the tool repeatedly with the same arguments
@ -59,6 +62,7 @@ pub struct ToolAnnotations {
/// (This property is meaningful only when `readOnlyHint == false`)
///
/// Default: false.
#[serde(skip_serializing_if = "Option::is_none")]
pub idempotent_hint: Option<bool>,
/// If true, this tool may interact with an "open world" of external
@ -67,6 +71,7 @@ pub struct ToolAnnotations {
/// of a memory tool is not.
///
/// Default: true
#[serde(skip_serializing_if = "Option::is_none")]
pub open_world_hint: Option<bool>,
}