spatial-memory-mcp 1.9.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.
- spatial_memory/__init__.py +97 -0
- spatial_memory/__main__.py +271 -0
- spatial_memory/adapters/__init__.py +7 -0
- spatial_memory/adapters/lancedb_repository.py +880 -0
- spatial_memory/config.py +769 -0
- spatial_memory/core/__init__.py +118 -0
- spatial_memory/core/cache.py +317 -0
- spatial_memory/core/circuit_breaker.py +297 -0
- spatial_memory/core/connection_pool.py +220 -0
- spatial_memory/core/consolidation_strategies.py +401 -0
- spatial_memory/core/database.py +3072 -0
- spatial_memory/core/db_idempotency.py +242 -0
- spatial_memory/core/db_indexes.py +576 -0
- spatial_memory/core/db_migrations.py +588 -0
- spatial_memory/core/db_search.py +512 -0
- spatial_memory/core/db_versioning.py +178 -0
- spatial_memory/core/embeddings.py +558 -0
- spatial_memory/core/errors.py +317 -0
- spatial_memory/core/file_security.py +701 -0
- spatial_memory/core/filesystem.py +178 -0
- spatial_memory/core/health.py +289 -0
- spatial_memory/core/helpers.py +79 -0
- spatial_memory/core/import_security.py +433 -0
- spatial_memory/core/lifecycle_ops.py +1067 -0
- spatial_memory/core/logging.py +194 -0
- spatial_memory/core/metrics.py +192 -0
- spatial_memory/core/models.py +660 -0
- spatial_memory/core/rate_limiter.py +326 -0
- spatial_memory/core/response_types.py +500 -0
- spatial_memory/core/security.py +588 -0
- spatial_memory/core/spatial_ops.py +430 -0
- spatial_memory/core/tracing.py +300 -0
- spatial_memory/core/utils.py +110 -0
- spatial_memory/core/validation.py +406 -0
- spatial_memory/factory.py +444 -0
- spatial_memory/migrations/__init__.py +40 -0
- spatial_memory/ports/__init__.py +11 -0
- spatial_memory/ports/repositories.py +630 -0
- spatial_memory/py.typed +0 -0
- spatial_memory/server.py +1214 -0
- spatial_memory/services/__init__.py +70 -0
- spatial_memory/services/decay_manager.py +411 -0
- spatial_memory/services/export_import.py +1031 -0
- spatial_memory/services/lifecycle.py +1139 -0
- spatial_memory/services/memory.py +412 -0
- spatial_memory/services/spatial.py +1152 -0
- spatial_memory/services/utility.py +429 -0
- spatial_memory/tools/__init__.py +5 -0
- spatial_memory/tools/definitions.py +695 -0
- spatial_memory/verify.py +140 -0
- spatial_memory_mcp-1.9.1.dist-info/METADATA +509 -0
- spatial_memory_mcp-1.9.1.dist-info/RECORD +55 -0
- spatial_memory_mcp-1.9.1.dist-info/WHEEL +4 -0
- spatial_memory_mcp-1.9.1.dist-info/entry_points.txt +2 -0
- spatial_memory_mcp-1.9.1.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,695 @@
|
|
|
1
|
+
"""MCP Tool definitions for Spatial Memory Server.
|
|
2
|
+
|
|
3
|
+
This module contains all the tool definitions that are exposed
|
|
4
|
+
to MCP clients for interacting with the spatial memory system.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from mcp.types import Tool
|
|
10
|
+
|
|
11
|
+
# Common parameter: _agent_id for request tracing and per-agent rate limiting
|
|
12
|
+
_AGENT_ID_PARAM: dict[str, Any] = {
|
|
13
|
+
"_agent_id": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "Optional agent identifier for request tracing and per-agent rate limiting.",
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _add_agent_id(properties: dict[str, Any]) -> dict[str, Any]:
|
|
21
|
+
"""Add _agent_id parameter to tool properties."""
|
|
22
|
+
return {**properties, **_AGENT_ID_PARAM}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# Tool definitions for MCP
|
|
26
|
+
TOOLS = [
|
|
27
|
+
Tool(
|
|
28
|
+
name="remember",
|
|
29
|
+
description="Store a new memory in the spatial memory system.",
|
|
30
|
+
inputSchema={
|
|
31
|
+
"type": "object",
|
|
32
|
+
"properties": _add_agent_id({
|
|
33
|
+
"content": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"description": "The text content to remember",
|
|
36
|
+
},
|
|
37
|
+
"namespace": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"description": "Namespace for organizing memories (default: 'default')",
|
|
40
|
+
"default": "default",
|
|
41
|
+
},
|
|
42
|
+
"tags": {
|
|
43
|
+
"type": "array",
|
|
44
|
+
"items": {"type": "string"},
|
|
45
|
+
"description": "Optional tags for categorization",
|
|
46
|
+
},
|
|
47
|
+
"importance": {
|
|
48
|
+
"type": "number",
|
|
49
|
+
"description": "Importance score from 0.0 to 1.0 (default: 0.5)",
|
|
50
|
+
"minimum": 0.0,
|
|
51
|
+
"maximum": 1.0,
|
|
52
|
+
"default": 0.5,
|
|
53
|
+
},
|
|
54
|
+
"metadata": {
|
|
55
|
+
"type": "object",
|
|
56
|
+
"description": "Optional metadata to attach to the memory",
|
|
57
|
+
},
|
|
58
|
+
"idempotency_key": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"description": (
|
|
61
|
+
"Optional unique key for idempotent writes. "
|
|
62
|
+
"If the same key is used again, returns the cached result "
|
|
63
|
+
"instead of creating a duplicate."
|
|
64
|
+
),
|
|
65
|
+
},
|
|
66
|
+
}),
|
|
67
|
+
"required": ["content"],
|
|
68
|
+
},
|
|
69
|
+
),
|
|
70
|
+
Tool(
|
|
71
|
+
name="remember_batch",
|
|
72
|
+
description="Store multiple memories efficiently in a single operation.",
|
|
73
|
+
inputSchema={
|
|
74
|
+
"type": "object",
|
|
75
|
+
"properties": _add_agent_id({
|
|
76
|
+
"memories": {
|
|
77
|
+
"type": "array",
|
|
78
|
+
"items": {
|
|
79
|
+
"type": "object",
|
|
80
|
+
"properties": {
|
|
81
|
+
"content": {"type": "string"},
|
|
82
|
+
"namespace": {"type": "string"},
|
|
83
|
+
"tags": {"type": "array", "items": {"type": "string"}},
|
|
84
|
+
"importance": {"type": "number"},
|
|
85
|
+
"metadata": {"type": "object"},
|
|
86
|
+
},
|
|
87
|
+
"required": ["content"],
|
|
88
|
+
},
|
|
89
|
+
"description": "Array of memories to store",
|
|
90
|
+
},
|
|
91
|
+
}),
|
|
92
|
+
"required": ["memories"],
|
|
93
|
+
},
|
|
94
|
+
),
|
|
95
|
+
Tool(
|
|
96
|
+
name="recall",
|
|
97
|
+
description="Search for similar memories using semantic similarity.",
|
|
98
|
+
inputSchema={
|
|
99
|
+
"type": "object",
|
|
100
|
+
"properties": _add_agent_id({
|
|
101
|
+
"query": {
|
|
102
|
+
"type": "string",
|
|
103
|
+
"description": "The search query text",
|
|
104
|
+
},
|
|
105
|
+
"limit": {
|
|
106
|
+
"type": "integer",
|
|
107
|
+
"description": "Maximum number of results (default: 5)",
|
|
108
|
+
"minimum": 1,
|
|
109
|
+
"maximum": 100,
|
|
110
|
+
"default": 5,
|
|
111
|
+
},
|
|
112
|
+
"namespace": {
|
|
113
|
+
"type": "string",
|
|
114
|
+
"description": "Filter to specific namespace",
|
|
115
|
+
},
|
|
116
|
+
"min_similarity": {
|
|
117
|
+
"type": "number",
|
|
118
|
+
"description": "Minimum similarity threshold (0.0-1.0)",
|
|
119
|
+
"minimum": 0.0,
|
|
120
|
+
"maximum": 1.0,
|
|
121
|
+
"default": 0.0,
|
|
122
|
+
},
|
|
123
|
+
}),
|
|
124
|
+
"required": ["query"],
|
|
125
|
+
},
|
|
126
|
+
),
|
|
127
|
+
Tool(
|
|
128
|
+
name="nearby",
|
|
129
|
+
description="Find memories similar to a specific memory.",
|
|
130
|
+
inputSchema={
|
|
131
|
+
"type": "object",
|
|
132
|
+
"properties": _add_agent_id({
|
|
133
|
+
"memory_id": {
|
|
134
|
+
"type": "string",
|
|
135
|
+
"description": "The ID of the reference memory",
|
|
136
|
+
},
|
|
137
|
+
"limit": {
|
|
138
|
+
"type": "integer",
|
|
139
|
+
"description": "Maximum number of neighbors (default: 5)",
|
|
140
|
+
"minimum": 1,
|
|
141
|
+
"maximum": 100,
|
|
142
|
+
"default": 5,
|
|
143
|
+
},
|
|
144
|
+
"namespace": {
|
|
145
|
+
"type": "string",
|
|
146
|
+
"description": "Filter neighbors to specific namespace",
|
|
147
|
+
},
|
|
148
|
+
}),
|
|
149
|
+
"required": ["memory_id"],
|
|
150
|
+
},
|
|
151
|
+
),
|
|
152
|
+
Tool(
|
|
153
|
+
name="forget",
|
|
154
|
+
description="Delete a memory by its ID.",
|
|
155
|
+
inputSchema={
|
|
156
|
+
"type": "object",
|
|
157
|
+
"properties": _add_agent_id({
|
|
158
|
+
"memory_id": {
|
|
159
|
+
"type": "string",
|
|
160
|
+
"description": "The ID of the memory to delete",
|
|
161
|
+
},
|
|
162
|
+
}),
|
|
163
|
+
"required": ["memory_id"],
|
|
164
|
+
},
|
|
165
|
+
),
|
|
166
|
+
Tool(
|
|
167
|
+
name="forget_batch",
|
|
168
|
+
description="Delete multiple memories by their IDs.",
|
|
169
|
+
inputSchema={
|
|
170
|
+
"type": "object",
|
|
171
|
+
"properties": _add_agent_id({
|
|
172
|
+
"memory_ids": {
|
|
173
|
+
"type": "array",
|
|
174
|
+
"items": {"type": "string"},
|
|
175
|
+
"description": "Array of memory IDs to delete",
|
|
176
|
+
},
|
|
177
|
+
}),
|
|
178
|
+
"required": ["memory_ids"],
|
|
179
|
+
},
|
|
180
|
+
),
|
|
181
|
+
Tool(
|
|
182
|
+
name="health",
|
|
183
|
+
description="Check system health status.",
|
|
184
|
+
inputSchema={
|
|
185
|
+
"type": "object",
|
|
186
|
+
"properties": _add_agent_id({
|
|
187
|
+
"verbose": {
|
|
188
|
+
"type": "boolean",
|
|
189
|
+
"description": "Include detailed check results",
|
|
190
|
+
"default": False,
|
|
191
|
+
},
|
|
192
|
+
}),
|
|
193
|
+
},
|
|
194
|
+
),
|
|
195
|
+
Tool(
|
|
196
|
+
name="journey",
|
|
197
|
+
description=(
|
|
198
|
+
"Navigate semantic space between two memories using spherical "
|
|
199
|
+
"interpolation (SLERP). Discovers memories along the conceptual path."
|
|
200
|
+
),
|
|
201
|
+
inputSchema={
|
|
202
|
+
"type": "object",
|
|
203
|
+
"properties": _add_agent_id({
|
|
204
|
+
"start_id": {
|
|
205
|
+
"type": "string",
|
|
206
|
+
"description": "Starting memory UUID",
|
|
207
|
+
},
|
|
208
|
+
"end_id": {
|
|
209
|
+
"type": "string",
|
|
210
|
+
"description": "Ending memory UUID",
|
|
211
|
+
},
|
|
212
|
+
"steps": {
|
|
213
|
+
"type": "integer",
|
|
214
|
+
"minimum": 2,
|
|
215
|
+
"maximum": 20,
|
|
216
|
+
"default": 10,
|
|
217
|
+
"description": "Number of interpolation steps",
|
|
218
|
+
},
|
|
219
|
+
"namespace": {
|
|
220
|
+
"type": "string",
|
|
221
|
+
"description": "Optional namespace filter for nearby search",
|
|
222
|
+
},
|
|
223
|
+
}),
|
|
224
|
+
"required": ["start_id", "end_id"],
|
|
225
|
+
},
|
|
226
|
+
),
|
|
227
|
+
Tool(
|
|
228
|
+
name="wander",
|
|
229
|
+
description=(
|
|
230
|
+
"Explore memory space through random walk. Uses temperature-based "
|
|
231
|
+
"selection to balance exploration and exploitation."
|
|
232
|
+
),
|
|
233
|
+
inputSchema={
|
|
234
|
+
"type": "object",
|
|
235
|
+
"properties": _add_agent_id({
|
|
236
|
+
"start_id": {
|
|
237
|
+
"type": "string",
|
|
238
|
+
"description": "Starting memory UUID (random if not provided)",
|
|
239
|
+
},
|
|
240
|
+
"steps": {
|
|
241
|
+
"type": "integer",
|
|
242
|
+
"minimum": 1,
|
|
243
|
+
"maximum": 20,
|
|
244
|
+
"default": 10,
|
|
245
|
+
"description": "Number of exploration steps",
|
|
246
|
+
},
|
|
247
|
+
"temperature": {
|
|
248
|
+
"type": "number",
|
|
249
|
+
"minimum": 0.0,
|
|
250
|
+
"maximum": 1.0,
|
|
251
|
+
"default": 0.5,
|
|
252
|
+
"description": "Randomness (0.0=focused, 1.0=very random)",
|
|
253
|
+
},
|
|
254
|
+
"namespace": {
|
|
255
|
+
"type": "string",
|
|
256
|
+
"description": "Optional namespace filter",
|
|
257
|
+
},
|
|
258
|
+
}),
|
|
259
|
+
"required": [],
|
|
260
|
+
},
|
|
261
|
+
),
|
|
262
|
+
Tool(
|
|
263
|
+
name="regions",
|
|
264
|
+
description=(
|
|
265
|
+
"Discover semantic clusters in memory space using HDBSCAN. "
|
|
266
|
+
"Returns cluster info with representative memories and keywords."
|
|
267
|
+
),
|
|
268
|
+
inputSchema={
|
|
269
|
+
"type": "object",
|
|
270
|
+
"properties": _add_agent_id({
|
|
271
|
+
"namespace": {
|
|
272
|
+
"type": "string",
|
|
273
|
+
"description": "Optional namespace filter",
|
|
274
|
+
},
|
|
275
|
+
"min_cluster_size": {
|
|
276
|
+
"type": "integer",
|
|
277
|
+
"minimum": 2,
|
|
278
|
+
"maximum": 50,
|
|
279
|
+
"default": 3,
|
|
280
|
+
"description": "Minimum memories per cluster",
|
|
281
|
+
},
|
|
282
|
+
"max_clusters": {
|
|
283
|
+
"type": "integer",
|
|
284
|
+
"minimum": 1,
|
|
285
|
+
"description": "Maximum clusters to return",
|
|
286
|
+
},
|
|
287
|
+
}),
|
|
288
|
+
"required": [],
|
|
289
|
+
},
|
|
290
|
+
),
|
|
291
|
+
Tool(
|
|
292
|
+
name="visualize",
|
|
293
|
+
description=(
|
|
294
|
+
"Project memories to 2D/3D for visualization using UMAP. "
|
|
295
|
+
"Returns coordinates and optional similarity edges."
|
|
296
|
+
),
|
|
297
|
+
inputSchema={
|
|
298
|
+
"type": "object",
|
|
299
|
+
"properties": _add_agent_id({
|
|
300
|
+
"memory_ids": {
|
|
301
|
+
"type": "array",
|
|
302
|
+
"items": {"type": "string"},
|
|
303
|
+
"description": "Specific memory UUIDs to visualize",
|
|
304
|
+
},
|
|
305
|
+
"namespace": {
|
|
306
|
+
"type": "string",
|
|
307
|
+
"description": "Namespace filter (if memory_ids not specified)",
|
|
308
|
+
},
|
|
309
|
+
"format": {
|
|
310
|
+
"type": "string",
|
|
311
|
+
"enum": ["json", "mermaid", "svg"],
|
|
312
|
+
"default": "json",
|
|
313
|
+
"description": "Output format",
|
|
314
|
+
},
|
|
315
|
+
"dimensions": {
|
|
316
|
+
"type": "integer",
|
|
317
|
+
"enum": [2, 3],
|
|
318
|
+
"default": 2,
|
|
319
|
+
"description": "Projection dimensionality",
|
|
320
|
+
},
|
|
321
|
+
"include_edges": {
|
|
322
|
+
"type": "boolean",
|
|
323
|
+
"default": True,
|
|
324
|
+
"description": "Include similarity edges",
|
|
325
|
+
},
|
|
326
|
+
}),
|
|
327
|
+
"required": [],
|
|
328
|
+
},
|
|
329
|
+
),
|
|
330
|
+
# Lifecycle tools
|
|
331
|
+
Tool(
|
|
332
|
+
name="decay",
|
|
333
|
+
description=(
|
|
334
|
+
"Apply time and access-based decay to memory importance scores. "
|
|
335
|
+
"Memories not accessed recently will have reduced importance."
|
|
336
|
+
),
|
|
337
|
+
inputSchema={
|
|
338
|
+
"type": "object",
|
|
339
|
+
"properties": _add_agent_id({
|
|
340
|
+
"namespace": {
|
|
341
|
+
"type": "string",
|
|
342
|
+
"description": "Namespace to decay (all if not specified)",
|
|
343
|
+
},
|
|
344
|
+
"decay_function": {
|
|
345
|
+
"type": "string",
|
|
346
|
+
"enum": ["exponential", "linear", "step"],
|
|
347
|
+
"default": "exponential",
|
|
348
|
+
"description": "Decay curve shape",
|
|
349
|
+
},
|
|
350
|
+
"half_life_days": {
|
|
351
|
+
"type": "number",
|
|
352
|
+
"minimum": 1,
|
|
353
|
+
"maximum": 365,
|
|
354
|
+
"default": 30,
|
|
355
|
+
"description": "Days until importance halves (exponential)",
|
|
356
|
+
},
|
|
357
|
+
"min_importance": {
|
|
358
|
+
"type": "number",
|
|
359
|
+
"minimum": 0.0,
|
|
360
|
+
"maximum": 0.5,
|
|
361
|
+
"default": 0.1,
|
|
362
|
+
"description": "Minimum importance floor",
|
|
363
|
+
},
|
|
364
|
+
"access_weight": {
|
|
365
|
+
"type": "number",
|
|
366
|
+
"minimum": 0.0,
|
|
367
|
+
"maximum": 1.0,
|
|
368
|
+
"default": 0.3,
|
|
369
|
+
"description": "Weight of access count in decay calculation",
|
|
370
|
+
},
|
|
371
|
+
"dry_run": {
|
|
372
|
+
"type": "boolean",
|
|
373
|
+
"default": True,
|
|
374
|
+
"description": "Preview changes without applying",
|
|
375
|
+
},
|
|
376
|
+
}),
|
|
377
|
+
},
|
|
378
|
+
),
|
|
379
|
+
Tool(
|
|
380
|
+
name="reinforce",
|
|
381
|
+
description=(
|
|
382
|
+
"Boost memory importance based on usage or explicit feedback. "
|
|
383
|
+
"Reinforcement increases importance and can reset decay timer."
|
|
384
|
+
),
|
|
385
|
+
inputSchema={
|
|
386
|
+
"type": "object",
|
|
387
|
+
"properties": _add_agent_id({
|
|
388
|
+
"memory_ids": {
|
|
389
|
+
"type": "array",
|
|
390
|
+
"items": {"type": "string"},
|
|
391
|
+
"description": "Memory IDs to reinforce",
|
|
392
|
+
},
|
|
393
|
+
"boost_type": {
|
|
394
|
+
"type": "string",
|
|
395
|
+
"enum": ["additive", "multiplicative", "set_value"],
|
|
396
|
+
"default": "additive",
|
|
397
|
+
"description": "Type of boost to apply",
|
|
398
|
+
},
|
|
399
|
+
"boost_amount": {
|
|
400
|
+
"type": "number",
|
|
401
|
+
"minimum": 0.0,
|
|
402
|
+
"maximum": 1.0,
|
|
403
|
+
"default": 0.1,
|
|
404
|
+
"description": "Amount to boost importance",
|
|
405
|
+
},
|
|
406
|
+
"update_access": {
|
|
407
|
+
"type": "boolean",
|
|
408
|
+
"default": True,
|
|
409
|
+
"description": "Update last_accessed timestamp",
|
|
410
|
+
},
|
|
411
|
+
}),
|
|
412
|
+
"required": ["memory_ids"],
|
|
413
|
+
},
|
|
414
|
+
),
|
|
415
|
+
Tool(
|
|
416
|
+
name="extract",
|
|
417
|
+
description=(
|
|
418
|
+
"Automatically extract memories from conversation text. "
|
|
419
|
+
"Uses pattern matching to identify facts, decisions, and key information."
|
|
420
|
+
),
|
|
421
|
+
inputSchema={
|
|
422
|
+
"type": "object",
|
|
423
|
+
"properties": _add_agent_id({
|
|
424
|
+
"text": {
|
|
425
|
+
"type": "string",
|
|
426
|
+
"description": "Text to extract memories from",
|
|
427
|
+
},
|
|
428
|
+
"namespace": {
|
|
429
|
+
"type": "string",
|
|
430
|
+
"default": "extracted",
|
|
431
|
+
"description": "Namespace for extracted memories",
|
|
432
|
+
},
|
|
433
|
+
"min_confidence": {
|
|
434
|
+
"type": "number",
|
|
435
|
+
"minimum": 0.0,
|
|
436
|
+
"maximum": 1.0,
|
|
437
|
+
"default": 0.5,
|
|
438
|
+
"description": "Minimum confidence to extract",
|
|
439
|
+
},
|
|
440
|
+
"deduplicate": {
|
|
441
|
+
"type": "boolean",
|
|
442
|
+
"default": True,
|
|
443
|
+
"description": "Skip if similar memory exists",
|
|
444
|
+
},
|
|
445
|
+
"dedup_threshold": {
|
|
446
|
+
"type": "number",
|
|
447
|
+
"minimum": 0.7,
|
|
448
|
+
"maximum": 0.99,
|
|
449
|
+
"default": 0.9,
|
|
450
|
+
"description": "Similarity threshold for deduplication",
|
|
451
|
+
},
|
|
452
|
+
}),
|
|
453
|
+
"required": ["text"],
|
|
454
|
+
},
|
|
455
|
+
),
|
|
456
|
+
Tool(
|
|
457
|
+
name="consolidate",
|
|
458
|
+
description=(
|
|
459
|
+
"Merge similar or duplicate memories to reduce redundancy. "
|
|
460
|
+
"Finds memories above similarity threshold and merges them."
|
|
461
|
+
),
|
|
462
|
+
inputSchema={
|
|
463
|
+
"type": "object",
|
|
464
|
+
"properties": _add_agent_id({
|
|
465
|
+
"namespace": {
|
|
466
|
+
"type": "string",
|
|
467
|
+
"description": "Namespace to consolidate (required)",
|
|
468
|
+
},
|
|
469
|
+
"similarity_threshold": {
|
|
470
|
+
"type": "number",
|
|
471
|
+
"minimum": 0.7,
|
|
472
|
+
"maximum": 0.99,
|
|
473
|
+
"default": 0.85,
|
|
474
|
+
"description": "Minimum similarity for duplicates",
|
|
475
|
+
},
|
|
476
|
+
"strategy": {
|
|
477
|
+
"type": "string",
|
|
478
|
+
"enum": [
|
|
479
|
+
"keep_newest",
|
|
480
|
+
"keep_oldest",
|
|
481
|
+
"keep_highest_importance",
|
|
482
|
+
"merge_content",
|
|
483
|
+
],
|
|
484
|
+
"default": "keep_highest_importance",
|
|
485
|
+
"description": "Strategy for merging duplicates",
|
|
486
|
+
},
|
|
487
|
+
"dry_run": {
|
|
488
|
+
"type": "boolean",
|
|
489
|
+
"default": True,
|
|
490
|
+
"description": "Preview without changes",
|
|
491
|
+
},
|
|
492
|
+
"max_groups": {
|
|
493
|
+
"type": "integer",
|
|
494
|
+
"minimum": 1,
|
|
495
|
+
"maximum": 100,
|
|
496
|
+
"default": 50,
|
|
497
|
+
"description": "Maximum groups to process",
|
|
498
|
+
},
|
|
499
|
+
}),
|
|
500
|
+
"required": ["namespace"],
|
|
501
|
+
},
|
|
502
|
+
),
|
|
503
|
+
# Phase 5: Utility Tools
|
|
504
|
+
Tool(
|
|
505
|
+
name="stats",
|
|
506
|
+
description="Get database statistics and health metrics.",
|
|
507
|
+
inputSchema={
|
|
508
|
+
"type": "object",
|
|
509
|
+
"properties": _add_agent_id({
|
|
510
|
+
"namespace": {
|
|
511
|
+
"type": "string",
|
|
512
|
+
"description": "Filter stats to specific namespace",
|
|
513
|
+
},
|
|
514
|
+
"include_index_details": {
|
|
515
|
+
"type": "boolean",
|
|
516
|
+
"default": True,
|
|
517
|
+
"description": "Include detailed index statistics",
|
|
518
|
+
},
|
|
519
|
+
}),
|
|
520
|
+
},
|
|
521
|
+
),
|
|
522
|
+
Tool(
|
|
523
|
+
name="namespaces",
|
|
524
|
+
description="List all namespaces with memory counts and date ranges.",
|
|
525
|
+
inputSchema={
|
|
526
|
+
"type": "object",
|
|
527
|
+
"properties": _add_agent_id({
|
|
528
|
+
"include_stats": {
|
|
529
|
+
"type": "boolean",
|
|
530
|
+
"default": True,
|
|
531
|
+
"description": "Include memory counts and date ranges per namespace",
|
|
532
|
+
},
|
|
533
|
+
}),
|
|
534
|
+
},
|
|
535
|
+
),
|
|
536
|
+
Tool(
|
|
537
|
+
name="delete_namespace",
|
|
538
|
+
description="Delete all memories in a namespace. DESTRUCTIVE - use dry_run first.",
|
|
539
|
+
inputSchema={
|
|
540
|
+
"type": "object",
|
|
541
|
+
"properties": _add_agent_id({
|
|
542
|
+
"namespace": {
|
|
543
|
+
"type": "string",
|
|
544
|
+
"description": "Namespace to delete",
|
|
545
|
+
},
|
|
546
|
+
"confirm": {
|
|
547
|
+
"type": "boolean",
|
|
548
|
+
"default": False,
|
|
549
|
+
"description": "Set to true to confirm deletion (required when dry_run=false)",
|
|
550
|
+
},
|
|
551
|
+
"dry_run": {
|
|
552
|
+
"type": "boolean",
|
|
553
|
+
"default": True,
|
|
554
|
+
"description": "Preview deletion without executing",
|
|
555
|
+
},
|
|
556
|
+
}),
|
|
557
|
+
"required": ["namespace"],
|
|
558
|
+
},
|
|
559
|
+
),
|
|
560
|
+
Tool(
|
|
561
|
+
name="rename_namespace",
|
|
562
|
+
description="Rename a namespace, moving all its memories to the new name.",
|
|
563
|
+
inputSchema={
|
|
564
|
+
"type": "object",
|
|
565
|
+
"properties": _add_agent_id({
|
|
566
|
+
"old_namespace": {
|
|
567
|
+
"type": "string",
|
|
568
|
+
"description": "Current namespace name",
|
|
569
|
+
},
|
|
570
|
+
"new_namespace": {
|
|
571
|
+
"type": "string",
|
|
572
|
+
"description": "New namespace name",
|
|
573
|
+
},
|
|
574
|
+
}),
|
|
575
|
+
"required": ["old_namespace", "new_namespace"],
|
|
576
|
+
},
|
|
577
|
+
),
|
|
578
|
+
Tool(
|
|
579
|
+
name="export_memories",
|
|
580
|
+
description="Export memories to file (Parquet, JSON, or CSV format).",
|
|
581
|
+
inputSchema={
|
|
582
|
+
"type": "object",
|
|
583
|
+
"properties": _add_agent_id({
|
|
584
|
+
"output_path": {
|
|
585
|
+
"type": "string",
|
|
586
|
+
"description": "Path for output file (extension determines format)",
|
|
587
|
+
},
|
|
588
|
+
"format": {
|
|
589
|
+
"type": "string",
|
|
590
|
+
"enum": ["parquet", "json", "csv"],
|
|
591
|
+
"description": "Export format (auto-detected from extension if not specified)",
|
|
592
|
+
},
|
|
593
|
+
"namespace": {
|
|
594
|
+
"type": "string",
|
|
595
|
+
"description": "Export only this namespace (all if not specified)",
|
|
596
|
+
},
|
|
597
|
+
"include_vectors": {
|
|
598
|
+
"type": "boolean",
|
|
599
|
+
"default": True,
|
|
600
|
+
"description": "Include embedding vectors in export",
|
|
601
|
+
},
|
|
602
|
+
}),
|
|
603
|
+
"required": ["output_path"],
|
|
604
|
+
},
|
|
605
|
+
),
|
|
606
|
+
Tool(
|
|
607
|
+
name="import_memories",
|
|
608
|
+
description="Import memories from file with validation. Use dry_run=true first.",
|
|
609
|
+
inputSchema={
|
|
610
|
+
"type": "object",
|
|
611
|
+
"properties": _add_agent_id({
|
|
612
|
+
"source_path": {
|
|
613
|
+
"type": "string",
|
|
614
|
+
"description": "Path to source file",
|
|
615
|
+
},
|
|
616
|
+
"format": {
|
|
617
|
+
"type": "string",
|
|
618
|
+
"enum": ["parquet", "json", "csv"],
|
|
619
|
+
"description": "Import format (auto-detected from extension if not specified)",
|
|
620
|
+
},
|
|
621
|
+
"namespace_override": {
|
|
622
|
+
"type": "string",
|
|
623
|
+
"description": "Override namespace for all imported memories",
|
|
624
|
+
},
|
|
625
|
+
"deduplicate": {
|
|
626
|
+
"type": "boolean",
|
|
627
|
+
"default": False,
|
|
628
|
+
"description": "Skip records similar to existing memories",
|
|
629
|
+
},
|
|
630
|
+
"dedup_threshold": {
|
|
631
|
+
"type": "number",
|
|
632
|
+
"minimum": 0.7,
|
|
633
|
+
"maximum": 0.99,
|
|
634
|
+
"default": 0.95,
|
|
635
|
+
"description": "Similarity threshold for deduplication",
|
|
636
|
+
},
|
|
637
|
+
"validate": {
|
|
638
|
+
"type": "boolean",
|
|
639
|
+
"default": True,
|
|
640
|
+
"description": "Validate records before import",
|
|
641
|
+
},
|
|
642
|
+
"regenerate_embeddings": {
|
|
643
|
+
"type": "boolean",
|
|
644
|
+
"default": False,
|
|
645
|
+
"description": "Generate new embeddings (required if vectors missing)",
|
|
646
|
+
},
|
|
647
|
+
"dry_run": {
|
|
648
|
+
"type": "boolean",
|
|
649
|
+
"default": True,
|
|
650
|
+
"description": "Validate without importing",
|
|
651
|
+
},
|
|
652
|
+
}),
|
|
653
|
+
"required": ["source_path"],
|
|
654
|
+
},
|
|
655
|
+
),
|
|
656
|
+
Tool(
|
|
657
|
+
name="hybrid_recall",
|
|
658
|
+
description="Search memories using combined vector and keyword (full-text) search.",
|
|
659
|
+
inputSchema={
|
|
660
|
+
"type": "object",
|
|
661
|
+
"properties": _add_agent_id({
|
|
662
|
+
"query": {
|
|
663
|
+
"type": "string",
|
|
664
|
+
"description": "Search query text",
|
|
665
|
+
},
|
|
666
|
+
"alpha": {
|
|
667
|
+
"type": "number",
|
|
668
|
+
"minimum": 0.0,
|
|
669
|
+
"maximum": 1.0,
|
|
670
|
+
"default": 0.5,
|
|
671
|
+
"description": "Balance: 1.0=pure vector, 0.0=pure keyword, 0.5=balanced",
|
|
672
|
+
},
|
|
673
|
+
"limit": {
|
|
674
|
+
"type": "integer",
|
|
675
|
+
"minimum": 1,
|
|
676
|
+
"maximum": 100,
|
|
677
|
+
"default": 5,
|
|
678
|
+
"description": "Maximum number of results",
|
|
679
|
+
},
|
|
680
|
+
"namespace": {
|
|
681
|
+
"type": "string",
|
|
682
|
+
"description": "Filter to specific namespace",
|
|
683
|
+
},
|
|
684
|
+
"min_similarity": {
|
|
685
|
+
"type": "number",
|
|
686
|
+
"minimum": 0.0,
|
|
687
|
+
"maximum": 1.0,
|
|
688
|
+
"default": 0.0,
|
|
689
|
+
"description": "Minimum similarity threshold",
|
|
690
|
+
},
|
|
691
|
+
}),
|
|
692
|
+
"required": ["query"],
|
|
693
|
+
},
|
|
694
|
+
),
|
|
695
|
+
]
|