spatial-memory-mcp 1.0.2__tar.gz
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 spatial-memory-mcp might be problematic. Click here for more details.
- spatial_memory_mcp-1.0.2/.env.example +153 -0
- spatial_memory_mcp-1.0.2/.gitignore +160 -0
- spatial_memory_mcp-1.0.2/CHANGELOG.md +69 -0
- spatial_memory_mcp-1.0.2/CLAUDE.md +34 -0
- spatial_memory_mcp-1.0.2/CONTRIBUTING.md +299 -0
- spatial_memory_mcp-1.0.2/IMPLEMENTATION_PLAN.md +601 -0
- spatial_memory_mcp-1.0.2/LICENSE +21 -0
- spatial_memory_mcp-1.0.2/LIFECYCLE_PHASE_PLAN.md +1052 -0
- spatial_memory_mcp-1.0.2/PHASE4B_PLAN.md +1853 -0
- spatial_memory_mcp-1.0.2/PHASE4_PLAN.md +1256 -0
- spatial_memory_mcp-1.0.2/PHASE5_UTILITIES_PLAN.md +1595 -0
- spatial_memory_mcp-1.0.2/PKG-INFO +377 -0
- spatial_memory_mcp-1.0.2/PROPOSED_CHANGES.md +486 -0
- spatial_memory_mcp-1.0.2/README.md +335 -0
- spatial_memory_mcp-1.0.2/SECURITY.md +230 -0
- spatial_memory_mcp-1.0.2/SPATIAL-MEMORY-ARCHITECTURE-DIAGRAMS.md +546 -0
- spatial_memory_mcp-1.0.2/SPATIAL-MEMORY-MCP-SERVER-PLAN (1).md +3005 -0
- spatial_memory_mcp-1.0.2/docs/API.md +1641 -0
- spatial_memory_mcp-1.0.2/docs/BENCHMARKS.md +238 -0
- spatial_memory_mcp-1.0.2/docs/METRICS.md +285 -0
- spatial_memory_mcp-1.0.2/docs/troubleshooting.md +166 -0
- spatial_memory_mcp-1.0.2/examples/demo_config_logging.py +98 -0
- spatial_memory_mcp-1.0.2/pyproject.toml +87 -0
- spatial_memory_mcp-1.0.2/scripts/benchmark.py +278 -0
- spatial_memory_mcp-1.0.2/scripts/inspect_db.py +120 -0
- spatial_memory_mcp-1.0.2/scripts/populate_test_data.py +157 -0
- spatial_memory_mcp-1.0.2/scripts/test_all_tools.py +382 -0
- spatial_memory_mcp-1.0.2/spatial_memory/__init__.py +97 -0
- spatial_memory_mcp-1.0.2/spatial_memory/__main__.py +14 -0
- spatial_memory_mcp-1.0.2/spatial_memory/adapters/__init__.py +7 -0
- spatial_memory_mcp-1.0.2/spatial_memory/adapters/lancedb_repository.py +809 -0
- spatial_memory_mcp-1.0.2/spatial_memory/config.py +615 -0
- spatial_memory_mcp-1.0.2/spatial_memory/core/__init__.py +83 -0
- spatial_memory_mcp-1.0.2/spatial_memory/core/connection_pool.py +182 -0
- spatial_memory_mcp-1.0.2/spatial_memory/core/database.py +3047 -0
- spatial_memory_mcp-1.0.2/spatial_memory/core/embeddings.py +420 -0
- spatial_memory_mcp-1.0.2/spatial_memory/core/errors.py +245 -0
- spatial_memory_mcp-1.0.2/spatial_memory/core/file_security.py +702 -0
- spatial_memory_mcp-1.0.2/spatial_memory/core/health.py +289 -0
- spatial_memory_mcp-1.0.2/spatial_memory/core/helpers.py +79 -0
- spatial_memory_mcp-1.0.2/spatial_memory/core/import_security.py +432 -0
- spatial_memory_mcp-1.0.2/spatial_memory/core/lifecycle_ops.py +1067 -0
- spatial_memory_mcp-1.0.2/spatial_memory/core/logging.py +103 -0
- spatial_memory_mcp-1.0.2/spatial_memory/core/metrics.py +192 -0
- spatial_memory_mcp-1.0.2/spatial_memory/core/models.py +624 -0
- spatial_memory_mcp-1.0.2/spatial_memory/core/rate_limiter.py +105 -0
- spatial_memory_mcp-1.0.2/spatial_memory/core/security.py +588 -0
- spatial_memory_mcp-1.0.2/spatial_memory/core/spatial_ops.py +426 -0
- spatial_memory_mcp-1.0.2/spatial_memory/core/utils.py +110 -0
- spatial_memory_mcp-1.0.2/spatial_memory/core/validation.py +319 -0
- spatial_memory_mcp-1.0.2/spatial_memory/ports/__init__.py +11 -0
- spatial_memory_mcp-1.0.2/spatial_memory/ports/repositories.py +581 -0
- spatial_memory_mcp-1.0.2/spatial_memory/py.typed +0 -0
- spatial_memory_mcp-1.0.2/spatial_memory/server.py +998 -0
- spatial_memory_mcp-1.0.2/spatial_memory/services/__init__.py +70 -0
- spatial_memory_mcp-1.0.2/spatial_memory/services/export_import.py +1005 -0
- spatial_memory_mcp-1.0.2/spatial_memory/services/lifecycle.py +845 -0
- spatial_memory_mcp-1.0.2/spatial_memory/services/memory.py +335 -0
- spatial_memory_mcp-1.0.2/spatial_memory/services/spatial.py +1064 -0
- spatial_memory_mcp-1.0.2/spatial_memory/services/utility.py +409 -0
- spatial_memory_mcp-1.0.2/spatial_memory/tools/__init__.py +5 -0
- spatial_memory_mcp-1.0.2/spatial_memory/tools/definitions.py +671 -0
- spatial_memory_mcp-1.0.2/spatial_memory/verify.py +140 -0
- spatial_memory_mcp-1.0.2/stubs/hdbscan/__init__.pyi +22 -0
- spatial_memory_mcp-1.0.2/stubs/lancedb/__init__.pyi +27 -0
- spatial_memory_mcp-1.0.2/stubs/lancedb/index.pyi +21 -0
- spatial_memory_mcp-1.0.2/stubs/lancedb/rerankers.pyi +6 -0
- spatial_memory_mcp-1.0.2/stubs/lancedb/table.pyi +90 -0
- spatial_memory_mcp-1.0.2/stubs/mcp/__init__.pyi +4 -0
- spatial_memory_mcp-1.0.2/stubs/mcp/server/__init__.pyi +33 -0
- spatial_memory_mcp-1.0.2/stubs/mcp/server/stdio.pyi +20 -0
- spatial_memory_mcp-1.0.2/stubs/mcp/types.pyi +27 -0
- spatial_memory_mcp-1.0.2/stubs/openai/__init__.pyi +26 -0
- spatial_memory_mcp-1.0.2/stubs/pyarrow/__init__.pyi +24 -0
- spatial_memory_mcp-1.0.2/stubs/pyarrow/parquet.pyi +18 -0
- spatial_memory_mcp-1.0.2/stubs/sklearn/__init__.pyi +1 -0
- spatial_memory_mcp-1.0.2/stubs/sklearn/metrics/__init__.pyi +12 -0
- spatial_memory_mcp-1.0.2/stubs/umap/__init__.pyi +22 -0
- spatial_memory_mcp-1.0.2/tests/__init__.py +1 -0
- spatial_memory_mcp-1.0.2/tests/conftest.py +308 -0
- spatial_memory_mcp-1.0.2/tests/integration/__init__.py +1 -0
- spatial_memory_mcp-1.0.2/tests/integration/conftest.py +371 -0
- spatial_memory_mcp-1.0.2/tests/integration/test_backup_restore.py +586 -0
- spatial_memory_mcp-1.0.2/tests/integration/test_concurrent_writes.py +401 -0
- spatial_memory_mcp-1.0.2/tests/integration/test_cross_process_locking.py +381 -0
- spatial_memory_mcp-1.0.2/tests/integration/test_database.py +1024 -0
- spatial_memory_mcp-1.0.2/tests/integration/test_database_safeguards.py +128 -0
- spatial_memory_mcp-1.0.2/tests/integration/test_embeddings.py +79 -0
- spatial_memory_mcp-1.0.2/tests/integration/test_enterprise_features.py +760 -0
- spatial_memory_mcp-1.0.2/tests/integration/test_indexing.py +522 -0
- spatial_memory_mcp-1.0.2/tests/integration/test_mcp_server.py +328 -0
- spatial_memory_mcp-1.0.2/tests/integration/test_namespace_ops.py +362 -0
- spatial_memory_mcp-1.0.2/tests/integration/test_phase5_tools.py +998 -0
- spatial_memory_mcp-1.0.2/tests/integration/test_security_edge_cases.py +481 -0
- spatial_memory_mcp-1.0.2/tests/integration/test_ttl_snapshots.py +282 -0
- spatial_memory_mcp-1.0.2/tests/test_config.py +178 -0
- spatial_memory_mcp-1.0.2/tests/test_connection_pool.py +193 -0
- spatial_memory_mcp-1.0.2/tests/test_health.py +303 -0
- spatial_memory_mcp-1.0.2/tests/test_helpers.py +246 -0
- spatial_memory_mcp-1.0.2/tests/test_logging.py +232 -0
- spatial_memory_mcp-1.0.2/tests/test_metrics.py +384 -0
- spatial_memory_mcp-1.0.2/tests/test_models.py +239 -0
- spatial_memory_mcp-1.0.2/tests/test_rate_limiter.py +279 -0
- spatial_memory_mcp-1.0.2/tests/test_validation.py +383 -0
- spatial_memory_mcp-1.0.2/tests/unit/__init__.py +1 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_config_phase5.py +400 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_errors_phase5.py +364 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_export_import_service.py +920 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_export_ops.py +275 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_file_security.py +1049 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_hybrid_search_ops.py +613 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_import_ops.py +349 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_import_security.py +802 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_lancedb_repository_phase5.py +609 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_lifecycle_ops.py +780 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_lifecycle_service.py +1045 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_memory_service.py +479 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_models_phase5.py +809 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_process_lock.py +437 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_security_facade.py +456 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_spatial_ops.py +346 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_spatial_service.py +637 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_stats_ops.py +290 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_utility_service.py +768 -0
- spatial_memory_mcp-1.0.2/tests/unit/test_utils.py +341 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Spatial Memory MCP Server Configuration
|
|
2
|
+
# Copy this file to .env and customize as needed.
|
|
3
|
+
# All settings have sensible defaults - none are required.
|
|
4
|
+
|
|
5
|
+
# =============================================================================
|
|
6
|
+
# STORAGE
|
|
7
|
+
# =============================================================================
|
|
8
|
+
|
|
9
|
+
# Path to LanceDB storage directory
|
|
10
|
+
# Default: ./.spatial-memory (relative to working directory)
|
|
11
|
+
# SPATIAL_MEMORY_MEMORY_PATH=~/.spatial-memory
|
|
12
|
+
|
|
13
|
+
# =============================================================================
|
|
14
|
+
# EMBEDDING MODEL
|
|
15
|
+
# =============================================================================
|
|
16
|
+
|
|
17
|
+
# Embedding model to use. Options:
|
|
18
|
+
#
|
|
19
|
+
# Local models (no API key required, runs on your machine):
|
|
20
|
+
# - all-MiniLM-L6-v2 (default, 384 dims, fast, good quality)
|
|
21
|
+
# - all-mpnet-base-v2 (768 dims, slower, better quality)
|
|
22
|
+
# - Any sentence-transformers model from HuggingFace
|
|
23
|
+
#
|
|
24
|
+
# OpenAI API (requires SPATIAL_MEMORY_OPENAI_API_KEY):
|
|
25
|
+
# - openai:text-embedding-3-small (1536 dims, fast, cheap)
|
|
26
|
+
# - openai:text-embedding-3-large (3072 dims, best quality)
|
|
27
|
+
# - openai:text-embedding-ada-002 (1536 dims, legacy)
|
|
28
|
+
#
|
|
29
|
+
# SPATIAL_MEMORY_EMBEDDING_MODEL=all-MiniLM-L6-v2
|
|
30
|
+
|
|
31
|
+
# Embedding dimensions (auto-detected for known models)
|
|
32
|
+
# Only set this if using a custom model
|
|
33
|
+
# SPATIAL_MEMORY_EMBEDDING_DIMENSIONS=384
|
|
34
|
+
|
|
35
|
+
# =============================================================================
|
|
36
|
+
# OPENAI (only needed for OpenAI embeddings)
|
|
37
|
+
# =============================================================================
|
|
38
|
+
|
|
39
|
+
# Your OpenAI API key (required only if using openai:* embedding model)
|
|
40
|
+
# SPATIAL_MEMORY_OPENAI_API_KEY=sk-...
|
|
41
|
+
|
|
42
|
+
# OpenAI model for embeddings (used when embedding_model starts with "openai:")
|
|
43
|
+
# SPATIAL_MEMORY_OPENAI_EMBEDDING_MODEL=text-embedding-3-small
|
|
44
|
+
|
|
45
|
+
# =============================================================================
|
|
46
|
+
# SERVER
|
|
47
|
+
# =============================================================================
|
|
48
|
+
|
|
49
|
+
# Logging level: DEBUG, INFO, WARNING, ERROR
|
|
50
|
+
# SPATIAL_MEMORY_LOG_LEVEL=INFO
|
|
51
|
+
|
|
52
|
+
# Log format: text or json
|
|
53
|
+
# SPATIAL_MEMORY_LOG_FORMAT=text
|
|
54
|
+
|
|
55
|
+
# =============================================================================
|
|
56
|
+
# MEMORY DEFAULTS
|
|
57
|
+
# =============================================================================
|
|
58
|
+
|
|
59
|
+
# Default namespace for memories (multi-tenant isolation)
|
|
60
|
+
# SPATIAL_MEMORY_DEFAULT_NAMESPACE=default
|
|
61
|
+
|
|
62
|
+
# Default importance score for new memories (0.0 to 1.0)
|
|
63
|
+
# SPATIAL_MEMORY_DEFAULT_IMPORTANCE=0.5
|
|
64
|
+
|
|
65
|
+
# =============================================================================
|
|
66
|
+
# LIMITS
|
|
67
|
+
# =============================================================================
|
|
68
|
+
|
|
69
|
+
# Maximum memories per batch operation (remember_batch, forget_batch)
|
|
70
|
+
# SPATIAL_MEMORY_MAX_BATCH_SIZE=100
|
|
71
|
+
|
|
72
|
+
# Maximum results returned from recall
|
|
73
|
+
# SPATIAL_MEMORY_MAX_RECALL_LIMIT=100
|
|
74
|
+
|
|
75
|
+
# Maximum steps in journey operation
|
|
76
|
+
# SPATIAL_MEMORY_MAX_JOURNEY_STEPS=20
|
|
77
|
+
|
|
78
|
+
# Maximum steps in wander operation
|
|
79
|
+
# SPATIAL_MEMORY_MAX_WANDER_STEPS=20
|
|
80
|
+
|
|
81
|
+
# Maximum memories to include in visualization
|
|
82
|
+
# SPATIAL_MEMORY_MAX_VISUALIZE_MEMORIES=500
|
|
83
|
+
|
|
84
|
+
# =============================================================================
|
|
85
|
+
# DECAY SETTINGS
|
|
86
|
+
# =============================================================================
|
|
87
|
+
|
|
88
|
+
# Weight for time-based decay factor (0.0 to 1.0)
|
|
89
|
+
# Higher = time since access matters more
|
|
90
|
+
# SPATIAL_MEMORY_DECAY_TIME_WEIGHT=0.5
|
|
91
|
+
|
|
92
|
+
# Weight for access-based decay factor (0.0 to 1.0)
|
|
93
|
+
# Higher = access frequency matters more
|
|
94
|
+
# SPATIAL_MEMORY_DECAY_ACCESS_WEIGHT=0.5
|
|
95
|
+
|
|
96
|
+
# Days without access before decay starts
|
|
97
|
+
# SPATIAL_MEMORY_DECAY_DAYS_THRESHOLD=30
|
|
98
|
+
|
|
99
|
+
# =============================================================================
|
|
100
|
+
# CLUSTERING (HDBSCAN)
|
|
101
|
+
# =============================================================================
|
|
102
|
+
|
|
103
|
+
# Minimum memories required to form a cluster
|
|
104
|
+
# SPATIAL_MEMORY_MIN_CLUSTER_SIZE=3
|
|
105
|
+
|
|
106
|
+
# =============================================================================
|
|
107
|
+
# VISUALIZATION (UMAP)
|
|
108
|
+
# =============================================================================
|
|
109
|
+
|
|
110
|
+
# UMAP neighborhood size (affects local vs global structure)
|
|
111
|
+
# Lower = more local structure, higher = more global structure
|
|
112
|
+
# SPATIAL_MEMORY_UMAP_N_NEIGHBORS=15
|
|
113
|
+
|
|
114
|
+
# UMAP minimum distance between points (0.0 to 1.0)
|
|
115
|
+
# Lower = tighter clusters, higher = more spread out
|
|
116
|
+
# SPATIAL_MEMORY_UMAP_MIN_DIST=0.1
|
|
117
|
+
|
|
118
|
+
# =============================================================================
|
|
119
|
+
# INDEXING CONFIGURATION
|
|
120
|
+
# =============================================================================
|
|
121
|
+
|
|
122
|
+
# Create vector index when dataset exceeds this size
|
|
123
|
+
# SPATIAL_MEMORY_VECTOR_INDEX_THRESHOLD=10000
|
|
124
|
+
|
|
125
|
+
# Automatically create indexes
|
|
126
|
+
# SPATIAL_MEMORY_AUTO_CREATE_INDEXES=true
|
|
127
|
+
|
|
128
|
+
# Search parameters (higher = better recall, slower)
|
|
129
|
+
# SPATIAL_MEMORY_INDEX_NPROBES=20
|
|
130
|
+
# SPATIAL_MEMORY_INDEX_REFINE_FACTOR=5
|
|
131
|
+
|
|
132
|
+
# =============================================================================
|
|
133
|
+
# HYBRID SEARCH
|
|
134
|
+
# =============================================================================
|
|
135
|
+
|
|
136
|
+
# Enable full-text search index
|
|
137
|
+
# SPATIAL_MEMORY_ENABLE_FTS_INDEX=true
|
|
138
|
+
|
|
139
|
+
# Default balance between vector (1.0) and keyword (0.0)
|
|
140
|
+
# SPATIAL_MEMORY_DEFAULT_HYBRID_ALPHA=0.5
|
|
141
|
+
|
|
142
|
+
# =============================================================================
|
|
143
|
+
# PERFORMANCE
|
|
144
|
+
# =============================================================================
|
|
145
|
+
|
|
146
|
+
# Maximum retry attempts for storage operations
|
|
147
|
+
# SPATIAL_MEMORY_MAX_RETRY_ATTEMPTS=3
|
|
148
|
+
|
|
149
|
+
# Backoff between retries in seconds
|
|
150
|
+
# SPATIAL_MEMORY_RETRY_BACKOFF_SECONDS=0.5
|
|
151
|
+
|
|
152
|
+
# Connection pool size
|
|
153
|
+
# SPATIAL_MEMORY_CONNECTION_POOL_MAX_SIZE=10
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
*.manifest
|
|
31
|
+
*.spec
|
|
32
|
+
|
|
33
|
+
# Installer logs
|
|
34
|
+
pip-log.txt
|
|
35
|
+
pip-delete-this-directory.txt
|
|
36
|
+
|
|
37
|
+
# Unit test / coverage reports
|
|
38
|
+
htmlcov/
|
|
39
|
+
.tox/
|
|
40
|
+
.nox/
|
|
41
|
+
.coverage
|
|
42
|
+
.coverage.*
|
|
43
|
+
.cache
|
|
44
|
+
nosetests.xml
|
|
45
|
+
coverage.xml
|
|
46
|
+
*.cover
|
|
47
|
+
*.py,cover
|
|
48
|
+
.hypothesis/
|
|
49
|
+
.pytest_cache/
|
|
50
|
+
|
|
51
|
+
# Translations
|
|
52
|
+
*.mo
|
|
53
|
+
*.pot
|
|
54
|
+
|
|
55
|
+
# Django stuff:
|
|
56
|
+
*.log
|
|
57
|
+
local_settings.py
|
|
58
|
+
db.sqlite3
|
|
59
|
+
db.sqlite3-journal
|
|
60
|
+
|
|
61
|
+
# Flask stuff:
|
|
62
|
+
instance/
|
|
63
|
+
.webassets-cache
|
|
64
|
+
|
|
65
|
+
# Scrapy stuff:
|
|
66
|
+
.scrapy
|
|
67
|
+
|
|
68
|
+
# Sphinx documentation
|
|
69
|
+
docs/_build/
|
|
70
|
+
|
|
71
|
+
# PyBuilder
|
|
72
|
+
.pybuilder/
|
|
73
|
+
target/
|
|
74
|
+
|
|
75
|
+
# Jupyter Notebook
|
|
76
|
+
.ipynb_checkpoints
|
|
77
|
+
|
|
78
|
+
# IPython
|
|
79
|
+
profile_default/
|
|
80
|
+
ipython_config.py
|
|
81
|
+
|
|
82
|
+
# pyenv
|
|
83
|
+
.python-version
|
|
84
|
+
|
|
85
|
+
# pipenv
|
|
86
|
+
Pipfile.lock
|
|
87
|
+
|
|
88
|
+
# PEP 582
|
|
89
|
+
__pypackages__/
|
|
90
|
+
|
|
91
|
+
# Celery stuff
|
|
92
|
+
celerybeat-schedule
|
|
93
|
+
celerybeat.pid
|
|
94
|
+
|
|
95
|
+
# SageMath parsed files
|
|
96
|
+
*.sage.py
|
|
97
|
+
|
|
98
|
+
# Environments
|
|
99
|
+
.env
|
|
100
|
+
.venv
|
|
101
|
+
env/
|
|
102
|
+
venv/
|
|
103
|
+
ENV/
|
|
104
|
+
env.bak/
|
|
105
|
+
venv.bak/
|
|
106
|
+
|
|
107
|
+
# Spyder project settings
|
|
108
|
+
.spyderproject
|
|
109
|
+
.spyproject
|
|
110
|
+
|
|
111
|
+
# Rope project settings
|
|
112
|
+
.ropeproject
|
|
113
|
+
|
|
114
|
+
# mkdocs documentation
|
|
115
|
+
/site
|
|
116
|
+
|
|
117
|
+
# mypy
|
|
118
|
+
.mypy_cache/
|
|
119
|
+
.dmypy.json
|
|
120
|
+
dmypy.json
|
|
121
|
+
|
|
122
|
+
# Pyre type checker
|
|
123
|
+
.pyre/
|
|
124
|
+
|
|
125
|
+
# pytype static type analyzer
|
|
126
|
+
.pytype/
|
|
127
|
+
|
|
128
|
+
# Cython debug symbols
|
|
129
|
+
cython_debug/
|
|
130
|
+
|
|
131
|
+
# IDE
|
|
132
|
+
.idea/
|
|
133
|
+
.vscode/
|
|
134
|
+
*.swp
|
|
135
|
+
*.swo
|
|
136
|
+
*~
|
|
137
|
+
|
|
138
|
+
# OS
|
|
139
|
+
.DS_Store
|
|
140
|
+
Thumbs.db
|
|
141
|
+
|
|
142
|
+
# Project specific
|
|
143
|
+
*.lancedb/
|
|
144
|
+
*.lance/
|
|
145
|
+
data/
|
|
146
|
+
memories/
|
|
147
|
+
.spatial-memory/
|
|
148
|
+
|
|
149
|
+
# Secrets
|
|
150
|
+
.env.local
|
|
151
|
+
.env.*.local
|
|
152
|
+
*.pem
|
|
153
|
+
*.key
|
|
154
|
+
credentials.json
|
|
155
|
+
secrets.json
|
|
156
|
+
|
|
157
|
+
# Claude Code local files
|
|
158
|
+
.claude/
|
|
159
|
+
.claude-memory/
|
|
160
|
+
.mcp.json
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Planned
|
|
11
|
+
- Phase 2: Core operations (`remember`, `recall`, `nearby`, `forget`)
|
|
12
|
+
- Phase 3: Spatial operations (`journey`, `wander`, `regions`, `visualize`)
|
|
13
|
+
- Phase 4: Lifecycle operations (`consolidate`, `extract`, `decay`, `reinforce`)
|
|
14
|
+
- Phase 5: Utility operations (`stats`, `namespaces`, `export`, `import`)
|
|
15
|
+
- Phase 6: Integration tests, documentation, PyPI release
|
|
16
|
+
|
|
17
|
+
## [0.1.0] - 2026-01-20
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
#### Configuration System
|
|
22
|
+
- Pydantic-based settings with environment variable support
|
|
23
|
+
- Dependency injection pattern for testability
|
|
24
|
+
- Full configuration validation with bounds checking
|
|
25
|
+
- Support for `.env` files
|
|
26
|
+
|
|
27
|
+
#### Database Layer
|
|
28
|
+
- LanceDB integration for vector storage
|
|
29
|
+
- SQL injection prevention with pattern detection
|
|
30
|
+
- UUID validation for memory IDs
|
|
31
|
+
- Namespace format validation
|
|
32
|
+
- Atomic updates with rollback support
|
|
33
|
+
|
|
34
|
+
#### Embedding Service
|
|
35
|
+
- Local embedding support via sentence-transformers
|
|
36
|
+
- OpenAI API embedding support
|
|
37
|
+
- Dual-backend architecture with automatic routing
|
|
38
|
+
- Model: `all-MiniLM-L6-v2` (384 dimensions) as default
|
|
39
|
+
|
|
40
|
+
#### Data Models
|
|
41
|
+
- `Memory` - Core memory representation
|
|
42
|
+
- `MemoryResult` - Search result with similarity score
|
|
43
|
+
- `Filter` / `FilterGroup` - Query filtering system
|
|
44
|
+
- `ClusterInfo` - Cluster metadata for regions
|
|
45
|
+
- `JourneyStep` - Step in journey interpolation
|
|
46
|
+
- `VisualizationData` - Visualization output format
|
|
47
|
+
|
|
48
|
+
#### Error Handling
|
|
49
|
+
- Custom exception hierarchy
|
|
50
|
+
- `SpatialMemoryError` base class
|
|
51
|
+
- Specific errors: `MemoryNotFoundError`, `NamespaceNotFoundError`, `EmbeddingError`, `StorageError`, `ValidationError`, `ConfigurationError`, `ClusteringError`, `VisualizationError`
|
|
52
|
+
|
|
53
|
+
#### Testing
|
|
54
|
+
- 71 unit tests covering all Phase 1 components
|
|
55
|
+
- Pytest fixtures for isolated testing
|
|
56
|
+
- Mock embedding service for fast tests
|
|
57
|
+
|
|
58
|
+
#### Documentation
|
|
59
|
+
- README with project overview and roadmap
|
|
60
|
+
- Architecture diagrams (Mermaid)
|
|
61
|
+
- Security documentation
|
|
62
|
+
- Contributing guidelines
|
|
63
|
+
- Configuration reference (`.env.example`)
|
|
64
|
+
|
|
65
|
+
### Security
|
|
66
|
+
- Input validation on all user-provided data
|
|
67
|
+
- SQL injection prevention
|
|
68
|
+
- Namespace isolation
|
|
69
|
+
- Sanitized error messages
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Claude Memory System
|
|
2
|
+
|
|
3
|
+
This project has a persistent memory system. On EVERY conversation start, call `start_session()` to load context.
|
|
4
|
+
|
|
5
|
+
## Automatic Behaviors
|
|
6
|
+
|
|
7
|
+
1. **Session Start**: Always call `start_session()` first. This loads relevant context.
|
|
8
|
+
|
|
9
|
+
2. **Memory Recognition**: When you recognize memory-worthy moments, ask briefly:
|
|
10
|
+
- "Save this decision?" (for architectural choices)
|
|
11
|
+
- "Save this fix?" (for error solutions)
|
|
12
|
+
- "Note this pattern?" (for reusable approaches)
|
|
13
|
+
|
|
14
|
+
Wait for "y" or similar confirmation, then save.
|
|
15
|
+
|
|
16
|
+
3. **Memory Queries**: When asked about past decisions or context, use `search_memories` or `get_context`. Don't guess or hallucinate.
|
|
17
|
+
|
|
18
|
+
4. **Session End**: If significant learnings occurred, offer: "Save session summary?"
|
|
19
|
+
|
|
20
|
+
## Memory-Worthy Triggers
|
|
21
|
+
|
|
22
|
+
Recognize these in conversation:
|
|
23
|
+
- "Let's go with...", "We decided...", "The approach is..." → Decision
|
|
24
|
+
- "The fix was...", "It was failing because..." → Error
|
|
25
|
+
- "This pattern works...", "The trick is..." → Pattern
|
|
26
|
+
- "Remember that...", "Important:..." → Explicit save request
|
|
27
|
+
- "?" in a note-to-self context → Question/TODO
|
|
28
|
+
|
|
29
|
+
## Tool Availability
|
|
30
|
+
|
|
31
|
+
If memory tools fail (MCP server unavailable), continue helping but note:
|
|
32
|
+
"Memory system is temporarily unavailable. I'll help without historical context."
|
|
33
|
+
|
|
34
|
+
Don't pretend to remember things you can't access.
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
# Contributing to Spatial Memory MCP Server
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing! This document provides guidelines for development.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
1. Read the [README](README.md) to understand project status (currently Phase 1)
|
|
8
|
+
2. Set up your development environment (see [Installation](#installation) below)
|
|
9
|
+
3. Run tests to verify setup: `pytest tests/ -v`
|
|
10
|
+
4. Look for issues labeled "good first issue" on GitHub
|
|
11
|
+
5. If using Claude Code, check [CLAUDE.md](CLAUDE.md) for AI assistant instructions
|
|
12
|
+
|
|
13
|
+
## Supported Platforms
|
|
14
|
+
|
|
15
|
+
This project supports development on:
|
|
16
|
+
- **Windows 11**
|
|
17
|
+
- **macOS** (latest)
|
|
18
|
+
- **Linux** (Fedora, Ubuntu, Linux Mint)
|
|
19
|
+
|
|
20
|
+
## Development Setup
|
|
21
|
+
|
|
22
|
+
### Prerequisites
|
|
23
|
+
|
|
24
|
+
- Python 3.10 or higher
|
|
25
|
+
- Git
|
|
26
|
+
|
|
27
|
+
### Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Clone the repository
|
|
31
|
+
git clone https://github.com/arman-tech/spatial-memory-mcp.git
|
|
32
|
+
cd spatial-memory-mcp
|
|
33
|
+
|
|
34
|
+
# Create virtual environment (recommended)
|
|
35
|
+
python -m venv .venv
|
|
36
|
+
|
|
37
|
+
# Activate virtual environment
|
|
38
|
+
# Linux/macOS:
|
|
39
|
+
source .venv/bin/activate
|
|
40
|
+
# Windows (PowerShell):
|
|
41
|
+
.venv\Scripts\Activate.ps1
|
|
42
|
+
# Windows (CMD):
|
|
43
|
+
.venv\Scripts\activate.bat
|
|
44
|
+
|
|
45
|
+
# Install in development mode with dev dependencies
|
|
46
|
+
pip install -e ".[dev]"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Verify Installation
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Run tests
|
|
53
|
+
pytest tests/ -v
|
|
54
|
+
|
|
55
|
+
# Type checking
|
|
56
|
+
mypy spatial_memory/ --ignore-missing-imports
|
|
57
|
+
|
|
58
|
+
# Linting
|
|
59
|
+
ruff check spatial_memory/ tests/
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Project Structure
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
spatial-memory-mcp/
|
|
66
|
+
├── spatial_memory/ # Main package
|
|
67
|
+
│ ├── __init__.py # Public API exports
|
|
68
|
+
│ ├── __main__.py # Entry point (shows status until Phase 2)
|
|
69
|
+
│ ├── config.py # Settings with DI pattern
|
|
70
|
+
│ ├── py.typed # PEP 561 marker for type checking
|
|
71
|
+
│ └── core/
|
|
72
|
+
│ ├── __init__.py # Core module exports
|
|
73
|
+
│ ├── database.py # LanceDB wrapper
|
|
74
|
+
│ ├── embeddings.py # Embedding service
|
|
75
|
+
│ ├── errors.py # Exception hierarchy
|
|
76
|
+
│ ├── models.py # Pydantic data models
|
|
77
|
+
│ └── utils.py # Shared utilities
|
|
78
|
+
├── tests/ # Test suite
|
|
79
|
+
│ ├── conftest.py # Pytest fixtures
|
|
80
|
+
│ ├── test_config.py
|
|
81
|
+
│ ├── test_database.py
|
|
82
|
+
│ ├── test_embeddings.py
|
|
83
|
+
│ └── test_models.py
|
|
84
|
+
├── .env.example # Example configuration
|
|
85
|
+
├── pyproject.toml # Package configuration
|
|
86
|
+
├── CLAUDE.md # Instructions for Claude Code AI assistant
|
|
87
|
+
├── SECURITY.md # Security policy and guidelines
|
|
88
|
+
├── CHANGELOG.md # Version history
|
|
89
|
+
└── README.md # Project overview
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
> **Note**: The `__main__.py` entry point currently displays a status message. The MCP server will be implemented in Phase 2.
|
|
93
|
+
|
|
94
|
+
## Testing
|
|
95
|
+
|
|
96
|
+
### Running Tests
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Run all tests
|
|
100
|
+
pytest tests/ -v
|
|
101
|
+
|
|
102
|
+
# Run specific test file
|
|
103
|
+
pytest tests/test_database.py -v
|
|
104
|
+
|
|
105
|
+
# Run tests matching a pattern
|
|
106
|
+
pytest tests/ -k "test_remember" -v
|
|
107
|
+
|
|
108
|
+
# Run with coverage
|
|
109
|
+
pytest tests/ --cov=spatial_memory --cov-report=html
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Test Categories
|
|
113
|
+
|
|
114
|
+
| File | Purpose |
|
|
115
|
+
|------|---------|
|
|
116
|
+
| `test_config.py` | Configuration loading, validation, environment variables |
|
|
117
|
+
| `test_database.py` | LanceDB operations, CRUD, filtering, SQL injection prevention |
|
|
118
|
+
| `test_embeddings.py` | Embedding service, local and API backends |
|
|
119
|
+
| `test_models.py` | Pydantic model validation, serialization |
|
|
120
|
+
|
|
121
|
+
### Writing Tests
|
|
122
|
+
|
|
123
|
+
#### Use Fixtures
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
# tests/conftest.py provides these fixtures:
|
|
127
|
+
|
|
128
|
+
def test_with_temp_storage(temp_storage):
|
|
129
|
+
"""temp_storage provides an isolated database directory."""
|
|
130
|
+
# Database operations here are isolated
|
|
131
|
+
pass
|
|
132
|
+
|
|
133
|
+
def test_with_mock_embeddings(mock_embedding_service):
|
|
134
|
+
"""mock_embedding_service avoids real embedding computation."""
|
|
135
|
+
vector = mock_embedding_service.embed("test")
|
|
136
|
+
assert len(vector) == 384
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### Test Naming Convention
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
def test_<function>_<scenario>_<expected_outcome>():
|
|
143
|
+
"""Tests should follow this naming pattern."""
|
|
144
|
+
pass
|
|
145
|
+
|
|
146
|
+
# Examples:
|
|
147
|
+
def test_remember_valid_content_returns_memory_id():
|
|
148
|
+
pass
|
|
149
|
+
|
|
150
|
+
def test_recall_empty_query_raises_validation_error():
|
|
151
|
+
pass
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
#### Testing Errors
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
import pytest
|
|
158
|
+
from spatial_memory.core.errors import ValidationError
|
|
159
|
+
|
|
160
|
+
def test_invalid_input_raises_validation_error():
|
|
161
|
+
with pytest.raises(ValidationError) as exc_info:
|
|
162
|
+
# Code that should raise
|
|
163
|
+
pass
|
|
164
|
+
assert "expected message" in str(exc_info.value)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Code Style
|
|
168
|
+
|
|
169
|
+
### Python Version
|
|
170
|
+
|
|
171
|
+
- Use Python 3.10+ features (union types with `|`, match statements, etc.)
|
|
172
|
+
- Type hints are required for all public functions
|
|
173
|
+
|
|
174
|
+
### Formatting & Linting
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Check for issues
|
|
178
|
+
ruff check spatial_memory/ tests/
|
|
179
|
+
|
|
180
|
+
# Auto-fix issues
|
|
181
|
+
ruff check --fix spatial_memory/ tests/
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Type Checking
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
mypy spatial_memory/ --ignore-missing-imports
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Documentation
|
|
191
|
+
|
|
192
|
+
- All public functions need docstrings
|
|
193
|
+
- Use Google-style docstrings:
|
|
194
|
+
|
|
195
|
+
```python
|
|
196
|
+
def remember(content: str, namespace: str = "default") -> str:
|
|
197
|
+
"""Store a memory in vector space.
|
|
198
|
+
|
|
199
|
+
Args:
|
|
200
|
+
content: The text content to remember.
|
|
201
|
+
namespace: Namespace for isolation.
|
|
202
|
+
|
|
203
|
+
Returns:
|
|
204
|
+
The UUID of the created memory.
|
|
205
|
+
|
|
206
|
+
Raises:
|
|
207
|
+
ValidationError: If content is empty or too long.
|
|
208
|
+
StorageError: If database operation fails.
|
|
209
|
+
"""
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Pull Request Process
|
|
213
|
+
|
|
214
|
+
1. **Fork** the repository at https://github.com/arman-tech/spatial-memory-mcp
|
|
215
|
+
2. **Create a branch** for your feature: `git checkout -b feature/my-feature`
|
|
216
|
+
3. **Write tests** for new functionality
|
|
217
|
+
4. **Ensure all tests pass**: `pytest tests/ -v`
|
|
218
|
+
5. **Ensure no lint errors**: `ruff check spatial_memory/ tests/`
|
|
219
|
+
6. **Ensure type checking passes**: `mypy spatial_memory/`
|
|
220
|
+
7. **Commit** with clear messages
|
|
221
|
+
8. **Push** to your fork
|
|
222
|
+
9. **Open a Pull Request** with:
|
|
223
|
+
- Clear description of changes
|
|
224
|
+
- Reference to related issues
|
|
225
|
+
- Test coverage for new code
|
|
226
|
+
|
|
227
|
+
## Error Handling
|
|
228
|
+
|
|
229
|
+
### Exception Hierarchy
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
SpatialMemoryError (base)
|
|
233
|
+
├── MemoryNotFoundError # Memory ID doesn't exist
|
|
234
|
+
├── NamespaceNotFoundError # Namespace doesn't exist
|
|
235
|
+
├── EmbeddingError # Embedding generation failed
|
|
236
|
+
├── StorageError # Database operation failed
|
|
237
|
+
├── ValidationError # Input validation failed
|
|
238
|
+
├── ConfigurationError # Invalid configuration
|
|
239
|
+
├── ClusteringError # Clustering operation failed
|
|
240
|
+
└── VisualizationError # Visualization generation failed
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### When to Use Each
|
|
244
|
+
|
|
245
|
+
```python
|
|
246
|
+
from spatial_memory.core.errors import (
|
|
247
|
+
ValidationError,
|
|
248
|
+
StorageError,
|
|
249
|
+
MemoryNotFoundError,
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
def my_function(memory_id: str):
|
|
253
|
+
# Input validation
|
|
254
|
+
if not memory_id:
|
|
255
|
+
raise ValidationError("memory_id cannot be empty")
|
|
256
|
+
|
|
257
|
+
# Database operations
|
|
258
|
+
try:
|
|
259
|
+
result = db.get(memory_id)
|
|
260
|
+
except Exception as e:
|
|
261
|
+
raise StorageError(f"Database error: {e}")
|
|
262
|
+
|
|
263
|
+
# Not found
|
|
264
|
+
if result is None:
|
|
265
|
+
raise MemoryNotFoundError(memory_id)
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Configuration
|
|
269
|
+
|
|
270
|
+
### Adding New Settings
|
|
271
|
+
|
|
272
|
+
1. Add the field to `Settings` class in `config.py`:
|
|
273
|
+
|
|
274
|
+
```python
|
|
275
|
+
class Settings(BaseSettings):
|
|
276
|
+
# ... existing fields ...
|
|
277
|
+
|
|
278
|
+
my_new_setting: int = Field(
|
|
279
|
+
default=10,
|
|
280
|
+
ge=1,
|
|
281
|
+
le=100,
|
|
282
|
+
description="Description of what this does",
|
|
283
|
+
)
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
2. Add to `.env.example`:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
# Description of what this does
|
|
290
|
+
# SPATIAL_MEMORY_MY_NEW_SETTING=10
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
3. Add tests in `test_config.py`
|
|
294
|
+
|
|
295
|
+
## Questions?
|
|
296
|
+
|
|
297
|
+
- Open a GitHub issue for bugs or feature requests
|
|
298
|
+
- Check existing issues before creating new ones
|
|
299
|
+
- See [SECURITY.md](SECURITY.md) for reporting security vulnerabilities
|