Skip to content

Commit b24a6fb

Browse files
8bit-wraithclaude
andcommitted
🐛 Fix MCP edit tool empty result bug (Issue #21)
FIXES: - wrap get_function_tree result in MCP content format - wrap smart_edit result in MCP content format - Add compression hints to initialization The edit tool was returning correct data in logs but Claude saw empty results because the responses weren't wrapped in the required MCP content format: ```json { "content": [{ "type": "text", "text": "..." }] } ``` Also added smart compression hints: - Server description now hints at using compress:true - Suggests quantum mode for massive codebases - Helps AI assistants save context automatically Fixes #21 🤖 Generated with Claude Code Co-Authored-By: Claude <[email protected]>
1 parent 6d323d9 commit b24a6fb

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ members = ["expert_prompt_engineer"]
33

44
[package]
55
name = "st"
6-
version = "5.0.0"
6+
version = "5.0.1"
77
edition = "2021"
88
authors = ["8bit-wraith", "Claude", "Omni", "8b-is Team"]
99
description = "Smart Tree - An intelligent, AI-friendly directory visualization tool"

src/mcp/mod.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ impl McpServer {
353353

354354
// Handler implementations
355355

356-
async fn handle_initialize(_params: Option<Value>, _ctx: Arc<McpContext>) -> Result<Value> {
356+
async fn handle_initialize(_params: Option<Value>, ctx: Arc<McpContext>) -> Result<Value> {
357357
Ok(json!({
358358
"protocolVersion": "2024-11-05",
359359
"capabilities": {
@@ -373,15 +373,18 @@ async fn handle_initialize(_params: Option<Value>, _ctx: Arc<McpContext>) -> Res
373373
"name": "smart-tree",
374374
"version": env!("CARGO_PKG_VERSION"),
375375
"vendor": "8b-is",
376-
"description": "Smart Tree - AI-optimized directory visualization with quantum compression",
376+
"description": "Smart Tree v5 - NOW WITH COMPRESSION HINTS! 🗜️ Use compress:true for 80% smaller outputs. For massive codebases, use mode:'quantum' for 100x compression!",
377377
"homepage": env!("CARGO_PKG_REPOSITORY"),
378378
"features": [
379379
"quantum-compression",
380380
"mcp-optimization",
381381
"content-search",
382382
"streaming",
383-
"caching"
384-
]
383+
"caching",
384+
"emotional-mode",
385+
"auto-compression-hints"
386+
],
387+
"compression_hint": "💡 Always add compress:true to analyze tools for optimal context usage!"
385388
}
386389
}))
387390
}

src/mcp/smart_edit.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -946,13 +946,21 @@ pub async fn handle_smart_edit(params: Option<Value>) -> Result<Value> {
946946
// Write back to file
947947
std::fs::write(file_path, &editor.content)?;
948948

949-
Ok(json!({
949+
let result = json!({
950950
"file_path": file_path,
951951
"language": format!("{:?}", language),
952952
"edits_applied": results,
953953
"initial_structure": initial_structure,
954954
"final_structure": final_structure,
955955
"content_preview": editor.content.lines().take(20).collect::<Vec<_>>().join("\n"),
956+
});
957+
958+
// Wrap in MCP content format
959+
Ok(json!({
960+
"content": [{
961+
"type": "text",
962+
"text": serde_json::to_string_pretty(&result)?
963+
}]
956964
}))
957965
}
958966

@@ -970,7 +978,15 @@ pub async fn handle_get_function_tree(params: Option<Value>) -> Result<Value> {
970978
let language = SupportedLanguage::from_extension(extension).context("Unsupported language")?;
971979

972980
let editor = SmartEditor::new(content, language)?;
973-
editor.get_function_tree()
981+
let function_tree = editor.get_function_tree()?;
982+
983+
// Wrap in MCP content format
984+
Ok(json!({
985+
"content": [{
986+
"type": "text",
987+
"text": serde_json::to_string_pretty(&function_tree)?
988+
}]
989+
}))
974990
}
975991

976992
/// Insert a single function using minimal tokens

st-v5.0.0-linux-x86_64

25.2 MB
Binary file not shown.

0 commit comments

Comments
 (0)