Skip to content

Commit b2fbdcc

Browse files
committed
skip serializing the tool annotations if none, fixes mcp inspector
1 parent 57e327b commit b2fbdcc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

crates/rmcp/src/model/tool.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ pub struct Tool {
3737
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
3838
pub struct ToolAnnotations {
3939
/// A human-readable title for the tool.
40+
#[serde(skip_serializing_if = "Option::is_none")]
4041
pub title: Option<String>,
4142

4243
/// If true, the tool does not modify its environment.
4344
///
4445
/// Default: false
46+
#[serde(skip_serializing_if = "Option::is_none")]
4547
pub read_only_hint: Option<bool>,
4648

4749
/// If true, the tool may perform destructive updates to its environment.
@@ -51,6 +53,7 @@ pub struct ToolAnnotations {
5153
///
5254
/// Default: true
5355
/// A human-readable description of the tool's purpose.
56+
#[serde(skip_serializing_if = "Option::is_none")]
5457
pub destructive_hint: Option<bool>,
5558

5659
/// If true, calling the tool repeatedly with the same arguments
@@ -59,6 +62,7 @@ pub struct ToolAnnotations {
5962
/// (This property is meaningful only when `readOnlyHint == false`)
6063
///
6164
/// Default: false.
65+
#[serde(skip_serializing_if = "Option::is_none")]
6266
pub idempotent_hint: Option<bool>,
6367

6468
/// If true, this tool may interact with an "open world" of external
@@ -67,6 +71,7 @@ pub struct ToolAnnotations {
6771
/// of a memory tool is not.
6872
///
6973
/// Default: true
74+
#[serde(skip_serializing_if = "Option::is_none")]
7075
pub open_world_hint: Option<bool>,
7176
}
7277

0 commit comments

Comments
 (0)