hanzo-mcp 0.7.3__py3-none-any.whl → 0.7.6__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.
- hanzo_mcp/cli.py +10 -0
- hanzo_mcp/prompts/__init__.py +43 -0
- hanzo_mcp/prompts/example_custom_prompt.py +40 -0
- hanzo_mcp/prompts/tool_explorer.py +603 -0
- hanzo_mcp/tools/__init__.py +52 -51
- hanzo_mcp/tools/agent/__init__.py +3 -16
- hanzo_mcp/tools/agent/agent_tool.py +365 -525
- hanzo_mcp/tools/agent/agent_tool_v1_deprecated.py +641 -0
- hanzo_mcp/tools/agent/network_tool.py +3 -5
- hanzo_mcp/tools/agent/swarm_tool.py +447 -349
- hanzo_mcp/tools/agent/swarm_tool_v1_deprecated.py +535 -0
- hanzo_mcp/tools/agent/tool_adapter.py +21 -2
- hanzo_mcp/tools/common/forgiving_edit.py +24 -14
- hanzo_mcp/tools/common/permissions.py +8 -0
- hanzo_mcp/tools/filesystem/__init__.py +5 -5
- hanzo_mcp/tools/filesystem/{symbols.py → ast_tool.py} +8 -8
- hanzo_mcp/tools/filesystem/batch_search.py +2 -2
- hanzo_mcp/tools/filesystem/directory_tree.py +8 -1
- hanzo_mcp/tools/filesystem/find.py +1 -0
- hanzo_mcp/tools/filesystem/grep.py +11 -2
- hanzo_mcp/tools/filesystem/read.py +8 -1
- hanzo_mcp/tools/filesystem/search_tool.py +1 -1
- hanzo_mcp/tools/jupyter/__init__.py +5 -1
- hanzo_mcp/tools/jupyter/base.py +2 -2
- hanzo_mcp/tools/jupyter/jupyter.py +89 -18
- hanzo_mcp/tools/search/find_tool.py +49 -8
- hanzo_mcp/tools/shell/base_process.py +7 -1
- hanzo_mcp/tools/shell/streaming_command.py +34 -1
- {hanzo_mcp-0.7.3.dist-info → hanzo_mcp-0.7.6.dist-info}/METADATA +7 -1
- {hanzo_mcp-0.7.3.dist-info → hanzo_mcp-0.7.6.dist-info}/RECORD +33 -31
- hanzo_mcp/tools/agent/agent_tool_v2.py +0 -492
- hanzo_mcp/tools/agent/swarm_tool_v2.py +0 -654
- {hanzo_mcp-0.7.3.dist-info → hanzo_mcp-0.7.6.dist-info}/WHEEL +0 -0
- {hanzo_mcp-0.7.3.dist-info → hanzo_mcp-0.7.6.dist-info}/entry_points.txt +0 -0
- {hanzo_mcp-0.7.3.dist-info → hanzo_mcp-0.7.6.dist-info}/top_level.txt +0 -0
hanzo_mcp/tools/__init__.py
CHANGED
|
@@ -65,7 +65,7 @@ def register_all_tools(
|
|
|
65
65
|
vector_config: dict | None = None,
|
|
66
66
|
use_mode: bool = True,
|
|
67
67
|
force_mode: str | None = None,
|
|
68
|
-
) ->
|
|
68
|
+
) -> list[BaseTool]:
|
|
69
69
|
"""Register all Hanzo tools with the MCP server.
|
|
70
70
|
|
|
71
71
|
Args:
|
|
@@ -84,10 +84,13 @@ def register_all_tools(
|
|
|
84
84
|
vector_config: Vector store configuration (default: None)
|
|
85
85
|
use_mode: Whether to use mode system for tool configuration (default: True)
|
|
86
86
|
force_mode: Force a specific mode to be active (default: None)
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
List of registered BaseTool instances
|
|
87
90
|
"""
|
|
88
91
|
# Dictionary to store all registered tools
|
|
89
92
|
all_tools: dict[str, BaseTool] = {}
|
|
90
|
-
|
|
93
|
+
|
|
91
94
|
# Load user plugins early
|
|
92
95
|
try:
|
|
93
96
|
plugins = load_user_plugins()
|
|
@@ -100,12 +103,12 @@ def register_all_tools(
|
|
|
100
103
|
logger = logging.getLogger(__name__)
|
|
101
104
|
logger.warning(f"Failed to load user plugins: {e}")
|
|
102
105
|
plugins = {}
|
|
103
|
-
|
|
106
|
+
|
|
104
107
|
# Apply mode configuration if enabled
|
|
105
108
|
if use_mode:
|
|
106
109
|
# First check for mode activation from environment
|
|
107
110
|
activate_mode_from_env()
|
|
108
|
-
|
|
111
|
+
|
|
109
112
|
tool_config = ModeLoader.get_enabled_tools_from_mode(
|
|
110
113
|
base_enabled_tools=enabled_tools,
|
|
111
114
|
force_mode=force_mode
|
|
@@ -115,7 +118,7 @@ def register_all_tools(
|
|
|
115
118
|
else:
|
|
116
119
|
# Use individual tool configuration if provided, otherwise fall back to category-level flags
|
|
117
120
|
tool_config = enabled_tools or {}
|
|
118
|
-
|
|
121
|
+
|
|
119
122
|
def is_tool_enabled(tool_name: str, category_enabled: bool = True) -> bool:
|
|
120
123
|
"""Check if a specific tool should be enabled."""
|
|
121
124
|
if tool_name in tool_config:
|
|
@@ -129,25 +132,19 @@ def register_all_tools(
|
|
|
129
132
|
"edit": is_tool_enabled("edit", not disable_write_tools),
|
|
130
133
|
"multi_edit": is_tool_enabled("multi_edit", not disable_write_tools),
|
|
131
134
|
"directory_tree": is_tool_enabled("directory_tree", True),
|
|
132
|
-
"
|
|
133
|
-
"symbols": is_tool_enabled("symbols", not disable_search_tools),
|
|
134
|
-
"git_search": is_tool_enabled("git_search", not disable_search_tools),
|
|
135
|
-
"content_replace": is_tool_enabled("content_replace", not disable_write_tools),
|
|
136
|
-
"batch_search": is_tool_enabled("batch_search", not disable_search_tools),
|
|
137
|
-
"find_files": is_tool_enabled("find_files", True),
|
|
135
|
+
"ast": is_tool_enabled("ast", not disable_search_tools),
|
|
138
136
|
"rules": is_tool_enabled("rules", True),
|
|
139
137
|
"search": is_tool_enabled("search", not disable_search_tools),
|
|
140
|
-
"unified_search": is_tool_enabled("unified_search", True), # Primary search tool
|
|
141
138
|
"find": is_tool_enabled("find", True), # Fast file finder
|
|
142
139
|
}
|
|
143
|
-
|
|
140
|
+
|
|
144
141
|
# Vector tools setup (needed for search)
|
|
145
142
|
project_manager = None
|
|
146
143
|
vector_enabled = {
|
|
147
144
|
"vector_index": is_tool_enabled("vector_index", False),
|
|
148
145
|
"vector_search": is_tool_enabled("vector_search", False),
|
|
149
146
|
}
|
|
150
|
-
|
|
147
|
+
|
|
151
148
|
# Create project manager if vector tools, batch_search, or unified_search are enabled
|
|
152
149
|
if any(vector_enabled.values()) or filesystem_enabled.get("batch_search", False) or filesystem_enabled.get("search", False):
|
|
153
150
|
if vector_config:
|
|
@@ -163,10 +160,10 @@ def register_all_tools(
|
|
|
163
160
|
import logging
|
|
164
161
|
logger = logging.getLogger(__name__)
|
|
165
162
|
logger.info(f"Detected {len(detected_projects)} projects with LLM.md files")
|
|
166
|
-
|
|
163
|
+
|
|
167
164
|
filesystem_tools = register_filesystem_tools(
|
|
168
|
-
mcp_server,
|
|
169
|
-
permission_manager,
|
|
165
|
+
mcp_server,
|
|
166
|
+
permission_manager,
|
|
170
167
|
enabled_tools=filesystem_enabled,
|
|
171
168
|
project_manager=project_manager,
|
|
172
169
|
)
|
|
@@ -175,10 +172,11 @@ def register_all_tools(
|
|
|
175
172
|
|
|
176
173
|
# Register jupyter tools if enabled
|
|
177
174
|
jupyter_enabled = {
|
|
178
|
-
"
|
|
179
|
-
"
|
|
175
|
+
"jupyter": is_tool_enabled("jupyter", True), # Unified tool
|
|
176
|
+
"notebook_read": is_tool_enabled("notebook_read", True), # Legacy support
|
|
177
|
+
"notebook_edit": is_tool_enabled("notebook_edit", True), # Legacy support
|
|
180
178
|
}
|
|
181
|
-
|
|
179
|
+
|
|
182
180
|
if any(jupyter_enabled.values()):
|
|
183
181
|
jupyter_tools = register_jupyter_tools(mcp_server, permission_manager, enabled_tools=jupyter_enabled)
|
|
184
182
|
for tool in jupyter_tools:
|
|
@@ -193,7 +191,7 @@ def register_all_tools(
|
|
|
193
191
|
# Register agent tools if enabled
|
|
194
192
|
agent_enabled = enable_agent_tool or is_tool_enabled("agent", False) or is_tool_enabled("dispatch_agent", False)
|
|
195
193
|
swarm_enabled = is_tool_enabled("swarm", False)
|
|
196
|
-
|
|
194
|
+
|
|
197
195
|
if agent_enabled or swarm_enabled:
|
|
198
196
|
agent_tools = register_agent_tools(
|
|
199
197
|
mcp_server,
|
|
@@ -222,7 +220,7 @@ def register_all_tools(
|
|
|
222
220
|
"todo_read": is_tool_enabled("todo_read", True),
|
|
223
221
|
"todo_write": is_tool_enabled("todo_write", True),
|
|
224
222
|
}
|
|
225
|
-
|
|
223
|
+
|
|
226
224
|
# Enable unified todo if any of the todo tools are enabled
|
|
227
225
|
if any(todo_enabled.values()):
|
|
228
226
|
todo_tools = register_todo_tools(mcp_server, enabled_tools={"todo": True})
|
|
@@ -234,7 +232,7 @@ def register_all_tools(
|
|
|
234
232
|
thinking_tool = register_thinking_tool(mcp_server)
|
|
235
233
|
for tool in thinking_tool:
|
|
236
234
|
all_tools[tool.name] = tool
|
|
237
|
-
|
|
235
|
+
|
|
238
236
|
# Register critic tool if enabled
|
|
239
237
|
if is_tool_enabled("critic", True):
|
|
240
238
|
critic_tools = register_critic_tool(mcp_server)
|
|
@@ -244,8 +242,8 @@ def register_all_tools(
|
|
|
244
242
|
# Register vector tools if enabled (reuse project_manager if available)
|
|
245
243
|
if any(vector_enabled.values()) and project_manager:
|
|
246
244
|
vector_tools = register_vector_tools(
|
|
247
|
-
mcp_server,
|
|
248
|
-
permission_manager,
|
|
245
|
+
mcp_server,
|
|
246
|
+
permission_manager,
|
|
249
247
|
vector_config=vector_config,
|
|
250
248
|
enabled_tools=vector_enabled,
|
|
251
249
|
project_manager=project_manager,
|
|
@@ -256,7 +254,7 @@ def register_all_tools(
|
|
|
256
254
|
# Register batch tool if enabled (batch tool is typically always enabled)
|
|
257
255
|
if is_tool_enabled("batch", True):
|
|
258
256
|
register_batch_tool(mcp_server, all_tools)
|
|
259
|
-
|
|
257
|
+
|
|
260
258
|
# Register database tools if enabled
|
|
261
259
|
db_manager = None
|
|
262
260
|
database_enabled = {
|
|
@@ -269,7 +267,7 @@ def register_all_tools(
|
|
|
269
267
|
"graph_search": is_tool_enabled("graph_search", True),
|
|
270
268
|
"graph_stats": is_tool_enabled("graph_stats", True),
|
|
271
269
|
}
|
|
272
|
-
|
|
270
|
+
|
|
273
271
|
if any(database_enabled.values()):
|
|
274
272
|
db_manager = DatabaseManager(permission_manager)
|
|
275
273
|
database_tools = register_database_tools(
|
|
@@ -281,87 +279,87 @@ def register_all_tools(
|
|
|
281
279
|
for tool in database_tools:
|
|
282
280
|
if database_enabled.get(tool.name, True):
|
|
283
281
|
all_tools[tool.name] = tool
|
|
284
|
-
|
|
282
|
+
|
|
285
283
|
# Register unified MCP tool if enabled
|
|
286
284
|
if is_tool_enabled("mcp", True):
|
|
287
285
|
tool = MCPTool()
|
|
288
286
|
tool.register(mcp_server)
|
|
289
287
|
all_tools[tool.name] = tool
|
|
290
|
-
|
|
288
|
+
|
|
291
289
|
# Register legacy MCP tools if explicitly enabled (disabled by default)
|
|
292
290
|
legacy_mcp_enabled = {
|
|
293
291
|
"mcp_add": is_tool_enabled("mcp_add", False),
|
|
294
292
|
"mcp_remove": is_tool_enabled("mcp_remove", False),
|
|
295
293
|
"mcp_stats": is_tool_enabled("mcp_stats", False),
|
|
296
294
|
}
|
|
297
|
-
|
|
295
|
+
|
|
298
296
|
if legacy_mcp_enabled.get("mcp_add", False):
|
|
299
297
|
tool = McpAddTool()
|
|
300
298
|
tool.register(mcp_server)
|
|
301
299
|
all_tools[tool.name] = tool
|
|
302
|
-
|
|
300
|
+
|
|
303
301
|
if legacy_mcp_enabled.get("mcp_remove", False):
|
|
304
302
|
tool = McpRemoveTool()
|
|
305
303
|
tool.register(mcp_server)
|
|
306
304
|
all_tools[tool.name] = tool
|
|
307
|
-
|
|
305
|
+
|
|
308
306
|
if legacy_mcp_enabled.get("mcp_stats", False):
|
|
309
307
|
tool = McpStatsTool()
|
|
310
308
|
tool.register(mcp_server)
|
|
311
309
|
all_tools[tool.name] = tool
|
|
312
|
-
|
|
310
|
+
|
|
313
311
|
# Register system tools (always enabled)
|
|
314
312
|
# Tool enable/disable tools
|
|
315
313
|
tool_enable = ToolEnableTool()
|
|
316
314
|
tool_enable.register(mcp_server)
|
|
317
315
|
all_tools[tool_enable.name] = tool_enable
|
|
318
|
-
|
|
316
|
+
|
|
319
317
|
tool_disable = ToolDisableTool()
|
|
320
318
|
tool_disable.register(mcp_server)
|
|
321
319
|
all_tools[tool_disable.name] = tool_disable
|
|
322
|
-
|
|
320
|
+
|
|
323
321
|
tool_list = ToolListTool()
|
|
324
322
|
tool_list.register(mcp_server)
|
|
325
323
|
all_tools[tool_list.name] = tool_list
|
|
326
|
-
|
|
324
|
+
|
|
327
325
|
# Stats tool
|
|
328
326
|
stats_tool = StatsTool(db_manager=db_manager)
|
|
329
327
|
stats_tool.register(mcp_server)
|
|
330
328
|
all_tools[stats_tool.name] = stats_tool
|
|
331
|
-
|
|
329
|
+
|
|
332
330
|
# Mode tool (always enabled for managing tool sets)
|
|
333
331
|
mode_tool.register(mcp_server)
|
|
334
332
|
all_tools[mode_tool.name] = mode_tool
|
|
335
|
-
|
|
333
|
+
|
|
336
334
|
# Register editor tools if enabled
|
|
337
335
|
editor_enabled = {
|
|
338
336
|
"neovim_edit": is_tool_enabled("neovim_edit", True),
|
|
339
337
|
"neovim_command": is_tool_enabled("neovim_command", True),
|
|
340
338
|
"neovim_session": is_tool_enabled("neovim_session", True),
|
|
341
339
|
}
|
|
342
|
-
|
|
340
|
+
|
|
343
341
|
if editor_enabled.get("neovim_edit", True):
|
|
344
342
|
tool = NeovimEditTool(permission_manager)
|
|
345
343
|
tool.register(mcp_server)
|
|
346
344
|
all_tools[tool.name] = tool
|
|
347
|
-
|
|
345
|
+
|
|
348
346
|
if editor_enabled.get("neovim_command", True):
|
|
349
347
|
tool = NeovimCommandTool(permission_manager)
|
|
350
348
|
tool.register(mcp_server)
|
|
351
349
|
all_tools[tool.name] = tool
|
|
352
|
-
|
|
350
|
+
|
|
353
351
|
if editor_enabled.get("neovim_session", True):
|
|
354
352
|
tool = NeovimSessionTool()
|
|
355
353
|
tool.register(mcp_server)
|
|
356
354
|
all_tools[tool.name] = tool
|
|
357
|
-
|
|
355
|
+
|
|
358
356
|
# Register unified LLM tool if enabled
|
|
359
357
|
if is_tool_enabled("llm", True):
|
|
360
358
|
tool = LLMTool()
|
|
361
359
|
if tool.available_providers: # Only register if API keys found
|
|
362
360
|
tool.register(mcp_server)
|
|
363
361
|
all_tools[tool.name] = tool
|
|
364
|
-
|
|
362
|
+
|
|
365
363
|
# Register consensus tool if enabled (enabled by default)
|
|
366
364
|
if is_tool_enabled("consensus", True):
|
|
367
365
|
tool = ConsensusTool()
|
|
@@ -375,24 +373,24 @@ def register_all_tools(
|
|
|
375
373
|
"consensus": is_tool_enabled("consensus", False),
|
|
376
374
|
"llm_manage": is_tool_enabled("llm_manage", False),
|
|
377
375
|
}
|
|
378
|
-
|
|
376
|
+
|
|
379
377
|
if legacy_llm_enabled.get("llm_legacy", False):
|
|
380
378
|
tool = LLMTool()
|
|
381
379
|
if tool.available_providers:
|
|
382
380
|
tool.register(mcp_server)
|
|
383
381
|
all_tools["llm_legacy"] = tool
|
|
384
|
-
|
|
382
|
+
|
|
385
383
|
if legacy_llm_enabled.get("consensus", False):
|
|
386
384
|
tool = ConsensusTool()
|
|
387
385
|
if tool.llm_tool.available_providers:
|
|
388
386
|
tool.register(mcp_server)
|
|
389
387
|
all_tools[tool.name] = tool
|
|
390
|
-
|
|
388
|
+
|
|
391
389
|
if legacy_llm_enabled.get("llm_manage", False):
|
|
392
390
|
tool = LLMManageTool()
|
|
393
391
|
tool.register(mcp_server)
|
|
394
392
|
all_tools[tool.name] = tool
|
|
395
|
-
|
|
393
|
+
|
|
396
394
|
# Register provider-specific LLM tools (disabled by default)
|
|
397
395
|
if is_tool_enabled("provider_specific_llm", False):
|
|
398
396
|
provider_tools = create_provider_tools()
|
|
@@ -400,7 +398,7 @@ def register_all_tools(
|
|
|
400
398
|
if is_tool_enabled(tool.name, False):
|
|
401
399
|
tool.register(mcp_server)
|
|
402
400
|
all_tools[tool.name] = tool
|
|
403
|
-
|
|
401
|
+
|
|
404
402
|
# Register memory tools if enabled
|
|
405
403
|
memory_enabled = {
|
|
406
404
|
"recall_memories": is_tool_enabled("recall_memories", True),
|
|
@@ -413,7 +411,7 @@ def register_all_tools(
|
|
|
413
411
|
"summarize_to_memory": is_tool_enabled("summarize_to_memory", True),
|
|
414
412
|
"manage_knowledge_bases": is_tool_enabled("manage_knowledge_bases", True),
|
|
415
413
|
}
|
|
416
|
-
|
|
414
|
+
|
|
417
415
|
if any(memory_enabled.values()) and MEMORY_TOOLS_AVAILABLE:
|
|
418
416
|
try:
|
|
419
417
|
memory_tools = register_memory_tools(
|
|
@@ -428,7 +426,7 @@ def register_all_tools(
|
|
|
428
426
|
all_tools[tool.name] = tool
|
|
429
427
|
except Exception as e:
|
|
430
428
|
logger.warning(f"Failed to register memory tools: {e}")
|
|
431
|
-
|
|
429
|
+
|
|
432
430
|
# Register LSP tool if enabled
|
|
433
431
|
if is_tool_enabled("lsp", True) and LSP_TOOL_AVAILABLE:
|
|
434
432
|
try:
|
|
@@ -437,7 +435,7 @@ def register_all_tools(
|
|
|
437
435
|
all_tools[tool.name] = tool
|
|
438
436
|
except Exception as e:
|
|
439
437
|
logger.warning(f"Failed to register LSP tool: {e}")
|
|
440
|
-
|
|
438
|
+
|
|
441
439
|
# Register user plugins last (so they can override built-in tools)
|
|
442
440
|
for plugin_name, plugin in plugins.items():
|
|
443
441
|
if is_tool_enabled(plugin_name, True):
|
|
@@ -448,3 +446,6 @@ def register_all_tools(
|
|
|
448
446
|
logger.info(f"Registered plugin tool: {plugin_name}")
|
|
449
447
|
except Exception as e:
|
|
450
448
|
logger.error(f"Failed to register plugin tool {plugin_name}: {e}")
|
|
449
|
+
|
|
450
|
+
# Return all registered tools
|
|
451
|
+
return list(all_tools.values())
|
|
@@ -7,22 +7,9 @@ enabling concurrent execution of multiple operations and specialized processing.
|
|
|
7
7
|
import os
|
|
8
8
|
from mcp.server import FastMCP
|
|
9
9
|
|
|
10
|
-
#
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
try:
|
|
14
|
-
if USE_HANZO_AGENTS:
|
|
15
|
-
from hanzo_mcp.tools.agent.agent_tool_v2 import AgentTool
|
|
16
|
-
from hanzo_mcp.tools.agent.swarm_tool_v2 import SwarmTool
|
|
17
|
-
print("[MCP] Using hanzo-agents SDK for agent and swarm tools")
|
|
18
|
-
else:
|
|
19
|
-
raise ImportError("USE_HANZO_AGENTS=false")
|
|
20
|
-
except ImportError:
|
|
21
|
-
# Fall back to original implementations
|
|
22
|
-
from hanzo_mcp.tools.agent.agent_tool import AgentTool
|
|
23
|
-
from hanzo_mcp.tools.agent.swarm_tool import SwarmTool
|
|
24
|
-
if USE_HANZO_AGENTS:
|
|
25
|
-
print("[MCP] hanzo-agents SDK not available, using original agent implementations")
|
|
10
|
+
# Import the main implementations (using hanzo-agents SDK)
|
|
11
|
+
from hanzo_mcp.tools.agent.agent_tool import AgentTool
|
|
12
|
+
from hanzo_mcp.tools.agent.swarm_tool import SwarmTool
|
|
26
13
|
|
|
27
14
|
from hanzo_mcp.tools.agent.claude_cli_tool import ClaudeCLITool
|
|
28
15
|
from hanzo_mcp.tools.agent.codex_cli_tool import CodexCLITool
|