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.

Files changed (87) hide show
  1. hanzo_mcp/__init__.py +1 -1
  2. hanzo_mcp/cli.py +123 -160
  3. hanzo_mcp/cli_enhanced.py +438 -0
  4. hanzo_mcp/config/__init__.py +19 -0
  5. hanzo_mcp/config/settings.py +388 -0
  6. hanzo_mcp/config/tool_config.py +197 -0
  7. hanzo_mcp/prompts/__init__.py +117 -0
  8. hanzo_mcp/prompts/compact_conversation.py +77 -0
  9. hanzo_mcp/prompts/create_release.py +38 -0
  10. hanzo_mcp/prompts/project_system.py +120 -0
  11. hanzo_mcp/prompts/project_todo_reminder.py +111 -0
  12. hanzo_mcp/prompts/utils.py +286 -0
  13. hanzo_mcp/server.py +120 -98
  14. hanzo_mcp/tools/__init__.py +107 -31
  15. hanzo_mcp/tools/agent/__init__.py +8 -11
  16. hanzo_mcp/tools/agent/agent_tool.py +290 -224
  17. hanzo_mcp/tools/agent/prompt.py +16 -13
  18. hanzo_mcp/tools/agent/tool_adapter.py +9 -9
  19. hanzo_mcp/tools/common/__init__.py +17 -16
  20. hanzo_mcp/tools/common/base.py +79 -110
  21. hanzo_mcp/tools/common/batch_tool.py +330 -0
  22. hanzo_mcp/tools/common/context.py +26 -292
  23. hanzo_mcp/tools/common/permissions.py +12 -12
  24. hanzo_mcp/tools/common/thinking_tool.py +153 -0
  25. hanzo_mcp/tools/common/validation.py +1 -63
  26. hanzo_mcp/tools/filesystem/__init__.py +88 -41
  27. hanzo_mcp/tools/filesystem/base.py +32 -24
  28. hanzo_mcp/tools/filesystem/content_replace.py +114 -107
  29. hanzo_mcp/tools/filesystem/directory_tree.py +129 -105
  30. hanzo_mcp/tools/filesystem/edit.py +279 -0
  31. hanzo_mcp/tools/filesystem/grep.py +458 -0
  32. hanzo_mcp/tools/filesystem/grep_ast_tool.py +250 -0
  33. hanzo_mcp/tools/filesystem/multi_edit.py +362 -0
  34. hanzo_mcp/tools/filesystem/read.py +255 -0
  35. hanzo_mcp/tools/filesystem/write.py +156 -0
  36. hanzo_mcp/tools/jupyter/__init__.py +41 -29
  37. hanzo_mcp/tools/jupyter/base.py +66 -57
  38. hanzo_mcp/tools/jupyter/{edit_notebook.py → notebook_edit.py} +162 -139
  39. hanzo_mcp/tools/jupyter/notebook_read.py +152 -0
  40. hanzo_mcp/tools/shell/__init__.py +29 -20
  41. hanzo_mcp/tools/shell/base.py +87 -45
  42. hanzo_mcp/tools/shell/bash_session.py +731 -0
  43. hanzo_mcp/tools/shell/bash_session_executor.py +295 -0
  44. hanzo_mcp/tools/shell/command_executor.py +435 -384
  45. hanzo_mcp/tools/shell/run_command.py +284 -131
  46. hanzo_mcp/tools/shell/run_command_windows.py +328 -0
  47. hanzo_mcp/tools/shell/session_manager.py +196 -0
  48. hanzo_mcp/tools/shell/session_storage.py +325 -0
  49. hanzo_mcp/tools/todo/__init__.py +66 -0
  50. hanzo_mcp/tools/todo/base.py +319 -0
  51. hanzo_mcp/tools/todo/todo_read.py +148 -0
  52. hanzo_mcp/tools/todo/todo_write.py +378 -0
  53. hanzo_mcp/tools/vector/__init__.py +95 -0
  54. hanzo_mcp/tools/vector/infinity_store.py +365 -0
  55. hanzo_mcp/tools/vector/project_manager.py +361 -0
  56. hanzo_mcp/tools/vector/vector_index.py +115 -0
  57. hanzo_mcp/tools/vector/vector_search.py +215 -0
  58. {hanzo_mcp-0.3.4.dist-info → hanzo_mcp-0.5.0.dist-info}/METADATA +35 -3
  59. hanzo_mcp-0.5.0.dist-info/RECORD +63 -0
  60. {hanzo_mcp-0.3.4.dist-info → hanzo_mcp-0.5.0.dist-info}/WHEEL +1 -1
  61. hanzo_mcp/tools/agent/base_provider.py +0 -73
  62. hanzo_mcp/tools/agent/litellm_provider.py +0 -45
  63. hanzo_mcp/tools/agent/lmstudio_agent.py +0 -385
  64. hanzo_mcp/tools/agent/lmstudio_provider.py +0 -219
  65. hanzo_mcp/tools/agent/provider_registry.py +0 -120
  66. hanzo_mcp/tools/common/error_handling.py +0 -86
  67. hanzo_mcp/tools/common/logging_config.py +0 -115
  68. hanzo_mcp/tools/common/session.py +0 -91
  69. hanzo_mcp/tools/common/think_tool.py +0 -123
  70. hanzo_mcp/tools/common/version_tool.py +0 -120
  71. hanzo_mcp/tools/filesystem/edit_file.py +0 -287
  72. hanzo_mcp/tools/filesystem/get_file_info.py +0 -170
  73. hanzo_mcp/tools/filesystem/read_files.py +0 -198
  74. hanzo_mcp/tools/filesystem/search_content.py +0 -275
  75. hanzo_mcp/tools/filesystem/write_file.py +0 -162
  76. hanzo_mcp/tools/jupyter/notebook_operations.py +0 -514
  77. hanzo_mcp/tools/jupyter/read_notebook.py +0 -165
  78. hanzo_mcp/tools/project/__init__.py +0 -64
  79. hanzo_mcp/tools/project/analysis.py +0 -882
  80. hanzo_mcp/tools/project/base.py +0 -66
  81. hanzo_mcp/tools/project/project_analyze.py +0 -173
  82. hanzo_mcp/tools/shell/run_script.py +0 -215
  83. hanzo_mcp/tools/shell/script_tool.py +0 -244
  84. hanzo_mcp-0.3.4.dist-info/RECORD +0 -53
  85. {hanzo_mcp-0.3.4.dist-info → hanzo_mcp-0.5.0.dist-info}/entry_points.txt +0 -0
  86. {hanzo_mcp-0.3.4.dist-info → hanzo_mcp-0.5.0.dist-info}/licenses/LICENSE +0 -0
  87. {hanzo_mcp-0.3.4.dist-info → hanzo_mcp-0.5.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,148 @@
1
+ """TodoRead tool implementation.
2
+
3
+ This module provides the TodoRead tool for reading the current todo list for a session.
4
+ """
5
+
6
+ import json
7
+ from typing import Annotated, TypedDict, Unpack, final, override
8
+
9
+ from fastmcp import Context as MCPContext
10
+ from fastmcp import FastMCP
11
+ from fastmcp.server.dependencies import get_context
12
+ from pydantic import Field
13
+
14
+ from hanzo_mcp.tools.todo.base import TodoBaseTool, TodoStorage
15
+
16
+ SessionId = Annotated[
17
+ str | int | float,
18
+ Field(
19
+ description="Unique identifier for the Claude Desktop session (generate using timestamp command)"
20
+ ),
21
+ ]
22
+
23
+
24
+ class TodoReadToolParams(TypedDict):
25
+ """Parameters for the TodoReadTool.
26
+
27
+ Attributes:
28
+ session_id: Unique identifier for the Claude Desktop session (generate using timestamp command)
29
+ """
30
+
31
+ session_id: SessionId
32
+
33
+
34
+ @final
35
+ class TodoReadTool(TodoBaseTool):
36
+ """Tool for reading the current todo list for a session."""
37
+
38
+ @property
39
+ @override
40
+ def name(self) -> str:
41
+ """Get the tool name.
42
+
43
+ Returns:
44
+ Tool name
45
+ """
46
+ return "todo_read"
47
+
48
+ @property
49
+ @override
50
+ def description(self) -> str:
51
+ """Get the tool description.
52
+
53
+ Returns:
54
+ Tool description
55
+ """
56
+ return """Use this tool to read the current to-do list for the session. This tool should be used proactively and frequently to ensure that you are aware of
57
+ the status of the current task list. You should make use of this tool as often as possible, especially in the following situations:
58
+ - At the beginning of conversations to see what's pending
59
+ - Before starting new tasks to prioritize work
60
+ - When the user asks about previous tasks or plans
61
+ - Whenever you're uncertain about what to do next
62
+ - After completing tasks to update your understanding of remaining work
63
+ - After every few messages to ensure you're on track
64
+
65
+ Usage:
66
+ - This tool requires a session_id parameter to identify the Claude Desktop conversation
67
+ - Returns a list of todo items with their status, priority, and content
68
+ - Use this information to track progress and plan next steps
69
+ - If no todos exist yet for the session, an empty list will be returned"""
70
+
71
+ @override
72
+ async def call(
73
+ self,
74
+ ctx: MCPContext,
75
+ **params: Unpack[TodoReadToolParams],
76
+ ) -> str:
77
+ """Execute the tool with the given parameters.
78
+
79
+ Args:
80
+ ctx: MCP context
81
+ **params: Tool parameters
82
+
83
+ Returns:
84
+ Tool result
85
+ """
86
+ tool_ctx = self.create_tool_context(ctx)
87
+ self.set_tool_context_info(tool_ctx)
88
+
89
+ # Extract parameters
90
+ session_id = params.get("session_id")
91
+
92
+ # Validate required parameters for direct calls (not through MCP framework)
93
+ if session_id is None:
94
+ await tool_ctx.error("Parameter 'session_id' is required but was None")
95
+ return "Error: Parameter 'session_id' is required but was None"
96
+
97
+ session_id = str(session_id)
98
+
99
+ # Validate session ID
100
+ is_valid, error_msg = self.validate_session_id(session_id)
101
+ if not is_valid:
102
+ await tool_ctx.error(f"Invalid session_id: {error_msg}")
103
+ return f"Error: Invalid session_id: {error_msg}"
104
+
105
+ await tool_ctx.info(f"Reading todos for session: {session_id}")
106
+
107
+ try:
108
+ # Get todos from storage
109
+ todos = TodoStorage.get_todos(session_id)
110
+
111
+ # Log status
112
+ if todos:
113
+ await tool_ctx.info(
114
+ f"Found {len(todos)} todos for session {session_id}"
115
+ )
116
+ else:
117
+ await tool_ctx.info(
118
+ f"No todos found for session {session_id} (returning empty list)"
119
+ )
120
+
121
+ # Return todos as JSON string
122
+ result = json.dumps(todos, indent=2)
123
+
124
+ return result
125
+
126
+ except Exception as e:
127
+ await tool_ctx.error(f"Error reading todos: {str(e)}")
128
+ return f"Error reading todos: {str(e)}"
129
+
130
+ @override
131
+ def register(self, mcp_server: FastMCP) -> None:
132
+ """Register this todo read tool with the MCP server.
133
+
134
+ Creates a wrapper function with explicitly defined parameters that match
135
+ the tool's parameter schema and registers it with the MCP server.
136
+
137
+ Args:
138
+ mcp_server: The FastMCP server instance
139
+ """
140
+ tool_self = self # Create a reference to self for use in the closure
141
+
142
+ @mcp_server.tool(name=self.name, description=self.description)
143
+ async def todo_read(
144
+ ctx: MCPContext,
145
+ session_id: SessionId,
146
+ ) -> str:
147
+ ctx = get_context()
148
+ return await tool_self.call(ctx, session_id=session_id)
@@ -0,0 +1,378 @@
1
+ """TodoWrite tool implementation.
2
+
3
+ This module provides the TodoWrite tool for creating and managing a structured task list for a session.
4
+ """
5
+
6
+ from typing import Annotated, Literal, TypedDict, Unpack, final, override
7
+
8
+ from fastmcp import Context as MCPContext
9
+ from fastmcp import FastMCP
10
+ from fastmcp.server.dependencies import get_context
11
+ from pydantic import Field
12
+
13
+ from hanzo_mcp.tools.todo.base import TodoBaseTool, TodoStorage
14
+
15
+
16
+ class TodoItem(TypedDict):
17
+ """A single todo item."""
18
+
19
+ content: Annotated[
20
+ str,
21
+ Field(
22
+ description="Description of the task to be completed",
23
+ min_length=1,
24
+ ),
25
+ ]
26
+ status: Annotated[
27
+ Literal["pending", "in_progress", "completed"],
28
+ Field(description="Current status of the task"),
29
+ ]
30
+ priority: Annotated[
31
+ Literal["high", "medium", "low"],
32
+ Field(description="Priority level of the task"),
33
+ ]
34
+ id: Annotated[
35
+ str,
36
+ Field(description="Unique identifier for the task", min_length=3),
37
+ ]
38
+
39
+
40
+ SessionId = Annotated[
41
+ str | int | float,
42
+ Field(
43
+ description="Unique identifier for the Claude Desktop session (generate using timestamp command)",
44
+ ),
45
+ ]
46
+
47
+ Todos = Annotated[
48
+ list[TodoItem],
49
+ Field(
50
+ description="The complete todo list to store for this session",
51
+ min_length=1,
52
+ ),
53
+ ]
54
+
55
+
56
+ class TodoWriteToolParams(TypedDict):
57
+ """Parameters for the TodoWriteTool.
58
+
59
+ Attributes:
60
+ session_id: Unique identifier for the Claude Desktop session (generate using timestamp command)
61
+ todos: The complete todo list to store for this session
62
+ """
63
+
64
+ session_id: SessionId
65
+ todos: Todos
66
+
67
+
68
+ @final
69
+ class TodoWriteTool(TodoBaseTool):
70
+ """Tool for creating and managing a structured task list for a session."""
71
+
72
+ @property
73
+ @override
74
+ def name(self) -> str:
75
+ """Get the tool name.
76
+
77
+ Returns:
78
+ Tool name
79
+ """
80
+ return "todo_write"
81
+
82
+ @property
83
+ @override
84
+ def description(self) -> str:
85
+ """Get the tool description.
86
+
87
+ Returns:
88
+ Tool description
89
+ """
90
+ return """Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
91
+ It also helps the user understand the progress of the task and overall progress of their requests.
92
+
93
+ ## When to Use This Tool
94
+ Use this tool proactively in these scenarios:
95
+
96
+ 1. Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
97
+ 2. Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
98
+ 3. User explicitly requests todo list - When the user directly asks you to use the todo list
99
+ 4. User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
100
+ 5. After receiving new instructions - Immediately capture user requirements as todos. Feel free to edit the todo list based on new information.
101
+ 6. After completing a task - Mark it complete and add any new follow-up tasks
102
+ 7. When you start working on a new task, mark the todo as in_progress. Ideally you should only have one todo as in_progress at a time. Complete existing tasks before starting new ones.
103
+
104
+ ## When NOT to Use This Tool
105
+
106
+ Skip using this tool when:
107
+ 1. There is only a single, straightforward task
108
+ 2. The task is trivial and tracking it provides no organizational benefit
109
+ 3. The task can be completed in less than 3 trivial steps
110
+ 4. The task is purely conversational or informational
111
+
112
+ NOTE that you should use should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.
113
+
114
+ ## Examples of When to Use the Todo List
115
+
116
+ <example>
117
+ User: I want to add a dark mode toggle to the application settings. Make sure you run the tests and build when you're done!
118
+ Assistant: I'll help add a dark mode toggle to your application settings. Let me create a todo list to track this implementation.
119
+ *Creates todo list with the following items:*
120
+ 1. Create dark mode toggle component in Settings page
121
+ 2. Add dark mode state management (context/store)
122
+ 3. Implement CSS-in-JS styles for dark theme
123
+ 4. Update existing components to support theme switching
124
+ 5. Run tests and build process, addressing any failures or errors that occur
125
+ *Begins working on the first task*
126
+
127
+ <reasoning>
128
+ The assistant used the todo list because:
129
+ 1. Adding dark mode is a multi-step feature requiring UI, state management, and styling changes
130
+ 2. The user explicitly requested tests and build be run afterward
131
+ 3. The assistant inferred that tests and build need to pass by adding \"Ensure tests and build succeed\" as the final task
132
+ </reasoning>
133
+ </example>
134
+
135
+ <example>
136
+ User: Help me rename the function getCwd to getCurrentWorkingDirectory across my project
137
+ Assistant: Let me first search through your codebase to find all occurrences of 'getCwd'.
138
+ *Uses grep or search tools to locate all instances of getCwd in the codebase*
139
+ Assistant: I've found 15 instances of 'getCwd' across 8 different files. Let me create a todo list to track these changes.
140
+ *Creates todo list with specific items for each file that needs updating*
141
+
142
+ <reasoning>
143
+ The assistant used the todo list because:
144
+ 1. First, the assistant searched to understand the scope of the task
145
+ 2. Upon finding multiple occurrences across different files, it determined this was a complex task with multiple steps
146
+ 3. The todo list helps ensure every instance is tracked and updated systematically
147
+ 4. This approach prevents missing any occurrences and maintains code consistency
148
+ </reasoning>
149
+ </example>
150
+
151
+
152
+ <example>
153
+ User: I need to implement these features for my e-commerce site: user registration, product catalog, shopping cart, and checkout flow.
154
+ Assistant: I'll help implement these features. First, let's add all the features to the todo list.
155
+ *Creates a todo list breaking down each feature into specific tasks based on the project architecture*
156
+ Assistant: Let's start with user registration. This will involve creating database models, API endpoints, and frontend forms that integrate with your existing authentication system.
157
+
158
+ <reasoning>
159
+ The assistant used the todo list because:
160
+ 1. The user provided multiple complex features to implement in a comma separated list
161
+ 2. The todo list helps organize these large features into manageable tasks
162
+ 3. This approach allows for tracking progress across the entire implementation
163
+ </reasoning>
164
+ </example>
165
+
166
+ <example>
167
+ User: Can you help optimize my React application? It's rendering slowly and has performance issues.</user>
168
+ Assistant: I'll help optimize your React application. First, let me examine your codebase to identify potential performance bottlenecks.
169
+ *Reviews component structure, render patterns, state management, and data fetching*
170
+ Assistant: After analyzing your codebase, I've identified several performance issues. Let me create a todo list to track our optimization efforts.
171
+ *Creates todo list with items like: 1) Implement memoization for expensive calculations in ProductList, 2) Add virtualization for long lists in Dashboard, 3) Optimize image loading in Gallery component, 4) Fix state update loops in ShoppingCart, 5) Review bundle size and implement code splitting*
172
+ Let's start by implementing memoization for the expensive calculations in your ProductList component.</assistant>
173
+
174
+ <reasoning>
175
+ The assistant used the todo list because:
176
+ 1. First, the assistant examined the codebase to identify specific performance issues
177
+ 2. Based on this analysis, it identified multiple optimization opportunities
178
+ 3. Performance optimization is a non-trivial task requiring multiple steps
179
+ 4. The todo list helps methodically track improvements across different components
180
+ 5. This systematic approach ensures all performance bottlenecks are addressed
181
+ </reasoning>
182
+ </example>
183
+
184
+ ## Examples of When NOT to Use the Todo List
185
+
186
+ <example>
187
+ User: How do I print 'Hello World' in Python?
188
+ Assistant: In Python, you can print \"Hello World\" with this simple code:
189
+
190
+ python
191
+ print(\"Hello World\")
192
+
193
+ This will output the text \"Hello World\" to the console when executed.</assistant>
194
+
195
+ <reasoning>
196
+ The assistant did not use the todo list because this is a single, trivial task that can be completed in one step. There's no need to track multiple tasks or steps for such a straightforward request.
197
+ </reasoning>
198
+ </example>
199
+
200
+ <example>
201
+ User: What does the git status command do?
202
+ Assistant: The git status command shows the current state of your working directory and staging area. It displays which changes have been staged, which haven't, and which files aren't being tracked by Git. This is a fundamental command for understanding the current state of your repository before making commits.
203
+
204
+ <reasoning>
205
+ The assistant did not use the todo list because this is an informational request with no actual coding task to complete. The user is simply asking for an explanation, not for the assistant to perform multiple steps or tasks.
206
+ </reasoning>
207
+ </example>
208
+
209
+ <example>
210
+ User: Can you add a comment to the calculateTotal function to explain what it does?
211
+ Assistant: Sure, let me add a comment to the calculateTotal function to explain what it does.
212
+ * Uses the Edit tool to add a comment to the calculateTotal function *
213
+
214
+ <reasoning>
215
+ The assistant did not use the todo list because this is a single, straightforward task confined to one location in the code. Adding a comment doesn't require tracking multiple steps or systematic organization.
216
+ </reasoning>
217
+ </example>
218
+
219
+ <example>
220
+ User: Run npm install for me and tell me what happens.
221
+ Assistant: I'll run the npm install command for you.
222
+
223
+ *Executes: npm install*
224
+
225
+ The command completed successfully. Here's the output:
226
+ [Output of npm install command]
227
+
228
+ All dependencies have been installed according to your package.json file.
229
+
230
+ <reasoning>
231
+ The assistant did not use the todo list because this is a single command execution with immediate results. There are no multiple steps to track or organize, making the todo list unnecessary for this straightforward task.
232
+ </reasoning>
233
+ </example>
234
+
235
+ ## Task States and Management
236
+
237
+ 1. **Task States**: Use these states to track progress:
238
+ - pending: Task not yet started
239
+ - in_progress: Currently working on (limit to ONE task at a time)
240
+ - completed: Task finished successfully
241
+ - cancelled: Task no longer needed
242
+
243
+ 2. **Task Management**:
244
+ - Update task status in real-time as you work
245
+ - Mark tasks complete IMMEDIATELY after finishing (don't batch completions)
246
+ - Only have ONE task in_progress at any time
247
+ - Complete current tasks before starting new ones
248
+ - Cancel tasks that become irrelevant
249
+
250
+ 3. **Task Breakdown**:
251
+ - Create specific, actionable items
252
+ - Break complex tasks into smaller, manageable steps
253
+ - Use clear, descriptive task names
254
+
255
+ When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully."""
256
+
257
+ @override
258
+ async def call(
259
+ self,
260
+ ctx: MCPContext,
261
+ **params: Unpack[TodoWriteToolParams],
262
+ ) -> str:
263
+ """Execute the tool with the given parameters.
264
+
265
+ Args:
266
+ ctx: MCP context
267
+ **params: Tool parameters
268
+
269
+ Returns:
270
+ Tool result
271
+ """
272
+ tool_ctx = self.create_tool_context(ctx)
273
+ self.set_tool_context_info(tool_ctx)
274
+
275
+ # Extract parameters
276
+ session_id = params.get("session_id")
277
+ todos = params.get("todos")
278
+
279
+ # Validate required parameters for direct calls (not through MCP framework)
280
+ if session_id is None:
281
+ await tool_ctx.error("Parameter 'session_id' is required but was None")
282
+ return "Error: Parameter 'session_id' is required but was None"
283
+
284
+ if todos is None:
285
+ await tool_ctx.error("Parameter 'todos' is required but was None")
286
+ return "Error: Parameter 'todos' is required but was None"
287
+
288
+ session_id = str(session_id)
289
+
290
+ # Validate session ID
291
+ is_valid, error_msg = self.validate_session_id(session_id)
292
+ if not is_valid:
293
+ await tool_ctx.error(f"Invalid session_id: {error_msg}")
294
+ return f"Error: Invalid session_id: {error_msg}"
295
+
296
+ # Normalize todos list (auto-generate missing fields)
297
+ todos = self.normalize_todos_list(todos)
298
+
299
+ # Validate todos list
300
+ is_valid, error_msg = self.validate_todos_list(todos)
301
+ if not is_valid:
302
+ await tool_ctx.error(f"Invalid todos: {error_msg}")
303
+ return f"Error: Invalid todos: {error_msg}"
304
+
305
+ await tool_ctx.info(f"Writing {len(todos)} todos for session: {session_id}")
306
+
307
+ try:
308
+ # Store todos in memory
309
+ TodoStorage.set_todos(session_id, todos)
310
+
311
+ # Log storage stats
312
+ session_count = TodoStorage.get_session_count()
313
+ await tool_ctx.info(
314
+ f"Successfully stored todos. Total active sessions: {session_count}"
315
+ )
316
+
317
+ # Provide feedback about the todos
318
+ if todos:
319
+ status_counts = {}
320
+ priority_counts = {}
321
+
322
+ for todo in todos:
323
+ status = todo.get("status", "unknown")
324
+ priority = todo.get("priority", "unknown")
325
+
326
+ status_counts[status] = status_counts.get(status, 0) + 1
327
+ priority_counts[priority] = priority_counts.get(priority, 0) + 1
328
+
329
+ # Create summary
330
+ summary_parts = []
331
+ if status_counts:
332
+ status_summary = ", ".join(
333
+ [f"{count} {status}" for status, count in status_counts.items()]
334
+ )
335
+ summary_parts.append(f"Status: {status_summary}")
336
+
337
+ if priority_counts:
338
+ priority_summary = ", ".join(
339
+ [
340
+ f"{count} {priority}"
341
+ for priority, count in priority_counts.items()
342
+ ]
343
+ )
344
+ summary_parts.append(f"Priority: {priority_summary}")
345
+
346
+ summary = (
347
+ f"Successfully stored {len(todos)} todos for session {session_id}.\n"
348
+ + "; ".join(summary_parts)
349
+ )
350
+
351
+ return summary
352
+ else:
353
+ return f"Successfully cleared todos for session {session_id} (stored empty list)."
354
+
355
+ except Exception as e:
356
+ await tool_ctx.error(f"Error storing todos: {str(e)}")
357
+ return f"Error storing todos: {str(e)}"
358
+
359
+ @override
360
+ def register(self, mcp_server: FastMCP) -> None:
361
+ """Register this todo write tool with the MCP server.
362
+
363
+ Creates a wrapper function with explicitly defined parameters that match
364
+ the tool's parameter schema and registers it with the MCP server.
365
+
366
+ Args:
367
+ mcp_server: The FastMCP server instance
368
+ """
369
+ tool_self = self # Create a reference to self for use in the closure
370
+
371
+ @mcp_server.tool(name=self.name, description=self.description)
372
+ async def todo_write(
373
+ ctx: MCPContext,
374
+ session_id: SessionId,
375
+ todos: Todos,
376
+ ) -> str:
377
+ ctx = get_context()
378
+ return await tool_self.call(ctx, session_id=session_id, todos=todos)
@@ -0,0 +1,95 @@
1
+ """Vector database tools for Hanzo MCP.
2
+
3
+ This package provides tools for working with local vector databases for semantic search,
4
+ document indexing, and retrieval-augmented generation (RAG) workflows.
5
+
6
+ Supported backends:
7
+ - Infinity database (default) - High-performance local vector database
8
+ """
9
+
10
+ from hanzo_mcp.tools.common.base import BaseTool
11
+ from hanzo_mcp.tools.common.permissions import PermissionManager
12
+ from fastmcp import FastMCP
13
+
14
+ # Try to import vector dependencies
15
+ try:
16
+ from .infinity_store import InfinityVectorStore
17
+ from .project_manager import ProjectVectorManager
18
+ from .vector_index import VectorIndexTool
19
+ from .vector_search import VectorSearchTool
20
+
21
+ VECTOR_AVAILABLE = True
22
+
23
+ def register_vector_tools(
24
+ mcp_server: FastMCP,
25
+ permission_manager: PermissionManager,
26
+ vector_config: dict | None = None,
27
+ enabled_tools: dict[str, bool] | None = None,
28
+ search_paths: list[str] | None = None,
29
+ ) -> list[BaseTool]:
30
+ """Register vector database tools with the MCP server.
31
+
32
+ Args:
33
+ mcp_server: The FastMCP server instance
34
+ permission_manager: Permission manager for access control
35
+ vector_config: Vector store configuration
36
+ enabled_tools: Dictionary of individual tool enable states
37
+ search_paths: Paths to search for projects (default: None, uses allowed paths)
38
+
39
+ Returns:
40
+ List of registered tools
41
+ """
42
+ if not vector_config or not vector_config.get("enabled", False):
43
+ return []
44
+
45
+ # Check individual tool enablement
46
+ tool_enabled = enabled_tools or {}
47
+ tools = []
48
+
49
+ # Initialize project-aware vector manager
50
+ store_config = vector_config.copy()
51
+ project_manager = ProjectVectorManager(
52
+ global_db_path=store_config.get("data_path"),
53
+ embedding_model=store_config.get("embedding_model", "text-embedding-3-small"),
54
+ dimension=store_config.get("dimension", 1536),
55
+ )
56
+
57
+ # Auto-detect projects from search paths
58
+ if search_paths:
59
+ detected_projects = project_manager.detect_projects(search_paths)
60
+ print(f"Detected {len(detected_projects)} projects with LLM.md files")
61
+
62
+ # Register individual tools if enabled
63
+ if tool_enabled.get("vector_index", True):
64
+ tools.append(VectorIndexTool(permission_manager, project_manager))
65
+
66
+ if tool_enabled.get("vector_search", True):
67
+ tools.append(VectorSearchTool(permission_manager, project_manager))
68
+
69
+ # Register with MCP server
70
+ from hanzo_mcp.tools.common.base import ToolRegistry
71
+ ToolRegistry.register_tools(mcp_server, tools)
72
+
73
+ return tools
74
+
75
+ except ImportError:
76
+ VECTOR_AVAILABLE = False
77
+
78
+ def register_vector_tools(*args, **kwargs) -> list[BaseTool]:
79
+ """Vector tools not available - missing dependencies."""
80
+ print("Warning: Vector tools not available. Install infinity-embedded: pip install infinity-embedded")
81
+ return []
82
+
83
+
84
+ __all__ = [
85
+ "register_vector_tools",
86
+ "VECTOR_AVAILABLE",
87
+ ]
88
+
89
+ if VECTOR_AVAILABLE:
90
+ __all__.extend([
91
+ "InfinityVectorStore",
92
+ "ProjectVectorManager",
93
+ "VectorIndexTool",
94
+ "VectorSearchTool",
95
+ ])