memorygraphMCP 0.11.7__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.
Files changed (65) hide show
  1. memorygraph/__init__.py +50 -0
  2. memorygraph/__main__.py +12 -0
  3. memorygraph/advanced_tools.py +509 -0
  4. memorygraph/analytics/__init__.py +46 -0
  5. memorygraph/analytics/advanced_queries.py +727 -0
  6. memorygraph/backends/__init__.py +21 -0
  7. memorygraph/backends/base.py +179 -0
  8. memorygraph/backends/cloud.py +75 -0
  9. memorygraph/backends/cloud_backend.py +858 -0
  10. memorygraph/backends/factory.py +577 -0
  11. memorygraph/backends/falkordb_backend.py +749 -0
  12. memorygraph/backends/falkordblite_backend.py +746 -0
  13. memorygraph/backends/ladybugdb_backend.py +242 -0
  14. memorygraph/backends/memgraph_backend.py +327 -0
  15. memorygraph/backends/neo4j_backend.py +298 -0
  16. memorygraph/backends/sqlite_fallback.py +463 -0
  17. memorygraph/backends/turso.py +448 -0
  18. memorygraph/cli.py +743 -0
  19. memorygraph/cloud_database.py +297 -0
  20. memorygraph/config.py +295 -0
  21. memorygraph/database.py +933 -0
  22. memorygraph/graph_analytics.py +631 -0
  23. memorygraph/integration/__init__.py +69 -0
  24. memorygraph/integration/context_capture.py +426 -0
  25. memorygraph/integration/project_analysis.py +583 -0
  26. memorygraph/integration/workflow_tracking.py +492 -0
  27. memorygraph/intelligence/__init__.py +59 -0
  28. memorygraph/intelligence/context_retrieval.py +447 -0
  29. memorygraph/intelligence/entity_extraction.py +386 -0
  30. memorygraph/intelligence/pattern_recognition.py +420 -0
  31. memorygraph/intelligence/temporal.py +374 -0
  32. memorygraph/migration/__init__.py +27 -0
  33. memorygraph/migration/manager.py +579 -0
  34. memorygraph/migration/models.py +142 -0
  35. memorygraph/migration/scripts/__init__.py +17 -0
  36. memorygraph/migration/scripts/bitemporal_migration.py +595 -0
  37. memorygraph/migration/scripts/multitenancy_migration.py +452 -0
  38. memorygraph/migration_tools_module.py +146 -0
  39. memorygraph/models.py +684 -0
  40. memorygraph/proactive/__init__.py +46 -0
  41. memorygraph/proactive/outcome_learning.py +444 -0
  42. memorygraph/proactive/predictive.py +410 -0
  43. memorygraph/proactive/session_briefing.py +399 -0
  44. memorygraph/relationships.py +668 -0
  45. memorygraph/server.py +883 -0
  46. memorygraph/sqlite_database.py +1876 -0
  47. memorygraph/tools/__init__.py +59 -0
  48. memorygraph/tools/activity_tools.py +262 -0
  49. memorygraph/tools/memory_tools.py +315 -0
  50. memorygraph/tools/migration_tools.py +181 -0
  51. memorygraph/tools/relationship_tools.py +147 -0
  52. memorygraph/tools/search_tools.py +406 -0
  53. memorygraph/tools/temporal_tools.py +339 -0
  54. memorygraph/utils/__init__.py +10 -0
  55. memorygraph/utils/context_extractor.py +429 -0
  56. memorygraph/utils/error_handling.py +151 -0
  57. memorygraph/utils/export_import.py +425 -0
  58. memorygraph/utils/graph_algorithms.py +200 -0
  59. memorygraph/utils/pagination.py +149 -0
  60. memorygraph/utils/project_detection.py +133 -0
  61. memorygraphmcp-0.11.7.dist-info/METADATA +970 -0
  62. memorygraphmcp-0.11.7.dist-info/RECORD +65 -0
  63. memorygraphmcp-0.11.7.dist-info/WHEEL +4 -0
  64. memorygraphmcp-0.11.7.dist-info/entry_points.txt +2 -0
  65. memorygraphmcp-0.11.7.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,142 @@
1
+ """
2
+ Data models for backend migration.
3
+
4
+ Provides configuration, options, and result models for migrating memories
5
+ between different backend types.
6
+ """
7
+
8
+ from dataclasses import dataclass, field
9
+ from typing import Optional, Dict, Any, List
10
+
11
+ from ..config import BackendType
12
+
13
+
14
+ @dataclass
15
+ class BackendConfig:
16
+ """
17
+ Configuration for a backend connection.
18
+
19
+ For SQLite/FalkorDBLite backends, use path.
20
+ For Neo4j/Memgraph/FalkorDB backends, use uri, username, password.
21
+ """
22
+ backend_type: BackendType
23
+ path: Optional[str] = None # For SQLite/FalkorDBLite
24
+ uri: Optional[str] = None # For Neo4j/Memgraph/FalkorDB
25
+ username: Optional[str] = None
26
+ password: Optional[str] = None
27
+ database: Optional[str] = None
28
+
29
+ @classmethod
30
+ def from_env(cls) -> "BackendConfig":
31
+ """
32
+ Create config from current environment variables.
33
+
34
+ Reads MEMORY_BACKEND and related env vars to construct config.
35
+ Note: Reads env vars directly to ensure fresh values.
36
+ """
37
+ import os
38
+
39
+ # Read backend type directly from env to get current value
40
+ backend_str = os.getenv("MEMORY_BACKEND", "sqlite")
41
+ backend_type = BackendType(backend_str)
42
+
43
+ # Determine URI and credentials based on backend type
44
+ uri = None
45
+ username = None
46
+ password = None
47
+ path = None
48
+
49
+ if backend_type == BackendType.NEO4J:
50
+ uri = os.getenv("MEMORY_NEO4J_URI") or os.getenv("NEO4J_URI", "bolt://localhost:7687")
51
+ username = os.getenv("MEMORY_NEO4J_USER") or os.getenv("NEO4J_USER", "neo4j")
52
+ password = os.getenv("MEMORY_NEO4J_PASSWORD") or os.getenv("NEO4J_PASSWORD")
53
+
54
+ elif backend_type == BackendType.MEMGRAPH:
55
+ uri = os.getenv("MEMORY_MEMGRAPH_URI", "bolt://localhost:7687")
56
+ username = os.getenv("MEMORY_MEMGRAPH_USER", "")
57
+ password = os.getenv("MEMORY_MEMGRAPH_PASSWORD", "")
58
+
59
+ elif backend_type == BackendType.FALKORDB:
60
+ # FalkorDB uses Redis protocol, construct URI from host:port
61
+ host = os.getenv("MEMORY_FALKORDB_HOST") or os.getenv("FALKORDB_HOST", "localhost")
62
+ port = os.getenv("MEMORY_FALKORDB_PORT") or os.getenv("FALKORDB_PORT", "6379")
63
+ uri = f"redis://{host}:{port}"
64
+ password = os.getenv("MEMORY_FALKORDB_PASSWORD") or os.getenv("FALKORDB_PASSWORD")
65
+
66
+ elif backend_type == BackendType.SQLITE:
67
+ path = os.getenv("MEMORY_SQLITE_PATH", os.path.expanduser("~/.memorygraph/memory.db"))
68
+
69
+ elif backend_type == BackendType.FALKORDBLITE:
70
+ path = os.getenv("MEMORY_FALKORDBLITE_PATH") or os.getenv("FALKORDBLITE_PATH", os.path.expanduser("~/.memorygraph/falkordblite.db"))
71
+
72
+ return cls(
73
+ backend_type=backend_type,
74
+ path=path,
75
+ uri=uri,
76
+ username=username,
77
+ password=password
78
+ )
79
+
80
+ def validate(self) -> List[str]:
81
+ """
82
+ Validate configuration has required fields for backend type.
83
+
84
+ Returns:
85
+ List of validation errors (empty if valid)
86
+ """
87
+ errors = []
88
+
89
+ if self.backend_type in (BackendType.SQLITE, BackendType.FALKORDBLITE):
90
+ if not self.path:
91
+ errors.append(f"{self.backend_type.value} backend requires 'path' parameter")
92
+
93
+ elif self.backend_type in (BackendType.NEO4J, BackendType.MEMGRAPH, BackendType.FALKORDB):
94
+ if not self.uri:
95
+ errors.append(f"{self.backend_type.value} backend requires 'uri' parameter")
96
+
97
+ return errors
98
+
99
+
100
+ @dataclass
101
+ class MigrationOptions:
102
+ """Options for migration operation."""
103
+ dry_run: bool = False
104
+ verbose: bool = False
105
+ skip_duplicates: bool = True
106
+ verify: bool = True
107
+ rollback_on_failure: bool = True
108
+ since: Optional[str] = None # Timestamp for incremental migration (future feature)
109
+
110
+
111
+ @dataclass
112
+ class ValidationResult:
113
+ """Result of validation checks."""
114
+ valid: bool
115
+ errors: List[str] = field(default_factory=list)
116
+ warnings: List[str] = field(default_factory=list)
117
+
118
+
119
+ @dataclass
120
+ class VerificationResult:
121
+ """Result of post-migration verification."""
122
+ valid: bool
123
+ errors: List[str] = field(default_factory=list)
124
+ source_count: int = 0
125
+ target_count: int = 0
126
+ sample_checks: int = 0
127
+ sample_passed: int = 0
128
+
129
+
130
+ @dataclass
131
+ class MigrationResult:
132
+ """Result of migration operation."""
133
+ success: bool
134
+ dry_run: bool = False
135
+ source_stats: Optional[Dict[str, Any]] = None
136
+ target_stats: Optional[Dict[str, Any]] = None
137
+ imported_memories: int = 0
138
+ imported_relationships: int = 0
139
+ skipped_memories: int = 0
140
+ verification_result: Optional[VerificationResult] = None
141
+ duration_seconds: float = 0.0
142
+ errors: List[str] = field(default_factory=list)
@@ -0,0 +1,17 @@
1
+ """
2
+ Migration scripts for schema and data changes.
3
+
4
+ This package contains migration scripts for evolving the MemoryGraph schema
5
+ and data structure over time.
6
+ """
7
+
8
+ from typing import List
9
+ from .multitenancy_migration import migrate_to_multitenant, rollback_from_multitenant
10
+ from .bitemporal_migration import migrate_to_bitemporal, rollback_from_bitemporal
11
+
12
+ __all__ = [
13
+ 'migrate_to_multitenant',
14
+ 'rollback_from_multitenant',
15
+ 'migrate_to_bitemporal',
16
+ 'rollback_from_bitemporal',
17
+ ]