hanzo-mcp 0.7.7__py3-none-any.whl → 0.8.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 +6 -0
- hanzo_mcp/__main__.py +1 -1
- hanzo_mcp/analytics/__init__.py +2 -2
- hanzo_mcp/analytics/posthog_analytics.py +76 -82
- hanzo_mcp/cli.py +31 -36
- hanzo_mcp/cli_enhanced.py +94 -72
- hanzo_mcp/cli_plugin.py +27 -17
- hanzo_mcp/config/__init__.py +2 -2
- hanzo_mcp/config/settings.py +112 -88
- hanzo_mcp/config/tool_config.py +32 -34
- hanzo_mcp/dev_server.py +66 -67
- hanzo_mcp/prompts/__init__.py +94 -12
- hanzo_mcp/prompts/enhanced_prompts.py +809 -0
- hanzo_mcp/prompts/example_custom_prompt.py +6 -5
- hanzo_mcp/prompts/project_todo_reminder.py +0 -1
- hanzo_mcp/prompts/tool_explorer.py +10 -7
- hanzo_mcp/server.py +17 -21
- hanzo_mcp/server_enhanced.py +15 -22
- hanzo_mcp/tools/__init__.py +56 -28
- hanzo_mcp/tools/agent/__init__.py +16 -19
- hanzo_mcp/tools/agent/agent.py +82 -65
- hanzo_mcp/tools/agent/agent_tool.py +152 -122
- hanzo_mcp/tools/agent/agent_tool_v1_deprecated.py +66 -62
- hanzo_mcp/tools/agent/clarification_protocol.py +55 -50
- hanzo_mcp/tools/agent/clarification_tool.py +11 -10
- hanzo_mcp/tools/agent/claude_cli_tool.py +21 -20
- hanzo_mcp/tools/agent/claude_desktop_auth.py +130 -144
- hanzo_mcp/tools/agent/cli_agent_base.py +59 -53
- hanzo_mcp/tools/agent/code_auth.py +102 -107
- hanzo_mcp/tools/agent/code_auth_tool.py +28 -27
- hanzo_mcp/tools/agent/codex_cli_tool.py +20 -19
- hanzo_mcp/tools/agent/critic_tool.py +86 -73
- hanzo_mcp/tools/agent/gemini_cli_tool.py +21 -20
- hanzo_mcp/tools/agent/grok_cli_tool.py +21 -20
- hanzo_mcp/tools/agent/iching_tool.py +404 -139
- hanzo_mcp/tools/agent/network_tool.py +89 -73
- hanzo_mcp/tools/agent/prompt.py +2 -1
- hanzo_mcp/tools/agent/review_tool.py +101 -98
- hanzo_mcp/tools/agent/swarm_alias.py +87 -0
- hanzo_mcp/tools/agent/swarm_tool.py +246 -161
- hanzo_mcp/tools/agent/swarm_tool_v1_deprecated.py +134 -92
- hanzo_mcp/tools/agent/tool_adapter.py +21 -11
- hanzo_mcp/tools/common/__init__.py +1 -1
- hanzo_mcp/tools/common/base.py +3 -5
- hanzo_mcp/tools/common/batch_tool.py +46 -39
- hanzo_mcp/tools/common/config_tool.py +120 -84
- hanzo_mcp/tools/common/context.py +1 -5
- hanzo_mcp/tools/common/context_fix.py +5 -3
- hanzo_mcp/tools/common/critic_tool.py +4 -8
- hanzo_mcp/tools/common/decorators.py +58 -56
- hanzo_mcp/tools/common/enhanced_base.py +29 -32
- hanzo_mcp/tools/common/fastmcp_pagination.py +91 -94
- hanzo_mcp/tools/common/forgiving_edit.py +91 -87
- hanzo_mcp/tools/common/mode.py +15 -17
- hanzo_mcp/tools/common/mode_loader.py +27 -24
- hanzo_mcp/tools/common/paginated_base.py +61 -53
- hanzo_mcp/tools/common/paginated_response.py +72 -79
- hanzo_mcp/tools/common/pagination.py +50 -53
- hanzo_mcp/tools/common/permissions.py +4 -4
- hanzo_mcp/tools/common/personality.py +186 -138
- hanzo_mcp/tools/common/plugin_loader.py +54 -54
- hanzo_mcp/tools/common/stats.py +65 -47
- hanzo_mcp/tools/common/test_helpers.py +31 -0
- hanzo_mcp/tools/common/thinking_tool.py +4 -8
- hanzo_mcp/tools/common/tool_disable.py +17 -12
- hanzo_mcp/tools/common/tool_enable.py +13 -14
- hanzo_mcp/tools/common/tool_list.py +36 -28
- hanzo_mcp/tools/common/truncate.py +23 -23
- hanzo_mcp/tools/config/__init__.py +4 -4
- hanzo_mcp/tools/config/config_tool.py +42 -29
- hanzo_mcp/tools/config/index_config.py +37 -34
- hanzo_mcp/tools/config/mode_tool.py +175 -55
- hanzo_mcp/tools/database/__init__.py +15 -12
- hanzo_mcp/tools/database/database_manager.py +77 -75
- hanzo_mcp/tools/database/graph.py +137 -91
- hanzo_mcp/tools/database/graph_add.py +30 -18
- hanzo_mcp/tools/database/graph_query.py +178 -102
- hanzo_mcp/tools/database/graph_remove.py +33 -28
- hanzo_mcp/tools/database/graph_search.py +97 -75
- hanzo_mcp/tools/database/graph_stats.py +91 -59
- hanzo_mcp/tools/database/sql.py +107 -79
- hanzo_mcp/tools/database/sql_query.py +30 -24
- hanzo_mcp/tools/database/sql_search.py +29 -25
- hanzo_mcp/tools/database/sql_stats.py +47 -35
- hanzo_mcp/tools/editor/neovim_command.py +25 -28
- hanzo_mcp/tools/editor/neovim_edit.py +21 -23
- hanzo_mcp/tools/editor/neovim_session.py +60 -54
- hanzo_mcp/tools/filesystem/__init__.py +31 -30
- hanzo_mcp/tools/filesystem/ast_multi_edit.py +329 -249
- hanzo_mcp/tools/filesystem/ast_tool.py +4 -4
- hanzo_mcp/tools/filesystem/base.py +1 -1
- hanzo_mcp/tools/filesystem/batch_search.py +316 -224
- hanzo_mcp/tools/filesystem/content_replace.py +4 -4
- hanzo_mcp/tools/filesystem/diff.py +71 -59
- hanzo_mcp/tools/filesystem/directory_tree.py +7 -7
- hanzo_mcp/tools/filesystem/directory_tree_paginated.py +49 -37
- hanzo_mcp/tools/filesystem/edit.py +4 -4
- hanzo_mcp/tools/filesystem/find.py +173 -80
- hanzo_mcp/tools/filesystem/find_files.py +73 -52
- hanzo_mcp/tools/filesystem/git_search.py +157 -104
- hanzo_mcp/tools/filesystem/grep.py +8 -8
- hanzo_mcp/tools/filesystem/multi_edit.py +4 -8
- hanzo_mcp/tools/filesystem/read.py +12 -10
- hanzo_mcp/tools/filesystem/rules_tool.py +59 -43
- hanzo_mcp/tools/filesystem/search_tool.py +263 -207
- hanzo_mcp/tools/filesystem/symbols_tool.py +94 -54
- hanzo_mcp/tools/filesystem/tree.py +35 -33
- hanzo_mcp/tools/filesystem/unix_aliases.py +13 -18
- hanzo_mcp/tools/filesystem/watch.py +37 -36
- hanzo_mcp/tools/filesystem/write.py +4 -8
- hanzo_mcp/tools/jupyter/__init__.py +4 -4
- hanzo_mcp/tools/jupyter/base.py +4 -5
- hanzo_mcp/tools/jupyter/jupyter.py +67 -47
- hanzo_mcp/tools/jupyter/notebook_edit.py +4 -4
- hanzo_mcp/tools/jupyter/notebook_read.py +4 -7
- hanzo_mcp/tools/llm/__init__.py +5 -7
- hanzo_mcp/tools/llm/consensus_tool.py +72 -52
- hanzo_mcp/tools/llm/llm_manage.py +101 -60
- hanzo_mcp/tools/llm/llm_tool.py +226 -166
- hanzo_mcp/tools/llm/provider_tools.py +25 -26
- hanzo_mcp/tools/lsp/__init__.py +1 -1
- hanzo_mcp/tools/lsp/lsp_tool.py +228 -143
- hanzo_mcp/tools/mcp/__init__.py +2 -3
- hanzo_mcp/tools/mcp/mcp_add.py +27 -25
- hanzo_mcp/tools/mcp/mcp_remove.py +7 -8
- hanzo_mcp/tools/mcp/mcp_stats.py +23 -22
- hanzo_mcp/tools/mcp/mcp_tool.py +129 -98
- hanzo_mcp/tools/memory/__init__.py +39 -21
- hanzo_mcp/tools/memory/knowledge_tools.py +124 -99
- hanzo_mcp/tools/memory/memory_tools.py +90 -108
- hanzo_mcp/tools/search/__init__.py +7 -2
- hanzo_mcp/tools/search/find_tool.py +297 -212
- hanzo_mcp/tools/search/unified_search.py +366 -314
- hanzo_mcp/tools/shell/__init__.py +8 -7
- hanzo_mcp/tools/shell/auto_background.py +56 -49
- hanzo_mcp/tools/shell/base.py +1 -1
- hanzo_mcp/tools/shell/base_process.py +75 -75
- hanzo_mcp/tools/shell/bash_session.py +2 -2
- hanzo_mcp/tools/shell/bash_session_executor.py +4 -4
- hanzo_mcp/tools/shell/bash_tool.py +24 -31
- hanzo_mcp/tools/shell/command_executor.py +12 -12
- hanzo_mcp/tools/shell/logs.py +43 -33
- hanzo_mcp/tools/shell/npx.py +13 -13
- hanzo_mcp/tools/shell/npx_background.py +24 -21
- hanzo_mcp/tools/shell/npx_tool.py +18 -22
- hanzo_mcp/tools/shell/open.py +19 -21
- hanzo_mcp/tools/shell/pkill.py +31 -26
- hanzo_mcp/tools/shell/process_tool.py +32 -32
- hanzo_mcp/tools/shell/processes.py +57 -58
- hanzo_mcp/tools/shell/run_background.py +24 -25
- hanzo_mcp/tools/shell/run_command.py +5 -5
- hanzo_mcp/tools/shell/run_command_windows.py +5 -5
- hanzo_mcp/tools/shell/session_storage.py +3 -3
- hanzo_mcp/tools/shell/streaming_command.py +141 -126
- hanzo_mcp/tools/shell/uvx.py +24 -25
- hanzo_mcp/tools/shell/uvx_background.py +35 -33
- hanzo_mcp/tools/shell/uvx_tool.py +18 -22
- hanzo_mcp/tools/todo/__init__.py +6 -2
- hanzo_mcp/tools/todo/todo.py +50 -37
- hanzo_mcp/tools/todo/todo_read.py +5 -8
- hanzo_mcp/tools/todo/todo_write.py +5 -7
- hanzo_mcp/tools/vector/__init__.py +40 -28
- hanzo_mcp/tools/vector/ast_analyzer.py +176 -143
- hanzo_mcp/tools/vector/git_ingester.py +170 -179
- hanzo_mcp/tools/vector/index_tool.py +96 -44
- hanzo_mcp/tools/vector/infinity_store.py +283 -228
- hanzo_mcp/tools/vector/mock_infinity.py +39 -40
- hanzo_mcp/tools/vector/project_manager.py +88 -78
- hanzo_mcp/tools/vector/vector.py +59 -42
- hanzo_mcp/tools/vector/vector_index.py +30 -27
- hanzo_mcp/tools/vector/vector_search.py +64 -45
- hanzo_mcp/types.py +6 -4
- {hanzo_mcp-0.7.7.dist-info → hanzo_mcp-0.8.1.dist-info}/METADATA +1 -1
- hanzo_mcp-0.8.1.dist-info/RECORD +185 -0
- hanzo_mcp-0.7.7.dist-info/RECORD +0 -182
- {hanzo_mcp-0.7.7.dist-info → hanzo_mcp-0.8.1.dist-info}/WHEEL +0 -0
- {hanzo_mcp-0.7.7.dist-info → hanzo_mcp-0.8.1.dist-info}/entry_points.txt +0 -0
- {hanzo_mcp-0.7.7.dist-info → hanzo_mcp-0.8.1.dist-info}/top_level.txt +0 -0
hanzo_mcp/tools/mcp/__init__.py
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"""MCP management tools."""
|
|
2
2
|
|
|
3
|
-
from hanzo_mcp.tools.mcp.mcp_tool import MCPTool
|
|
4
|
-
|
|
5
3
|
# Legacy imports
|
|
6
4
|
from hanzo_mcp.tools.mcp.mcp_add import McpAddTool
|
|
7
|
-
from hanzo_mcp.tools.mcp.
|
|
5
|
+
from hanzo_mcp.tools.mcp.mcp_tool import MCPTool
|
|
8
6
|
from hanzo_mcp.tools.mcp.mcp_stats import McpStatsTool
|
|
7
|
+
from hanzo_mcp.tools.mcp.mcp_remove import McpRemoveTool
|
|
9
8
|
|
|
10
9
|
__all__ = [
|
|
11
10
|
"MCPTool",
|
hanzo_mcp/tools/mcp/mcp_add.py
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
"""Add MCP servers dynamically."""
|
|
2
2
|
|
|
3
3
|
import json
|
|
4
|
-
import subprocess
|
|
5
4
|
import shutil
|
|
6
|
-
from typing import
|
|
5
|
+
from typing import Any, Dict, Unpack, Optional, Annotated, TypedDict, final, override
|
|
7
6
|
from pathlib import Path
|
|
8
7
|
|
|
9
|
-
from mcp.server.fastmcp import Context as MCPContext
|
|
10
8
|
from pydantic import Field
|
|
9
|
+
from mcp.server.fastmcp import Context as MCPContext
|
|
11
10
|
|
|
12
11
|
from hanzo_mcp.tools.common.base import BaseTool
|
|
13
12
|
from hanzo_mcp.tools.common.context import create_tool_context
|
|
14
13
|
|
|
15
|
-
|
|
16
14
|
ServerCommand = Annotated[
|
|
17
15
|
str,
|
|
18
16
|
Field(
|
|
@@ -67,7 +65,7 @@ class McpAddParams(TypedDict, total=False):
|
|
|
67
65
|
@final
|
|
68
66
|
class McpAddTool(BaseTool):
|
|
69
67
|
"""Tool for adding MCP servers dynamically."""
|
|
70
|
-
|
|
68
|
+
|
|
71
69
|
# Class variable to store added servers
|
|
72
70
|
_mcp_servers: Dict[str, Dict[str, Any]] = {}
|
|
73
71
|
_config_file = Path.home() / ".hanzo" / "mcp" / "servers.json"
|
|
@@ -82,7 +80,7 @@ class McpAddTool(BaseTool):
|
|
|
82
80
|
"""Load servers from config file."""
|
|
83
81
|
if cls._config_file.exists():
|
|
84
82
|
try:
|
|
85
|
-
with open(cls._config_file,
|
|
83
|
+
with open(cls._config_file, "r") as f:
|
|
86
84
|
cls._mcp_servers = json.load(f)
|
|
87
85
|
except Exception:
|
|
88
86
|
cls._mcp_servers = {}
|
|
@@ -91,7 +89,7 @@ class McpAddTool(BaseTool):
|
|
|
91
89
|
def _save_servers(cls):
|
|
92
90
|
"""Save servers to config file."""
|
|
93
91
|
cls._config_file.parent.mkdir(parents=True, exist_ok=True)
|
|
94
|
-
with open(cls._config_file,
|
|
92
|
+
with open(cls._config_file, "w") as f:
|
|
95
93
|
json.dump(cls._mcp_servers, f, indent=2)
|
|
96
94
|
|
|
97
95
|
@classmethod
|
|
@@ -171,9 +169,7 @@ Use 'mcp_stats' to see all added servers and their status.
|
|
|
171
169
|
server_type = "unknown"
|
|
172
170
|
if command.startswith("npx"):
|
|
173
171
|
server_type = "node"
|
|
174
|
-
elif command.startswith("uvx"):
|
|
175
|
-
server_type = "python"
|
|
176
|
-
elif command.startswith("python"):
|
|
172
|
+
elif command.startswith("uvx") or command.startswith("python"):
|
|
177
173
|
server_type = "python"
|
|
178
174
|
elif command.startswith("node"):
|
|
179
175
|
server_type = "node"
|
|
@@ -182,16 +178,20 @@ Use 'mcp_stats' to see all added servers and their status.
|
|
|
182
178
|
full_command = [command]
|
|
183
179
|
if args:
|
|
184
180
|
import shlex
|
|
181
|
+
|
|
185
182
|
# If command contains spaces, split it first
|
|
186
|
-
if
|
|
183
|
+
if " " in command:
|
|
187
184
|
full_command = shlex.split(command)
|
|
188
185
|
full_command.extend(shlex.split(args))
|
|
189
186
|
else:
|
|
190
|
-
if
|
|
187
|
+
if " " in command:
|
|
191
188
|
import shlex
|
|
189
|
+
|
|
192
190
|
full_command = shlex.split(command)
|
|
193
191
|
|
|
194
|
-
await tool_ctx.info(
|
|
192
|
+
await tool_ctx.info(
|
|
193
|
+
f"Adding MCP server '{name}' with command: {' '.join(full_command)}"
|
|
194
|
+
)
|
|
195
195
|
|
|
196
196
|
# Create server configuration
|
|
197
197
|
server_config = {
|
|
@@ -203,7 +203,7 @@ Use 'mcp_stats' to see all added servers and their status.
|
|
|
203
203
|
"process_id": None,
|
|
204
204
|
"tools": [],
|
|
205
205
|
"resources": [],
|
|
206
|
-
"prompts": []
|
|
206
|
+
"prompts": [],
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
# Test if command is valid
|
|
@@ -211,7 +211,7 @@ Use 'mcp_stats' to see all added servers and their status.
|
|
|
211
211
|
try:
|
|
212
212
|
# Try to start the server briefly to validate
|
|
213
213
|
test_env = {**env} if env else {}
|
|
214
|
-
|
|
214
|
+
|
|
215
215
|
# Quick test to see if command exists
|
|
216
216
|
test_cmd = full_command[0]
|
|
217
217
|
if test_cmd == "npx":
|
|
@@ -220,11 +220,11 @@ Use 'mcp_stats' to see all added servers and their status.
|
|
|
220
220
|
elif test_cmd == "uvx":
|
|
221
221
|
if not shutil.which("uvx"):
|
|
222
222
|
return "Error: uvx not found. Install uv first."
|
|
223
|
-
|
|
223
|
+
|
|
224
224
|
# TODO: Actually start and connect to the MCP server
|
|
225
225
|
# For now, we just store the configuration
|
|
226
226
|
server_config["status"] = "ready"
|
|
227
|
-
|
|
227
|
+
|
|
228
228
|
except Exception as e:
|
|
229
229
|
await tool_ctx.error(f"Failed to validate server: {str(e)}")
|
|
230
230
|
server_config["status"] = "error"
|
|
@@ -240,22 +240,24 @@ Use 'mcp_stats' to see all added servers and their status.
|
|
|
240
240
|
f" Command: {' '.join(full_command)}",
|
|
241
241
|
f" Status: {server_config['status']}",
|
|
242
242
|
]
|
|
243
|
-
|
|
243
|
+
|
|
244
244
|
if env:
|
|
245
245
|
output.append(f" Environment: {list(env.keys())}")
|
|
246
|
-
|
|
247
|
-
output.extend(
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
246
|
+
|
|
247
|
+
output.extend(
|
|
248
|
+
[
|
|
249
|
+
"",
|
|
250
|
+
"Use 'mcp_stats' to see server details.",
|
|
251
|
+
f"Use 'mcp_remove --name {name}' to remove this server.",
|
|
252
|
+
]
|
|
253
|
+
)
|
|
252
254
|
|
|
253
255
|
# Note: In a real implementation, we would:
|
|
254
256
|
# 1. Start the MCP server process
|
|
255
257
|
# 2. Connect to it via stdio/HTTP
|
|
256
258
|
# 3. Query its capabilities (tools, resources, prompts)
|
|
257
259
|
# 4. Register those with our MCP server
|
|
258
|
-
|
|
260
|
+
|
|
259
261
|
return "\n".join(output)
|
|
260
262
|
|
|
261
263
|
def register(self, mcp_server) -> None:
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"""Remove MCP servers."""
|
|
2
2
|
|
|
3
|
-
from typing import Annotated, TypedDict,
|
|
3
|
+
from typing import Unpack, Annotated, TypedDict, final, override
|
|
4
4
|
|
|
5
|
-
from mcp.server.fastmcp import Context as MCPContext
|
|
6
5
|
from pydantic import Field
|
|
6
|
+
from mcp.server.fastmcp import Context as MCPContext
|
|
7
7
|
|
|
8
8
|
from hanzo_mcp.tools.common.base import BaseTool
|
|
9
|
-
from hanzo_mcp.tools.common.context import create_tool_context
|
|
10
9
|
from hanzo_mcp.tools.mcp.mcp_add import McpAddTool
|
|
11
|
-
|
|
10
|
+
from hanzo_mcp.tools.common.context import create_tool_context
|
|
12
11
|
|
|
13
12
|
ServerName = Annotated[
|
|
14
13
|
str,
|
|
@@ -91,12 +90,12 @@ Use 'mcp_stats' to see all servers before removing.
|
|
|
91
90
|
|
|
92
91
|
# Get current servers
|
|
93
92
|
servers = McpAddTool.get_servers()
|
|
94
|
-
|
|
93
|
+
|
|
95
94
|
if name not in servers:
|
|
96
95
|
return f"Error: Server '{name}' not found. Use 'mcp_stats' to see available servers."
|
|
97
96
|
|
|
98
97
|
server = servers[name]
|
|
99
|
-
|
|
98
|
+
|
|
100
99
|
await tool_ctx.info(f"Removing MCP server '{name}'")
|
|
101
100
|
|
|
102
101
|
# Check if server is running
|
|
@@ -116,10 +115,10 @@ Use 'mcp_stats' to see all servers before removing.
|
|
|
116
115
|
f" Type: {server.get('type', 'unknown')}",
|
|
117
116
|
f" Command: {' '.join(server.get('command', []))}",
|
|
118
117
|
]
|
|
119
|
-
|
|
118
|
+
|
|
120
119
|
if server.get("tools"):
|
|
121
120
|
output.append(f" Tools removed: {len(server['tools'])}")
|
|
122
|
-
|
|
121
|
+
|
|
123
122
|
return "\n".join(output)
|
|
124
123
|
|
|
125
124
|
def register(self, mcp_server) -> None:
|
hanzo_mcp/tools/mcp/mcp_stats.py
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
"""MCP server statistics."""
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
from typing import TypedDict, Unpack, final, override
|
|
5
|
-
from datetime import datetime
|
|
3
|
+
from typing import Unpack, TypedDict, final, override
|
|
6
4
|
|
|
7
5
|
from mcp.server.fastmcp import Context as MCPContext
|
|
8
6
|
|
|
9
7
|
from hanzo_mcp.tools.common.base import BaseTool
|
|
10
|
-
from hanzo_mcp.tools.common.context import create_tool_context
|
|
11
8
|
from hanzo_mcp.tools.mcp.mcp_add import McpAddTool
|
|
9
|
+
from hanzo_mcp.tools.common.context import create_tool_context
|
|
12
10
|
|
|
13
11
|
|
|
14
12
|
class McpStatsParams(TypedDict, total=False):
|
|
15
13
|
"""Parameters for MCP stats tool."""
|
|
14
|
+
|
|
16
15
|
pass
|
|
17
16
|
|
|
18
17
|
|
|
@@ -67,66 +66,68 @@ Example:
|
|
|
67
66
|
|
|
68
67
|
# Get all servers
|
|
69
68
|
servers = McpAddTool.get_servers()
|
|
70
|
-
|
|
69
|
+
|
|
71
70
|
if not servers:
|
|
72
|
-
return
|
|
71
|
+
return (
|
|
72
|
+
"No MCP servers have been added yet.\n\nUse 'mcp_add' to add servers."
|
|
73
|
+
)
|
|
73
74
|
|
|
74
75
|
output = []
|
|
75
76
|
output.append("=== MCP Server Statistics ===")
|
|
76
77
|
output.append(f"Total Servers: {len(servers)}")
|
|
77
78
|
output.append("")
|
|
78
|
-
|
|
79
|
+
|
|
79
80
|
# Count by type
|
|
80
81
|
type_counts = {}
|
|
81
82
|
status_counts = {}
|
|
82
83
|
total_tools = 0
|
|
83
84
|
total_resources = 0
|
|
84
|
-
|
|
85
|
+
|
|
85
86
|
for server in servers.values():
|
|
86
87
|
# Count types
|
|
87
88
|
server_type = server.get("type", "unknown")
|
|
88
89
|
type_counts[server_type] = type_counts.get(server_type, 0) + 1
|
|
89
|
-
|
|
90
|
+
|
|
90
91
|
# Count status
|
|
91
92
|
status = server.get("status", "unknown")
|
|
92
93
|
status_counts[status] = status_counts.get(status, 0) + 1
|
|
93
|
-
|
|
94
|
+
|
|
94
95
|
# Count tools and resources
|
|
95
96
|
total_tools += len(server.get("tools", []))
|
|
96
97
|
total_resources += len(server.get("resources", []))
|
|
97
|
-
|
|
98
|
+
|
|
98
99
|
# Server types
|
|
99
100
|
output.append("Server Types:")
|
|
100
101
|
for stype, count in sorted(type_counts.items()):
|
|
101
102
|
output.append(f" {stype}: {count}")
|
|
102
103
|
output.append("")
|
|
103
|
-
|
|
104
|
+
|
|
104
105
|
# Server status
|
|
105
106
|
output.append("Server Status:")
|
|
106
107
|
for status, count in sorted(status_counts.items()):
|
|
107
108
|
output.append(f" {status}: {count}")
|
|
108
109
|
output.append("")
|
|
109
|
-
|
|
110
|
+
|
|
110
111
|
# Tools and resources
|
|
111
112
|
output.append(f"Total Tools Available: {total_tools}")
|
|
112
113
|
output.append(f"Total Resources Available: {total_resources}")
|
|
113
114
|
output.append("")
|
|
114
|
-
|
|
115
|
+
|
|
115
116
|
# Individual server details
|
|
116
117
|
output.append("=== Server Details ===")
|
|
117
|
-
|
|
118
|
+
|
|
118
119
|
for name, server in sorted(servers.items()):
|
|
119
120
|
output.append(f"\n{name}:")
|
|
120
121
|
output.append(f" Type: {server.get('type', 'unknown')}")
|
|
121
122
|
output.append(f" Status: {server.get('status', 'unknown')}")
|
|
122
123
|
output.append(f" Command: {' '.join(server.get('command', []))}")
|
|
123
|
-
|
|
124
|
+
|
|
124
125
|
if server.get("process_id"):
|
|
125
126
|
output.append(f" Process ID: {server['process_id']}")
|
|
126
|
-
|
|
127
|
+
|
|
127
128
|
if server.get("error"):
|
|
128
129
|
output.append(f" Error: {server['error']}")
|
|
129
|
-
|
|
130
|
+
|
|
130
131
|
tools = server.get("tools", [])
|
|
131
132
|
if tools:
|
|
132
133
|
output.append(f" Tools ({len(tools)}):")
|
|
@@ -134,7 +135,7 @@ Example:
|
|
|
134
135
|
output.append(f" - {tool}")
|
|
135
136
|
if len(tools) > 5:
|
|
136
137
|
output.append(f" ... and {len(tools) - 5} more")
|
|
137
|
-
|
|
138
|
+
|
|
138
139
|
resources = server.get("resources", [])
|
|
139
140
|
if resources:
|
|
140
141
|
output.append(f" Resources ({len(resources)}):")
|
|
@@ -142,10 +143,10 @@ Example:
|
|
|
142
143
|
output.append(f" - {resource}")
|
|
143
144
|
if len(resources) > 5:
|
|
144
145
|
output.append(f" ... and {len(resources) - 5} more")
|
|
145
|
-
|
|
146
|
+
|
|
146
147
|
if server.get("env"):
|
|
147
148
|
output.append(f" Environment vars: {list(server['env'].keys())}")
|
|
148
|
-
|
|
149
|
+
|
|
149
150
|
# Common MCP servers hint
|
|
150
151
|
output.append("\n=== Available MCP Servers ===")
|
|
151
152
|
output.append("Common servers you can add:")
|
|
@@ -157,7 +158,7 @@ Example:
|
|
|
157
158
|
output.append(" - @modelcontextprotocol/server-iterm2")
|
|
158
159
|
output.append(" - @modelcontextprotocol/server-linear")
|
|
159
160
|
output.append(" - @modelcontextprotocol/server-slack")
|
|
160
|
-
|
|
161
|
+
|
|
161
162
|
return "\n".join(output)
|
|
162
163
|
|
|
163
164
|
def register(self, mcp_server) -> None:
|