hanzo-mcp 0.3.8__py3-none-any.whl → 0.5.1__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/__init__.py +1 -1
- hanzo_mcp/cli.py +118 -170
- hanzo_mcp/cli_enhanced.py +438 -0
- hanzo_mcp/config/__init__.py +19 -0
- hanzo_mcp/config/settings.py +449 -0
- hanzo_mcp/config/tool_config.py +197 -0
- hanzo_mcp/prompts/__init__.py +117 -0
- hanzo_mcp/prompts/compact_conversation.py +77 -0
- hanzo_mcp/prompts/create_release.py +38 -0
- hanzo_mcp/prompts/project_system.py +120 -0
- hanzo_mcp/prompts/project_todo_reminder.py +111 -0
- hanzo_mcp/prompts/utils.py +286 -0
- hanzo_mcp/server.py +117 -99
- hanzo_mcp/tools/__init__.py +121 -33
- hanzo_mcp/tools/agent/__init__.py +8 -11
- hanzo_mcp/tools/agent/agent_tool.py +290 -224
- hanzo_mcp/tools/agent/prompt.py +16 -13
- hanzo_mcp/tools/agent/tool_adapter.py +9 -9
- hanzo_mcp/tools/common/__init__.py +17 -16
- hanzo_mcp/tools/common/base.py +79 -110
- hanzo_mcp/tools/common/batch_tool.py +330 -0
- hanzo_mcp/tools/common/config_tool.py +396 -0
- hanzo_mcp/tools/common/context.py +26 -292
- hanzo_mcp/tools/common/permissions.py +12 -12
- hanzo_mcp/tools/common/thinking_tool.py +153 -0
- hanzo_mcp/tools/common/validation.py +1 -63
- hanzo_mcp/tools/filesystem/__init__.py +97 -57
- hanzo_mcp/tools/filesystem/base.py +32 -24
- hanzo_mcp/tools/filesystem/content_replace.py +114 -107
- hanzo_mcp/tools/filesystem/directory_tree.py +129 -105
- hanzo_mcp/tools/filesystem/edit.py +279 -0
- hanzo_mcp/tools/filesystem/grep.py +458 -0
- hanzo_mcp/tools/filesystem/grep_ast_tool.py +250 -0
- hanzo_mcp/tools/filesystem/multi_edit.py +362 -0
- hanzo_mcp/tools/filesystem/read.py +255 -0
- hanzo_mcp/tools/filesystem/unified_search.py +689 -0
- hanzo_mcp/tools/filesystem/write.py +156 -0
- hanzo_mcp/tools/jupyter/__init__.py +41 -29
- hanzo_mcp/tools/jupyter/base.py +66 -57
- hanzo_mcp/tools/jupyter/{edit_notebook.py → notebook_edit.py} +162 -139
- hanzo_mcp/tools/jupyter/notebook_read.py +152 -0
- hanzo_mcp/tools/shell/__init__.py +29 -20
- hanzo_mcp/tools/shell/base.py +87 -45
- hanzo_mcp/tools/shell/bash_session.py +731 -0
- hanzo_mcp/tools/shell/bash_session_executor.py +295 -0
- hanzo_mcp/tools/shell/command_executor.py +435 -384
- hanzo_mcp/tools/shell/run_command.py +284 -131
- hanzo_mcp/tools/shell/run_command_windows.py +328 -0
- hanzo_mcp/tools/shell/session_manager.py +196 -0
- hanzo_mcp/tools/shell/session_storage.py +325 -0
- hanzo_mcp/tools/todo/__init__.py +66 -0
- hanzo_mcp/tools/todo/base.py +319 -0
- hanzo_mcp/tools/todo/todo_read.py +148 -0
- hanzo_mcp/tools/todo/todo_write.py +378 -0
- hanzo_mcp/tools/vector/__init__.py +99 -0
- hanzo_mcp/tools/vector/ast_analyzer.py +459 -0
- hanzo_mcp/tools/vector/git_ingester.py +482 -0
- hanzo_mcp/tools/vector/infinity_store.py +731 -0
- hanzo_mcp/tools/vector/mock_infinity.py +162 -0
- hanzo_mcp/tools/vector/project_manager.py +361 -0
- hanzo_mcp/tools/vector/vector_index.py +116 -0
- hanzo_mcp/tools/vector/vector_search.py +225 -0
- hanzo_mcp-0.5.1.dist-info/METADATA +276 -0
- hanzo_mcp-0.5.1.dist-info/RECORD +68 -0
- {hanzo_mcp-0.3.8.dist-info → hanzo_mcp-0.5.1.dist-info}/WHEEL +1 -1
- hanzo_mcp/tools/agent/base_provider.py +0 -73
- hanzo_mcp/tools/agent/litellm_provider.py +0 -45
- hanzo_mcp/tools/agent/lmstudio_agent.py +0 -385
- hanzo_mcp/tools/agent/lmstudio_provider.py +0 -219
- hanzo_mcp/tools/agent/provider_registry.py +0 -120
- hanzo_mcp/tools/common/error_handling.py +0 -86
- hanzo_mcp/tools/common/logging_config.py +0 -115
- hanzo_mcp/tools/common/session.py +0 -91
- hanzo_mcp/tools/common/think_tool.py +0 -123
- hanzo_mcp/tools/common/version_tool.py +0 -120
- hanzo_mcp/tools/filesystem/edit_file.py +0 -287
- hanzo_mcp/tools/filesystem/get_file_info.py +0 -170
- hanzo_mcp/tools/filesystem/read_files.py +0 -199
- hanzo_mcp/tools/filesystem/search_content.py +0 -275
- hanzo_mcp/tools/filesystem/write_file.py +0 -162
- hanzo_mcp/tools/jupyter/notebook_operations.py +0 -514
- hanzo_mcp/tools/jupyter/read_notebook.py +0 -165
- hanzo_mcp/tools/project/__init__.py +0 -64
- hanzo_mcp/tools/project/analysis.py +0 -886
- hanzo_mcp/tools/project/base.py +0 -66
- hanzo_mcp/tools/project/project_analyze.py +0 -173
- hanzo_mcp/tools/shell/run_script.py +0 -215
- hanzo_mcp/tools/shell/script_tool.py +0 -244
- hanzo_mcp-0.3.8.dist-info/METADATA +0 -196
- hanzo_mcp-0.3.8.dist-info/RECORD +0 -53
- {hanzo_mcp-0.3.8.dist-info → hanzo_mcp-0.5.1.dist-info}/entry_points.txt +0 -0
- {hanzo_mcp-0.3.8.dist-info → hanzo_mcp-0.5.1.dist-info}/licenses/LICENSE +0 -0
- {hanzo_mcp-0.3.8.dist-info → hanzo_mcp-0.5.1.dist-info}/top_level.txt +0 -0
hanzo_mcp/tools/__init__.py
CHANGED
|
@@ -9,81 +9,169 @@ space for structured thinking. It also includes an "agent" tool that enables Cla
|
|
|
9
9
|
to delegate tasks to sub-agents for concurrent execution and specialized processing.
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
|
-
from
|
|
12
|
+
from fastmcp import FastMCP
|
|
13
13
|
|
|
14
14
|
from hanzo_mcp.tools.agent import register_agent_tools
|
|
15
|
-
from hanzo_mcp.tools.common import
|
|
16
|
-
from hanzo_mcp.tools.common.base import
|
|
17
|
-
|
|
15
|
+
from hanzo_mcp.tools.common import register_batch_tool, register_thinking_tool
|
|
16
|
+
from hanzo_mcp.tools.common.base import BaseTool
|
|
17
|
+
|
|
18
18
|
from hanzo_mcp.tools.common.permissions import PermissionManager
|
|
19
19
|
from hanzo_mcp.tools.filesystem import register_filesystem_tools
|
|
20
20
|
from hanzo_mcp.tools.jupyter import register_jupyter_tools
|
|
21
|
-
from hanzo_mcp.tools.project import register_project_tools
|
|
22
21
|
from hanzo_mcp.tools.shell import register_shell_tools
|
|
23
|
-
from hanzo_mcp.tools.
|
|
22
|
+
from hanzo_mcp.tools.todo import register_todo_tools
|
|
23
|
+
from hanzo_mcp.tools.vector import register_vector_tools
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
def register_all_tools(
|
|
27
27
|
mcp_server: FastMCP,
|
|
28
|
-
document_context: DocumentContext,
|
|
29
28
|
permission_manager: PermissionManager,
|
|
30
29
|
agent_model: str | None = None,
|
|
31
30
|
agent_max_tokens: int | None = None,
|
|
32
31
|
agent_api_key: str | None = None,
|
|
32
|
+
agent_base_url: str | None = None,
|
|
33
33
|
agent_max_iterations: int = 10,
|
|
34
34
|
agent_max_tool_uses: int = 30,
|
|
35
35
|
enable_agent_tool: bool = False,
|
|
36
36
|
disable_write_tools: bool = False,
|
|
37
37
|
disable_search_tools: bool = False,
|
|
38
|
+
enabled_tools: dict[str, bool] | None = None,
|
|
39
|
+
vector_config: dict | None = None,
|
|
38
40
|
) -> None:
|
|
39
41
|
"""Register all Hanzo tools with the MCP server.
|
|
40
42
|
|
|
41
43
|
Args:
|
|
42
44
|
mcp_server: The FastMCP server instance
|
|
43
|
-
document_context: Document context for tracking file contents
|
|
44
45
|
permission_manager: Permission manager for access control
|
|
45
46
|
agent_model: Optional model name for agent tool in LiteLLM format
|
|
46
47
|
agent_max_tokens: Optional maximum tokens for agent responses
|
|
47
48
|
agent_api_key: Optional API key for the LLM provider
|
|
49
|
+
agent_base_url: Optional base URL for the LLM provider API endpoint
|
|
48
50
|
agent_max_iterations: Maximum number of iterations for agent (default: 10)
|
|
49
51
|
agent_max_tool_uses: Maximum number of total tool uses for agent (default: 30)
|
|
50
52
|
enable_agent_tool: Whether to enable the agent tool (default: False)
|
|
51
|
-
disable_write_tools: Whether to disable write
|
|
53
|
+
disable_write_tools: Whether to disable write tools (default: False)
|
|
52
54
|
disable_search_tools: Whether to disable search tools (default: False)
|
|
55
|
+
enabled_tools: Dictionary of individual tool enable/disable states (default: None)
|
|
56
|
+
vector_config: Vector store configuration (default: None)
|
|
53
57
|
"""
|
|
54
|
-
#
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
#
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
# Dictionary to store all registered tools
|
|
59
|
+
all_tools: dict[str, BaseTool] = {}
|
|
60
|
+
|
|
61
|
+
# Use individual tool configuration if provided, otherwise fall back to category-level flags
|
|
62
|
+
tool_config = enabled_tools or {}
|
|
63
|
+
|
|
64
|
+
def is_tool_enabled(tool_name: str, category_enabled: bool = True) -> bool:
|
|
65
|
+
"""Check if a specific tool should be enabled."""
|
|
66
|
+
if tool_name in tool_config:
|
|
67
|
+
return tool_config[tool_name]
|
|
68
|
+
return category_enabled
|
|
62
69
|
|
|
63
|
-
# Register
|
|
64
|
-
|
|
70
|
+
# Register filesystem tools with individual configuration
|
|
71
|
+
filesystem_enabled = {
|
|
72
|
+
"read": is_tool_enabled("read", True),
|
|
73
|
+
"write": is_tool_enabled("write", not disable_write_tools),
|
|
74
|
+
"edit": is_tool_enabled("edit", not disable_write_tools),
|
|
75
|
+
"multi_edit": is_tool_enabled("multi_edit", not disable_write_tools),
|
|
76
|
+
"directory_tree": is_tool_enabled("directory_tree", True),
|
|
77
|
+
"grep": is_tool_enabled("grep", not disable_search_tools),
|
|
78
|
+
"grep_ast": is_tool_enabled("grep_ast", not disable_search_tools),
|
|
79
|
+
"content_replace": is_tool_enabled("content_replace", not disable_write_tools),
|
|
80
|
+
"unified_search": is_tool_enabled("unified_search", not disable_search_tools),
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
# Vector tools setup (needed for unified search)
|
|
84
|
+
project_manager = None
|
|
85
|
+
vector_enabled = {
|
|
86
|
+
"vector_index": is_tool_enabled("vector_index", False),
|
|
87
|
+
"vector_search": is_tool_enabled("vector_search", False),
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
# Create project manager if vector tools or unified search are enabled
|
|
91
|
+
if any(vector_enabled.values()) or filesystem_enabled.get("unified_search", False):
|
|
92
|
+
if vector_config:
|
|
93
|
+
from hanzo_mcp.tools.vector.project_manager import ProjectVectorManager
|
|
94
|
+
search_paths = [str(path) for path in permission_manager.allowed_paths]
|
|
95
|
+
project_manager = ProjectVectorManager(
|
|
96
|
+
global_db_path=vector_config.get("data_path"),
|
|
97
|
+
embedding_model=vector_config.get("embedding_model", "text-embedding-3-small"),
|
|
98
|
+
dimension=vector_config.get("dimension", 1536),
|
|
99
|
+
)
|
|
100
|
+
# Auto-detect projects from search paths
|
|
101
|
+
detected_projects = project_manager.detect_projects(search_paths)
|
|
102
|
+
print(f"Detected {len(detected_projects)} projects with LLM.md files")
|
|
103
|
+
|
|
104
|
+
filesystem_tools = register_filesystem_tools(
|
|
65
105
|
mcp_server,
|
|
66
106
|
permission_manager,
|
|
67
|
-
|
|
68
|
-
|
|
107
|
+
enabled_tools=filesystem_enabled,
|
|
108
|
+
project_manager=project_manager,
|
|
69
109
|
)
|
|
110
|
+
for tool in filesystem_tools:
|
|
111
|
+
all_tools[tool.name] = tool
|
|
70
112
|
|
|
71
|
-
# Register
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
113
|
+
# Register jupyter tools if enabled
|
|
114
|
+
jupyter_enabled = {
|
|
115
|
+
"notebook_read": is_tool_enabled("notebook_read", True),
|
|
116
|
+
"notebook_edit": is_tool_enabled("notebook_edit", True),
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if any(jupyter_enabled.values()):
|
|
120
|
+
jupyter_tools = register_jupyter_tools(mcp_server, permission_manager, enabled_tools=jupyter_enabled)
|
|
121
|
+
for tool in jupyter_tools:
|
|
122
|
+
all_tools[tool.name] = tool
|
|
123
|
+
|
|
124
|
+
# Register shell tools if enabled
|
|
125
|
+
if is_tool_enabled("run_command", True):
|
|
126
|
+
shell_tools = register_shell_tools(mcp_server, permission_manager)
|
|
127
|
+
for tool in shell_tools:
|
|
128
|
+
all_tools[tool.name] = tool
|
|
129
|
+
|
|
130
|
+
# Register agent tools if enabled
|
|
131
|
+
agent_enabled = enable_agent_tool or is_tool_enabled("dispatch_agent", False)
|
|
132
|
+
if agent_enabled:
|
|
133
|
+
agent_tools = register_agent_tools(
|
|
134
|
+
mcp_server,
|
|
76
135
|
permission_manager,
|
|
77
|
-
CommandExecutor(permission_manager),
|
|
78
136
|
agent_model=agent_model,
|
|
79
137
|
agent_max_tokens=agent_max_tokens,
|
|
80
138
|
agent_api_key=agent_api_key,
|
|
139
|
+
agent_base_url=agent_base_url,
|
|
81
140
|
agent_max_iterations=agent_max_iterations,
|
|
82
|
-
agent_max_tool_uses=agent_max_tool_uses
|
|
141
|
+
agent_max_tool_uses=agent_max_tool_uses,
|
|
83
142
|
)
|
|
143
|
+
for tool in agent_tools:
|
|
144
|
+
all_tools[tool.name] = tool
|
|
145
|
+
|
|
146
|
+
# Register todo tools if enabled
|
|
147
|
+
todo_enabled = {
|
|
148
|
+
"todo_read": is_tool_enabled("todo_read", True),
|
|
149
|
+
"todo_write": is_tool_enabled("todo_write", True),
|
|
150
|
+
}
|
|
84
151
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
152
|
+
if any(todo_enabled.values()):
|
|
153
|
+
todo_tools = register_todo_tools(mcp_server, enabled_tools=todo_enabled)
|
|
154
|
+
for tool in todo_tools:
|
|
155
|
+
all_tools[tool.name] = tool
|
|
156
|
+
|
|
157
|
+
# Register thinking tool if enabled
|
|
158
|
+
if is_tool_enabled("think", True):
|
|
159
|
+
thinking_tool = register_thinking_tool(mcp_server)
|
|
160
|
+
for tool in thinking_tool:
|
|
161
|
+
all_tools[tool.name] = tool
|
|
162
|
+
|
|
163
|
+
# Register vector tools if enabled (reuse project_manager if available)
|
|
164
|
+
if any(vector_enabled.values()) and project_manager:
|
|
165
|
+
vector_tools = register_vector_tools(
|
|
166
|
+
mcp_server,
|
|
167
|
+
permission_manager,
|
|
168
|
+
vector_config=vector_config,
|
|
169
|
+
enabled_tools=vector_enabled,
|
|
170
|
+
project_manager=project_manager,
|
|
171
|
+
)
|
|
172
|
+
for tool in vector_tools:
|
|
173
|
+
all_tools[tool.name] = tool
|
|
174
|
+
|
|
175
|
+
# Register batch tool if enabled (batch tool is typically always enabled)
|
|
176
|
+
if is_tool_enabled("batch", True):
|
|
177
|
+
register_batch_tool(mcp_server, all_tools)
|
|
@@ -4,23 +4,21 @@ This module provides tools that allow Claude to delegate tasks to sub-agents,
|
|
|
4
4
|
enabling concurrent execution of multiple operations and specialized processing.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
-
from
|
|
7
|
+
from fastmcp import FastMCP
|
|
8
8
|
|
|
9
9
|
from hanzo_mcp.tools.agent.agent_tool import AgentTool
|
|
10
|
-
from hanzo_mcp.tools.common.base import BaseTool, ToolRegistry
|
|
11
|
-
|
|
10
|
+
from hanzo_mcp.tools.common.base import BaseTool, ToolRegistry
|
|
11
|
+
|
|
12
12
|
from hanzo_mcp.tools.common.permissions import PermissionManager
|
|
13
|
-
from hanzo_mcp.tools.shell.command_executor import CommandExecutor
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
def register_agent_tools(
|
|
17
16
|
mcp_server: FastMCP,
|
|
18
|
-
document_context: DocumentContext,
|
|
19
17
|
permission_manager: PermissionManager,
|
|
20
|
-
command_executor: CommandExecutor,
|
|
21
18
|
agent_model: str | None = None,
|
|
22
19
|
agent_max_tokens: int | None = None,
|
|
23
20
|
agent_api_key: str | None = None,
|
|
21
|
+
agent_base_url: str | None = None,
|
|
24
22
|
agent_max_iterations: int = 10,
|
|
25
23
|
agent_max_tool_uses: int = 30,
|
|
26
24
|
) -> list[BaseTool]:
|
|
@@ -28,12 +26,12 @@ def register_agent_tools(
|
|
|
28
26
|
|
|
29
27
|
Args:
|
|
30
28
|
mcp_server: The FastMCP server instance
|
|
31
|
-
|
|
29
|
+
|
|
32
30
|
permission_manager: Permission manager for access control
|
|
33
|
-
command_executor: Command executor for running shell commands
|
|
34
31
|
agent_model: Optional model name for agent tool in LiteLLM format
|
|
35
32
|
agent_max_tokens: Optional maximum tokens for agent responses
|
|
36
33
|
agent_api_key: Optional API key for the LLM provider
|
|
34
|
+
agent_base_url: Optional base URL for the LLM provider API endpoint
|
|
37
35
|
agent_max_iterations: Maximum number of iterations for agent (default: 10)
|
|
38
36
|
agent_max_tool_uses: Maximum number of total tool uses for agent (default: 30)
|
|
39
37
|
|
|
@@ -42,14 +40,13 @@ def register_agent_tools(
|
|
|
42
40
|
"""
|
|
43
41
|
# Create agent tool
|
|
44
42
|
agent_tool = AgentTool(
|
|
45
|
-
document_context=document_context,
|
|
46
43
|
permission_manager=permission_manager,
|
|
47
|
-
command_executor=command_executor,
|
|
48
44
|
model=agent_model,
|
|
49
45
|
api_key=agent_api_key,
|
|
46
|
+
base_url=agent_base_url,
|
|
50
47
|
max_tokens=agent_max_tokens,
|
|
51
48
|
max_iterations=agent_max_iterations,
|
|
52
|
-
max_tool_uses=agent_max_tool_uses
|
|
49
|
+
max_tool_uses=agent_max_tool_uses,
|
|
53
50
|
)
|
|
54
51
|
|
|
55
52
|
# Register agent tool
|