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/__init__.py
CHANGED
hanzo_mcp/cli.py
CHANGED
|
@@ -1,41 +1,19 @@
|
|
|
1
|
-
"""Command-line interface for the Hanzo MCP server.
|
|
2
|
-
|
|
3
|
-
Includes logging configuration and enhanced error handling.
|
|
4
|
-
"""
|
|
1
|
+
"""Command-line interface for the Hanzo MCP server."""
|
|
5
2
|
|
|
6
3
|
import argparse
|
|
7
4
|
import json
|
|
8
|
-
import logging
|
|
9
5
|
import os
|
|
10
6
|
import sys
|
|
11
7
|
from pathlib import Path
|
|
12
8
|
from typing import Any, cast
|
|
13
9
|
|
|
14
|
-
from hanzo_mcp import
|
|
15
|
-
from hanzo_mcp.tools.common.logging_config import setup_logging
|
|
16
|
-
|
|
17
|
-
from hanzo_mcp.server import HanzoServer
|
|
10
|
+
from hanzo_mcp.server import HanzoMCPServer
|
|
18
11
|
|
|
19
12
|
|
|
20
13
|
def main() -> None:
|
|
21
14
|
"""Run the CLI for the Hanzo MCP server."""
|
|
22
|
-
# Initialize logger
|
|
23
|
-
logger = logging.getLogger(__name__)
|
|
24
|
-
|
|
25
|
-
# Check if 'version' is the first argument
|
|
26
|
-
if len(sys.argv) > 1 and sys.argv[1] == 'version':
|
|
27
|
-
print(f"hanzo-mcp {__version__}")
|
|
28
|
-
return
|
|
29
|
-
|
|
30
15
|
parser = argparse.ArgumentParser(
|
|
31
|
-
description="MCP server implementing Hanzo capabilities"
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
parser.add_argument(
|
|
35
|
-
"--version",
|
|
36
|
-
action="version",
|
|
37
|
-
version=f"%(prog)s {__version__}",
|
|
38
|
-
help="Show the current version and exit"
|
|
16
|
+
description="MCP server implementing Hanzo AI capabilities"
|
|
39
17
|
)
|
|
40
18
|
|
|
41
19
|
_ = parser.add_argument(
|
|
@@ -45,53 +23,49 @@ def main() -> None:
|
|
|
45
23
|
help="Transport protocol to use (default: stdio)",
|
|
46
24
|
)
|
|
47
25
|
|
|
48
|
-
_ = parser.add_argument(
|
|
49
|
-
"--port",
|
|
50
|
-
type=int,
|
|
51
|
-
default=3001,
|
|
52
|
-
help="Port to use for SSE transport (default: 3001)",
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
_ = parser.add_argument(
|
|
56
|
-
"--host",
|
|
57
|
-
default="0.0.0.0",
|
|
58
|
-
help="Host to bind to for SSE transport (default: 0.0.0.0)",
|
|
59
|
-
)
|
|
60
|
-
|
|
61
26
|
_ = parser.add_argument(
|
|
62
27
|
"--name",
|
|
63
|
-
default="
|
|
64
|
-
help="Name of the MCP server (default:
|
|
28
|
+
default="hanzo-mcp",
|
|
29
|
+
help="Name of the MCP server (default: hanzo-mcp)",
|
|
65
30
|
)
|
|
66
31
|
|
|
67
32
|
_ = parser.add_argument(
|
|
68
33
|
"--allow-path",
|
|
69
34
|
action="append",
|
|
70
35
|
dest="allowed_paths",
|
|
71
|
-
help="Add an allowed path (can be specified multiple times
|
|
36
|
+
help="Add an allowed path (can be specified multiple times)",
|
|
72
37
|
)
|
|
73
38
|
|
|
74
39
|
_ = parser.add_argument(
|
|
75
|
-
"--project
|
|
40
|
+
"--project",
|
|
41
|
+
action="append",
|
|
42
|
+
dest="project_paths",
|
|
43
|
+
help="Add a project path for prompt generation (can be specified multiple times)",
|
|
76
44
|
)
|
|
77
45
|
|
|
78
46
|
_ = parser.add_argument(
|
|
79
47
|
"--agent-model",
|
|
80
48
|
dest="agent_model",
|
|
81
|
-
help="Specify the model name in LiteLLM format (e.g., 'openai/gpt-4o', 'anthropic/claude-
|
|
49
|
+
help="Specify the model name in LiteLLM format (e.g., 'openai/gpt-4o', 'anthropic/claude-4-sonnet')",
|
|
82
50
|
)
|
|
83
51
|
|
|
84
52
|
_ = parser.add_argument(
|
|
85
53
|
"--agent-max-tokens",
|
|
86
54
|
dest="agent_max_tokens",
|
|
87
55
|
type=int,
|
|
88
|
-
help="Specify the maximum tokens for agent responses"
|
|
56
|
+
help="Specify the maximum tokens for agent responses",
|
|
89
57
|
)
|
|
90
58
|
|
|
91
59
|
_ = parser.add_argument(
|
|
92
60
|
"--agent-api-key",
|
|
93
61
|
dest="agent_api_key",
|
|
94
|
-
help="Specify the API key for the LLM provider (for development/testing only)"
|
|
62
|
+
help="Specify the API key for the LLM provider (for development/testing only)",
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
_ = parser.add_argument(
|
|
66
|
+
"--agent-base-url",
|
|
67
|
+
dest="agent_base_url",
|
|
68
|
+
help="Specify the base URL for the LLM provider API endpoint (e.g., 'http://localhost:1234/v1')",
|
|
95
69
|
)
|
|
96
70
|
|
|
97
71
|
_ = parser.add_argument(
|
|
@@ -99,7 +73,7 @@ def main() -> None:
|
|
|
99
73
|
dest="agent_max_iterations",
|
|
100
74
|
type=int,
|
|
101
75
|
default=10,
|
|
102
|
-
help="Maximum number of iterations for agent (default: 10)"
|
|
76
|
+
help="Maximum number of iterations for agent (default: 10)",
|
|
103
77
|
)
|
|
104
78
|
|
|
105
79
|
_ = parser.add_argument(
|
|
@@ -107,7 +81,7 @@ def main() -> None:
|
|
|
107
81
|
dest="agent_max_tool_uses",
|
|
108
82
|
type=int,
|
|
109
83
|
default=30,
|
|
110
|
-
help="Maximum number of total tool uses for agent (default: 30)"
|
|
84
|
+
help="Maximum number of total tool uses for agent (default: 30)",
|
|
111
85
|
)
|
|
112
86
|
|
|
113
87
|
_ = parser.add_argument(
|
|
@@ -115,47 +89,60 @@ def main() -> None:
|
|
|
115
89
|
dest="enable_agent_tool",
|
|
116
90
|
action="store_true",
|
|
117
91
|
default=False,
|
|
118
|
-
help="Enable the agent tool (disabled by default)"
|
|
92
|
+
help="Enable the agent tool (disabled by default)",
|
|
119
93
|
)
|
|
120
94
|
|
|
121
95
|
_ = parser.add_argument(
|
|
122
|
-
"--
|
|
123
|
-
dest="
|
|
124
|
-
|
|
125
|
-
default=
|
|
126
|
-
help="
|
|
96
|
+
"--command-timeout",
|
|
97
|
+
dest="command_timeout",
|
|
98
|
+
type=float,
|
|
99
|
+
default=120.0,
|
|
100
|
+
help="Default timeout for command execution in seconds (default: 120.0)",
|
|
127
101
|
)
|
|
128
102
|
|
|
129
103
|
_ = parser.add_argument(
|
|
130
|
-
"--disable-
|
|
131
|
-
dest="
|
|
104
|
+
"--disable-write-tools",
|
|
105
|
+
dest="disable_write_tools",
|
|
132
106
|
action="store_true",
|
|
133
107
|
default=False,
|
|
134
|
-
help="Disable
|
|
108
|
+
help="Disable write tools (edit, write, etc.)",
|
|
135
109
|
)
|
|
136
|
-
|
|
110
|
+
|
|
137
111
|
_ = parser.add_argument(
|
|
138
|
-
"--
|
|
139
|
-
dest="
|
|
112
|
+
"--disable-search-tools",
|
|
113
|
+
dest="disable_search_tools",
|
|
140
114
|
action="store_true",
|
|
141
115
|
default=False,
|
|
142
|
-
help="
|
|
116
|
+
help="Disable search tools (grep, search_content, etc.)",
|
|
143
117
|
)
|
|
144
118
|
|
|
145
119
|
_ = parser.add_argument(
|
|
146
|
-
"--
|
|
147
|
-
dest="
|
|
148
|
-
|
|
149
|
-
default
|
|
150
|
-
help="Disable write/edit tools (file writing, editing, notebook editing) to use IDE tools instead. Note: Shell commands can still modify files."
|
|
120
|
+
"--host",
|
|
121
|
+
dest="host",
|
|
122
|
+
default="127.0.0.1",
|
|
123
|
+
help="Host for SSE server (default: 127.0.0.1)",
|
|
151
124
|
)
|
|
152
125
|
|
|
153
126
|
_ = parser.add_argument(
|
|
154
|
-
"--
|
|
155
|
-
dest="
|
|
156
|
-
|
|
157
|
-
default=
|
|
158
|
-
help="
|
|
127
|
+
"--port",
|
|
128
|
+
dest="port",
|
|
129
|
+
type=int,
|
|
130
|
+
default=3000,
|
|
131
|
+
help="Port for SSE server (default: 3000)",
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
_ = parser.add_argument(
|
|
135
|
+
"--log-level",
|
|
136
|
+
dest="log_level",
|
|
137
|
+
default="INFO",
|
|
138
|
+
choices=["DEBUG", "INFO", "WARNING", "ERROR"],
|
|
139
|
+
help="Logging level (default: INFO)",
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
_ = parser.add_argument(
|
|
143
|
+
"--project-dir",
|
|
144
|
+
dest="project_dir",
|
|
145
|
+
help="Single project directory (alias for --project)",
|
|
159
146
|
)
|
|
160
147
|
|
|
161
148
|
_ = parser.add_argument(
|
|
@@ -170,120 +157,87 @@ def main() -> None:
|
|
|
170
157
|
name: str = cast(str, args.name)
|
|
171
158
|
install: bool = cast(bool, args.install)
|
|
172
159
|
transport: str = cast(str, args.transport)
|
|
173
|
-
port: int = cast(int, args.port)
|
|
174
|
-
host: str = cast(str, args.host)
|
|
175
|
-
project_dir: str | None = cast(str | None, args.project_dir)
|
|
176
160
|
agent_model: str | None = cast(str | None, args.agent_model)
|
|
177
161
|
agent_max_tokens: int | None = cast(int | None, args.agent_max_tokens)
|
|
178
162
|
agent_api_key: str | None = cast(str | None, args.agent_api_key)
|
|
163
|
+
agent_base_url: str | None = cast(str | None, args.agent_base_url)
|
|
179
164
|
agent_max_iterations: int = cast(int, args.agent_max_iterations)
|
|
180
165
|
agent_max_tool_uses: int = cast(int, args.agent_max_tool_uses)
|
|
181
166
|
enable_agent_tool: bool = cast(bool, args.enable_agent_tool)
|
|
167
|
+
command_timeout: float = cast(float, args.command_timeout)
|
|
182
168
|
disable_write_tools: bool = cast(bool, args.disable_write_tools)
|
|
183
169
|
disable_search_tools: bool = cast(bool, args.disable_search_tools)
|
|
170
|
+
host: str = cast(str, args.host)
|
|
171
|
+
port: int = cast(int, args.port)
|
|
184
172
|
log_level: str = cast(str, args.log_level)
|
|
185
|
-
|
|
186
|
-
enable_console_logging: bool = cast(bool, args.enable_console_logging)
|
|
173
|
+
project_dir: str | None = cast(str | None, args.project_dir)
|
|
187
174
|
allowed_paths: list[str] = (
|
|
188
175
|
cast(list[str], args.allowed_paths) if args.allowed_paths else []
|
|
189
176
|
)
|
|
177
|
+
project_paths: list[str] = (
|
|
178
|
+
cast(list[str], args.project_paths) if args.project_paths else []
|
|
179
|
+
)
|
|
190
180
|
|
|
191
|
-
#
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
log_level=log_level,
|
|
198
|
-
log_to_file=not disable_file_logging and transport != "stdio", # Disable file logging for stdio transport
|
|
199
|
-
log_to_console=enable_console_logging and transport != "stdio", # Only enable console logging if requested AND not using stdio
|
|
200
|
-
transport=transport, # Pass the transport to ensure it's properly handled
|
|
201
|
-
testing="pytest" in sys.modules
|
|
202
|
-
)
|
|
203
|
-
logger.debug(f"Hanzo MCP CLI started with arguments: {args}")
|
|
204
|
-
# No logging setup at all for stdio transport unless explicitly requested
|
|
205
|
-
|
|
181
|
+
# Handle project_dir parameter (add to both allowed_paths and project_paths)
|
|
182
|
+
if project_dir:
|
|
183
|
+
if project_dir not in allowed_paths:
|
|
184
|
+
allowed_paths.append(project_dir)
|
|
185
|
+
if project_dir not in project_paths:
|
|
186
|
+
project_paths.append(project_dir)
|
|
206
187
|
|
|
207
188
|
if install:
|
|
208
|
-
install_claude_desktop_config(
|
|
189
|
+
install_claude_desktop_config(
|
|
190
|
+
name,
|
|
191
|
+
allowed_paths,
|
|
192
|
+
disable_write_tools,
|
|
193
|
+
disable_search_tools,
|
|
194
|
+
host,
|
|
195
|
+
port
|
|
196
|
+
)
|
|
209
197
|
return
|
|
210
198
|
|
|
211
|
-
# If no allowed paths are specified, use the
|
|
199
|
+
# If no allowed paths are specified, use the current directory
|
|
212
200
|
if not allowed_paths:
|
|
213
|
-
allowed_paths = [
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
allowed_paths
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
logger.debug(f"Allowed paths: {allowed_paths}")
|
|
235
|
-
logger.debug(f"Project directory: {project_dir}")
|
|
236
|
-
|
|
237
|
-
try:
|
|
238
|
-
server = HanzoServer(
|
|
239
|
-
name=name,
|
|
240
|
-
allowed_paths=allowed_paths,
|
|
241
|
-
project_dir=project_dir, # Pass project_dir for initial working directory
|
|
242
|
-
agent_model=agent_model,
|
|
243
|
-
agent_max_tokens=agent_max_tokens,
|
|
244
|
-
agent_api_key=agent_api_key,
|
|
245
|
-
agent_max_iterations=agent_max_iterations,
|
|
246
|
-
agent_max_tool_uses=agent_max_tool_uses,
|
|
247
|
-
enable_agent_tool=enable_agent_tool,
|
|
248
|
-
disable_write_tools=disable_write_tools,
|
|
249
|
-
disable_search_tools=disable_search_tools,
|
|
250
|
-
host=host,
|
|
251
|
-
port=port
|
|
252
|
-
)
|
|
253
|
-
|
|
254
|
-
# Only log if not using stdio transport or logging is explicitly enabled
|
|
255
|
-
if transport != "stdio" or (enable_console_logging or not disable_file_logging):
|
|
256
|
-
logger.info(f"Server initialized successfully, running with transport: {transport}")
|
|
257
|
-
|
|
258
|
-
# Transport will be automatically cast to Literal['stdio', 'sse'] by the server
|
|
259
|
-
server.run(transport=transport)
|
|
260
|
-
except Exception as e:
|
|
261
|
-
# Only log if not using stdio transport or logging is explicitly enabled
|
|
262
|
-
if transport != "stdio" or (enable_console_logging or not disable_file_logging):
|
|
263
|
-
logger.error(f"Error starting server: {str(e)}")
|
|
264
|
-
logger.exception("Server startup failed with exception:")
|
|
265
|
-
# For stdio transport, we want a clean exception without any logging
|
|
266
|
-
# Re-raise the exception for proper error handling
|
|
267
|
-
raise
|
|
201
|
+
allowed_paths = [os.getcwd()]
|
|
202
|
+
|
|
203
|
+
# Run the server
|
|
204
|
+
server = HanzoMCPServer(
|
|
205
|
+
name=name,
|
|
206
|
+
allowed_paths=allowed_paths,
|
|
207
|
+
project_dir=project_dir,
|
|
208
|
+
agent_model=agent_model,
|
|
209
|
+
agent_max_tokens=agent_max_tokens,
|
|
210
|
+
agent_api_key=agent_api_key,
|
|
211
|
+
agent_base_url=agent_base_url,
|
|
212
|
+
agent_max_iterations=agent_max_iterations,
|
|
213
|
+
agent_max_tool_uses=agent_max_tool_uses,
|
|
214
|
+
enable_agent_tool=enable_agent_tool,
|
|
215
|
+
disable_write_tools=disable_write_tools,
|
|
216
|
+
disable_search_tools=disable_search_tools,
|
|
217
|
+
host=host,
|
|
218
|
+
port=port,
|
|
219
|
+
)
|
|
220
|
+
# Transport will be automatically cast to Literal['stdio', 'sse'] by the server
|
|
221
|
+
server.run(transport=transport)
|
|
268
222
|
|
|
269
223
|
|
|
270
224
|
def install_claude_desktop_config(
|
|
271
|
-
name: str = "
|
|
272
|
-
|
|
273
|
-
|
|
225
|
+
name: str = "hanzo-mcp",
|
|
226
|
+
allowed_paths: list[str] | None = None,
|
|
227
|
+
disable_write_tools: bool = False,
|
|
228
|
+
disable_search_tools: bool = False,
|
|
229
|
+
host: str = "127.0.0.1",
|
|
230
|
+
port: int = 3000,
|
|
274
231
|
) -> None:
|
|
275
232
|
"""Install the server configuration in Claude Desktop.
|
|
276
233
|
|
|
277
234
|
Args:
|
|
278
235
|
name: The name to use for the server in the config
|
|
279
236
|
allowed_paths: Optional list of paths to allow
|
|
280
|
-
disable_write_tools: Whether to disable write
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
semantic search capabilities. (default: False)
|
|
285
|
-
host: Host to bind to for SSE transport (default: '0.0.0.0')
|
|
286
|
-
port: Port to use for SSE transport (default: 3001)
|
|
237
|
+
disable_write_tools: Whether to disable write tools
|
|
238
|
+
disable_search_tools: Whether to disable search tools
|
|
239
|
+
host: Host for SSE server
|
|
240
|
+
port: Port for SSE server
|
|
287
241
|
"""
|
|
288
242
|
# Find the Claude Desktop config directory
|
|
289
243
|
home: Path = Path.home()
|
|
@@ -314,25 +268,16 @@ def install_claude_desktop_config(
|
|
|
314
268
|
# Allow home directory by default
|
|
315
269
|
args.extend(["--allow-path", str(home)])
|
|
316
270
|
|
|
317
|
-
# Add
|
|
318
|
-
args.extend(["--host", host])
|
|
319
|
-
args.extend(["--port", str(port)])
|
|
320
|
-
|
|
321
|
-
# Add disable_write_tools flag if specified
|
|
271
|
+
# Add tool disable flags if specified
|
|
322
272
|
if disable_write_tools:
|
|
323
273
|
args.append("--disable-write-tools")
|
|
324
|
-
|
|
325
|
-
# Add disable_search_tools flag if specified
|
|
274
|
+
|
|
326
275
|
if disable_search_tools:
|
|
327
276
|
args.append("--disable-search-tools")
|
|
328
277
|
|
|
329
|
-
# Add host and port
|
|
330
|
-
args.extend(["--host", host])
|
|
331
|
-
args.extend(["--port", str(port)])
|
|
332
|
-
|
|
333
278
|
# Create config object
|
|
334
279
|
config: dict[str, Any] = {
|
|
335
|
-
"mcpServers": {name: {"command":
|
|
280
|
+
"mcpServers": {name: {"command": script_path.as_posix(), "args": args}}
|
|
336
281
|
}
|
|
337
282
|
|
|
338
283
|
# Check if the file already exists
|
|
@@ -364,7 +309,10 @@ def install_claude_desktop_config(
|
|
|
364
309
|
print(f"- {path}")
|
|
365
310
|
else:
|
|
366
311
|
print(f"\nDefault allowed path: {home}")
|
|
367
|
-
|
|
312
|
+
|
|
313
|
+
print(
|
|
314
|
+
"\nYou can modify allowed paths in the config file directly."
|
|
315
|
+
)
|
|
368
316
|
print("Restart Claude Desktop for changes to take effect.")
|
|
369
317
|
|
|
370
318
|
|