hanzo-mcp 0.7.3__py3-none-any.whl → 0.7.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of hanzo-mcp might be problematic. Click here for more details.

Files changed (36) hide show
  1. hanzo_mcp/__init__.py +1 -1
  2. hanzo_mcp/cli.py +10 -0
  3. hanzo_mcp/prompts/__init__.py +43 -0
  4. hanzo_mcp/prompts/example_custom_prompt.py +40 -0
  5. hanzo_mcp/prompts/tool_explorer.py +603 -0
  6. hanzo_mcp/tools/__init__.py +52 -51
  7. hanzo_mcp/tools/agent/__init__.py +3 -16
  8. hanzo_mcp/tools/agent/agent_tool.py +365 -525
  9. hanzo_mcp/tools/agent/agent_tool_v1_deprecated.py +641 -0
  10. hanzo_mcp/tools/agent/network_tool.py +3 -5
  11. hanzo_mcp/tools/agent/swarm_tool.py +447 -349
  12. hanzo_mcp/tools/agent/swarm_tool_v1_deprecated.py +535 -0
  13. hanzo_mcp/tools/agent/tool_adapter.py +21 -2
  14. hanzo_mcp/tools/common/forgiving_edit.py +24 -14
  15. hanzo_mcp/tools/common/permissions.py +8 -0
  16. hanzo_mcp/tools/filesystem/__init__.py +5 -5
  17. hanzo_mcp/tools/filesystem/{symbols.py → ast_tool.py} +8 -8
  18. hanzo_mcp/tools/filesystem/batch_search.py +2 -2
  19. hanzo_mcp/tools/filesystem/directory_tree.py +8 -1
  20. hanzo_mcp/tools/filesystem/find.py +1 -0
  21. hanzo_mcp/tools/filesystem/grep.py +11 -2
  22. hanzo_mcp/tools/filesystem/read.py +8 -1
  23. hanzo_mcp/tools/filesystem/search_tool.py +1 -1
  24. hanzo_mcp/tools/jupyter/__init__.py +5 -1
  25. hanzo_mcp/tools/jupyter/base.py +2 -2
  26. hanzo_mcp/tools/jupyter/jupyter.py +89 -18
  27. hanzo_mcp/tools/search/find_tool.py +49 -8
  28. hanzo_mcp/tools/shell/base_process.py +7 -1
  29. hanzo_mcp/tools/shell/streaming_command.py +34 -1
  30. {hanzo_mcp-0.7.3.dist-info → hanzo_mcp-0.7.7.dist-info}/METADATA +7 -1
  31. {hanzo_mcp-0.7.3.dist-info → hanzo_mcp-0.7.7.dist-info}/RECORD +34 -32
  32. hanzo_mcp/tools/agent/agent_tool_v2.py +0 -492
  33. hanzo_mcp/tools/agent/swarm_tool_v2.py +0 -654
  34. {hanzo_mcp-0.7.3.dist-info → hanzo_mcp-0.7.7.dist-info}/WHEEL +0 -0
  35. {hanzo_mcp-0.7.3.dist-info → hanzo_mcp-0.7.7.dist-info}/entry_points.txt +0 -0
  36. {hanzo_mcp-0.7.3.dist-info → hanzo_mcp-0.7.7.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,603 @@
1
+ """Tool explorer prompts for discovering and using Hanzo MCP tools."""
2
+
3
+ TOOL_EXPLORER_PROMPT = """# Hanzo MCP Tool Explorer
4
+
5
+ You have access to a comprehensive suite of tools through the Hanzo MCP system. These tools can be used individually or combined using the batch tool for powerful multi-agent workflows.
6
+
7
+ ## Tool Categories
8
+
9
+ ### 🤖 Agent Tools
10
+ Tools for delegating tasks to specialized AI agents:
11
+ - **dispatch_agent**: Launch a specialized agent for file exploration and analysis
12
+ - **swarm**: Orchestrate multiple agents working together
13
+ - **claude_cli**: Interact with Claude via CLI
14
+ - **critic**: Critical analysis and review
15
+ - **review**: Code review and feedback
16
+ - **iching**: Decision-making guidance using I Ching
17
+
18
+ ### 📁 Filesystem Tools
19
+ Tools for file and directory operations:
20
+ - **read_files**: Read one or multiple files
21
+ - **write_file**: Create or overwrite files
22
+ - **edit_file**: Make precise edits to files
23
+ - **multi_edit**: Multiple edits in one operation
24
+ - **directory_tree**: View directory structure
25
+ - **find**: Find files by pattern
26
+ - **grep**: Search file contents
27
+ - **grep_ast**: Search with AST context
28
+ - **search_content**: Unified search across multiple methods
29
+ - **symbols**: Find code symbols
30
+ - **content_replace**: Replace patterns across files
31
+ - **batch_search**: Run multiple searches in parallel
32
+
33
+ ### 🐚 Shell Tools
34
+ Tools for command execution:
35
+ - **run_command**: Execute shell commands
36
+ - **bash**: Run bash commands with session persistence
37
+ - **npx**: Run Node packages
38
+ - **uvx**: Run Python packages
39
+ - **process**: Manage background processes
40
+ - **open**: Open files/URLs in default app
41
+
42
+ ### 🧠 AI/LLM Tools
43
+ Tools for AI operations:
44
+ - **llm**: Query various LLM providers
45
+ - **consensus**: Get consensus from multiple models
46
+ - **think**: Structured thinking and planning
47
+ - **critic**: Critical analysis
48
+
49
+ ### 💾 Database Tools
50
+ Tools for data operations:
51
+ - **sql_query**: Execute SQL queries
52
+ - **graph_add**: Add to graph database
53
+ - **vector_search**: Semantic search
54
+ - **index**: Manage search indices
55
+
56
+ ### 📓 Jupyter Tools
57
+ Tools for notebook operations:
58
+ - **notebook_read**: Read Jupyter notebooks
59
+ - **notebook_edit**: Edit notebook cells
60
+
61
+ ### ✅ Todo Tools
62
+ Tools for task management:
63
+ - **todo**: Manage todo lists
64
+ - **todo_read**: Read current todos
65
+ - **todo_write**: Update todo items
66
+
67
+ ### 🔧 Configuration Tools
68
+ Tools for settings and configuration:
69
+ - **config**: Manage tool configuration
70
+ - **mode**: Switch developer modes
71
+ - **tool_list**: List available tools
72
+ - **tool_enable/disable**: Toggle tools
73
+
74
+ ### 🔍 LSP Tools
75
+ Language Server Protocol tools:
76
+ - **lsp**: Code intelligence operations
77
+
78
+ ### 🌐 MCP Tools
79
+ Model Context Protocol management:
80
+ - **mcp_add**: Add MCP servers
81
+ - **mcp_remove**: Remove MCP servers
82
+ - **mcp_stats**: View MCP statistics
83
+
84
+ ## Using Tools with Batch
85
+
86
+ The batch tool allows you to run multiple tools in parallel for maximum efficiency:
87
+
88
+ ```python
89
+ batch(
90
+ description="Analyze project structure",
91
+ invocations=[
92
+ {"tool_name": "directory_tree", "input": {"path": "/project"}},
93
+ {"tool_name": "grep", "input": {"pattern": "TODO", "path": "/project"}},
94
+ {"tool_name": "find", "input": {"pattern": "*.test.js", "path": "/project"}}
95
+ ]
96
+ )
97
+ ```
98
+
99
+ ## Tool Usage Examples
100
+
101
+ ### Example 1: Code Analysis Workflow
102
+ ```python
103
+ # First, explore the project structure
104
+ directory_tree(path="/project", depth=3)
105
+
106
+ # Search for specific patterns
107
+ batch(
108
+ description="Find all API endpoints",
109
+ invocations=[
110
+ {"tool_name": "grep", "input": {"pattern": "app\\.(get|post|put|delete)", "path": "/project/src"}},
111
+ {"tool_name": "grep_ast", "input": {"pattern": "router", "path": "/project/src"}}
112
+ ]
113
+ )
114
+ ```
115
+
116
+ ### Example 2: Multi-Agent Analysis
117
+ ```python
118
+ # Dispatch specialized agents for different tasks
119
+ batch(
120
+ description="Comprehensive code analysis",
121
+ invocations=[
122
+ {"tool_name": "dispatch_agent", "input": {"prompt": "Analyze security vulnerabilities in /project/src"}},
123
+ {"tool_name": "dispatch_agent", "input": {"prompt": "Find performance bottlenecks in database queries"}},
124
+ {"tool_name": "dispatch_agent", "input": {"prompt": "Review test coverage and suggest improvements"}}
125
+ ]
126
+ )
127
+ ```
128
+
129
+ ### Example 3: Refactoring Workflow
130
+ ```python
131
+ # Find all instances of a pattern
132
+ search_content(pattern="oldFunction", path="/project")
133
+
134
+ # Review the code
135
+ critic(analysis="Review the usage of oldFunction and suggest refactoring approach")
136
+
137
+ # Make the changes
138
+ batch(
139
+ description="Refactor oldFunction to newFunction",
140
+ invocations=[
141
+ {"tool_name": "content_replace", "input": {
142
+ "pattern": "oldFunction",
143
+ "replacement": "newFunction",
144
+ "path": "/project/src"
145
+ }},
146
+ {"tool_name": "run_command", "input": {"command": "npm test"}}
147
+ ]
148
+ )
149
+ ```
150
+
151
+ ## Best Practices
152
+
153
+ 1. **Use batch for parallel operations**: When you need to run multiple independent operations, use batch to run them concurrently.
154
+
155
+ 2. **Combine search tools**: Use unified_search for comprehensive results, grep for simple text matching, and grep_ast for code structure understanding.
156
+
157
+ 3. **Leverage agents for complex tasks**: Use dispatch_agent for tasks requiring deep analysis or multiple steps.
158
+
159
+ 4. **Track progress with todos**: Use todo tools to manage multi-step workflows.
160
+
161
+ 5. **Think before acting**: Use the think tool to plan complex operations.
162
+
163
+ ## Getting Started
164
+
165
+ To explore available tools in detail:
166
+ 1. Use `tool_list()` to see all available tools
167
+ 2. Each tool has detailed documentation in its implementation
168
+ 3. Tools can be combined creatively for powerful workflows
169
+
170
+ Would you like to explore any specific tool category or see more examples?"""
171
+
172
+ # Tool category specific prompts
173
+ FILESYSTEM_TOOLS_HELP = """# Filesystem Tools Guide
174
+
175
+ ## Core File Operations
176
+
177
+ ### Reading Files
178
+ ```python
179
+ # Read a single file
180
+ read_files(paths=["/path/to/file.py"])
181
+
182
+ # Read multiple files at once
183
+ read_files(paths=[
184
+ "/project/src/main.py",
185
+ "/project/src/utils.py",
186
+ "/project/tests/test_main.py"
187
+ ])
188
+
189
+ # Read with line limits
190
+ read_files(paths=["/large/file.py"], lines=100, offset=500)
191
+ ```
192
+
193
+ ### Editing Files
194
+ ```python
195
+ # Simple edit
196
+ edit_file(
197
+ path="/src/main.py",
198
+ edits=[{"oldText": "old code", "newText": "new code"}]
199
+ )
200
+
201
+ # Multiple edits in one file
202
+ multi_edit(
203
+ file_path="/src/utils.py",
204
+ edits=[
205
+ {"old_string": "import old", "new_string": "import new"},
206
+ {"old_string": "old_function", "new_string": "new_function"}
207
+ ]
208
+ )
209
+ ```
210
+
211
+ ### Searching
212
+ ```python
213
+ # Find files by pattern
214
+ find(pattern="*.test.js", path="/project")
215
+
216
+ # Search file contents
217
+ grep(pattern="TODO|FIXME", path="/project", include="*.py")
218
+
219
+ # Search with AST context
220
+ grep_ast(pattern="class.*Controller", path="/project/src")
221
+
222
+ # Unified search (combines multiple search methods)
223
+ search_content(
224
+ pattern="authentication",
225
+ path="/project",
226
+ enable_vector=True,
227
+ enable_ast=True
228
+ )
229
+ ```
230
+
231
+ ### Batch Operations
232
+ ```python
233
+ # Search across multiple patterns simultaneously
234
+ batch_search(
235
+ queries=[
236
+ {"pattern": "login", "type": "text"},
237
+ {"pattern": "authenticate", "type": "semantic"},
238
+ {"pattern": "class.*Auth", "type": "ast"}
239
+ ],
240
+ path="/project"
241
+ )
242
+ ```
243
+
244
+ ## Advanced Features
245
+
246
+ ### Content Replacement
247
+ ```python
248
+ # Replace across multiple files
249
+ content_replace(
250
+ pattern="oldAPI",
251
+ replacement="newAPI",
252
+ path="/project/src",
253
+ dry_run=True # Preview changes first
254
+ )
255
+ ```
256
+
257
+ ### Directory Exploration
258
+ ```python
259
+ # View directory structure
260
+ directory_tree(path="/project", depth=3, include_filtered=False)
261
+
262
+ # Find specific file types
263
+ find(
264
+ pattern="*.py",
265
+ path="/project",
266
+ min_size="1KB",
267
+ max_size="100KB",
268
+ modified_after="1 week ago"
269
+ )
270
+ ```"""
271
+
272
+ AGENT_TOOLS_HELP = """# Agent Tools Guide
273
+
274
+ ## Dispatching Agents
275
+
276
+ The agent tools allow you to delegate complex tasks to specialized sub-agents that have access to file operations and search capabilities.
277
+
278
+ ### Basic Agent Dispatch
279
+ ```python
280
+ # Dispatch a single agent for analysis
281
+ dispatch_agent(
282
+ prompt="Analyze the authentication system in /project/src/auth and identify security vulnerabilities"
283
+ )
284
+
285
+ # Multiple agents for different aspects
286
+ batch(
287
+ description="Comprehensive security audit",
288
+ invocations=[
289
+ {"tool_name": "dispatch_agent", "input": {
290
+ "prompt": "Review authentication implementation for security issues"
291
+ }},
292
+ {"tool_name": "dispatch_agent", "input": {
293
+ "prompt": "Check for SQL injection vulnerabilities in database queries"
294
+ }},
295
+ {"tool_name": "dispatch_agent", "input": {
296
+ "prompt": "Analyze API endpoints for authorization bypass risks"
297
+ }}
298
+ ]
299
+ )
300
+ ```
301
+
302
+ ### Swarm Operations
303
+ ```python
304
+ # Create a swarm of agents working together
305
+ swarm(
306
+ agents=[
307
+ {
308
+ "id": "analyzer",
309
+ "role": "Code Analyzer",
310
+ "goal": "Identify code quality issues",
311
+ "backstory": "Expert in clean code principles",
312
+ "tools": ["grep_ast", "read_files", "symbols"]
313
+ },
314
+ {
315
+ "id": "refactorer",
316
+ "role": "Code Refactorer",
317
+ "goal": "Suggest and implement improvements",
318
+ "backstory": "Specialist in code optimization",
319
+ "tools": ["edit_file", "multi_edit", "content_replace"]
320
+ }
321
+ ],
322
+ tasks=[
323
+ {
324
+ "description": "Find code smells and anti-patterns",
325
+ "assigned_to": "analyzer"
326
+ },
327
+ {
328
+ "description": "Refactor identified issues",
329
+ "assigned_to": "refactorer",
330
+ "depends_on": ["analyzer"]
331
+ }
332
+ ]
333
+ )
334
+ ```
335
+
336
+ ### Specialized Agents
337
+
338
+ #### Critic Agent
339
+ ```python
340
+ # Get critical analysis
341
+ critic(
342
+ analysis="Review this implementation for potential issues:\\n" + code_snippet
343
+ )
344
+ ```
345
+
346
+ #### Review Agent
347
+ ```python
348
+ # Comprehensive code review
349
+ review(
350
+ files=["/src/main.py", "/src/utils.py"],
351
+ focus_areas=["security", "performance", "maintainability"]
352
+ )
353
+ ```
354
+
355
+ #### I Ching Guidance
356
+ ```python
357
+ # Get decision-making guidance
358
+ iching(
359
+ question="Should we refactor the authentication system now or after the release?"
360
+ )
361
+ ```
362
+
363
+ ## Agent Capabilities
364
+
365
+ Agents dispatched through these tools have access to:
366
+ - File reading and searching
367
+ - Pattern matching and AST analysis
368
+ - Directory exploration
369
+ - Comprehensive search capabilities
370
+
371
+ They cannot:
372
+ - Modify files directly
373
+ - Execute shell commands
374
+ - Make external API calls
375
+
376
+ This makes them safe for exploration and analysis tasks."""
377
+
378
+ SHELL_TOOLS_HELP = """# Shell Tools Guide
379
+
380
+ ## Command Execution
381
+
382
+ ### Basic Commands
383
+ ```python
384
+ # Run simple commands
385
+ run_command(command="ls -la", cwd="/project")
386
+ run_command(command="git status")
387
+
388
+ # Run with environment variables
389
+ run_command(
390
+ command="npm test",
391
+ env={"NODE_ENV": "test", "CI": "true"}
392
+ )
393
+ ```
394
+
395
+ ### Bash Sessions
396
+ ```python
397
+ # Use bash for session persistence
398
+ bash(command="cd /project && npm install")
399
+ bash(command="export API_KEY=test123 && npm run dev")
400
+ ```
401
+
402
+ ### Package Runners
403
+ ```python
404
+ # Run Node packages
405
+ npx(package="prettier", args="--write src/**/*.js")
406
+ npx(package="create-react-app", args="my-app")
407
+
408
+ # Run Python packages
409
+ uvx(package="ruff", args="check .")
410
+ uvx(package="black", args="--check src/")
411
+ ```
412
+
413
+ ### Background Processes
414
+ ```python
415
+ # Start long-running processes
416
+ run_command(command="npm run dev", background=True)
417
+
418
+ # Manage processes
419
+ process(action="list") # List all background processes
420
+ process(action="logs", id="npm_abc123") # View logs
421
+ process(action="kill", id="npm_abc123") # Stop process
422
+ ```
423
+
424
+ ## Advanced Usage
425
+
426
+ ### Batch Operations
427
+ ```python
428
+ # Run multiple commands efficiently
429
+ batch(
430
+ description="Run tests and linting",
431
+ invocations=[
432
+ {"tool_name": "run_command", "input": {"command": "npm test"}},
433
+ {"tool_name": "run_command", "input": {"command": "npm run lint"}},
434
+ {"tool_name": "run_command", "input": {"command": "npm audit"}}
435
+ ]
436
+ )
437
+ ```
438
+
439
+ ### Working with Output
440
+ ```python
441
+ # Capture and process output
442
+ result = run_command(command="git log --oneline -10")
443
+ # Process result.output for analysis
444
+ ```
445
+
446
+ ### Platform-Specific Commands
447
+ ```python
448
+ # Open files/URLs in default application
449
+ open(path="https://github.com/user/repo")
450
+ open(path="/path/to/document.pdf")
451
+ ```"""
452
+
453
+ BATCH_TOOL_EXAMPLES = """# Batch Tool Mastery
454
+
455
+ The batch tool is one of the most powerful features in Hanzo MCP, allowing parallel execution of multiple tools for maximum efficiency.
456
+
457
+ ## Basic Batch Usage
458
+
459
+ ```python
460
+ batch(
461
+ description="Project setup",
462
+ invocations=[
463
+ {"tool_name": "run_command", "input": {"command": "npm install"}},
464
+ {"tool_name": "run_command", "input": {"command": "pip install -r requirements.txt"}},
465
+ {"tool_name": "directory_tree", "input": {"path": ".", "depth": 2}}
466
+ ]
467
+ )
468
+ ```
469
+
470
+ ## Advanced Patterns
471
+
472
+ ### 1. Parallel Search Operations
473
+ ```python
474
+ batch(
475
+ description="Find all authentication code",
476
+ invocations=[
477
+ {"tool_name": "grep", "input": {
478
+ "pattern": "login|auth|session",
479
+ "path": "/src"
480
+ }},
481
+ {"tool_name": "grep_ast", "input": {
482
+ "pattern": "class.*Auth",
483
+ "path": "/src"
484
+ }},
485
+ {"tool_name": "find", "input": {
486
+ "pattern": "*auth*.py",
487
+ "path": "/src"
488
+ }}
489
+ ]
490
+ )
491
+ ```
492
+
493
+ ### 2. Multi-Agent Analysis
494
+ ```python
495
+ batch(
496
+ description="Comprehensive code analysis",
497
+ invocations=[
498
+ {"tool_name": "dispatch_agent", "input": {
499
+ "prompt": "Analyze code quality in /src/core modules"
500
+ }},
501
+ {"tool_name": "dispatch_agent", "input": {
502
+ "prompt": "Review test coverage for /src/core modules"
503
+ }},
504
+ {"tool_name": "dispatch_agent", "input": {
505
+ "prompt": "Identify performance bottlenecks in database operations"
506
+ }}
507
+ ]
508
+ )
509
+ ```
510
+
511
+ ### 3. File Operations
512
+ ```python
513
+ batch(
514
+ description="Read configuration files",
515
+ invocations=[
516
+ {"tool_name": "read_files", "input": {
517
+ "paths": ["package.json", "tsconfig.json", ".env.example"]
518
+ }},
519
+ {"tool_name": "read_files", "input": {
520
+ "paths": ["src/config/database.js", "src/config/auth.js"]
521
+ }}
522
+ ]
523
+ )
524
+ ```
525
+
526
+ ### 4. Complex Workflows
527
+ ```python
528
+ # Step 1: Analyze
529
+ analysis_batch = batch(
530
+ description="Analyze codebase",
531
+ invocations=[
532
+ {"tool_name": "grep", "input": {"pattern": "TODO|FIXME", "path": "."}},
533
+ {"tool_name": "dispatch_agent", "input": {
534
+ "prompt": "Find unused imports and dead code"
535
+ }}
536
+ ]
537
+ )
538
+
539
+ # Step 2: Based on analysis, perform fixes
540
+ fix_batch = batch(
541
+ description="Fix identified issues",
542
+ invocations=[
543
+ {"tool_name": "content_replace", "input": {
544
+ "pattern": "old_import",
545
+ "replacement": "new_import",
546
+ "path": "/src"
547
+ }},
548
+ {"tool_name": "run_command", "input": {"command": "npm run lint:fix"}}
549
+ ]
550
+ )
551
+ ```
552
+
553
+ ## Batch Tool Best Practices
554
+
555
+ 1. **Group Related Operations**: Batch operations that are logically related
556
+ 2. **Maximize Parallelism**: Independent operations should be in the same batch
557
+ 3. **Use Descriptive Names**: The description helps track what the batch does
558
+ 4. **Handle Results**: Each tool result is returned in order
559
+
560
+ ## Limitations
561
+
562
+ - Tools in a batch cannot depend on each other's results
563
+ - All tools run in parallel when possible
564
+ - Maximum efficiency with truly independent operations
565
+
566
+ ## Available Tools for Batch
567
+
568
+ The following tools can be used in batch operations:
569
+ - dispatch_agent
570
+ - read_files
571
+ - directory_tree
572
+ - grep
573
+ - grep_ast
574
+ - run_command
575
+ - notebook_read
576
+ - find
577
+ - search_content
578
+ - symbols
579
+ - git_search
580
+
581
+ Tools NOT available in batch (require state/session):
582
+ - write_file
583
+ - edit_file
584
+ - multi_edit
585
+ - think
586
+ - todo_write"""
587
+
588
+ def create_tool_category_prompt(category: str, tools: list[str]):
589
+ """Create a dynamic prompt for a specific tool category."""
590
+
591
+ tool_descriptions = {
592
+ "filesystem": FILESYSTEM_TOOLS_HELP,
593
+ "agent": AGENT_TOOLS_HELP,
594
+ "shell": SHELL_TOOLS_HELP,
595
+ "batch": BATCH_TOOL_EXAMPLES
596
+ }
597
+
598
+ base_prompt = tool_descriptions.get(category, f"# {category.title()} Tools\n\nAvailable tools in this category:\n")
599
+
600
+ if category not in tool_descriptions:
601
+ base_prompt += "\n".join(f"- **{tool}**: [Tool description]" for tool in tools)
602
+
603
+ return base_prompt