feat(mcp): switch to YAML serialization for tool outputs
- Replaced serde_json with serde_yaml in all handler endpoints. - This drastically reduces token consumption for large list/graph responses by removing JSON braces and quotes.
This commit is contained in:
1 parent
410b0c42ca
commit
cb0c55775a
12 files changed
+65
-37
No files matched your search
@@ -758,7 +758,7 @@ impl McpTool for ClipboardHandler {
|
||||
);
|
||||
|
||||
if let Some(img) = item {
|
||||
Ok(serde_json::to_string_pretty(&img)?)
|
||||
Ok(serde_yaml::to_string(&img)?)
|
||||
} else {
|
||||
Ok(json!({
|
||||
"status": "no_image_in_clipboard",
|
||||
@@ -786,7 +786,7 @@ impl McpTool for ClipboardHandler {
|
||||
|
||||
state.record_activity("clipboard", "Retrieved text from clipboard cache", None);
|
||||
if let Some(txt) = item {
|
||||
Ok(serde_json::to_string_pretty(&txt)?)
|
||||
Ok(serde_yaml::to_string(&txt)?)
|
||||
} else {
|
||||
Ok(json!({
|
||||
"text": "",
|
||||
@@ -818,7 +818,7 @@ impl McpTool for ClipboardHandler {
|
||||
};
|
||||
|
||||
state.record_activity("clipboard", "Viewed clipboard history ring buffer", None);
|
||||
Ok(serde_json::to_string_pretty(&history)?)
|
||||
Ok(serde_yaml::to_string(&history)?)
|
||||
}
|
||||
ClipboardAction::Clear => {
|
||||
tokio::task::spawn_blocking(|| {
|
||||
@@ -905,7 +905,7 @@ impl McpTool for ClipboardHandler {
|
||||
.map_err(|e| crate::error::AppError::Internal(format!("Task panic: {}", e)))??;
|
||||
|
||||
state.record_activity("clipboard", "Read contents from OS clipboard", None);
|
||||
Ok::<String, crate::error::AppError>(serde_json::to_string_pretty(&Value::Object(
|
||||
Ok::<String, crate::error::AppError>(serde_yaml::to_string(&Value::Object(
|
||||
out,
|
||||
))?)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user