hanzo-mcp 0.8.11__py3-none-any.whl → 0.9.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.

Files changed (166) hide show
  1. hanzo_mcp/__init__.py +1 -3
  2. hanzo_mcp/analytics/posthog_analytics.py +3 -9
  3. hanzo_mcp/bridge.py +9 -25
  4. hanzo_mcp/cli.py +6 -15
  5. hanzo_mcp/cli_enhanced.py +5 -14
  6. hanzo_mcp/cli_plugin.py +3 -9
  7. hanzo_mcp/config/settings.py +6 -20
  8. hanzo_mcp/config/tool_config.py +1 -3
  9. hanzo_mcp/core/base_agent.py +88 -88
  10. hanzo_mcp/core/model_registry.py +238 -210
  11. hanzo_mcp/dev_server.py +5 -15
  12. hanzo_mcp/prompts/__init__.py +2 -6
  13. hanzo_mcp/prompts/project_todo_reminder.py +3 -9
  14. hanzo_mcp/prompts/tool_explorer.py +1 -3
  15. hanzo_mcp/prompts/utils.py +7 -21
  16. hanzo_mcp/server.py +2 -6
  17. hanzo_mcp/tools/__init__.py +26 -27
  18. hanzo_mcp/tools/agent/__init__.py +2 -1
  19. hanzo_mcp/tools/agent/agent.py +10 -30
  20. hanzo_mcp/tools/agent/agent_tool.py +22 -15
  21. hanzo_mcp/tools/agent/claude_desktop_auth.py +3 -9
  22. hanzo_mcp/tools/agent/cli_agent_base.py +7 -24
  23. hanzo_mcp/tools/agent/cli_tools.py +75 -74
  24. hanzo_mcp/tools/agent/code_auth.py +1 -3
  25. hanzo_mcp/tools/agent/code_auth_tool.py +2 -6
  26. hanzo_mcp/tools/agent/critic_tool.py +8 -24
  27. hanzo_mcp/tools/agent/iching_tool.py +12 -36
  28. hanzo_mcp/tools/agent/network_tool.py +7 -18
  29. hanzo_mcp/tools/agent/prompt.py +1 -5
  30. hanzo_mcp/tools/agent/review_tool.py +10 -25
  31. hanzo_mcp/tools/agent/swarm_alias.py +1 -3
  32. hanzo_mcp/tools/agent/unified_cli_tools.py +38 -38
  33. hanzo_mcp/tools/common/batch_tool.py +15 -45
  34. hanzo_mcp/tools/common/config_tool.py +9 -28
  35. hanzo_mcp/tools/common/context.py +1 -3
  36. hanzo_mcp/tools/common/critic_tool.py +1 -3
  37. hanzo_mcp/tools/common/decorators.py +2 -6
  38. hanzo_mcp/tools/common/enhanced_base.py +2 -6
  39. hanzo_mcp/tools/common/fastmcp_pagination.py +4 -12
  40. hanzo_mcp/tools/common/forgiving_edit.py +9 -28
  41. hanzo_mcp/tools/common/mode.py +1 -5
  42. hanzo_mcp/tools/common/paginated_base.py +3 -11
  43. hanzo_mcp/tools/common/paginated_response.py +10 -30
  44. hanzo_mcp/tools/common/pagination.py +3 -9
  45. hanzo_mcp/tools/common/path_utils.py +34 -0
  46. hanzo_mcp/tools/common/permissions.py +14 -13
  47. hanzo_mcp/tools/common/personality.py +983 -701
  48. hanzo_mcp/tools/common/plugin_loader.py +3 -15
  49. hanzo_mcp/tools/common/stats.py +6 -18
  50. hanzo_mcp/tools/common/thinking_tool.py +1 -3
  51. hanzo_mcp/tools/common/tool_disable.py +2 -6
  52. hanzo_mcp/tools/common/tool_list.py +2 -6
  53. hanzo_mcp/tools/common/validation.py +1 -3
  54. hanzo_mcp/tools/compiler/__init__.py +8 -0
  55. hanzo_mcp/tools/compiler/sandboxed_compiler.py +681 -0
  56. hanzo_mcp/tools/config/config_tool.py +7 -13
  57. hanzo_mcp/tools/config/index_config.py +1 -3
  58. hanzo_mcp/tools/config/mode_tool.py +5 -15
  59. hanzo_mcp/tools/database/database_manager.py +3 -9
  60. hanzo_mcp/tools/database/graph.py +1 -3
  61. hanzo_mcp/tools/database/graph_add.py +3 -9
  62. hanzo_mcp/tools/database/graph_query.py +11 -34
  63. hanzo_mcp/tools/database/graph_remove.py +3 -9
  64. hanzo_mcp/tools/database/graph_search.py +6 -20
  65. hanzo_mcp/tools/database/graph_stats.py +11 -33
  66. hanzo_mcp/tools/database/sql.py +4 -12
  67. hanzo_mcp/tools/database/sql_query.py +6 -10
  68. hanzo_mcp/tools/database/sql_search.py +2 -6
  69. hanzo_mcp/tools/database/sql_stats.py +5 -15
  70. hanzo_mcp/tools/editor/neovim_command.py +1 -3
  71. hanzo_mcp/tools/editor/neovim_session.py +7 -13
  72. hanzo_mcp/tools/environment/__init__.py +8 -0
  73. hanzo_mcp/tools/environment/environment_detector.py +594 -0
  74. hanzo_mcp/tools/filesystem/__init__.py +28 -26
  75. hanzo_mcp/tools/filesystem/ast_multi_edit.py +14 -43
  76. hanzo_mcp/tools/filesystem/ast_tool.py +3 -0
  77. hanzo_mcp/tools/filesystem/base.py +20 -12
  78. hanzo_mcp/tools/filesystem/content_replace.py +7 -12
  79. hanzo_mcp/tools/filesystem/diff.py +2 -10
  80. hanzo_mcp/tools/filesystem/directory_tree.py +285 -51
  81. hanzo_mcp/tools/filesystem/edit.py +10 -18
  82. hanzo_mcp/tools/filesystem/find.py +312 -179
  83. hanzo_mcp/tools/filesystem/git_search.py +12 -24
  84. hanzo_mcp/tools/filesystem/multi_edit.py +10 -18
  85. hanzo_mcp/tools/filesystem/read.py +14 -30
  86. hanzo_mcp/tools/filesystem/rules_tool.py +9 -17
  87. hanzo_mcp/tools/filesystem/search.py +1160 -0
  88. hanzo_mcp/tools/filesystem/watch.py +2 -4
  89. hanzo_mcp/tools/filesystem/write.py +7 -10
  90. hanzo_mcp/tools/framework/__init__.py +8 -0
  91. hanzo_mcp/tools/framework/framework_modes.py +714 -0
  92. hanzo_mcp/tools/jupyter/base.py +6 -20
  93. hanzo_mcp/tools/jupyter/jupyter.py +4 -12
  94. hanzo_mcp/tools/llm/consensus_tool.py +8 -24
  95. hanzo_mcp/tools/llm/llm_manage.py +2 -6
  96. hanzo_mcp/tools/llm/llm_tool.py +17 -58
  97. hanzo_mcp/tools/llm/llm_unified.py +18 -59
  98. hanzo_mcp/tools/llm/provider_tools.py +1 -3
  99. hanzo_mcp/tools/lsp/lsp_tool.py +621 -481
  100. hanzo_mcp/tools/mcp/mcp_add.py +1 -3
  101. hanzo_mcp/tools/mcp/mcp_stats.py +1 -3
  102. hanzo_mcp/tools/mcp/mcp_tool.py +9 -23
  103. hanzo_mcp/tools/memory/__init__.py +10 -27
  104. hanzo_mcp/tools/memory/conversation_memory.py +636 -0
  105. hanzo_mcp/tools/memory/knowledge_tools.py +7 -25
  106. hanzo_mcp/tools/memory/memory_tools.py +6 -18
  107. hanzo_mcp/tools/search/find_tool.py +12 -34
  108. hanzo_mcp/tools/search/unified_search.py +24 -78
  109. hanzo_mcp/tools/shell/__init__.py +16 -4
  110. hanzo_mcp/tools/shell/auto_background.py +2 -6
  111. hanzo_mcp/tools/shell/base.py +1 -5
  112. hanzo_mcp/tools/shell/base_process.py +5 -7
  113. hanzo_mcp/tools/shell/bash_session.py +7 -24
  114. hanzo_mcp/tools/shell/bash_session_executor.py +5 -15
  115. hanzo_mcp/tools/shell/bash_tool.py +3 -7
  116. hanzo_mcp/tools/shell/command_executor.py +26 -79
  117. hanzo_mcp/tools/shell/logs.py +4 -16
  118. hanzo_mcp/tools/shell/npx.py +2 -8
  119. hanzo_mcp/tools/shell/npx_tool.py +1 -3
  120. hanzo_mcp/tools/shell/pkill.py +4 -12
  121. hanzo_mcp/tools/shell/process_tool.py +2 -8
  122. hanzo_mcp/tools/shell/processes.py +5 -17
  123. hanzo_mcp/tools/shell/run_background.py +1 -3
  124. hanzo_mcp/tools/shell/run_command.py +1 -3
  125. hanzo_mcp/tools/shell/run_command_windows.py +1 -3
  126. hanzo_mcp/tools/shell/run_tool.py +56 -0
  127. hanzo_mcp/tools/shell/session_manager.py +2 -6
  128. hanzo_mcp/tools/shell/session_storage.py +2 -6
  129. hanzo_mcp/tools/shell/streaming_command.py +7 -23
  130. hanzo_mcp/tools/shell/uvx.py +4 -14
  131. hanzo_mcp/tools/shell/uvx_background.py +2 -6
  132. hanzo_mcp/tools/shell/uvx_tool.py +1 -3
  133. hanzo_mcp/tools/shell/zsh_tool.py +12 -20
  134. hanzo_mcp/tools/todo/todo.py +1 -3
  135. hanzo_mcp/tools/vector/__init__.py +97 -50
  136. hanzo_mcp/tools/vector/ast_analyzer.py +6 -20
  137. hanzo_mcp/tools/vector/git_ingester.py +10 -30
  138. hanzo_mcp/tools/vector/index_tool.py +3 -9
  139. hanzo_mcp/tools/vector/infinity_store.py +7 -27
  140. hanzo_mcp/tools/vector/mock_infinity.py +1 -3
  141. hanzo_mcp/tools/vector/node_tool.py +538 -0
  142. hanzo_mcp/tools/vector/project_manager.py +4 -12
  143. hanzo_mcp/tools/vector/unified_vector.py +384 -0
  144. hanzo_mcp/tools/vector/vector.py +2 -6
  145. hanzo_mcp/tools/vector/vector_index.py +8 -8
  146. hanzo_mcp/tools/vector/vector_search.py +7 -21
  147. {hanzo_mcp-0.8.11.dist-info → hanzo_mcp-0.9.0.dist-info}/METADATA +2 -2
  148. hanzo_mcp-0.9.0.dist-info/RECORD +191 -0
  149. hanzo_mcp/tools/agent/agent_tool_v1_deprecated.py +0 -645
  150. hanzo_mcp/tools/agent/swarm_tool.py +0 -718
  151. hanzo_mcp/tools/agent/swarm_tool_v1_deprecated.py +0 -577
  152. hanzo_mcp/tools/filesystem/batch_search.py +0 -900
  153. hanzo_mcp/tools/filesystem/directory_tree_paginated.py +0 -350
  154. hanzo_mcp/tools/filesystem/find_files.py +0 -369
  155. hanzo_mcp/tools/filesystem/grep.py +0 -467
  156. hanzo_mcp/tools/filesystem/search_tool.py +0 -767
  157. hanzo_mcp/tools/filesystem/symbols_tool.py +0 -515
  158. hanzo_mcp/tools/filesystem/tree.py +0 -270
  159. hanzo_mcp/tools/jupyter/notebook_edit.py +0 -317
  160. hanzo_mcp/tools/jupyter/notebook_read.py +0 -147
  161. hanzo_mcp/tools/todo/todo_read.py +0 -143
  162. hanzo_mcp/tools/todo/todo_write.py +0 -374
  163. hanzo_mcp-0.8.11.dist-info/RECORD +0 -193
  164. {hanzo_mcp-0.8.11.dist-info → hanzo_mcp-0.9.0.dist-info}/WHEEL +0 -0
  165. {hanzo_mcp-0.8.11.dist-info → hanzo_mcp-0.9.0.dist-info}/entry_points.txt +0 -0
  166. {hanzo_mcp-0.8.11.dist-info → hanzo_mcp-0.9.0.dist-info}/top_level.txt +0 -0
@@ -131,9 +131,7 @@ config --action toggle index.scope --path ./project"""
131
131
  else:
132
132
  return f"Error: Unknown action '{action}'. Valid actions: get, set, list, toggle"
133
133
 
134
- async def _handle_get(
135
- self, key: Optional[str], scope: str, path: Optional[str], tool_ctx
136
- ) -> str:
134
+ async def _handle_get(self, key: Optional[str], scope: str, path: Optional[str], tool_ctx) -> str:
137
135
  """Get configuration value."""
138
136
  if not key:
139
137
  return "Error: key required for get action"
@@ -173,7 +171,9 @@ config --action toggle index.scope --path ./project"""
173
171
  project_path = Path(project_dir)
174
172
  project_path.mkdir(parents=True, exist_ok=True)
175
173
  cfg = project_path / ".hanzo-mcp.json"
176
- cfg.write_text(__import__("json").dumps(settings.__dict__ if hasattr(settings, "__dict__") else {}, indent=2))
174
+ cfg.write_text(
175
+ __import__("json").dumps(settings.__dict__ if hasattr(settings, "__dict__") else {}, indent=2)
176
+ )
177
177
  return cfg
178
178
  # Fallback to global handler
179
179
  return save_settings(settings, global_config=True)
@@ -196,9 +196,7 @@ config --action toggle index.scope --path ./project"""
196
196
  if key == "index.scope":
197
197
  try:
198
198
  new_scope = IndexScope(value)
199
- self.index_config.set_scope(
200
- new_scope, path if scope == "local" else None
201
- )
199
+ self.index_config.set_scope(new_scope, path if scope == "local" else None)
202
200
  return f"Set {key}={value} ({'project' if path else 'global'})"
203
201
  except ValueError:
204
202
  return f"Error: Invalid scope value '{value}'. Valid: project, global, auto"
@@ -281,18 +279,14 @@ config --action toggle index.scope --path ./project"""
281
279
 
282
280
  return "\n".join(output)
283
281
 
284
- async def _handle_toggle(
285
- self, key: Optional[str], scope: str, path: Optional[str], tool_ctx
286
- ) -> str:
282
+ async def _handle_toggle(self, key: Optional[str], scope: str, path: Optional[str], tool_ctx) -> str:
287
283
  """Toggle configuration value."""
288
284
  if not key:
289
285
  return "Error: key required for toggle action"
290
286
 
291
287
  # Handle index scope toggle
292
288
  if key == "index.scope":
293
- new_scope = self.index_config.toggle_scope(
294
- path if scope == "local" else None
295
- )
289
+ new_scope = self.index_config.toggle_scope(path if scope == "local" else None)
296
290
  return f"Toggled index.scope to {new_scope.value}"
297
291
 
298
292
  # Handle execution tool enable/disable: tools.<name>.enabled or enabled_tools.<name>
@@ -99,9 +99,7 @@ class IndexConfig:
99
99
  if project_root:
100
100
  if str(project_root) not in self._config["project_configs"]:
101
101
  self._config["project_configs"][str(project_root)] = {}
102
- self._config["project_configs"][str(project_root)][
103
- "scope"
104
- ] = scope.value
102
+ self._config["project_configs"][str(project_root)]["scope"] = scope.value
105
103
  else:
106
104
  # Set global default
107
105
  self._config["default_scope"] = scope.value
@@ -187,12 +187,8 @@ mode --action current"""
187
187
  for mode_name in mode_names:
188
188
  mode = next((m for m in modes if m.name == mode_name), None)
189
189
  if mode:
190
- marker = (
191
- " (active)" if active and active.name == mode.name else ""
192
- )
193
- output.append(
194
- f" {mode.name}{marker}: {mode.programmer} - {mode.description}"
195
- )
190
+ marker = " (active)" if active and active.name == mode.name else ""
191
+ output.append(f" {mode.name}{marker}: {mode.programmer} - {mode.description}")
196
192
 
197
193
  output.append("\nUse 'mode --action activate <name>' to activate a mode")
198
194
 
@@ -256,9 +252,7 @@ mode --action current"""
256
252
  for key, value in mode.environment.items():
257
253
  output.append(f" {key}={value}")
258
254
 
259
- output.append(
260
- "\nNote: Restart MCP session for changes to take full effect"
261
- )
255
+ output.append("\nNote: Restart MCP session for changes to take full effect")
262
256
 
263
257
  return "\n".join(output)
264
258
 
@@ -312,17 +306,13 @@ mode --action current"""
312
306
  tool_self = self
313
307
 
314
308
  @server.tool(name=self.name, description=self.description)
315
- async def mode_handler(
316
- ctx: MCPContext, action: str = "list", name: Optional[str] = None
317
- ) -> str:
309
+ async def mode_handler(ctx: MCPContext, action: str = "list", name: Optional[str] = None) -> str:
318
310
  """Handle mode tool calls."""
319
311
  return await tool_self.run(ctx, action=action, name=name)
320
312
 
321
313
  async def call(self, ctx: MCPContext, **params) -> str:
322
314
  """Call the tool with arguments."""
323
- return await self.run(
324
- ctx, action=params.get("action", "list"), name=params.get("name")
325
- )
315
+ return await self.run(ctx, action=params.get("action", "list"), name=params.get("name"))
326
316
 
327
317
 
328
318
  # Create tool instance
@@ -127,9 +127,7 @@ class ProjectDatabase:
127
127
  # Indexes for graph traversal
128
128
  conn.execute("CREATE INDEX IF NOT EXISTS idx_edges_source ON edges(source)")
129
129
  conn.execute("CREATE INDEX IF NOT EXISTS idx_edges_target ON edges(target)")
130
- conn.execute(
131
- "CREATE INDEX IF NOT EXISTS idx_edges_relationship ON edges(relationship)"
132
- )
130
+ conn.execute("CREATE INDEX IF NOT EXISTS idx_edges_relationship ON edges(relationship)")
133
131
  conn.execute("CREATE INDEX IF NOT EXISTS idx_nodes_type ON nodes(type)")
134
132
 
135
133
  def _load_graph_from_disk(self):
@@ -138,15 +136,11 @@ class ProjectDatabase:
138
136
  try:
139
137
  # Copy nodes
140
138
  nodes = disk_conn.execute("SELECT * FROM nodes").fetchall()
141
- self.graph_conn.executemany(
142
- "INSERT OR REPLACE INTO nodes VALUES (?, ?, ?, ?)", nodes
143
- )
139
+ self.graph_conn.executemany("INSERT OR REPLACE INTO nodes VALUES (?, ?, ?, ?)", nodes)
144
140
 
145
141
  # Copy edges
146
142
  edges = disk_conn.execute("SELECT * FROM edges").fetchall()
147
- self.graph_conn.executemany(
148
- "INSERT OR REPLACE INTO edges VALUES (?, ?, ?, ?, ?, ?)", edges
149
- )
143
+ self.graph_conn.executemany("INSERT OR REPLACE INTO edges VALUES (?, ?, ?, ?, ?, ?)", edges)
150
144
 
151
145
  self.graph_conn.commit()
152
146
  finally:
@@ -120,9 +120,7 @@ class GraphParams(TypedDict, total=False):
120
120
  class GraphTool(BaseTool):
121
121
  """Unified graph database tool."""
122
122
 
123
- def __init__(
124
- self, permission_manager: PermissionManager, db_manager: DatabaseManager
125
- ):
123
+ def __init__(self, permission_manager: PermissionManager, db_manager: DatabaseManager):
126
124
  """Initialize the graph tool."""
127
125
  super().__init__(permission_manager)
128
126
  self.db_manager = db_manager
@@ -93,9 +93,7 @@ class GraphAddParams(TypedDict, total=False):
93
93
  class GraphAddTool(BaseTool):
94
94
  """Tool for adding nodes and edges to graph database."""
95
95
 
96
- def __init__(
97
- self, permission_manager: PermissionManager, db_manager: DatabaseManager
98
- ):
96
+ def __init__(self, permission_manager: PermissionManager, db_manager: DatabaseManager):
99
97
  """Initialize the graph add tool.
100
98
 
101
99
  Args:
@@ -225,15 +223,11 @@ Examples:
225
223
  if not relationship:
226
224
  return "Error: relationship is required when adding an edge"
227
225
 
228
- await tool_ctx.info(
229
- f"Adding edge: {source} --[{relationship}]--> {target}"
230
- )
226
+ await tool_ctx.info(f"Adding edge: {source} --[{relationship}]--> {target}")
231
227
 
232
228
  # Check if nodes exist
233
229
  cursor = graph_conn.cursor()
234
- cursor.execute(
235
- "SELECT id FROM nodes WHERE id IN (?, ?)", (source, target)
236
- )
230
+ cursor.execute("SELECT id FROM nodes WHERE id IN (?, ?)", (source, target))
237
231
  existing = [row[0] for row in cursor.fetchall()]
238
232
 
239
233
  if source not in existing:
@@ -102,9 +102,7 @@ class GraphQueryParams(TypedDict, total=False):
102
102
  class GraphQueryTool(BaseTool):
103
103
  """Tool for querying the graph database."""
104
104
 
105
- def __init__(
106
- self, permission_manager: PermissionManager, db_manager: DatabaseManager
107
- ):
105
+ def __init__(self, permission_manager: PermissionManager, db_manager: DatabaseManager):
108
106
  """Initialize the graph query tool.
109
107
 
110
108
  Args:
@@ -192,10 +190,7 @@ Examples:
192
190
  return f"Error: Invalid query '{query}'. Must be one of: {', '.join(valid_queries)}"
193
191
 
194
192
  # Validate required parameters
195
- if (
196
- query in ["neighbors", "subgraph", "connected", "ancestors", "descendants"]
197
- and not node_id
198
- ):
193
+ if query in ["neighbors", "subgraph", "connected", "ancestors", "descendants"] and not node_id:
199
194
  return f"Error: node_id is required for '{query}' query"
200
195
 
201
196
  if query == "path" and (not node_id or not target_id):
@@ -225,27 +220,17 @@ Examples:
225
220
 
226
221
  try:
227
222
  if query == "neighbors":
228
- return self._query_neighbors(
229
- graph_conn, node_id, relationship, node_type, direction
230
- )
223
+ return self._query_neighbors(graph_conn, node_id, relationship, node_type, direction)
231
224
  elif query == "path":
232
225
  return self._query_path(graph_conn, node_id, target_id, relationship)
233
226
  elif query == "subgraph":
234
- return self._query_subgraph(
235
- graph_conn, node_id, depth, relationship, node_type, direction
236
- )
227
+ return self._query_subgraph(graph_conn, node_id, depth, relationship, node_type, direction)
237
228
  elif query == "connected":
238
- return self._query_connected(
239
- graph_conn, node_id, relationship, node_type, direction
240
- )
229
+ return self._query_connected(graph_conn, node_id, relationship, node_type, direction)
241
230
  elif query == "ancestors":
242
- return self._query_ancestors(
243
- graph_conn, node_id, depth, relationship, node_type
244
- )
231
+ return self._query_ancestors(graph_conn, node_id, depth, relationship, node_type)
245
232
  elif query == "descendants":
246
- return self._query_descendants(
247
- graph_conn, node_id, depth, relationship, node_type
248
- )
233
+ return self._query_descendants(graph_conn, node_id, depth, relationship, node_type)
249
234
 
250
235
  except Exception as e:
251
236
  await tool_ctx.error(f"Failed to execute query: {str(e)}")
@@ -331,13 +316,9 @@ Examples:
331
316
  output = [f"Neighbors of '{node_id}' ({node_info[0]}):\n"]
332
317
  for n in neighbors:
333
318
  arrow = "<--" if n["direction"] == "incoming" else "-->"
334
- output.append(
335
- f" {node_id} {arrow}[{n['relationship']}]--> {n['node_id']} ({n['node_type']})"
336
- )
319
+ output.append(f" {node_id} {arrow}[{n['relationship']}]--> {n['node_id']} ({n['node_type']})")
337
320
  if n["properties"]:
338
- output.append(
339
- f" Properties: {json.dumps(n['properties'], indent=6)[:100]}"
340
- )
321
+ output.append(f" Properties: {json.dumps(n['properties'], indent=6)[:100]}")
341
322
 
342
323
  output.append(f"\nTotal neighbors: {len(neighbors)}")
343
324
  return "\n".join(output)
@@ -590,9 +571,7 @@ Examples:
590
571
  node_type: Optional[str],
591
572
  ) -> str:
592
573
  """Find nodes that point TO this node (incoming edges only)."""
593
- return self._query_subgraph(
594
- conn, node_id, depth, relationship, node_type, "incoming"
595
- )
574
+ return self._query_subgraph(conn, node_id, depth, relationship, node_type, "incoming")
596
575
 
597
576
  def _query_descendants(
598
577
  self,
@@ -603,9 +582,7 @@ Examples:
603
582
  node_type: Optional[str],
604
583
  ) -> str:
605
584
  """Find nodes that this node points TO (outgoing edges only)."""
606
- return self._query_subgraph(
607
- conn, node_id, depth, relationship, node_type, "outgoing"
608
- )
585
+ return self._query_subgraph(conn, node_id, depth, relationship, node_type, "outgoing")
609
586
 
610
587
  def register(self, mcp_server) -> None:
611
588
  """Register this tool with the MCP server."""
@@ -74,9 +74,7 @@ class GraphRemoveParams(TypedDict, total=False):
74
74
  class GraphRemoveTool(BaseTool):
75
75
  """Tool for removing nodes and edges from graph database."""
76
76
 
77
- def __init__(
78
- self, permission_manager: PermissionManager, db_manager: DatabaseManager
79
- ):
77
+ def __init__(self, permission_manager: PermissionManager, db_manager: DatabaseManager):
80
78
  """Initialize the graph remove tool.
81
79
 
82
80
  Args:
@@ -220,9 +218,7 @@ Examples:
220
218
  # Remove edge(s)
221
219
  if relationship:
222
220
  # Remove specific edge
223
- await tool_ctx.info(
224
- f"Removing edge: {source} --[{relationship}]--> {target}"
225
- )
221
+ await tool_ctx.info(f"Removing edge: {source} --[{relationship}]--> {target}")
226
222
 
227
223
  cursor = graph_conn.cursor()
228
224
  cursor.execute(
@@ -242,9 +238,7 @@ Examples:
242
238
  return f"Successfully removed edge: {source} --[{relationship}]--> {target}"
243
239
  else:
244
240
  # Remove all edges between nodes
245
- await tool_ctx.info(
246
- f"Removing all edges between {source} and {target}"
247
- )
241
+ await tool_ctx.info(f"Removing all edges between {source} and {target}")
248
242
 
249
243
  cursor = graph_conn.cursor()
250
244
  cursor.execute(
@@ -76,9 +76,7 @@ class GraphSearchParams(TypedDict, total=False):
76
76
  class GraphSearchTool(BaseTool):
77
77
  """Tool for searching nodes and edges in graph database."""
78
78
 
79
- def __init__(
80
- self, permission_manager: PermissionManager, db_manager: DatabaseManager
81
- ):
79
+ def __init__(self, permission_manager: PermissionManager, db_manager: DatabaseManager):
82
80
  """Initialize the graph search tool.
83
81
 
84
82
  Args:
@@ -315,13 +313,8 @@ Examples:
315
313
  output.append(f"Nodes ({len(nodes)}):")
316
314
  for node in nodes[:20]: # Show first 20
317
315
  output.append(f" {node['id']} ({node['node_type']})")
318
- if (
319
- node["match_field"] == "properties"
320
- and "matching_properties" in node
321
- ):
322
- output.append(
323
- f" Matched in: {list(node['matching_properties'].keys())}"
324
- )
316
+ if node["match_field"] == "properties" and "matching_properties" in node:
317
+ output.append(f" Matched in: {list(node['matching_properties'].keys())}")
325
318
  if node["properties"] and node["match_field"] != "properties":
326
319
  props_str = json.dumps(node["properties"], indent=6)[:100]
327
320
  if len(props_str) == 100:
@@ -335,16 +328,9 @@ Examples:
335
328
  if edges:
336
329
  output.append(f"Edges ({len(edges)}):")
337
330
  for edge in edges[:20]: # Show first 20
338
- output.append(
339
- f" {edge['source']} --[{edge['relationship']}]--> {edge['target']}"
340
- )
341
- if (
342
- edge["match_field"] == "properties"
343
- and "matching_properties" in edge
344
- ):
345
- output.append(
346
- f" Matched in: {list(edge['matching_properties'].keys())}"
347
- )
331
+ output.append(f" {edge['source']} --[{edge['relationship']}]--> {edge['target']}")
332
+ if edge["match_field"] == "properties" and "matching_properties" in edge:
333
+ output.append(f" Matched in: {list(edge['matching_properties'].keys())}")
348
334
  if edge["weight"] != 1.0:
349
335
  output.append(f" Weight: {edge['weight']}")
350
336
  if edge["properties"]:
@@ -58,9 +58,7 @@ class GraphStatsParams(TypedDict, total=False):
58
58
  class GraphStatsTool(BaseTool):
59
59
  """Tool for getting graph database statistics."""
60
60
 
61
- def __init__(
62
- self, permission_manager: PermissionManager, db_manager: DatabaseManager
63
- ):
61
+ def __init__(self, permission_manager: PermissionManager, db_manager: DatabaseManager):
64
62
  """Initialize the graph stats tool.
65
63
 
66
64
  Args:
@@ -139,9 +137,7 @@ Examples:
139
137
  except Exception as e:
140
138
  return f"Error accessing project database: {str(e)}"
141
139
 
142
- await tool_ctx.info(
143
- f"Getting graph statistics for project: {project_db.project_path}"
144
- )
140
+ await tool_ctx.info(f"Getting graph statistics for project: {project_db.project_path}")
145
141
 
146
142
  # Get graph connection
147
143
  graph_conn = project_db.get_graph_connection()
@@ -156,9 +152,7 @@ Examples:
156
152
 
157
153
  # Basic counts
158
154
  if node_type_filter:
159
- cursor.execute(
160
- "SELECT COUNT(*) FROM nodes WHERE type = ?", (node_type_filter,)
161
- )
155
+ cursor.execute("SELECT COUNT(*) FROM nodes WHERE type = ?", (node_type_filter,))
162
156
  node_count = cursor.fetchone()[0]
163
157
  output.append(f"Nodes (type='{node_type_filter}'): {node_count:,}")
164
158
  else:
@@ -172,9 +166,7 @@ Examples:
172
166
  (relationship_filter,),
173
167
  )
174
168
  edge_count = cursor.fetchone()[0]
175
- output.append(
176
- f"Edges (relationship='{relationship_filter}'): {edge_count:,}"
177
- )
169
+ output.append(f"Edges (relationship='{relationship_filter}'): {edge_count:,}")
178
170
  else:
179
171
  cursor.execute("SELECT COUNT(*) FROM edges")
180
172
  edge_count = cursor.fetchone()[0]
@@ -188,9 +180,7 @@ Examples:
188
180
 
189
181
  # Node type distribution
190
182
  output.append("=== Node Types ===")
191
- cursor.execute(
192
- "SELECT type, COUNT(*) as count FROM nodes GROUP BY type ORDER BY count DESC"
193
- )
183
+ cursor.execute("SELECT type, COUNT(*) as count FROM nodes GROUP BY type ORDER BY count DESC")
194
184
  node_types = cursor.fetchall()
195
185
 
196
186
  for n_type, count in node_types[:10]:
@@ -285,31 +275,21 @@ Examples:
285
275
  output.append("\n=== Detailed Analysis ===")
286
276
 
287
277
  # Node properties usage
288
- cursor.execute(
289
- "SELECT COUNT(*) FROM nodes WHERE properties IS NOT NULL"
290
- )
278
+ cursor.execute("SELECT COUNT(*) FROM nodes WHERE properties IS NOT NULL")
291
279
  nodes_with_props = cursor.fetchone()[0]
292
280
  if nodes_with_props > 0:
293
281
  props_pct = (nodes_with_props / node_count) * 100
294
- output.append(
295
- f"Nodes with properties: {nodes_with_props} ({props_pct:.1f}%)"
296
- )
282
+ output.append(f"Nodes with properties: {nodes_with_props} ({props_pct:.1f}%)")
297
283
 
298
284
  # Edge properties usage
299
- cursor.execute(
300
- "SELECT COUNT(*) FROM edges WHERE properties IS NOT NULL"
301
- )
285
+ cursor.execute("SELECT COUNT(*) FROM edges WHERE properties IS NOT NULL")
302
286
  edges_with_props = cursor.fetchone()[0]
303
287
  if edges_with_props > 0 and edge_count > 0:
304
288
  props_pct = (edges_with_props / edge_count) * 100
305
- output.append(
306
- f"Edges with properties: {edges_with_props} ({props_pct:.1f}%)"
307
- )
289
+ output.append(f"Edges with properties: {edges_with_props} ({props_pct:.1f}%)")
308
290
 
309
291
  # Weight distribution
310
- cursor.execute(
311
- "SELECT MIN(weight), MAX(weight), AVG(weight) FROM edges"
312
- )
292
+ cursor.execute("SELECT MIN(weight), MAX(weight), AVG(weight) FROM edges")
313
293
  weight_stats = cursor.fetchone()
314
294
  if weight_stats[0] is not None:
315
295
  output.append(f"\nEdge weights:")
@@ -338,9 +318,7 @@ Examples:
338
318
  if patterns:
339
319
  output.append("Most common connections:")
340
320
  for src_type, rel, tgt_type, count in patterns:
341
- output.append(
342
- f" {src_type} --[{rel}]--> {tgt_type}: {count} times"
343
- )
321
+ output.append(f" {src_type} --[{rel}]--> {tgt_type}: {count} times")
344
322
 
345
323
  # Component analysis (simplified)
346
324
  output.append("\n=== Graph Structure ===")
@@ -75,9 +75,7 @@ class SQLParams(TypedDict, total=False):
75
75
  class SQLTool(BaseTool):
76
76
  """Unified SQL database tool."""
77
77
 
78
- def __init__(
79
- self, permission_manager: PermissionManager, db_manager: DatabaseManager
80
- ):
78
+ def __init__(self, permission_manager: PermissionManager, db_manager: DatabaseManager):
81
79
  """Initialize the SQL tool."""
82
80
  super().__init__(permission_manager)
83
81
  self.db_manager = db_manager
@@ -296,9 +294,7 @@ sql --action stats --table users
296
294
  output.append("-" * 60)
297
295
 
298
296
  for col in columns:
299
- output.append(
300
- f"{col[1]} | {col[2]} | {col[3]} | {col[4]} | {col[5]}"
301
- )
297
+ output.append(f"{col[1]} | {col[2]} | {col[3]} | {col[4]} | {col[5]}")
302
298
 
303
299
  # Get indexes
304
300
  cursor = conn.execute(f"PRAGMA index_list({table})")
@@ -336,9 +332,7 @@ sql --action stats --table users
336
332
  # Get columns
337
333
  cursor = conn.execute(f"PRAGMA table_info({table_name})")
338
334
  columns = cursor.fetchall()
339
- output.append(
340
- f"Columns: {', '.join([col[1] for col in columns])}"
341
- )
335
+ output.append(f"Columns: {', '.join([col[1] for col in columns])}")
342
336
 
343
337
  return "\n".join(output)
344
338
 
@@ -402,9 +396,7 @@ sql --action stats --table users
402
396
  """
403
397
  )
404
398
  stats = cursor.fetchone()
405
- output.append(
406
- f" {col_name}: distinct={stats[0]}, nulls={stats[1]}"
407
- )
399
+ output.append(f" {col_name}: distinct={stats[0]}, nulls={stats[1]}")
408
400
 
409
401
  else:
410
402
  # Overall database stats
@@ -48,9 +48,7 @@ class SqlQueryParams(TypedDict, total=False):
48
48
  class SqlQueryTool(BaseTool):
49
49
  """Tool for executing SQL queries on project databases."""
50
50
 
51
- def __init__(
52
- self, permission_manager: PermissionManager, db_manager: DatabaseManager
53
- ):
51
+ def __init__(self, permission_manager: PermissionManager, db_manager: DatabaseManager):
54
52
  """Initialize the SQL query tool.
55
53
 
56
54
  Args:
@@ -140,11 +138,11 @@ Note: Use sql_search for text search operations."""
140
138
  query_upper = query.upper()
141
139
  for keyword in write_keywords:
142
140
  if keyword in query_upper:
143
- return f"Error: Query contains {keyword} operation. Set --read-only false to allow write operations."
141
+ return (
142
+ f"Error: Query contains {keyword} operation. Set --read-only false to allow write operations."
143
+ )
144
144
 
145
- await tool_ctx.info(
146
- f"Executing SQL query on project: {project_db.project_path}"
147
- )
145
+ await tool_ctx.info(f"Executing SQL query on project: {project_db.project_path}")
148
146
 
149
147
  # Execute query
150
148
  conn = None
@@ -209,9 +207,7 @@ Note: Use sql_search for text search operations."""
209
207
  output_rows = []
210
208
  for row in rows[:1000]: # Limit to 1000 rows
211
209
  row_str = " | ".join(
212
- self._truncate(str(val) if val is not None else "NULL", width).ljust(
213
- width
214
- )
210
+ self._truncate(str(val) if val is not None else "NULL", width).ljust(width)
215
211
  for val, width in zip(row, col_widths)
216
212
  )
217
213
  output_rows.append(row_str)
@@ -66,9 +66,7 @@ class SqlSearchParams(TypedDict, total=False):
66
66
  class SqlSearchTool(BaseTool):
67
67
  """Tool for searching text in SQLite database."""
68
68
 
69
- def __init__(
70
- self, permission_manager: PermissionManager, db_manager: DatabaseManager
71
- ):
69
+ def __init__(self, permission_manager: PermissionManager, db_manager: DatabaseManager):
72
70
  """Initialize the SQL search tool.
73
71
 
74
72
  Args:
@@ -253,9 +251,7 @@ Use sql_query for complex queries with joins, conditions, etc."""
253
251
 
254
252
  return text_columns
255
253
 
256
- def _format_results(
257
- self, table: str, results: list, pattern: str, search_columns: list[str]
258
- ) -> str:
254
+ def _format_results(self, table: str, results: list, pattern: str, search_columns: list[str]) -> str:
259
255
  """Format search results based on table type."""
260
256
  output = []
261
257
 
@@ -39,9 +39,7 @@ class SqlStatsParams(TypedDict, total=False):
39
39
  class SqlStatsTool(BaseTool):
40
40
  """Tool for getting SQLite database statistics."""
41
41
 
42
- def __init__(
43
- self, permission_manager: PermissionManager, db_manager: DatabaseManager
44
- ):
42
+ def __init__(self, permission_manager: PermissionManager, db_manager: DatabaseManager):
45
43
  """Initialize the SQL stats tool.
46
44
 
47
45
  Args:
@@ -115,9 +113,7 @@ Examples:
115
113
  except Exception as e:
116
114
  return f"Error accessing project database: {str(e)}"
117
115
 
118
- await tool_ctx.info(
119
- f"Getting statistics for project: {project_db.project_path}"
120
- )
116
+ await tool_ctx.info(f"Getting statistics for project: {project_db.project_path}")
121
117
 
122
118
  # Collect statistics
123
119
  conn = None
@@ -136,9 +132,7 @@ Examples:
136
132
  output.append("")
137
133
 
138
134
  # Get table statistics
139
- cursor.execute(
140
- "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name"
141
- )
135
+ cursor.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name")
142
136
  tables = cursor.fetchall()
143
137
 
144
138
  output.append("=== Tables ===")
@@ -182,9 +176,7 @@ Examples:
182
176
 
183
177
  # Show sample data for specific tables
184
178
  if table_name == "files" and row_count > 0:
185
- cursor.execute(
186
- f"SELECT COUNT(DISTINCT SUBSTR(path, -3)) as ext_count FROM {table_name}"
187
- )
179
+ cursor.execute(f"SELECT COUNT(DISTINCT SUBSTR(path, -3)) as ext_count FROM {table_name}")
188
180
  ext_count = cursor.fetchone()[0]
189
181
  output.append(f" File types: ~{ext_count}")
190
182
 
@@ -206,9 +198,7 @@ Examples:
206
198
  output.append(f"\nTotal Rows: {total_rows:,}")
207
199
 
208
200
  # Get index statistics
209
- cursor.execute(
210
- "SELECT name FROM sqlite_master WHERE type='index' AND sql IS NOT NULL ORDER BY name"
211
- )
201
+ cursor.execute("SELECT name FROM sqlite_master WHERE type='index' AND sql IS NOT NULL ORDER BY name")
212
202
  indexes = cursor.fetchall()
213
203
  if indexes:
214
204
  output.append(f"\n=== Indexes ===")
@@ -158,9 +158,7 @@ Note: Requires Neovim to be installed.
158
158
  return "Error: Must provide either 'command', 'commands', or 'macro'"
159
159
 
160
160
  if sum(bool(x) for x in [command, commands, macro]) > 1:
161
- return (
162
- "Error: Can only use one of 'command', 'commands', or 'macro' at a time"
163
- )
161
+ return "Error: Can only use one of 'command', 'commands', or 'macro' at a time"
164
162
 
165
163
  # Check if Neovim is available
166
164
  nvim_cmd = shutil.which("nvim")