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
|
@@ -4,7 +4,8 @@ This module provides MCP tools that use the hanzo-memory package as a library.
|
|
|
4
4
|
The hanzo-memory package provides embedded database and vector search capabilities.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
-
from typing import
|
|
7
|
+
from typing import Dict, List, Optional, final, override
|
|
8
|
+
|
|
8
9
|
from mcp.server import FastMCP
|
|
9
10
|
from mcp.server.fastmcp import Context as MCPContext
|
|
10
11
|
|
|
@@ -13,23 +14,23 @@ from hanzo_mcp.tools.common.context import create_tool_context
|
|
|
13
14
|
|
|
14
15
|
# Import from hanzo-memory package
|
|
15
16
|
try:
|
|
16
|
-
from hanzo_memory.services.memory import MemoryService, get_memory_service
|
|
17
17
|
from hanzo_memory.models.memory import Memory, MemoryWithScore
|
|
18
|
+
from hanzo_memory.services.memory import MemoryService, get_memory_service
|
|
19
|
+
|
|
18
20
|
MEMORY_AVAILABLE = True
|
|
19
21
|
except ImportError:
|
|
20
22
|
MEMORY_AVAILABLE = False
|
|
21
23
|
raise ImportError(
|
|
22
|
-
"hanzo-memory package is required for memory tools. "
|
|
23
|
-
"Install it from ~/work/hanzo/ide/pkg/memory"
|
|
24
|
+
"hanzo-memory package is required for memory tools. Install it from ~/work/hanzo/ide/pkg/memory"
|
|
24
25
|
)
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
class MemoryToolBase(BaseTool):
|
|
28
29
|
"""Base class for memory tools using hanzo-memory package."""
|
|
29
|
-
|
|
30
|
+
|
|
30
31
|
def __init__(self, user_id: str = "default", project_id: str = "default", **kwargs):
|
|
31
32
|
"""Initialize memory tool.
|
|
32
|
-
|
|
33
|
+
|
|
33
34
|
Args:
|
|
34
35
|
user_id: User ID for memory operations
|
|
35
36
|
project_id: Project ID for memory operations
|
|
@@ -44,13 +45,13 @@ class MemoryToolBase(BaseTool):
|
|
|
44
45
|
@final
|
|
45
46
|
class RecallMemoriesTool(MemoryToolBase):
|
|
46
47
|
"""Tool for recalling memories."""
|
|
47
|
-
|
|
48
|
+
|
|
48
49
|
@property
|
|
49
50
|
@override
|
|
50
51
|
def name(self) -> str:
|
|
51
52
|
"""Get the tool name."""
|
|
52
53
|
return "recall_memories"
|
|
53
|
-
|
|
54
|
+
|
|
54
55
|
@property
|
|
55
56
|
@override
|
|
56
57
|
def description(self) -> str:
|
|
@@ -66,30 +67,30 @@ recall_memories(queries=["user preferences", "previous conversations"])
|
|
|
66
67
|
recall_memories(queries=["project requirements"], scope="project")
|
|
67
68
|
recall_memories(queries=["coding standards"], scope="global")
|
|
68
69
|
"""
|
|
69
|
-
|
|
70
|
+
|
|
70
71
|
@override
|
|
71
72
|
async def call(
|
|
72
73
|
self,
|
|
73
74
|
ctx: MCPContext,
|
|
74
75
|
queries: List[str],
|
|
75
76
|
limit: int = 10,
|
|
76
|
-
scope: str = "project"
|
|
77
|
+
scope: str = "project",
|
|
77
78
|
) -> str:
|
|
78
79
|
"""Recall memories matching queries.
|
|
79
|
-
|
|
80
|
+
|
|
80
81
|
Args:
|
|
81
82
|
ctx: MCP context
|
|
82
83
|
queries: Search queries
|
|
83
84
|
limit: Max results per query
|
|
84
|
-
|
|
85
|
+
|
|
85
86
|
Returns:
|
|
86
87
|
Formatted memory results
|
|
87
88
|
"""
|
|
88
89
|
tool_ctx = create_tool_context(ctx)
|
|
89
90
|
await tool_ctx.set_tool_info(self.name)
|
|
90
|
-
|
|
91
|
+
|
|
91
92
|
await tool_ctx.info(f"Searching for {len(queries)} queries")
|
|
92
|
-
|
|
93
|
+
|
|
93
94
|
all_results = []
|
|
94
95
|
for query in queries:
|
|
95
96
|
# Use hanzo-memory's search_memories method
|
|
@@ -97,10 +98,10 @@ recall_memories(queries=["coding standards"], scope="global")
|
|
|
97
98
|
user_id=self.user_id,
|
|
98
99
|
query=query,
|
|
99
100
|
project_id=self.project_id,
|
|
100
|
-
limit=limit
|
|
101
|
+
limit=limit,
|
|
101
102
|
)
|
|
102
103
|
all_results.extend(results)
|
|
103
|
-
|
|
104
|
+
|
|
104
105
|
# Deduplicate by memory_id
|
|
105
106
|
seen = set()
|
|
106
107
|
unique_results = []
|
|
@@ -108,29 +109,26 @@ recall_memories(queries=["coding standards"], scope="global")
|
|
|
108
109
|
if result.memory_id not in seen:
|
|
109
110
|
seen.add(result.memory_id)
|
|
110
111
|
unique_results.append(result)
|
|
111
|
-
|
|
112
|
+
|
|
112
113
|
if not unique_results:
|
|
113
114
|
return "No relevant memories found."
|
|
114
|
-
|
|
115
|
+
|
|
115
116
|
# Format results
|
|
116
117
|
formatted = [f"Found {len(unique_results)} relevant memories:\n"]
|
|
117
118
|
for i, memory in enumerate(unique_results, 1):
|
|
118
|
-
score = getattr(memory,
|
|
119
|
+
score = getattr(memory, "similarity_score", 0.0)
|
|
119
120
|
formatted.append(f"{i}. {memory.content} (relevance: {score:.2f})")
|
|
120
|
-
|
|
121
|
+
|
|
121
122
|
return "\n".join(formatted)
|
|
122
|
-
|
|
123
|
+
|
|
123
124
|
@override
|
|
124
125
|
def register(self, mcp_server: FastMCP) -> None:
|
|
125
126
|
"""Register this tool with the MCP server."""
|
|
126
127
|
tool_self = self
|
|
127
|
-
|
|
128
|
+
|
|
128
129
|
@mcp_server.tool(name=self.name, description=self.description)
|
|
129
130
|
async def recall_memories(
|
|
130
|
-
ctx: MCPContext,
|
|
131
|
-
queries: List[str],
|
|
132
|
-
limit: int = 10,
|
|
133
|
-
scope: str = "project"
|
|
131
|
+
ctx: MCPContext, queries: List[str], limit: int = 10, scope: str = "project"
|
|
134
132
|
) -> str:
|
|
135
133
|
return await tool_self.call(ctx, queries=queries, limit=limit, scope=scope)
|
|
136
134
|
|
|
@@ -138,13 +136,13 @@ recall_memories(queries=["coding standards"], scope="global")
|
|
|
138
136
|
@final
|
|
139
137
|
class CreateMemoriesTool(MemoryToolBase):
|
|
140
138
|
"""Tool for creating memories."""
|
|
141
|
-
|
|
139
|
+
|
|
142
140
|
@property
|
|
143
141
|
@override
|
|
144
142
|
def name(self) -> str:
|
|
145
143
|
"""Get the tool name."""
|
|
146
144
|
return "create_memories"
|
|
147
|
-
|
|
145
|
+
|
|
148
146
|
@property
|
|
149
147
|
@override
|
|
150
148
|
def description(self) -> str:
|
|
@@ -157,27 +155,23 @@ Each statement is stored as a separate memory.
|
|
|
157
155
|
Usage:
|
|
158
156
|
create_memories(statements=["User prefers dark mode", "User works in Python"])
|
|
159
157
|
"""
|
|
160
|
-
|
|
158
|
+
|
|
161
159
|
@override
|
|
162
|
-
async def call(
|
|
163
|
-
self,
|
|
164
|
-
ctx: MCPContext,
|
|
165
|
-
statements: List[str]
|
|
166
|
-
) -> str:
|
|
160
|
+
async def call(self, ctx: MCPContext, statements: List[str]) -> str:
|
|
167
161
|
"""Create new memories.
|
|
168
|
-
|
|
162
|
+
|
|
169
163
|
Args:
|
|
170
164
|
ctx: MCP context
|
|
171
165
|
statements: Statements to memorize
|
|
172
|
-
|
|
166
|
+
|
|
173
167
|
Returns:
|
|
174
168
|
Success message
|
|
175
169
|
"""
|
|
176
170
|
tool_ctx = create_tool_context(ctx)
|
|
177
171
|
await tool_ctx.set_tool_info(self.name)
|
|
178
|
-
|
|
172
|
+
|
|
179
173
|
await tool_ctx.info(f"Creating {len(statements)} memories")
|
|
180
|
-
|
|
174
|
+
|
|
181
175
|
created_memories = []
|
|
182
176
|
for statement in statements:
|
|
183
177
|
# Use hanzo-memory's create_memory method
|
|
@@ -185,35 +179,32 @@ create_memories(statements=["User prefers dark mode", "User works in Python"])
|
|
|
185
179
|
user_id=self.user_id,
|
|
186
180
|
project_id=self.project_id,
|
|
187
181
|
content=statement,
|
|
188
|
-
metadata={"type": "statement"}
|
|
182
|
+
metadata={"type": "statement"},
|
|
189
183
|
)
|
|
190
184
|
created_memories.append(memory)
|
|
191
|
-
|
|
185
|
+
|
|
192
186
|
return f"Successfully created {len(created_memories)} new memories."
|
|
193
|
-
|
|
187
|
+
|
|
194
188
|
@override
|
|
195
189
|
def register(self, mcp_server: FastMCP) -> None:
|
|
196
190
|
"""Register this tool with the MCP server."""
|
|
197
191
|
tool_self = self
|
|
198
|
-
|
|
192
|
+
|
|
199
193
|
@mcp_server.tool(name=self.name, description=self.description)
|
|
200
|
-
async def create_memories(
|
|
201
|
-
ctx: MCPContext,
|
|
202
|
-
statements: List[str]
|
|
203
|
-
) -> str:
|
|
194
|
+
async def create_memories(ctx: MCPContext, statements: List[str]) -> str:
|
|
204
195
|
return await tool_self.call(ctx, statements=statements)
|
|
205
196
|
|
|
206
197
|
|
|
207
198
|
@final
|
|
208
199
|
class UpdateMemoriesTool(MemoryToolBase):
|
|
209
200
|
"""Tool for updating memories."""
|
|
210
|
-
|
|
201
|
+
|
|
211
202
|
@property
|
|
212
203
|
@override
|
|
213
204
|
def name(self) -> str:
|
|
214
205
|
"""Get the tool name."""
|
|
215
206
|
return "update_memories"
|
|
216
|
-
|
|
207
|
+
|
|
217
208
|
@property
|
|
218
209
|
@override
|
|
219
210
|
def description(self) -> str:
|
|
@@ -228,52 +219,49 @@ update_memories(updates=[
|
|
|
228
219
|
{"id": "mem_2", "statement": "User primarily works in TypeScript"}
|
|
229
220
|
])
|
|
230
221
|
"""
|
|
231
|
-
|
|
222
|
+
|
|
232
223
|
@override
|
|
233
|
-
async def call(
|
|
234
|
-
self,
|
|
235
|
-
ctx: MCPContext,
|
|
236
|
-
updates: List[Dict[str, str]]
|
|
237
|
-
) -> str:
|
|
224
|
+
async def call(self, ctx: MCPContext, updates: List[Dict[str, str]]) -> str:
|
|
238
225
|
"""Update memories.
|
|
239
|
-
|
|
226
|
+
|
|
240
227
|
Args:
|
|
241
228
|
ctx: MCP context
|
|
242
229
|
updates: List of {id, statement} dicts
|
|
243
|
-
|
|
230
|
+
|
|
244
231
|
Returns:
|
|
245
232
|
Success message
|
|
246
233
|
"""
|
|
247
234
|
tool_ctx = create_tool_context(ctx)
|
|
248
235
|
await tool_ctx.set_tool_info(self.name)
|
|
249
|
-
|
|
236
|
+
|
|
250
237
|
await tool_ctx.info(f"Updating {len(updates)} memories")
|
|
251
|
-
|
|
238
|
+
|
|
252
239
|
# Note: hanzo-memory's update methods are not fully implemented yet
|
|
253
240
|
# For now, we'll track what would be updated
|
|
254
241
|
success_count = 0
|
|
255
242
|
for update in updates:
|
|
256
243
|
memory_id = update.get("id")
|
|
257
244
|
statement = update.get("statement")
|
|
258
|
-
|
|
245
|
+
|
|
259
246
|
if memory_id and statement:
|
|
260
247
|
# The hanzo-memory service doesn't have update implemented yet
|
|
261
248
|
# When it's implemented, we would call:
|
|
262
249
|
# success = self.service.update_memory(self.user_id, memory_id, content=statement)
|
|
263
|
-
await tool_ctx.warning(
|
|
250
|
+
await tool_ctx.warning(
|
|
251
|
+
f"Memory update not fully implemented in hanzo-memory yet: {memory_id}"
|
|
252
|
+
)
|
|
264
253
|
success_count += 1
|
|
265
|
-
|
|
254
|
+
|
|
266
255
|
return f"Would update {success_count} of {len(updates)} memories (update not fully implemented in hanzo-memory yet)."
|
|
267
|
-
|
|
256
|
+
|
|
268
257
|
@override
|
|
269
258
|
def register(self, mcp_server: FastMCP) -> None:
|
|
270
259
|
"""Register this tool with the MCP server."""
|
|
271
260
|
tool_self = self
|
|
272
|
-
|
|
261
|
+
|
|
273
262
|
@mcp_server.tool(name=self.name, description=self.description)
|
|
274
263
|
async def update_memories(
|
|
275
|
-
ctx: MCPContext,
|
|
276
|
-
updates: List[Dict[str, str]]
|
|
264
|
+
ctx: MCPContext, updates: List[Dict[str, str]]
|
|
277
265
|
) -> str:
|
|
278
266
|
return await tool_self.call(ctx, updates=updates)
|
|
279
267
|
|
|
@@ -281,13 +269,13 @@ update_memories(updates=[
|
|
|
281
269
|
@final
|
|
282
270
|
class DeleteMemoriesTool(MemoryToolBase):
|
|
283
271
|
"""Tool for deleting memories."""
|
|
284
|
-
|
|
272
|
+
|
|
285
273
|
@property
|
|
286
274
|
@override
|
|
287
275
|
def name(self) -> str:
|
|
288
276
|
"""Get the tool name."""
|
|
289
277
|
return "delete_memories"
|
|
290
|
-
|
|
278
|
+
|
|
291
279
|
@property
|
|
292
280
|
@override
|
|
293
281
|
def description(self) -> str:
|
|
@@ -299,59 +287,52 @@ This tool removes memories by their IDs.
|
|
|
299
287
|
Usage:
|
|
300
288
|
delete_memories(ids=["mem_1", "mem_2"])
|
|
301
289
|
"""
|
|
302
|
-
|
|
290
|
+
|
|
303
291
|
@override
|
|
304
|
-
async def call(
|
|
305
|
-
self,
|
|
306
|
-
ctx: MCPContext,
|
|
307
|
-
ids: List[str]
|
|
308
|
-
) -> str:
|
|
292
|
+
async def call(self, ctx: MCPContext, ids: List[str]) -> str:
|
|
309
293
|
"""Delete memories.
|
|
310
|
-
|
|
294
|
+
|
|
311
295
|
Args:
|
|
312
296
|
ctx: MCP context
|
|
313
297
|
ids: Memory IDs to delete
|
|
314
|
-
|
|
298
|
+
|
|
315
299
|
Returns:
|
|
316
300
|
Success message
|
|
317
301
|
"""
|
|
318
302
|
tool_ctx = create_tool_context(ctx)
|
|
319
303
|
await tool_ctx.set_tool_info(self.name)
|
|
320
|
-
|
|
304
|
+
|
|
321
305
|
await tool_ctx.info(f"Deleting {len(ids)} memories")
|
|
322
|
-
|
|
306
|
+
|
|
323
307
|
success_count = 0
|
|
324
308
|
for memory_id in ids:
|
|
325
309
|
# Use hanzo-memory's delete_memory method
|
|
326
310
|
success = self.service.delete_memory(self.user_id, memory_id)
|
|
327
311
|
if success:
|
|
328
312
|
success_count += 1
|
|
329
|
-
|
|
313
|
+
|
|
330
314
|
return f"Successfully deleted {success_count} of {len(ids)} memories."
|
|
331
|
-
|
|
315
|
+
|
|
332
316
|
@override
|
|
333
317
|
def register(self, mcp_server: FastMCP) -> None:
|
|
334
318
|
"""Register this tool with the MCP server."""
|
|
335
319
|
tool_self = self
|
|
336
|
-
|
|
320
|
+
|
|
337
321
|
@mcp_server.tool(name=self.name, description=self.description)
|
|
338
|
-
async def delete_memories(
|
|
339
|
-
ctx: MCPContext,
|
|
340
|
-
ids: List[str]
|
|
341
|
-
) -> str:
|
|
322
|
+
async def delete_memories(ctx: MCPContext, ids: List[str]) -> str:
|
|
342
323
|
return await tool_self.call(ctx, ids=ids)
|
|
343
324
|
|
|
344
325
|
|
|
345
326
|
@final
|
|
346
327
|
class ManageMemoriesTool(MemoryToolBase):
|
|
347
328
|
"""Tool for managing memories atomically."""
|
|
348
|
-
|
|
329
|
+
|
|
349
330
|
@property
|
|
350
331
|
@override
|
|
351
332
|
def name(self) -> str:
|
|
352
333
|
"""Get the tool name."""
|
|
353
334
|
return "manage_memories"
|
|
354
|
-
|
|
335
|
+
|
|
355
336
|
@property
|
|
356
337
|
@override
|
|
357
338
|
def description(self) -> str:
|
|
@@ -368,31 +349,31 @@ manage_memories(
|
|
|
368
349
|
deletions=["mem_old1", "mem_old2"]
|
|
369
350
|
)
|
|
370
351
|
"""
|
|
371
|
-
|
|
352
|
+
|
|
372
353
|
@override
|
|
373
354
|
async def call(
|
|
374
355
|
self,
|
|
375
356
|
ctx: MCPContext,
|
|
376
357
|
creations: Optional[List[str]] = None,
|
|
377
358
|
updates: Optional[List[Dict[str, str]]] = None,
|
|
378
|
-
deletions: Optional[List[str]] = None
|
|
359
|
+
deletions: Optional[List[str]] = None,
|
|
379
360
|
) -> str:
|
|
380
361
|
"""Manage memories atomically.
|
|
381
|
-
|
|
362
|
+
|
|
382
363
|
Args:
|
|
383
364
|
ctx: MCP context
|
|
384
365
|
creations: Statements to create
|
|
385
366
|
updates: Memories to update
|
|
386
367
|
deletions: Memory IDs to delete
|
|
387
|
-
|
|
368
|
+
|
|
388
369
|
Returns:
|
|
389
370
|
Summary of operations
|
|
390
371
|
"""
|
|
391
372
|
tool_ctx = create_tool_context(ctx)
|
|
392
373
|
await tool_ctx.set_tool_info(self.name)
|
|
393
|
-
|
|
374
|
+
|
|
394
375
|
results = []
|
|
395
|
-
|
|
376
|
+
|
|
396
377
|
# Create memories
|
|
397
378
|
if creations:
|
|
398
379
|
await tool_ctx.info(f"Creating {len(creations)} memories")
|
|
@@ -402,11 +383,11 @@ manage_memories(
|
|
|
402
383
|
user_id=self.user_id,
|
|
403
384
|
project_id=self.project_id,
|
|
404
385
|
content=statement,
|
|
405
|
-
metadata={"type": "statement"}
|
|
386
|
+
metadata={"type": "statement"},
|
|
406
387
|
)
|
|
407
388
|
created.append(memory)
|
|
408
389
|
results.append(f"Created {len(created)} memories")
|
|
409
|
-
|
|
390
|
+
|
|
410
391
|
# Update memories
|
|
411
392
|
if updates:
|
|
412
393
|
await tool_ctx.info(f"Updating {len(updates)} memories")
|
|
@@ -414,13 +395,17 @@ manage_memories(
|
|
|
414
395
|
for update in updates:
|
|
415
396
|
memory_id = update.get("id")
|
|
416
397
|
statement = update.get("statement")
|
|
417
|
-
|
|
398
|
+
|
|
418
399
|
if memory_id and statement:
|
|
419
400
|
# Update not fully implemented in hanzo-memory yet
|
|
420
|
-
await tool_ctx.warning(
|
|
401
|
+
await tool_ctx.warning(
|
|
402
|
+
f"Memory update not fully implemented: {memory_id}"
|
|
403
|
+
)
|
|
421
404
|
success_count += 1
|
|
422
|
-
results.append(
|
|
423
|
-
|
|
405
|
+
results.append(
|
|
406
|
+
f"Would update {success_count} memories (update pending implementation)"
|
|
407
|
+
)
|
|
408
|
+
|
|
424
409
|
# Delete memories
|
|
425
410
|
if deletions:
|
|
426
411
|
await tool_ctx.info(f"Deleting {len(deletions)} memories")
|
|
@@ -430,27 +415,24 @@ manage_memories(
|
|
|
430
415
|
if success:
|
|
431
416
|
success_count += 1
|
|
432
417
|
results.append(f"Deleted {success_count} memories")
|
|
433
|
-
|
|
418
|
+
|
|
434
419
|
if not results:
|
|
435
420
|
return "No memory operations performed."
|
|
436
|
-
|
|
421
|
+
|
|
437
422
|
return "Memory operations completed: " + ", ".join(results)
|
|
438
|
-
|
|
423
|
+
|
|
439
424
|
@override
|
|
440
425
|
def register(self, mcp_server: FastMCP) -> None:
|
|
441
426
|
"""Register this tool with the MCP server."""
|
|
442
427
|
tool_self = self
|
|
443
|
-
|
|
428
|
+
|
|
444
429
|
@mcp_server.tool(name=self.name, description=self.description)
|
|
445
430
|
async def manage_memories(
|
|
446
431
|
ctx: MCPContext,
|
|
447
432
|
creations: Optional[List[str]] = None,
|
|
448
433
|
updates: Optional[List[Dict[str, str]]] = None,
|
|
449
|
-
deletions: Optional[List[str]] = None
|
|
434
|
+
deletions: Optional[List[str]] = None,
|
|
450
435
|
) -> str:
|
|
451
436
|
return await tool_self.call(
|
|
452
|
-
ctx,
|
|
453
|
-
|
|
454
|
-
updates=updates,
|
|
455
|
-
deletions=deletions
|
|
456
|
-
)
|
|
437
|
+
ctx, creations=creations, updates=updates, deletions=deletions
|
|
438
|
+
)
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"""Search tools for finding code, files, and information."""
|
|
2
2
|
|
|
3
|
-
from .unified_search import UnifiedSearch, create_unified_search_tool
|
|
4
3
|
from .find_tool import FindTool, create_find_tool
|
|
4
|
+
from .unified_search import UnifiedSearch, create_unified_search_tool
|
|
5
5
|
|
|
6
|
-
__all__ = [
|
|
6
|
+
__all__ = [
|
|
7
|
+
"UnifiedSearch",
|
|
8
|
+
"create_unified_search_tool",
|
|
9
|
+
"FindTool",
|
|
10
|
+
"create_find_tool",
|
|
11
|
+
]
|