Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/tools/calculator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,14 @@ impl ToolProvider for CalculatorTool {
text: result.to_string(),
}],
is_error: false,
_meta: None,
}),
Err(error) => Ok(ToolResult {
content: vec![ToolContent::Text {
text: error.to_string(),
}],
is_error: true,
_meta: None,
}),
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/tools/file_system/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ impl ToolProvider for DirectoryTool {
text: format!("Created directory: {}", path),
}],
is_error: false,
_meta: None,
})
}
Some("list_directory") => {
Expand All @@ -96,6 +97,7 @@ impl ToolProvider for DirectoryTool {
text: listing.join("\n"),
}],
is_error: false,
_meta: None,
})
}
Some("move_file") => {
Expand All @@ -115,6 +117,7 @@ impl ToolProvider for DirectoryTool {
text: format!("Moved {} to {}", source, destination),
}],
is_error: false,
_meta: None,
})
}
_ => Err(McpError::InvalidParams),
Expand Down
1 change: 1 addition & 0 deletions src/tools/file_system/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ impl ToolProvider for FileSystemTools {
return Ok(ToolResult {
content: vec![ToolContent::Text { text: dirs }],
is_error: false,
_meta: None,
});
}

Expand Down
2 changes: 2 additions & 0 deletions src/tools/file_system/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ impl ToolProvider for ReadFileTool {
Ok(ToolResult {
content: vec![ToolContent::Text { text: content }],
is_error: false,
_meta: None,
})
}
Some("read_multiple_files") => {
Expand Down Expand Up @@ -119,6 +120,7 @@ impl ToolProvider for ReadFileTool {
Ok(ToolResult {
content: contents,
is_error: false,
_meta: None,
})
}
_ => Err(McpError::InvalidParams),
Expand Down
2 changes: 2 additions & 0 deletions src/tools/file_system/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ impl ToolProvider for SearchTool {
},
}],
is_error: false,
_meta: None,
})
}
Some("get_file_info") => {
Expand All @@ -140,6 +141,7 @@ impl ToolProvider for SearchTool {
Ok(ToolResult {
content: vec![ToolContent::Text { text: info }],
is_error: false,
_meta: None,
})
}
_ => Err(McpError::InvalidParams),
Expand Down
1 change: 1 addition & 0 deletions src/tools/file_system/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ impl ToolProvider for WriteFileTool {
text: format!("Successfully wrote {} bytes to {}", content.len(), path),
}],
is_error: false,
_meta: None,
})
}
}
5 changes: 5 additions & 0 deletions src/tools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ pub struct ResourceContent {
pub struct ToolResult {
pub content: Vec<ToolContent>,
pub is_error: bool,

#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
#[serde(rename = "_meta")]
pub _meta: Option<HashMap<String, Value>>,
}

// Request/Response types
Expand Down
2 changes: 2 additions & 0 deletions src/tools/test_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ impl ToolProvider for TestTool {
Ok(ToolResult {
content: vec![],
is_error: false,
_meta: None,
})
}
}
Expand Down Expand Up @@ -99,6 +100,7 @@ impl ToolProvider for PingTool {
Ok(ToolResult {
content: vec![ToolContent::Text { text: body }],
is_error: false,
_meta: None,
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ impl ToolProvider for MockCalculatorTool {
text: "Division by zero".to_string(),
}],
is_error: true,
_meta: None,
});
}
params.a / params.b
Expand All @@ -78,6 +79,7 @@ impl ToolProvider for MockCalculatorTool {
text: result.to_string(),
}],
is_error: false,
_meta: None,
})
}
}
Expand Down