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
@@ -297,12 +297,12 @@ impl McpTool for TasksHandler {
|
||||
_ => serde_json::json!({ "id": t.id, "title": t.title, "status": t.status, "description": t.description, "git_branch": t.git_branch }),
|
||||
})
|
||||
.collect();
|
||||
let mut json_str = serde_json::to_string(&filtered)?;
|
||||
let mut json_str = serde_yaml::to_string(&filtered)?;
|
||||
if let Some(max_t) = req.max_tokens {
|
||||
let char_limit = max_t * 4;
|
||||
while json_str.len() > char_limit && !filtered.is_empty() {
|
||||
filtered.pop();
|
||||
json_str = serde_json::to_string(&filtered)?;
|
||||
json_str = serde_yaml::to_string(&filtered)?;
|
||||
}
|
||||
}
|
||||
Ok::<String, crate::error::AppError>(json_str)
|
||||
@@ -514,7 +514,7 @@ impl McpTool for MilestonesHandler {
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
Ok::<String, crate::error::AppError>(serde_json::to_string(&filtered)?)
|
||||
Ok::<String, crate::error::AppError>(serde_yaml::to_string(&filtered)?)
|
||||
})?;
|
||||
Ok(data)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user