hanzo-mcp 0.3.4__py3-none-any.whl → 0.5.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.
- hanzo_mcp/__init__.py +1 -1
- hanzo_mcp/cli.py +123 -160
- hanzo_mcp/cli_enhanced.py +438 -0
- hanzo_mcp/config/__init__.py +19 -0
- hanzo_mcp/config/settings.py +388 -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 +120 -98
- hanzo_mcp/tools/__init__.py +107 -31
- 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/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 +88 -41
- 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/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 +95 -0
- hanzo_mcp/tools/vector/infinity_store.py +365 -0
- hanzo_mcp/tools/vector/project_manager.py +361 -0
- hanzo_mcp/tools/vector/vector_index.py +115 -0
- hanzo_mcp/tools/vector/vector_search.py +215 -0
- {hanzo_mcp-0.3.4.dist-info → hanzo_mcp-0.5.0.dist-info}/METADATA +35 -3
- hanzo_mcp-0.5.0.dist-info/RECORD +63 -0
- {hanzo_mcp-0.3.4.dist-info → hanzo_mcp-0.5.0.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 -198
- 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 -882
- 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.4.dist-info/RECORD +0 -53
- {hanzo_mcp-0.3.4.dist-info → hanzo_mcp-0.5.0.dist-info}/entry_points.txt +0 -0
- {hanzo_mcp-0.3.4.dist-info → hanzo_mcp-0.5.0.dist-info}/licenses/LICENSE +0 -0
- {hanzo_mcp-0.3.4.dist-info → hanzo_mcp-0.5.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
"""Enhanced command-line interface for the Hanzo MCP server with full tool configuration."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any, Dict, cast
|
|
9
|
+
|
|
10
|
+
from hanzo_mcp.config import HanzoMCPSettings, load_settings, save_settings, TOOL_REGISTRY
|
|
11
|
+
from hanzo_mcp.server import HanzoMCPServer
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def create_parser() -> argparse.ArgumentParser:
|
|
15
|
+
"""Create the argument parser with all tool configuration options."""
|
|
16
|
+
parser = argparse.ArgumentParser(
|
|
17
|
+
description="Hanzo MCP server with comprehensive tool configuration",
|
|
18
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
19
|
+
epilog="""
|
|
20
|
+
Tool Configuration:
|
|
21
|
+
Each tool can be individually enabled/disabled using CLI flags.
|
|
22
|
+
Use --list-tools to see all available tools and their current status.
|
|
23
|
+
|
|
24
|
+
Configuration Files:
|
|
25
|
+
Global: ~/.config/hanzo/mcp-settings.json
|
|
26
|
+
Project: ./.hanzo-mcp.json or ./.hanzo/mcp-settings.json
|
|
27
|
+
|
|
28
|
+
Examples:
|
|
29
|
+
# Start server with only read tools
|
|
30
|
+
hanzo-mcp --disable-write --disable-edit --disable-multi-edit
|
|
31
|
+
|
|
32
|
+
# Enable agent tool with custom model
|
|
33
|
+
hanzo-mcp --enable-dispatch-agent --agent-model anthropic/claude-3-sonnet
|
|
34
|
+
|
|
35
|
+
# Save current configuration
|
|
36
|
+
hanzo-mcp --save-config
|
|
37
|
+
"""
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
# Basic server options
|
|
41
|
+
server_group = parser.add_argument_group("Server Configuration")
|
|
42
|
+
server_group.add_argument(
|
|
43
|
+
"--name",
|
|
44
|
+
default="hanzo-mcp",
|
|
45
|
+
help="Name of the MCP server (default: hanzo-mcp)",
|
|
46
|
+
)
|
|
47
|
+
server_group.add_argument(
|
|
48
|
+
"--transport",
|
|
49
|
+
choices=["stdio", "sse"],
|
|
50
|
+
default="stdio",
|
|
51
|
+
help="Transport protocol to use (default: stdio)",
|
|
52
|
+
)
|
|
53
|
+
server_group.add_argument(
|
|
54
|
+
"--host",
|
|
55
|
+
default="127.0.0.1",
|
|
56
|
+
help="Host for SSE server (default: 127.0.0.1)",
|
|
57
|
+
)
|
|
58
|
+
server_group.add_argument(
|
|
59
|
+
"--port",
|
|
60
|
+
type=int,
|
|
61
|
+
default=3000,
|
|
62
|
+
help="Port for SSE server (default: 3000)",
|
|
63
|
+
)
|
|
64
|
+
server_group.add_argument(
|
|
65
|
+
"--log-level",
|
|
66
|
+
choices=["DEBUG", "INFO", "WARNING", "ERROR"],
|
|
67
|
+
default="INFO",
|
|
68
|
+
help="Logging level (default: INFO)",
|
|
69
|
+
)
|
|
70
|
+
server_group.add_argument(
|
|
71
|
+
"--command-timeout",
|
|
72
|
+
type=float,
|
|
73
|
+
default=120.0,
|
|
74
|
+
help="Default timeout for command execution in seconds (default: 120.0)",
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
# Path configuration
|
|
78
|
+
path_group = parser.add_argument_group("Path Configuration")
|
|
79
|
+
path_group.add_argument(
|
|
80
|
+
"--allow-path",
|
|
81
|
+
action="append",
|
|
82
|
+
dest="allowed_paths",
|
|
83
|
+
help="Add an allowed path (can be specified multiple times)",
|
|
84
|
+
)
|
|
85
|
+
path_group.add_argument(
|
|
86
|
+
"--project",
|
|
87
|
+
action="append",
|
|
88
|
+
dest="project_paths",
|
|
89
|
+
help="Add a project path (can be specified multiple times)",
|
|
90
|
+
)
|
|
91
|
+
path_group.add_argument(
|
|
92
|
+
"--project-dir",
|
|
93
|
+
help="Single project directory (added to both allowed and project paths)",
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Individual tool configuration
|
|
97
|
+
tool_group = parser.add_argument_group("Individual Tool Configuration")
|
|
98
|
+
|
|
99
|
+
# Add CLI flags for each tool
|
|
100
|
+
for tool_name, tool_config in TOOL_REGISTRY.items():
|
|
101
|
+
flag_name = tool_config.cli_flag.lstrip('-')
|
|
102
|
+
help_text = f"{tool_config.description}"
|
|
103
|
+
|
|
104
|
+
if tool_config.enabled:
|
|
105
|
+
# Tool is enabled by default, add disable flag
|
|
106
|
+
tool_group.add_argument(
|
|
107
|
+
f"--disable-{tool_name.replace('_', '-')}",
|
|
108
|
+
action="store_true",
|
|
109
|
+
help=f"Disable {tool_name} tool: {help_text}",
|
|
110
|
+
)
|
|
111
|
+
else:
|
|
112
|
+
# Tool is disabled by default, add enable flag
|
|
113
|
+
tool_group.add_argument(
|
|
114
|
+
f"--enable-{tool_name.replace('_', '-')}",
|
|
115
|
+
action="store_true",
|
|
116
|
+
help=f"Enable {tool_name} tool: {help_text}",
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
# Category-level tool configuration (for backward compatibility)
|
|
120
|
+
category_group = parser.add_argument_group("Category-level Tool Configuration")
|
|
121
|
+
category_group.add_argument(
|
|
122
|
+
"--disable-write-tools",
|
|
123
|
+
action="store_true",
|
|
124
|
+
help="Disable all write tools (write, edit, multi_edit, content_replace)",
|
|
125
|
+
)
|
|
126
|
+
category_group.add_argument(
|
|
127
|
+
"--disable-search-tools",
|
|
128
|
+
action="store_true",
|
|
129
|
+
help="Disable all search tools (grep, grep_ast)",
|
|
130
|
+
)
|
|
131
|
+
category_group.add_argument(
|
|
132
|
+
"--disable-filesystem-tools",
|
|
133
|
+
action="store_true",
|
|
134
|
+
help="Disable all filesystem tools",
|
|
135
|
+
)
|
|
136
|
+
category_group.add_argument(
|
|
137
|
+
"--disable-jupyter-tools",
|
|
138
|
+
action="store_true",
|
|
139
|
+
help="Disable all Jupyter notebook tools",
|
|
140
|
+
)
|
|
141
|
+
category_group.add_argument(
|
|
142
|
+
"--disable-shell-tools",
|
|
143
|
+
action="store_true",
|
|
144
|
+
help="Disable shell command execution tools",
|
|
145
|
+
)
|
|
146
|
+
category_group.add_argument(
|
|
147
|
+
"--disable-todo-tools",
|
|
148
|
+
action="store_true",
|
|
149
|
+
help="Disable todo management tools",
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
# Agent configuration
|
|
153
|
+
agent_group = parser.add_argument_group("Agent Tool Configuration")
|
|
154
|
+
agent_group.add_argument(
|
|
155
|
+
"--agent-model",
|
|
156
|
+
help="Model name in LiteLLM format (e.g., 'openai/gpt-4o', 'anthropic/claude-3-sonnet')",
|
|
157
|
+
)
|
|
158
|
+
agent_group.add_argument(
|
|
159
|
+
"--agent-max-tokens",
|
|
160
|
+
type=int,
|
|
161
|
+
help="Maximum tokens for agent responses",
|
|
162
|
+
)
|
|
163
|
+
agent_group.add_argument(
|
|
164
|
+
"--agent-api-key",
|
|
165
|
+
help="API key for the LLM provider",
|
|
166
|
+
)
|
|
167
|
+
agent_group.add_argument(
|
|
168
|
+
"--agent-base-url",
|
|
169
|
+
help="Base URL for the LLM provider API endpoint",
|
|
170
|
+
)
|
|
171
|
+
agent_group.add_argument(
|
|
172
|
+
"--agent-max-iterations",
|
|
173
|
+
type=int,
|
|
174
|
+
default=10,
|
|
175
|
+
help="Maximum iterations for agent (default: 10)",
|
|
176
|
+
)
|
|
177
|
+
agent_group.add_argument(
|
|
178
|
+
"--agent-max-tool-uses",
|
|
179
|
+
type=int,
|
|
180
|
+
default=30,
|
|
181
|
+
help="Maximum tool uses for agent (default: 30)",
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
# Vector store configuration
|
|
185
|
+
vector_group = parser.add_argument_group("Vector Store Configuration")
|
|
186
|
+
vector_group.add_argument(
|
|
187
|
+
"--enable-vector-store",
|
|
188
|
+
action="store_true",
|
|
189
|
+
help="Enable local vector store (Infinity database)",
|
|
190
|
+
)
|
|
191
|
+
vector_group.add_argument(
|
|
192
|
+
"--vector-store-path",
|
|
193
|
+
help="Path for vector store data (default: ~/.config/hanzo/vector-store)",
|
|
194
|
+
)
|
|
195
|
+
vector_group.add_argument(
|
|
196
|
+
"--embedding-model",
|
|
197
|
+
default="text-embedding-3-small",
|
|
198
|
+
help="Embedding model for vector store (default: text-embedding-3-small)",
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
# Configuration management
|
|
202
|
+
config_group = parser.add_argument_group("Configuration Management")
|
|
203
|
+
config_group.add_argument(
|
|
204
|
+
"--config-file",
|
|
205
|
+
help="Load configuration from specific file",
|
|
206
|
+
)
|
|
207
|
+
config_group.add_argument(
|
|
208
|
+
"--save-config",
|
|
209
|
+
action="store_true",
|
|
210
|
+
help="Save current configuration to global config file",
|
|
211
|
+
)
|
|
212
|
+
config_group.add_argument(
|
|
213
|
+
"--save-project-config",
|
|
214
|
+
action="store_true",
|
|
215
|
+
help="Save current configuration to project config file",
|
|
216
|
+
)
|
|
217
|
+
config_group.add_argument(
|
|
218
|
+
"--list-tools",
|
|
219
|
+
action="store_true",
|
|
220
|
+
help="List all available tools and their status",
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
# Installation
|
|
224
|
+
install_group = parser.add_argument_group("Installation")
|
|
225
|
+
install_group.add_argument(
|
|
226
|
+
"--install",
|
|
227
|
+
action="store_true",
|
|
228
|
+
help="Install server configuration in Claude Desktop",
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
return parser
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def apply_cli_overrides(args: argparse.Namespace) -> Dict[str, Any]:
|
|
235
|
+
"""Convert CLI arguments to configuration overrides."""
|
|
236
|
+
overrides = {}
|
|
237
|
+
|
|
238
|
+
# Server configuration
|
|
239
|
+
server_config = {}
|
|
240
|
+
if hasattr(args, 'name') and args.name != "hanzo-mcp":
|
|
241
|
+
server_config["name"] = args.name
|
|
242
|
+
if hasattr(args, 'host') and args.host != "127.0.0.1":
|
|
243
|
+
server_config["host"] = args.host
|
|
244
|
+
if hasattr(args, 'port') and args.port != 3000:
|
|
245
|
+
server_config["port"] = args.port
|
|
246
|
+
if hasattr(args, 'transport') and args.transport != "stdio":
|
|
247
|
+
server_config["transport"] = args.transport
|
|
248
|
+
if hasattr(args, 'log_level') and args.log_level != "INFO":
|
|
249
|
+
server_config["log_level"] = args.log_level
|
|
250
|
+
if hasattr(args, 'command_timeout') and args.command_timeout != 120.0:
|
|
251
|
+
server_config["command_timeout"] = args.command_timeout
|
|
252
|
+
|
|
253
|
+
if server_config:
|
|
254
|
+
overrides["server"] = server_config
|
|
255
|
+
|
|
256
|
+
# Path configuration
|
|
257
|
+
if hasattr(args, 'allowed_paths') and args.allowed_paths:
|
|
258
|
+
overrides["allowed_paths"] = args.allowed_paths
|
|
259
|
+
if hasattr(args, 'project_paths') and args.project_paths:
|
|
260
|
+
overrides["project_paths"] = args.project_paths
|
|
261
|
+
if hasattr(args, 'project_dir') and args.project_dir:
|
|
262
|
+
overrides["project_dir"] = args.project_dir
|
|
263
|
+
|
|
264
|
+
# Tool configuration
|
|
265
|
+
enabled_tools = {}
|
|
266
|
+
|
|
267
|
+
# Handle individual tool flags
|
|
268
|
+
for tool_name, tool_config in TOOL_REGISTRY.items():
|
|
269
|
+
flag_name = tool_name.replace('_', '-')
|
|
270
|
+
|
|
271
|
+
if tool_config.enabled:
|
|
272
|
+
# Check for disable flag
|
|
273
|
+
disable_flag = f"disable_{tool_name}"
|
|
274
|
+
if hasattr(args, disable_flag) and getattr(args, disable_flag):
|
|
275
|
+
enabled_tools[tool_name] = False
|
|
276
|
+
else:
|
|
277
|
+
# Check for enable flag
|
|
278
|
+
enable_flag = f"enable_{tool_name}"
|
|
279
|
+
if hasattr(args, enable_flag) and getattr(args, enable_flag):
|
|
280
|
+
enabled_tools[tool_name] = True
|
|
281
|
+
|
|
282
|
+
# Handle category-level disables
|
|
283
|
+
if hasattr(args, 'disable_write_tools') and args.disable_write_tools:
|
|
284
|
+
for tool_name in ["write", "edit", "multi_edit", "content_replace"]:
|
|
285
|
+
enabled_tools[tool_name] = False
|
|
286
|
+
|
|
287
|
+
if hasattr(args, 'disable_search_tools') and args.disable_search_tools:
|
|
288
|
+
for tool_name in ["grep", "grep_ast"]:
|
|
289
|
+
enabled_tools[tool_name] = False
|
|
290
|
+
|
|
291
|
+
if hasattr(args, 'disable_filesystem_tools') and args.disable_filesystem_tools:
|
|
292
|
+
filesystem_tools = ["read", "write", "edit", "multi_edit", "directory_tree",
|
|
293
|
+
"grep", "grep_ast", "content_replace"]
|
|
294
|
+
for tool_name in filesystem_tools:
|
|
295
|
+
enabled_tools[tool_name] = False
|
|
296
|
+
|
|
297
|
+
if hasattr(args, 'disable_jupyter_tools') and args.disable_jupyter_tools:
|
|
298
|
+
for tool_name in ["notebook_read", "notebook_edit"]:
|
|
299
|
+
enabled_tools[tool_name] = False
|
|
300
|
+
|
|
301
|
+
if hasattr(args, 'disable_shell_tools') and args.disable_shell_tools:
|
|
302
|
+
enabled_tools["run_command"] = False
|
|
303
|
+
|
|
304
|
+
if hasattr(args, 'disable_todo_tools') and args.disable_todo_tools:
|
|
305
|
+
for tool_name in ["todo_read", "todo_write"]:
|
|
306
|
+
enabled_tools[tool_name] = False
|
|
307
|
+
|
|
308
|
+
if enabled_tools:
|
|
309
|
+
overrides["enabled_tools"] = enabled_tools
|
|
310
|
+
|
|
311
|
+
# Agent configuration
|
|
312
|
+
agent_config = {}
|
|
313
|
+
if hasattr(args, 'agent_model') and args.agent_model:
|
|
314
|
+
agent_config["model"] = args.agent_model
|
|
315
|
+
agent_config["enabled"] = True
|
|
316
|
+
if hasattr(args, 'agent_api_key') and args.agent_api_key:
|
|
317
|
+
agent_config["api_key"] = args.agent_api_key
|
|
318
|
+
if hasattr(args, 'agent_base_url') and args.agent_base_url:
|
|
319
|
+
agent_config["base_url"] = args.agent_base_url
|
|
320
|
+
if hasattr(args, 'agent_max_tokens') and args.agent_max_tokens:
|
|
321
|
+
agent_config["max_tokens"] = args.agent_max_tokens
|
|
322
|
+
if hasattr(args, 'agent_max_iterations') and args.agent_max_iterations != 10:
|
|
323
|
+
agent_config["max_iterations"] = args.agent_max_iterations
|
|
324
|
+
if hasattr(args, 'agent_max_tool_uses') and args.agent_max_tool_uses != 30:
|
|
325
|
+
agent_config["max_tool_uses"] = args.agent_max_tool_uses
|
|
326
|
+
|
|
327
|
+
if agent_config:
|
|
328
|
+
overrides["agent"] = agent_config
|
|
329
|
+
|
|
330
|
+
# Vector store configuration
|
|
331
|
+
vector_config = {}
|
|
332
|
+
if hasattr(args, 'enable_vector_store') and args.enable_vector_store:
|
|
333
|
+
vector_config["enabled"] = True
|
|
334
|
+
if hasattr(args, 'vector_store_path') and args.vector_store_path:
|
|
335
|
+
vector_config["data_path"] = args.vector_store_path
|
|
336
|
+
if hasattr(args, 'embedding_model') and args.embedding_model != "text-embedding-3-small":
|
|
337
|
+
vector_config["embedding_model"] = args.embedding_model
|
|
338
|
+
|
|
339
|
+
if vector_config:
|
|
340
|
+
overrides["vector_store"] = vector_config
|
|
341
|
+
|
|
342
|
+
return overrides
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
def list_tools(settings: HanzoMCPSettings) -> None:
|
|
346
|
+
"""List all tools and their current status."""
|
|
347
|
+
print("Hanzo MCP Tools Status:")
|
|
348
|
+
print("=" * 50)
|
|
349
|
+
|
|
350
|
+
categories = {}
|
|
351
|
+
for tool_name, tool_config in TOOL_REGISTRY.items():
|
|
352
|
+
category = tool_config.category.value
|
|
353
|
+
if category not in categories:
|
|
354
|
+
categories[category] = []
|
|
355
|
+
|
|
356
|
+
enabled = settings.is_tool_enabled(tool_name)
|
|
357
|
+
status = "✅ ENABLED " if enabled else "❌ DISABLED"
|
|
358
|
+
categories[category].append((tool_name, status, tool_config.description))
|
|
359
|
+
|
|
360
|
+
for category, tools in categories.items():
|
|
361
|
+
print(f"\n{category.upper()} TOOLS:")
|
|
362
|
+
print("-" * 30)
|
|
363
|
+
for tool_name, status, description in tools:
|
|
364
|
+
print(f" {status} {tool_name:<15} - {description}")
|
|
365
|
+
|
|
366
|
+
print(f"\nTotal: {len(TOOL_REGISTRY)} tools")
|
|
367
|
+
enabled_count = len(settings.get_enabled_tools())
|
|
368
|
+
print(f"Enabled: {enabled_count}, Disabled: {len(TOOL_REGISTRY) - enabled_count}")
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
def main() -> None:
|
|
372
|
+
"""Run the enhanced CLI for the Hanzo MCP server."""
|
|
373
|
+
parser = create_parser()
|
|
374
|
+
args = parser.parse_args()
|
|
375
|
+
|
|
376
|
+
# Handle list tools command
|
|
377
|
+
if hasattr(args, 'list_tools') and args.list_tools:
|
|
378
|
+
settings = load_settings()
|
|
379
|
+
list_tools(settings)
|
|
380
|
+
return
|
|
381
|
+
|
|
382
|
+
# Load configuration with CLI overrides
|
|
383
|
+
config_overrides = apply_cli_overrides(args)
|
|
384
|
+
project_dir = getattr(args, 'project_dir', None)
|
|
385
|
+
settings = load_settings(project_dir=project_dir, config_overrides=config_overrides)
|
|
386
|
+
|
|
387
|
+
# Handle configuration saving
|
|
388
|
+
if hasattr(args, 'save_config') and args.save_config:
|
|
389
|
+
saved_path = save_settings(settings, global_config=True)
|
|
390
|
+
print(f"Configuration saved to: {saved_path}")
|
|
391
|
+
return
|
|
392
|
+
|
|
393
|
+
if hasattr(args, 'save_project_config') and args.save_project_config:
|
|
394
|
+
saved_path = save_settings(settings, global_config=False)
|
|
395
|
+
print(f"Project configuration saved to: {saved_path}")
|
|
396
|
+
return
|
|
397
|
+
|
|
398
|
+
# Handle installation
|
|
399
|
+
if hasattr(args, 'install') and args.install:
|
|
400
|
+
from hanzo_mcp.cli import install_claude_desktop_config
|
|
401
|
+
install_claude_desktop_config(
|
|
402
|
+
settings.server.name,
|
|
403
|
+
settings.allowed_paths,
|
|
404
|
+
)
|
|
405
|
+
return
|
|
406
|
+
|
|
407
|
+
# Set up allowed paths
|
|
408
|
+
allowed_paths = settings.allowed_paths[:]
|
|
409
|
+
if settings.project_dir and settings.project_dir not in allowed_paths:
|
|
410
|
+
allowed_paths.append(settings.project_dir)
|
|
411
|
+
|
|
412
|
+
if not allowed_paths:
|
|
413
|
+
allowed_paths = [os.getcwd()]
|
|
414
|
+
|
|
415
|
+
# Create and run server
|
|
416
|
+
server = HanzoMCPServer(
|
|
417
|
+
name=settings.server.name,
|
|
418
|
+
allowed_paths=allowed_paths,
|
|
419
|
+
project_dir=settings.project_dir,
|
|
420
|
+
agent_model=settings.agent.model,
|
|
421
|
+
agent_max_tokens=settings.agent.max_tokens,
|
|
422
|
+
agent_api_key=settings.agent.api_key,
|
|
423
|
+
agent_base_url=settings.agent.base_url,
|
|
424
|
+
agent_max_iterations=settings.agent.max_iterations,
|
|
425
|
+
agent_max_tool_uses=settings.agent.max_tool_uses,
|
|
426
|
+
enable_agent_tool=settings.agent.enabled or settings.is_tool_enabled("dispatch_agent"),
|
|
427
|
+
disable_write_tools=not any(settings.is_tool_enabled(t) for t in ["write", "edit", "multi_edit", "content_replace"]),
|
|
428
|
+
disable_search_tools=not any(settings.is_tool_enabled(t) for t in ["grep", "grep_ast"]),
|
|
429
|
+
host=settings.server.host,
|
|
430
|
+
port=settings.server.port,
|
|
431
|
+
enabled_tools=settings.enabled_tools, # Pass individual tool configuration
|
|
432
|
+
)
|
|
433
|
+
|
|
434
|
+
server.run(transport=settings.server.transport)
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
if __name__ == "__main__":
|
|
438
|
+
main()
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Configuration management for Hanzo MCP.
|
|
2
|
+
|
|
3
|
+
This module provides a comprehensive configuration system that supports:
|
|
4
|
+
- CLI arguments for individual tool control
|
|
5
|
+
- Configuration files for persistent settings
|
|
6
|
+
- Environment variable overrides
|
|
7
|
+
- Per-project settings
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from .settings import HanzoMCPSettings, load_settings, save_settings
|
|
11
|
+
from .tool_config import ToolConfig, ToolCategory
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"HanzoMCPSettings",
|
|
15
|
+
"ToolConfig",
|
|
16
|
+
"ToolCategory",
|
|
17
|
+
"load_settings",
|
|
18
|
+
"save_settings",
|
|
19
|
+
]
|