hanzo-mcp 0.7.6__py3-none-any.whl → 0.8.0__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 (178) hide show
  1. hanzo_mcp/__init__.py +7 -1
  2. hanzo_mcp/__main__.py +1 -1
  3. hanzo_mcp/analytics/__init__.py +2 -2
  4. hanzo_mcp/analytics/posthog_analytics.py +76 -82
  5. hanzo_mcp/cli.py +31 -36
  6. hanzo_mcp/cli_enhanced.py +94 -72
  7. hanzo_mcp/cli_plugin.py +27 -17
  8. hanzo_mcp/config/__init__.py +2 -2
  9. hanzo_mcp/config/settings.py +112 -88
  10. hanzo_mcp/config/tool_config.py +32 -34
  11. hanzo_mcp/dev_server.py +66 -67
  12. hanzo_mcp/prompts/__init__.py +94 -12
  13. hanzo_mcp/prompts/enhanced_prompts.py +809 -0
  14. hanzo_mcp/prompts/example_custom_prompt.py +6 -5
  15. hanzo_mcp/prompts/project_todo_reminder.py +0 -1
  16. hanzo_mcp/prompts/tool_explorer.py +10 -7
  17. hanzo_mcp/server.py +17 -21
  18. hanzo_mcp/server_enhanced.py +15 -22
  19. hanzo_mcp/tools/__init__.py +56 -28
  20. hanzo_mcp/tools/agent/__init__.py +16 -19
  21. hanzo_mcp/tools/agent/agent.py +82 -65
  22. hanzo_mcp/tools/agent/agent_tool.py +152 -122
  23. hanzo_mcp/tools/agent/agent_tool_v1_deprecated.py +66 -62
  24. hanzo_mcp/tools/agent/clarification_protocol.py +55 -50
  25. hanzo_mcp/tools/agent/clarification_tool.py +11 -10
  26. hanzo_mcp/tools/agent/claude_cli_tool.py +21 -20
  27. hanzo_mcp/tools/agent/claude_desktop_auth.py +130 -144
  28. hanzo_mcp/tools/agent/cli_agent_base.py +59 -53
  29. hanzo_mcp/tools/agent/code_auth.py +102 -107
  30. hanzo_mcp/tools/agent/code_auth_tool.py +28 -27
  31. hanzo_mcp/tools/agent/codex_cli_tool.py +20 -19
  32. hanzo_mcp/tools/agent/critic_tool.py +86 -73
  33. hanzo_mcp/tools/agent/gemini_cli_tool.py +21 -20
  34. hanzo_mcp/tools/agent/grok_cli_tool.py +21 -20
  35. hanzo_mcp/tools/agent/iching_tool.py +404 -139
  36. hanzo_mcp/tools/agent/network_tool.py +89 -73
  37. hanzo_mcp/tools/agent/prompt.py +2 -1
  38. hanzo_mcp/tools/agent/review_tool.py +101 -98
  39. hanzo_mcp/tools/agent/swarm_alias.py +87 -0
  40. hanzo_mcp/tools/agent/swarm_tool.py +246 -161
  41. hanzo_mcp/tools/agent/swarm_tool_v1_deprecated.py +134 -92
  42. hanzo_mcp/tools/agent/tool_adapter.py +21 -11
  43. hanzo_mcp/tools/common/__init__.py +1 -1
  44. hanzo_mcp/tools/common/base.py +3 -5
  45. hanzo_mcp/tools/common/batch_tool.py +46 -39
  46. hanzo_mcp/tools/common/config_tool.py +120 -84
  47. hanzo_mcp/tools/common/context.py +1 -5
  48. hanzo_mcp/tools/common/context_fix.py +5 -3
  49. hanzo_mcp/tools/common/critic_tool.py +4 -8
  50. hanzo_mcp/tools/common/decorators.py +58 -56
  51. hanzo_mcp/tools/common/enhanced_base.py +29 -32
  52. hanzo_mcp/tools/common/fastmcp_pagination.py +91 -94
  53. hanzo_mcp/tools/common/forgiving_edit.py +91 -87
  54. hanzo_mcp/tools/common/mode.py +15 -17
  55. hanzo_mcp/tools/common/mode_loader.py +27 -24
  56. hanzo_mcp/tools/common/paginated_base.py +61 -53
  57. hanzo_mcp/tools/common/paginated_response.py +72 -79
  58. hanzo_mcp/tools/common/pagination.py +50 -53
  59. hanzo_mcp/tools/common/permissions.py +4 -4
  60. hanzo_mcp/tools/common/personality.py +186 -138
  61. hanzo_mcp/tools/common/plugin_loader.py +54 -54
  62. hanzo_mcp/tools/common/stats.py +65 -47
  63. hanzo_mcp/tools/common/test_helpers.py +31 -0
  64. hanzo_mcp/tools/common/thinking_tool.py +4 -8
  65. hanzo_mcp/tools/common/tool_disable.py +17 -12
  66. hanzo_mcp/tools/common/tool_enable.py +13 -14
  67. hanzo_mcp/tools/common/tool_list.py +36 -28
  68. hanzo_mcp/tools/common/truncate.py +23 -23
  69. hanzo_mcp/tools/config/__init__.py +4 -4
  70. hanzo_mcp/tools/config/config_tool.py +42 -29
  71. hanzo_mcp/tools/config/index_config.py +37 -34
  72. hanzo_mcp/tools/config/mode_tool.py +175 -55
  73. hanzo_mcp/tools/database/__init__.py +15 -12
  74. hanzo_mcp/tools/database/database_manager.py +77 -75
  75. hanzo_mcp/tools/database/graph.py +137 -91
  76. hanzo_mcp/tools/database/graph_add.py +30 -18
  77. hanzo_mcp/tools/database/graph_query.py +178 -102
  78. hanzo_mcp/tools/database/graph_remove.py +33 -28
  79. hanzo_mcp/tools/database/graph_search.py +97 -75
  80. hanzo_mcp/tools/database/graph_stats.py +91 -59
  81. hanzo_mcp/tools/database/sql.py +107 -79
  82. hanzo_mcp/tools/database/sql_query.py +30 -24
  83. hanzo_mcp/tools/database/sql_search.py +29 -25
  84. hanzo_mcp/tools/database/sql_stats.py +47 -35
  85. hanzo_mcp/tools/editor/neovim_command.py +25 -28
  86. hanzo_mcp/tools/editor/neovim_edit.py +21 -23
  87. hanzo_mcp/tools/editor/neovim_session.py +60 -54
  88. hanzo_mcp/tools/filesystem/__init__.py +31 -30
  89. hanzo_mcp/tools/filesystem/ast_multi_edit.py +329 -249
  90. hanzo_mcp/tools/filesystem/ast_tool.py +4 -4
  91. hanzo_mcp/tools/filesystem/base.py +1 -1
  92. hanzo_mcp/tools/filesystem/batch_search.py +316 -224
  93. hanzo_mcp/tools/filesystem/content_replace.py +4 -4
  94. hanzo_mcp/tools/filesystem/diff.py +71 -59
  95. hanzo_mcp/tools/filesystem/directory_tree.py +7 -7
  96. hanzo_mcp/tools/filesystem/directory_tree_paginated.py +49 -37
  97. hanzo_mcp/tools/filesystem/edit.py +4 -4
  98. hanzo_mcp/tools/filesystem/find.py +173 -80
  99. hanzo_mcp/tools/filesystem/find_files.py +73 -52
  100. hanzo_mcp/tools/filesystem/git_search.py +157 -104
  101. hanzo_mcp/tools/filesystem/grep.py +8 -8
  102. hanzo_mcp/tools/filesystem/multi_edit.py +4 -8
  103. hanzo_mcp/tools/filesystem/read.py +12 -10
  104. hanzo_mcp/tools/filesystem/rules_tool.py +59 -43
  105. hanzo_mcp/tools/filesystem/search_tool.py +263 -207
  106. hanzo_mcp/tools/filesystem/symbols_tool.py +94 -54
  107. hanzo_mcp/tools/filesystem/tree.py +35 -33
  108. hanzo_mcp/tools/filesystem/unix_aliases.py +13 -18
  109. hanzo_mcp/tools/filesystem/watch.py +37 -36
  110. hanzo_mcp/tools/filesystem/write.py +4 -8
  111. hanzo_mcp/tools/jupyter/__init__.py +4 -4
  112. hanzo_mcp/tools/jupyter/base.py +4 -5
  113. hanzo_mcp/tools/jupyter/jupyter.py +67 -47
  114. hanzo_mcp/tools/jupyter/notebook_edit.py +4 -4
  115. hanzo_mcp/tools/jupyter/notebook_read.py +4 -7
  116. hanzo_mcp/tools/llm/__init__.py +5 -7
  117. hanzo_mcp/tools/llm/consensus_tool.py +72 -52
  118. hanzo_mcp/tools/llm/llm_manage.py +101 -60
  119. hanzo_mcp/tools/llm/llm_tool.py +226 -166
  120. hanzo_mcp/tools/llm/provider_tools.py +25 -26
  121. hanzo_mcp/tools/lsp/__init__.py +1 -1
  122. hanzo_mcp/tools/lsp/lsp_tool.py +228 -143
  123. hanzo_mcp/tools/mcp/__init__.py +2 -3
  124. hanzo_mcp/tools/mcp/mcp_add.py +27 -25
  125. hanzo_mcp/tools/mcp/mcp_remove.py +7 -8
  126. hanzo_mcp/tools/mcp/mcp_stats.py +23 -22
  127. hanzo_mcp/tools/mcp/mcp_tool.py +129 -98
  128. hanzo_mcp/tools/memory/__init__.py +39 -21
  129. hanzo_mcp/tools/memory/knowledge_tools.py +124 -99
  130. hanzo_mcp/tools/memory/memory_tools.py +90 -108
  131. hanzo_mcp/tools/search/__init__.py +7 -2
  132. hanzo_mcp/tools/search/find_tool.py +297 -212
  133. hanzo_mcp/tools/search/unified_search.py +366 -314
  134. hanzo_mcp/tools/shell/__init__.py +8 -7
  135. hanzo_mcp/tools/shell/auto_background.py +56 -49
  136. hanzo_mcp/tools/shell/base.py +1 -1
  137. hanzo_mcp/tools/shell/base_process.py +75 -75
  138. hanzo_mcp/tools/shell/bash_session.py +2 -2
  139. hanzo_mcp/tools/shell/bash_session_executor.py +4 -4
  140. hanzo_mcp/tools/shell/bash_tool.py +24 -31
  141. hanzo_mcp/tools/shell/command_executor.py +12 -12
  142. hanzo_mcp/tools/shell/logs.py +43 -33
  143. hanzo_mcp/tools/shell/npx.py +13 -13
  144. hanzo_mcp/tools/shell/npx_background.py +24 -21
  145. hanzo_mcp/tools/shell/npx_tool.py +18 -22
  146. hanzo_mcp/tools/shell/open.py +19 -21
  147. hanzo_mcp/tools/shell/pkill.py +31 -26
  148. hanzo_mcp/tools/shell/process_tool.py +32 -32
  149. hanzo_mcp/tools/shell/processes.py +57 -58
  150. hanzo_mcp/tools/shell/run_background.py +24 -25
  151. hanzo_mcp/tools/shell/run_command.py +5 -5
  152. hanzo_mcp/tools/shell/run_command_windows.py +5 -5
  153. hanzo_mcp/tools/shell/session_storage.py +3 -3
  154. hanzo_mcp/tools/shell/streaming_command.py +141 -126
  155. hanzo_mcp/tools/shell/uvx.py +24 -25
  156. hanzo_mcp/tools/shell/uvx_background.py +35 -33
  157. hanzo_mcp/tools/shell/uvx_tool.py +18 -22
  158. hanzo_mcp/tools/todo/__init__.py +6 -2
  159. hanzo_mcp/tools/todo/todo.py +50 -37
  160. hanzo_mcp/tools/todo/todo_read.py +5 -8
  161. hanzo_mcp/tools/todo/todo_write.py +5 -7
  162. hanzo_mcp/tools/vector/__init__.py +40 -28
  163. hanzo_mcp/tools/vector/ast_analyzer.py +176 -143
  164. hanzo_mcp/tools/vector/git_ingester.py +170 -179
  165. hanzo_mcp/tools/vector/index_tool.py +96 -44
  166. hanzo_mcp/tools/vector/infinity_store.py +283 -228
  167. hanzo_mcp/tools/vector/mock_infinity.py +39 -40
  168. hanzo_mcp/tools/vector/project_manager.py +88 -78
  169. hanzo_mcp/tools/vector/vector.py +59 -42
  170. hanzo_mcp/tools/vector/vector_index.py +30 -27
  171. hanzo_mcp/tools/vector/vector_search.py +64 -45
  172. hanzo_mcp/types.py +6 -4
  173. {hanzo_mcp-0.7.6.dist-info → hanzo_mcp-0.8.0.dist-info}/METADATA +1 -1
  174. hanzo_mcp-0.8.0.dist-info/RECORD +185 -0
  175. hanzo_mcp-0.7.6.dist-info/RECORD +0 -182
  176. {hanzo_mcp-0.7.6.dist-info → hanzo_mcp-0.8.0.dist-info}/WHEEL +0 -0
  177. {hanzo_mcp-0.7.6.dist-info → hanzo_mcp-0.8.0.dist-info}/entry_points.txt +0 -0
  178. {hanzo_mcp-0.7.6.dist-info → hanzo_mcp-0.8.0.dist-info}/top_level.txt +0 -0
@@ -1,22 +1,19 @@
1
1
  """Background process execution tool."""
2
2
 
3
- import asyncio
4
3
  import os
5
- import subprocess
6
- import time
7
4
  import uuid
8
- from datetime import datetime
5
+ import subprocess
6
+ from typing import Unpack, Optional, Annotated, TypedDict, final, override
9
7
  from pathlib import Path
10
- from typing import Annotated, Optional, TypedDict, Unpack, final, override
8
+ from datetime import datetime
11
9
 
12
- from mcp.server.fastmcp import Context as MCPContext
13
10
  from pydantic import Field
11
+ from mcp.server.fastmcp import Context as MCPContext
14
12
 
15
13
  from hanzo_mcp.tools.common.base import BaseTool
16
14
  from hanzo_mcp.tools.common.context import create_tool_context
17
15
  from hanzo_mcp.tools.common.permissions import PermissionManager
18
16
 
19
-
20
17
  Command = Annotated[
21
18
  str,
22
19
  Field(
@@ -70,7 +67,7 @@ class RunBackgroundParams(TypedDict, total=False):
70
67
 
71
68
  class BackgroundProcess:
72
69
  """Represents a running background process."""
73
-
70
+
74
71
  def __init__(
75
72
  self,
76
73
  process_id: str,
@@ -88,34 +85,34 @@ class BackgroundProcess:
88
85
  self.process = process
89
86
  self.start_time = datetime.now()
90
87
  self.end_time: Optional[datetime] = None
91
-
88
+
92
89
  @property
93
90
  def is_running(self) -> bool:
94
91
  """Check if process is still running."""
95
92
  return self.process.poll() is None
96
-
93
+
97
94
  @property
98
95
  def pid(self) -> int:
99
96
  """Get process ID."""
100
97
  return self.process.pid
101
-
98
+
102
99
  @property
103
100
  def return_code(self) -> Optional[int]:
104
101
  """Get return code if process has finished."""
105
102
  return self.process.poll()
106
-
103
+
107
104
  def terminate(self) -> None:
108
105
  """Terminate the process."""
109
106
  if self.is_running:
110
107
  self.process.terminate()
111
108
  self.end_time = datetime.now()
112
-
109
+
113
110
  def kill(self) -> None:
114
111
  """Kill the process forcefully."""
115
112
  if self.is_running:
116
113
  self.process.kill()
117
114
  self.end_time = datetime.now()
118
-
115
+
119
116
  def to_dict(self) -> dict:
120
117
  """Convert to dictionary for display."""
121
118
  return {
@@ -135,10 +132,10 @@ class BackgroundProcess:
135
132
  @final
136
133
  class RunBackgroundTool(BaseTool):
137
134
  """Tool for running commands in the background."""
138
-
135
+
139
136
  # Class variable to store running processes
140
137
  _processes: dict[str, BackgroundProcess] = {}
141
-
138
+
142
139
  def __init__(self, permission_manager: PermissionManager):
143
140
  """Initialize the background runner tool.
144
141
 
@@ -213,7 +210,7 @@ Examples:
213
210
 
214
211
  # Resolve absolute path for working directory
215
212
  abs_working_dir = os.path.abspath(working_dir)
216
-
213
+
217
214
  # Check permissions
218
215
  if not self.permission_manager.has_permission(abs_working_dir):
219
216
  return f"Permission denied: {abs_working_dir}"
@@ -224,7 +221,7 @@ Examples:
224
221
 
225
222
  # Generate process ID
226
223
  process_id = str(uuid.uuid4())[:8]
227
-
224
+
228
225
  # Setup logging
229
226
  log_file = None
230
227
  if log_to_file:
@@ -241,7 +238,7 @@ Examples:
241
238
 
242
239
  # Open log file for writing
243
240
  if log_file:
244
- log_handle = open(log_file, 'w')
241
+ log_handle = open(log_file, "w")
245
242
  stdout = log_handle
246
243
  stderr = subprocess.STDOUT
247
244
  else:
@@ -272,11 +269,13 @@ Examples:
272
269
 
273
270
  # Store in class variable
274
271
  RunBackgroundTool._processes[process_id] = bg_process
275
-
272
+
276
273
  # Clean up finished processes
277
274
  self._cleanup_finished_processes()
278
275
 
279
- await tool_ctx.info(f"Process started with ID: {process_id}, PID: {process.pid}")
276
+ await tool_ctx.info(
277
+ f"Process started with ID: {process_id}, PID: {process.pid}"
278
+ )
280
279
 
281
280
  # Return process information
282
281
  return f"""Background process started successfully!
@@ -286,7 +285,7 @@ Name: {name}
286
285
  PID: {process.pid}
287
286
  Command: {command}
288
287
  Working Directory: {abs_working_dir}
289
- Log File: {log_file if log_file else 'Not logging'}
288
+ Log File: {log_file if log_file else "Not logging"}
290
289
 
291
290
  Use 'processes' to list all running processes
292
291
  Use 'pkill --id {process_id}' to stop this process
@@ -311,16 +310,16 @@ Use 'logs --id {process_id}' to view output (if logging enabled)
311
310
  """Remove finished processes that have been terminated for a while."""
312
311
  now = datetime.now()
313
312
  to_remove = []
314
-
313
+
315
314
  for process_id, process in RunBackgroundTool._processes.items():
316
315
  if not process.is_running and process.end_time:
317
316
  # Keep finished processes for 5 minutes for log access
318
317
  if (now - process.end_time).total_seconds() > 300:
319
318
  to_remove.append(process_id)
320
-
319
+
321
320
  for process_id in to_remove:
322
321
  del RunBackgroundTool._processes[process_id]
323
322
 
324
323
  def register(self, mcp_server) -> None:
325
324
  """Register this tool with the MCP server."""
326
- pass
325
+ pass
@@ -3,15 +3,15 @@
3
3
  This module provides the RunCommandTool for running shell commands.
4
4
  """
5
5
 
6
- from typing import Annotated, Any, TypedDict, Unpack, final, override
6
+ from typing import Any, Unpack, Annotated, TypedDict, final, override
7
7
 
8
- from mcp.server.fastmcp import Context as MCPContext
9
- from mcp.server import FastMCP
10
8
  from pydantic import Field
9
+ from mcp.server import FastMCP
10
+ from mcp.server.fastmcp import Context as MCPContext
11
11
 
12
+ from hanzo_mcp.tools.shell.base import ShellBaseTool
12
13
  from hanzo_mcp.tools.common.base import handle_connection_errors
13
14
  from hanzo_mcp.tools.common.context import create_tool_context
14
- from hanzo_mcp.tools.shell.base import ShellBaseTool
15
15
  from hanzo_mcp.tools.shell.bash_session_executor import BashSessionExecutor
16
16
 
17
17
  Command = Annotated[
@@ -344,7 +344,7 @@ Important:
344
344
  time_out: TimeOut,
345
345
  is_input: IsInput,
346
346
  blocking: Blocking,
347
- ctx: MCPContext
347
+ ctx: MCPContext,
348
348
  ) -> str:
349
349
  return await tool_self.call(
350
350
  ctx,
@@ -4,15 +4,15 @@ This module provides the RunCommandTool for running shell commands on Windows.
4
4
  """
5
5
 
6
6
  import os
7
- from typing import Annotated, Any, final, override
7
+ from typing import Any, Annotated, final, override
8
8
 
9
- from mcp.server.fastmcp import Context as MCPContext
10
- from mcp.server import FastMCP
11
9
  from pydantic import Field
10
+ from mcp.server import FastMCP
11
+ from mcp.server.fastmcp import Context as MCPContext
12
12
 
13
+ from hanzo_mcp.tools.shell.base import ShellBaseTool
13
14
  from hanzo_mcp.tools.common.base import handle_connection_errors
14
15
  from hanzo_mcp.tools.common.context import create_tool_context
15
- from hanzo_mcp.tools.shell.base import ShellBaseTool
16
16
  from hanzo_mcp.tools.shell.command_executor import CommandExecutor
17
17
 
18
18
 
@@ -288,6 +288,7 @@ Important:
288
288
  @mcp_server.tool(name=self.name, description=self.description)
289
289
  @handle_connection_errors
290
290
  async def run_command(
291
+ ctx: MCPContext,
291
292
  command: Annotated[
292
293
  str,
293
294
  Field(
@@ -316,7 +317,6 @@ Important:
316
317
  default=True,
317
318
  ),
318
319
  ] = True,
319
- ctx: MCPContext
320
320
  ) -> str:
321
321
  return await tool_self.call(
322
322
  ctx,
@@ -201,9 +201,9 @@ class SessionStorageInstance:
201
201
  return {
202
202
  "total_sessions": len(self._sessions),
203
203
  "max_sessions": self.max_sessions,
204
- "utilization": len(self._sessions) / self.max_sessions
205
- if self.max_sessions > 0
206
- else 0,
204
+ "utilization": (
205
+ len(self._sessions) / self.max_sessions if self.max_sessions > 0 else 0
206
+ ),
207
207
  "default_ttl_seconds": self.default_ttl_seconds,
208
208
  }
209
209