smart-tree 8.0.1

Smart Tree - An intelligent, AI-friendly directory visualization tool
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
// Enhanced Consolidated MCP Tools with AI-Friendly Tips and Examples
// Making Smart Tree irresistible to AI assistants! 🌳✨

use crate::feature_flags;
use serde_json::{json, Value};

// Re-export the dispatcher from the original consolidated tools
pub use super::tools_consolidated::dispatch_consolidated_tool;

/// Get enhanced consolidated tool list with attractive tips and examples
pub fn get_enhanced_consolidated_tools() -> Vec<Value> {
    // Get feature flags to filter tools
    let flags = feature_flags::features();
    let mut tools = Vec::new();

    // Always include overview (basic tool)
    tools.push(
        json!({
            "name": "overview",
            "description": "🚀 START HERE! Lightning-fast project understanding in seconds. Get a comprehensive overview with automatic project type detection, key files, and structure insights. Perfect first tool for any new codebase!

💡 TIP: Your friend wants comprehensive project info? Try these:
• overview {mode:'quick', path:'.'} - 3-level instant overview
• overview {mode:'project'} - Full project analysis with key files

EXAMPLES:
✓ Quick explore: overview {mode:'quick', depth:2}
✓ Deep dive: overview {mode:'project', path:'/src'}
✓ Token-efficient: Uses 10x compression by default!",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "mode": {
                        "type": "string",
                        "enum": ["quick", "project"],
                        "description": "quick=3-level fast scan, project=comprehensive analysis",
                        "default": "quick"
                    },
                    "path": {
                        "type": "string",
                        "description": "Directory to analyze (default: current)",
                        "default": "."
                    },
                    "depth": {
                        "type": "integer",
                        "description": "Max depth for quick mode (default: 3)",
                        "default": 3
                    }
                },
                "required": []
            }
        }));

    // Add find tool if enabled
    if flags.mcp_tools.enable_find {
        tools.push(json!({
            "name": "find",
            "description": "🔍 POWERFUL FINDER - One tool for ALL file discovery needs! Find code, tests, configs, docs, large files, recent changes, and more with a single versatile tool.

💡 TIP: Need to locate specific files? Try these power moves:
• find {type:'code', languages:['rust','python']} - All code files
• find {type:'tests'} - Instantly locate all test files
• find {type:'recent', days:7} - What changed this week?
• find {type:'large', min_size:'10M'} - Find space hogs
• find {type:'projects'} - 🚀 Discover forgotten 3am coding gems!

EXAMPLES:
✓ Find Python tests: find {type:'tests', path:'src', pattern:'test_*.py'}
✓ Recent work: find {type:'recent', days:3}
✓ Config files: find {type:'config'}
✓ Documentation: find {type:'documentation'}
✓ Find all projects: find {type:'projects', depth:10}",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "type": {
                        "type": "string",
                        "enum": ["files", "code", "config", "documentation", "tests", "build",
                                 "large", "recent", "timespan", "duplicates", "empty_dirs", "projects"],
                        "description": "What to find (code/tests/config/docs/etc)"
                    },
                    "path": {
                        "type": "string",
                        "description": "Where to search (default: current)",
                        "default": "."
                    },
                    "pattern": {
                        "type": "string",
                        "description": "Regex pattern for file names"
                    },
                    "languages": {
                        "type": "array",
                        "items": { "type": "string" },
                        "description": "Languages for code type: rust, python, js, etc"
                    },
                    "days": {
                        "type": "integer",
                        "description": "Days back for recent type",
                        "default": 7
                    },
                    "min_size": {
                        "type": "string",
                        "description": "Min size for large type (e.g., '10M', '1G')",
                        "default": "10M"
                    },
                    "limit": {
                        "type": "integer",
                        "description": "Maximum results to return (for pagination)"
                    },
                    "offset": {
                        "type": "integer",
                        "description": "Number of results to skip (for pagination)"
                    }
                },
                "required": ["type"]
            }
        }));
    }

    // Add search tool if enabled
    if flags.mcp_tools.enable_search {
        tools.push(json!({
            "name": "search",
            "description": "🔎 CONTENT SEARCH - Like grep but AI-optimized! Search file contents with line numbers, context, and actual content returned. Perfect for finding implementations, TODOs, or any text pattern.

💡 TIP: Looking for specific code? Try these:
• search {keyword:'TODO'} - Find all TODOs with line content
• search {keyword:'function.*async', file_type:'rs'} - Async functions in Rust
• search {keyword:'import', context_lines:2} - Imports with context

EXAMPLES:
✓ Find TODOs: search {keyword:'TODO', include_content:true}
✓ Function usage: search {keyword:'processPayment', context_lines:3}
✓ Error handling: search {keyword:'catch|except|Result', file_type:'js'}",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "keyword": {
                        "type": "string",
                        "description": "Text/regex to search for"
                    },
                    "path": {
                        "type": "string",
                        "description": "Where to search",
                        "default": "."
                    },
                    "case_sensitive": {
                        "type": "boolean",
                        "description": "Case sensitive search",
                        "default": false
                    },
                    "file_type": {
                        "type": "string",
                        "description": "Limit to file type (rs, py, js, etc)"
                    },
                    "context_lines": {
                        "type": "integer",
                        "description": "Lines before/after match",
                        "default": 0
                    },
                    "include_content": {
                        "type": "boolean",
                        "description": "Include actual line content",
                        "default": true
                    }
                },
                "required": ["keyword"]
            }
        }));
    }

    // Add analyze tool if enabled
    if flags.mcp_tools.enable_analyze {
        tools.push(json!({
            "name": "analyze",
            "description": "📊 DEEP ANALYSIS - Multiple analysis modes for different insights. Get statistics, git status, semantic grouping, size breakdowns, and more!

🚀 TOKEN-AWARE: Semantic mode auto-compresses large outputs to stay under limits!

💡 TIP: Want detailed insights? Try these:
• analyze {mode:'statistics'} - File type distribution & sizes
• analyze {mode:'git_status'} - Git-aware directory tree
• analyze {mode:'semantic'} - AI semantic grouping (AUTO-COMPRESSES if needed!)
• analyze {mode:'quantum-semantic'} - Maximum compression for huge codebases
• analyze {mode:'directory', format:'ai'} - AI-optimized tree

EXAMPLES:
✓ Project stats: analyze {mode:'statistics', show_hidden:true}
✓ Git overview: analyze {mode:'git_status'}
✓ Semantic groups: analyze {mode:'semantic', show_wave_signatures:true}
✓ Huge codebase: analyze {mode:'quantum-semantic', path:'./burn'}
✓ Size analysis: analyze {mode:'size_breakdown'}",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "mode": {
                        "type": "string",
                        "enum": ["directory", "workspace", "statistics", "git_status",
                                 "digest", "semantic", "size_breakdown", "ai_tools"],
                        "description": "Analysis type"
                    },
                    "path": {
                        "type": "string",
                        "description": "Path to analyze",
                        "default": "."
                    },
                    "format": {
                        "type": "string",
                        "description": "Output format for directory mode",
                        "default": "ai"
                    },
                    "max_depth": {
                        "type": "integer",
                        "description": "Max traversal depth",
                        "default": 0
                    },
                    "show_hidden": {
                        "type": "boolean",
                        "description": "Include hidden files",
                        "default": false
                    }
                },
                "required": ["mode"]
            }
        }));
    }

    // Add edit tool if enabled
    if flags.mcp_tools.enable_edit {
        tools.push(json!({
            "name": "edit",
            "description": "✨ SMART EDIT - Revolutionary AST-aware editing with 90% token reduction! Edit code by describing changes, not sending diffs. Understands code structure!

💡 OPERATION TYPES:

0️⃣ **create_file** - Create a new file (use this first!)
   Required: file_path
   Optional: content (defaults to empty file if not provided)
   Creates a new file with initial content. Creates parent directories if needed.
   Example: {operation:'create_file', file_path:'src/utils.rs', content:'// New file\\npub fn hello() {}'}
   Empty file: {operation:'create_file', file_path:'README.md'}

1️⃣ **get_functions** - View code structure
   Required: file_path
   Returns: All functions, classes, and their relationships
   Example: {operation:'get_functions', file_path:'app.py'}

2️⃣ **insert_function** - Add a new function
   Required: file_path, name, body
   Optional: after, before, class_name, visibility
   Example: {operation:'insert_function', file_path:'utils.rs', name:'validate', body:'fn validate(input: &str) -> bool { !input.is_empty() }', visibility:'public'}

3️⃣ **remove_function** - Remove a function
   Required: file_path, name
   Optional: class_name, force, cascade
   Example: {operation:'remove_function', file_path:'old.js', name:'deprecated'}

4️⃣ **smart_edit** - Multiple AST-aware edits
   Required: file_path, edits (array)
   Each edit in array must have 'operation' field
   Operations: InsertFunction, ReplaceFunction, AddImport, SmartAppend
   
   InsertFunction example: {operation:'InsertFunction', name:'helper', body:'def helper(): pass'}
   AddImport example: {operation:'AddImport', import:'os'}
   SmartAppend example: {operation:'SmartAppend', section:'functions', content:'def new_func(): pass'}",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "operation": {
                        "type": "string",
                        "enum": ["create_file", "smart_edit", "get_functions", "insert_function", "remove_function"],
                        "description": "Edit operation type: 'create_file' (create new file), 'get_functions' (view structure), 'insert_function' (add function), 'remove_function' (delete function), 'smart_edit' (multiple AST edits)"
                    },
                    "file_path": {
                        "type": "string",
                        "description": "Path to the file to edit (REQUIRED for all operations)"
                    },
                    "edits": {
                        "type": "array",
                        "description": "Array of edit operations (REQUIRED for 'smart_edit' operation only). Each edit must have 'operation' field and additional fields based on operation type.",
                        "items": {
                            "type": "object",
                            "description": "Individual edit operation. Required fields depend on operation type:\n- InsertFunction: name, body (optional: after, before, class_name, visibility)\n- ReplaceFunction: name, new_body (optional: class_name)\n- AddImport: import (optional: alias)\n- InsertClass: name, body (optional: namespace, extends, implements)\n- AddMethod: class_name, method_name, body (optional: visibility)\n- SmartAppend: section, content\n- DeleteElement: element_type, name (optional: parent)\n- Rename: old_name, new_name (optional: scope)\n- WrapCode: start_line, end_line, wrapper_type (optional: condition)\n- AddDocumentation: target_type, target_name, documentation",
                            "properties": {
                                "operation": {
                                    "type": "string",
                                    "description": "Type of edit operation",
                                    "enum": ["InsertFunction", "ReplaceFunction", "AddImport", "InsertClass", "AddMethod", "WrapCode", "DeleteElement", "Rename", "AddDocumentation", "SmartAppend"]
                                },
                                "name": {
                                    "type": "string",
                                    "description": "Name of element (REQUIRED for InsertFunction, InsertClass, ReplaceFunction, DeleteElement)"
                                },
                                "body": {
                                    "type": "string",
                                    "description": "Code body (REQUIRED for InsertFunction, InsertClass, AddMethod)"
                                },
                                "new_body": {
                                    "type": "string",
                                    "description": "New body (REQUIRED for ReplaceFunction)"
                                },
                                "import": {
                                    "type": "string",
                                    "description": "Import statement (REQUIRED for AddImport)"
                                },
                                "section": {
                                    "type": "string",
                                    "description": "Section to append to (REQUIRED for SmartAppend)",
                                    "enum": ["imports", "functions", "classes", "main"]
                                },
                                "content": {
                                    "type": "string",
                                    "description": "Content to append (REQUIRED for SmartAppend)"
                                },
                                "class_name": {
                                    "type": "string",
                                    "description": "Class name (optional for methods, REQUIRED for AddMethod)"
                                },
                                "method_name": {
                                    "type": "string",
                                    "description": "Method name (REQUIRED for AddMethod)"
                                },
                                "after": {
                                    "type": "string",
                                    "description": "Insert after this element (optional positioning)"
                                },
                                "before": {
                                    "type": "string",
                                    "description": "Insert before this element (optional positioning)"
                                },
                                "visibility": {
                                    "type": "string",
                                    "description": "Visibility modifier (optional, defaults to 'private')",
                                    "enum": ["public", "private", "protected"]
                                }
                            },
                            "required": ["operation"]
                        }
                    },
                    "name": {
                        "type": "string",
                        "description": "Function/element name (REQUIRED for 'insert_function' and 'remove_function' operations)"
                    },
                    "body": {
                        "type": "string",
                        "description": "Function body/code (REQUIRED for 'insert_function' operation)"
                    },
                    "after": {
                        "type": "string",
                        "description": "Insert after this function (optional for 'insert_function')"
                    },
                    "before": {
                        "type": "string",
                        "description": "Insert before this function (optional for 'insert_function')"
                    },
                    "class_name": {
                        "type": "string",
                        "description": "Class name for methods (optional for 'insert_function' and 'remove_function')"
                    },
                    "visibility": {
                        "type": "string",
                        "description": "Visibility modifier (optional for 'insert_function', defaults to 'private')",
                        "enum": ["public", "private", "protected"]
                    },
                    "force": {
                        "type": "boolean",
                        "description": "Force removal even if dependencies exist (optional for 'remove_function')"
                    },
                    "cascade": {
                        "type": "boolean",
                        "description": "Also remove dependent functions (optional for 'remove_function')"
                    },
                    "content": {
                        "type": "string",
                        "description": "File content (optional for 'create_file' operation; defaults to empty string if omitted). Can be empty string for an intentionally empty file."
                    }
                },
                "required": ["operation", "file_path"]
            }
        }));
    }

    // Add history tool (always enabled - part of core functionality)
    tools.push(json!({
            "name": "history",
            "description": "📜 FILE HISTORY - Track all AI file operations with complete audit trail. See what changed, when, and by whom. Perfect for understanding code evolution!

💡 TIP: Track your collaborative work:
• history {operation:'get_file', file_path:'main.py'} - File's history
• history {operation:'get_project', project_path:'.'} - Project summary
• history {operation:'track', file_path:'new.rs', op:'create'} - Track changes

EXAMPLES:
✓ File history: history {operation:'get_file', file_path:'src/app.rs'}
✓ Project audit: history {operation:'get_project', project_path:'.'}",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "operation": {
                        "type": "string",
                        "enum": ["track", "get_file", "get_project"],
                        "description": "History operation"
                    },
                    "file_path": {
                        "type": "string",
                        "description": "File path"
                    },
                    "project_path": {
                        "type": "string",
                        "description": "Project path"
                    }
                },
                "required": ["operation"]
            }
        }));

    // Add context tool if enabled
    if flags.mcp_tools.enable_context {
        tools.push(json!({
            "name": "context",
            "description": "🧠 AI CONTEXT - Gather project context, check collaboration rapport, find patterns across sessions. Perfect for maintaining continuity!

💡 TIP: Build better AI collaboration:
• context {operation:'gather_project', project_path:'.'} - Full context
• context {operation:'collaboration_rapport', ai_tool:'claude'} - Our rapport!
• context {operation:'suggest_insights', keywords:['optimization']} - Get insights

EXAMPLES:
✓ Project context: context {operation:'gather_project', project_path:'.', output_format:'summary'}
✓ Check rapport: context {operation:'collaboration_rapport', ai_tool:'claude'}",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "operation": {
                        "type": "string",
                        "enum": ["gather_project", "collaboration_rapport", "engagement_heatmap",
                                 "cross_domain_patterns", "suggest_insights"],
                        "description": "Context operation"
                    },
                    "project_path": {
                        "type": "string",
                        "description": "Project path"
                    },
                    "ai_tool": {
                        "type": "string",
                        "description": "AI tool name (claude, cursor, etc)"
                    },
                    "keywords": {
                        "type": "array",
                        "items": { "type": "string" },
                        "description": "Keywords for insights"
                    }
                },
                "required": ["operation"]
            }
        }));
    }

    // Add memory tool if enabled
    if flags.mcp_tools.enable_memory {
        tools.push(json!({
            "name": "memory",
            "description": "💭 COLLABORATIVE MEMORY - Anchor important insights and breakthroughs for future retrieval. Build a shared knowledge base!

💡 TIP: Remember important moments:
• memory {operation:'anchor', keywords:['solution'], context:'We solved X by...'} 
• memory {operation:'find', keywords:['performance']} - Recall insights

EXAMPLES:
✓ Save insight: memory {operation:'anchor', anchor_type:'breakthrough', keywords:['caching','performance'], context:'Discovered Redis caching improved response by 10x'}
✓ Recall: memory {operation:'find', keywords:['optimization']}",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "operation": {
                        "type": "string",
                        "enum": ["anchor", "find"],
                        "description": "Memory operation"
                    },
                    "context": {
                        "type": "string",
                        "description": "Memory content to save"
                    },
                    "keywords": {
                        "type": "array",
                        "items": { "type": "string" },
                        "description": "Keywords for storage/retrieval"
                    },
                    "anchor_type": {
                        "type": "string",
                        "description": "Type: breakthrough, solution, pattern, joke"
                    },
                    "origin": {
                        "type": "string",
                        "description": "Who created this? 'human', 'ai:claude', or 'tandem:human:claude' (default: tandem:human:claude)"
                    }
                },
                "required": ["operation", "keywords"]
            }
        }));
    }

    // Add compare tool (always enabled - basic functionality)
    tools.push(json!({
            "name": "compare",
            "description": "🔄 DIRECTORY COMPARE - See what's different between two directories. Perfect for comparing branches, versions, or similar projects!

💡 TIP: compare {path1:'main-branch', path2:'feature-branch'}

EXAMPLE:
✓ Compare dirs: compare {path1:'./v1', path2:'./v2'}",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "path1": {
                        "type": "string",
                        "description": "First directory"
                    },
                    "path2": {
                        "type": "string",
                        "description": "Second directory"
                    }
                },
                "required": ["path1", "path2"]
            }
        }));

    // Add feedback tool (always enabled - for user experience)
    tools.push(json!({
            "name": "feedback",
            "description": "💬 FEEDBACK - Help improve Smart Tree! Submit feedback, request new tools, or check for updates.

💡 TIP: Your input shapes Smart Tree's future!
• feedback {operation:'request_tool', tool_name:'symbol_search', description:'Find symbol definitions'}
• feedback {operation:'check_updates'} - Get latest version

EXAMPLES:
✓ Request feature: feedback {operation:'request_tool', tool_name:'refactor', description:'Automated refactoring tool'}
✓ Check updates: feedback {operation:'check_updates'}",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "operation": {
                        "type": "string",
                        "enum": ["submit", "request_tool", "check_updates"],
                        "description": "Feedback operation"
                    },
                    "title": {
                        "type": "string",
                        "description": "Feedback title"
                    },
                    "description": {
                        "type": "string",
                        "description": "Detailed description"
                    }
                },
                "required": ["operation"]
            }
        }));

    // Add server_info tool (always enabled - for transparency)
    tools.push(json!({
            "name": "server_info",
            "description": "ℹ️ SERVER INFO - Get Smart Tree capabilities, performance tips, and configuration. Always check this for the latest features!

💡 TIP: server_info {} - Learn what Smart Tree can do!",
            "inputSchema": {
                "type": "object",
                "properties": {},
                "required": []
            }
        }));

    // Add verify_permissions tool (always enabled - for security)
    tools.push(json!({
            "name": "verify_permissions",
            "description": "🔐 VERIFY PERMISSIONS - Check what operations are allowed on a path. Always run this first for new directories!

💡 TIP: verify_permissions {path:'/'} - Check access rights",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "path": {
                        "type": "string",
                        "description": "Path to verify"
                    }
                },
                "required": ["path"]
            }
        }));

    // Add sse tool if enabled
    if flags.mcp_tools.enable_sse {
        tools.push(json!({
            "name": "sse",
            "description": "📡 REAL-TIME WATCH - Monitor directories for live changes via Server-Sent Events. Perfect for watching builds, logs, or active development!

💡 TIP: sse {path:'./logs', format:'ai'} - Watch logs in real-time

EXAMPLE:
✓ Watch builds: sse {path:'./dist', heartbeat_interval:30}",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "path": {
                        "type": "string",
                        "description": "Path to watch"
                    },
                    "format": {
                        "type": "string",
                        "description": "Output format",
                        "default": "ai"
                    },
                    "heartbeat_interval": {
                        "type": "integer",
                        "description": "Heartbeat interval in seconds",
                        "default": 30
                    }
                },
                "required": ["path"]
            }
        }));
    }

    // Add unified_watcher tool if enabled
    if flags.mcp_tools.enable_unified_watcher {
        tools.push(json!({
            "name": "unified_watcher",
            "description": "🌐 UNIFIED WATCHER - The all-seeing eye! Automatically watches directories for JSON/JSONL/MD files, absorbs context, and provides intelligent search. Perfect for tracking AI assistant conversations, notes, and logs!

💡 REVOLUTIONARY FEATURES:
• Watches for NEW files in real-time
• Absorbs context from Cursor AI, VS Code, Claude exports
• Smart search (only first 1000 lines of JSONL!)
• Transparent logging to ~/.st/watcher.jsonl

EXAMPLES:
✓ Start watching: unified_watcher {action:'start', project:'my-app'}
✓ Search absorbed content: unified_watcher {action:'search', query:'performance'}
✓ Check status: unified_watcher {action:'status'}
✓ Stop watching: unified_watcher {action:'stop'}

🎯 This is THE tool for automatic context awareness!",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "action": {
                        "type": "string",
                        "enum": ["start", "stop", "search", "status"],
                        "description": "Watcher action"
                    },
                    "project": {
                        "type": "string",
                        "description": "Project name to watch for"
                    },
                    "paths": {
                        "type": "array",
                        "items": {"type": "string"},
                        "description": "Paths to watch (default: Documents, config dirs, AI assistant dirs)"
                    },
                    "query": {
                        "type": "string",
                        "description": "Search query for absorbed content"
                    },
                    "enable_absorption": {
                        "type": "boolean",
                        "default": true,
                        "description": "Enable context absorption"
                    },
                    "enable_search": {
                        "type": "boolean",
                        "default": true,
                        "description": "Enable smart background search"
                    },
                    "enable_logging": {
                        "type": "boolean",
                        "default": true,
                        "description": "Enable transparent activity logging"
                    }
                },
                "required": ["action"]
            }
        }));
    }

    // Add hooks tool if enabled
    if flags.mcp_tools.enable_hooks_management {
        tools.push(json!({
            "name": "hooks",
            "description": "🎣 HOOK MANAGEMENT - Control Claude Code hooks programmatically! Manage UserPromptSubmit, PreToolUse, PostToolUse, and SessionStart hooks without manual /hooks commands.

💡 TIP: Automate your Claude Code context flow!
• hooks {operation:'list'} - See all configured hooks
• hooks {operation:'set', hook_type:'UserPromptSubmit'} - Enable Smart Tree context
• hooks {operation:'test', hook_type:'UserPromptSubmit', input:'test'} - Test a hook

EXAMPLES:
✓ Enable context hook: hooks {operation:'set', hook_type:'UserPromptSubmit', enabled:true}
✓ List all hooks: hooks {operation:'list'}
✓ Test hook: hooks {operation:'test', hook_type:'UserPromptSubmit', input:'analyze /src'}
✓ Remove hook: hooks {operation:'remove', hook_type:'PreToolUse'}",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "operation": {
                        "type": "string",
                        "enum": ["list", "set", "remove", "test", "get_commands"],
                        "description": "Hook operation to perform"
                    },
                    "hook_type": {
                        "type": "string",
                        "enum": ["UserPromptSubmit", "PreToolUse", "PostToolUse", "SessionStart"],
                        "description": "Type of Claude Code hook"
                    },
                    "enabled": {
                        "type": "boolean",
                        "description": "Enable or disable the hook",
                        "default": true
                    },
                    "command": {
                        "type": "string",
                        "description": "Custom command (default: Smart Tree with appropriate flag)"
                    },
                    "input": {
                        "type": "string",
                        "description": "Test input for testing hooks"
                    }
                },
                "required": ["operation"]
            }
        }));
    }

    // Add project context dump tool - THE POWER TOOL for AI onboarding!
    tools.push(json!({
        "name": "project_context_dump",
        "description": "📦 FULL PROJECT CONTEXT - The ULTIMATE AI onboarding tool! Get a complete, token-efficient project dump in ONE CALL instead of dozens of searches. Configurable depth, file limits, and compression.

💡 NEW AI WALKING INTO A PROJECT? This is your first tool!
• project_context_dump {path:'.'} - Complete project overview
• project_context_dump {path:'.', include_content:true} - With key file contents
• project_context_dump {path:'.', compression:'quantum'} - Maximum compression

FEATURES:
✓ Directory tree with depth limit (max_depth)
✓ Key file detection (CLAUDE.md, README, Cargo.toml, package.json, etc.)
✓ Git branch & status info
✓ Project type detection
✓ Token budget awareness
✓ Multiple compression modes (auto, marqant, summary-ai, quantum)

EXAMPLES:
✓ Quick context: project_context_dump {path:'.', max_depth:3}
✓ With contents: project_context_dump {path:'.', include_content:true, max_files:50}
✓ Key files only: project_context_dump {path:'.', key_files_only:true}
✓ Token budget: project_context_dump {path:'.', token_budget:5000}",
        "inputSchema": {
            "type": "object",
            "properties": {
                "path": {
                    "type": "string",
                    "description": "Path to the project root"
                },
                "max_depth": {
                    "type": "integer",
                    "description": "Maximum directory depth (1-20, default: 5)",
                    "default": 5
                },
                "max_files": {
                    "type": "integer",
                    "description": "Maximum files to include (10-1000, default: 100)",
                    "default": 100
                },
                "include_content": {
                    "type": "boolean",
                    "description": "Include contents of key files (default: false)",
                    "default": false
                },
                "compression": {
                    "type": "string",
                    "enum": ["auto", "marqant", "summary-ai", "quantum"],
                    "description": "Compression mode (default: auto = summary-ai)",
                    "default": "auto"
                },
                "token_budget": {
                    "type": "integer",
                    "description": "Token budget warning threshold (default: 10000)",
                    "default": 10000
                },
                "include_git": {
                    "type": "boolean",
                    "description": "Include git status info (default: true)",
                    "default": true
                },
                "key_files_only": {
                    "type": "boolean",
                    "description": "Only show key project files (default: false)",
                    "default": false
                }
            },
            "required": ["path"]
        }
    }));

    // Add smart read tool - always enabled (core functionality)
    tools.push(json!({
        "name": "read",
        "description": "📖 SMART FILE READER - AST-aware compression for code files! Reads files and automatically collapses function bodies to signatures. Perfect for understanding large files without burning tokens!

💡 TIP: Reading code files? Try these smart options:
• read {file_path:'src/main.rs'} - Auto-compress with function signatures
• read {file_path:'app.py', expand_functions:['main']} - Expand specific functions
• read {file_path:'utils.ts', expand_context:['error','auth']} - Auto-expand matching functions
• read {file_path:'README.md', compress:false} - Raw content for non-code
• read {file_path:'big.rs', hex_line_numbers:true} - Hex line nums (1000→3E8)

EXAMPLES:
✓ Quick scan: read {file_path:'src/lib.rs'} - See structure with [fn:name] refs
✓ Focus on main: read {file_path:'main.py', expand_functions:['main','__init__']}
✓ Find errors: read {file_path:'handler.rs', expand_context:['error','panic']}
✓ Full view: read {file_path:'config.rs', expand_all:true}
✓ Compact hex: read {file_path:'large.rs', hex_line_numbers:true}",
        "inputSchema": {
            "type": "object",
            "properties": {
                "file_path": {
                    "type": "string",
                    "description": "Path to the file to read"
                },
                "compress": {
                    "type": "boolean",
                    "description": "Enable AST-aware compression (collapses function bodies). Default: true for code files",
                    "default": true
                },
                "expand_functions": {
                    "type": "array",
                    "items": { "type": "string" },
                    "description": "List of function names to expand fully (e.g., ['main', 'handle_request'])"
                },
                "expand_context": {
                    "type": "array",
                    "items": { "type": "string" },
                    "description": "Keywords to auto-expand matching functions (e.g., ['error', 'auth'])"
                },
                "expand_all": {
                    "type": "boolean",
                    "description": "Expand all functions (disables compression)",
                    "default": false
                },
                "max_lines": {
                    "type": "integer",
                    "description": "Maximum lines to return (0 = unlimited)",
                    "default": 0
                },
                "offset": {
                    "type": "integer",
                    "description": "Line offset to start from (1-based)",
                    "default": 1
                },
                "show_line_numbers": {
                    "type": "boolean",
                    "description": "Show line numbers",
                    "default": true
                },
                "hex_line_numbers": {
                    "type": "boolean",
                    "description": "Use hexadecimal line numbers - MORE COMPACT! (1000→3E8, 65535→FFFF). Default: true in MCP mode for token efficiency!",
                    "default": true
                }
            },
            "required": ["file_path"]
        }
    }));

    // Add ask_user tool (always enabled - interaction functionality)
    tools.push(json!({
        "name": "ask_user",
        "description": "🗣️ Ask the human user a question and wait for their answer via the Smart Tree web dashboard. Ideal for clarifying requirements, getting explicit permission, or prompting for input without filling the chat log.",
        "inputSchema": {
            "type": "object",
            "properties": {
                "question": {
                    "type": "string",
                    "description": "The question or prompt to ask the user"
                }
            },
            "required": ["question"]
        }
    }));

    tools
}

/// Create a welcoming first-contact message for AI assistants
pub fn get_welcome_message() -> Value {
    json!({
        "message": "🌳 Welcome to Smart Tree MCP! 🌳",
        "greeting": "Hello AI friend! Smart Tree is here to make your file exploration lightning fast and token-efficient!",
        "quick_start": {
            "tip": "💡 Does your friend want comprehensive information about a project? Try these power commands:",
            "recommended_sequence": [
                {
                    "step": 1,
                    "tool": "overview",
                    "command": "overview {mode:'quick'}",
                    "description": "Get instant 3-level project overview with 10x compression"
                },
                {
                    "step": 2,
                    "tool": "find",
                    "command": "find {type:'code', languages:['all']}",
                    "description": "Locate all source code files by language"
                },
                {
                    "step": 3,
                    "tool": "search",
                    "command": "search {keyword:'TODO|FIXME', include_content:true}",
                    "description": "Find all TODOs and FIXMEs with line content"
                },
                {
                    "step": 4,
                    "tool": "analyze",
                    "command": "analyze {mode:'statistics'}",
                    "description": "Get comprehensive project statistics"
                }
            ]
        },
        "pro_tips": [
            "🚀 Always start with 'overview' for new projects - it's optimized for AI!",
            "💾 Use 'find {type:recent}' to see what changed recently",
            "🔍 'search' returns actual line content, not just file paths",
            "✨ 'edit' uses AST understanding for 90% token reduction",
            "🧠 'context' helps maintain continuity across sessions",
            "💭 'memory' lets you anchor and recall important insights"
        ],
        "efficiency": {
            "token_savings": "Smart Tree uses 10-100x compression compared to traditional tools",
            "speed": "973x faster than traditional vector stores",
            "ai_optimized": "Every format is designed specifically for AI consumption"
        },
        "collaboration": {
            "message": "Let's build something amazing together! 🎸",
            "support": "Need help? Use 'feedback {operation:request_tool}' to request features!"
        }
    })
}