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.
- memorygraph/__init__.py +50 -0
- memorygraph/__main__.py +12 -0
- memorygraph/advanced_tools.py +509 -0
- memorygraph/analytics/__init__.py +46 -0
- memorygraph/analytics/advanced_queries.py +727 -0
- memorygraph/backends/__init__.py +21 -0
- memorygraph/backends/base.py +179 -0
- memorygraph/backends/cloud.py +75 -0
- memorygraph/backends/cloud_backend.py +858 -0
- memorygraph/backends/factory.py +577 -0
- memorygraph/backends/falkordb_backend.py +749 -0
- memorygraph/backends/falkordblite_backend.py +746 -0
- memorygraph/backends/ladybugdb_backend.py +242 -0
- memorygraph/backends/memgraph_backend.py +327 -0
- memorygraph/backends/neo4j_backend.py +298 -0
- memorygraph/backends/sqlite_fallback.py +463 -0
- memorygraph/backends/turso.py +448 -0
- memorygraph/cli.py +743 -0
- memorygraph/cloud_database.py +297 -0
- memorygraph/config.py +295 -0
- memorygraph/database.py +933 -0
- memorygraph/graph_analytics.py +631 -0
- memorygraph/integration/__init__.py +69 -0
- memorygraph/integration/context_capture.py +426 -0
- memorygraph/integration/project_analysis.py +583 -0
- memorygraph/integration/workflow_tracking.py +492 -0
- memorygraph/intelligence/__init__.py +59 -0
- memorygraph/intelligence/context_retrieval.py +447 -0
- memorygraph/intelligence/entity_extraction.py +386 -0
- memorygraph/intelligence/pattern_recognition.py +420 -0
- memorygraph/intelligence/temporal.py +374 -0
- memorygraph/migration/__init__.py +27 -0
- memorygraph/migration/manager.py +579 -0
- memorygraph/migration/models.py +142 -0
- memorygraph/migration/scripts/__init__.py +17 -0
- memorygraph/migration/scripts/bitemporal_migration.py +595 -0
- memorygraph/migration/scripts/multitenancy_migration.py +452 -0
- memorygraph/migration_tools_module.py +146 -0
- memorygraph/models.py +684 -0
- memorygraph/proactive/__init__.py +46 -0
- memorygraph/proactive/outcome_learning.py +444 -0
- memorygraph/proactive/predictive.py +410 -0
- memorygraph/proactive/session_briefing.py +399 -0
- memorygraph/relationships.py +668 -0
- memorygraph/server.py +883 -0
- memorygraph/sqlite_database.py +1876 -0
- memorygraph/tools/__init__.py +59 -0
- memorygraph/tools/activity_tools.py +262 -0
- memorygraph/tools/memory_tools.py +315 -0
- memorygraph/tools/migration_tools.py +181 -0
- memorygraph/tools/relationship_tools.py +147 -0
- memorygraph/tools/search_tools.py +406 -0
- memorygraph/tools/temporal_tools.py +339 -0
- memorygraph/utils/__init__.py +10 -0
- memorygraph/utils/context_extractor.py +429 -0
- memorygraph/utils/error_handling.py +151 -0
- memorygraph/utils/export_import.py +425 -0
- memorygraph/utils/graph_algorithms.py +200 -0
- memorygraph/utils/pagination.py +149 -0
- memorygraph/utils/project_detection.py +133 -0
- memorygraphmcp-0.11.7.dist-info/METADATA +970 -0
- memorygraphmcp-0.11.7.dist-info/RECORD +65 -0
- memorygraphmcp-0.11.7.dist-info/WHEEL +4 -0
- memorygraphmcp-0.11.7.dist-info/entry_points.txt +2 -0
- memorygraphmcp-0.11.7.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Backend abstraction layer for the Claude Code Memory Server.
|
|
3
|
+
|
|
4
|
+
This package provides a unified interface for different graph database backends,
|
|
5
|
+
allowing the memory server to work with Neo4j, Memgraph, or SQLite.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .base import GraphBackend
|
|
9
|
+
from .factory import BackendFactory
|
|
10
|
+
|
|
11
|
+
# Backend classes are imported lazily via the factory to avoid
|
|
12
|
+
# import-time dependencies on optional packages (neo4j, etc.)
|
|
13
|
+
# Import them explicitly when needed:
|
|
14
|
+
# from memorygraph.backends.neo4j_backend import Neo4jBackend
|
|
15
|
+
# from memorygraph.backends.memgraph_backend import MemgraphBackend
|
|
16
|
+
# from memorygraph.backends.sqlite_fallback import SQLiteFallbackBackend
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"GraphBackend",
|
|
20
|
+
"BackendFactory",
|
|
21
|
+
]
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Abstract base class for graph database backends.
|
|
3
|
+
|
|
4
|
+
This module defines the interface that all backend implementations must follow,
|
|
5
|
+
ensuring compatibility across Neo4j, Memgraph, and SQLite fallback.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from abc import ABC, abstractmethod
|
|
9
|
+
from typing import Any, Optional
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class GraphBackend(ABC):
|
|
13
|
+
"""
|
|
14
|
+
Abstract base class for graph database backends.
|
|
15
|
+
|
|
16
|
+
All backend implementations (Neo4j, Memgraph, SQLite) must implement
|
|
17
|
+
this interface to ensure compatibility with the memory server.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
@abstractmethod
|
|
21
|
+
async def connect(self) -> bool:
|
|
22
|
+
"""
|
|
23
|
+
Establish connection to the database backend.
|
|
24
|
+
|
|
25
|
+
Returns:
|
|
26
|
+
bool: True if connection successful, False otherwise
|
|
27
|
+
|
|
28
|
+
Raises:
|
|
29
|
+
DatabaseConnectionError: If connection cannot be established
|
|
30
|
+
"""
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
@abstractmethod
|
|
34
|
+
async def disconnect(self) -> None:
|
|
35
|
+
"""
|
|
36
|
+
Close the database connection and clean up resources.
|
|
37
|
+
|
|
38
|
+
This method should be idempotent and safe to call multiple times.
|
|
39
|
+
"""
|
|
40
|
+
pass
|
|
41
|
+
|
|
42
|
+
@abstractmethod
|
|
43
|
+
async def execute_query(
|
|
44
|
+
self,
|
|
45
|
+
query: str,
|
|
46
|
+
parameters: Optional[dict[str, Any]] = None,
|
|
47
|
+
write: bool = False
|
|
48
|
+
) -> list[dict[str, Any]]:
|
|
49
|
+
"""
|
|
50
|
+
Execute a Cypher query and return results.
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
query: The Cypher query string
|
|
54
|
+
parameters: Query parameters for parameterized queries
|
|
55
|
+
write: Whether this is a write operation (default: False)
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
List of result records as dictionaries
|
|
59
|
+
|
|
60
|
+
Raises:
|
|
61
|
+
DatabaseConnectionError: If not connected
|
|
62
|
+
Exception: For query execution errors
|
|
63
|
+
"""
|
|
64
|
+
pass
|
|
65
|
+
|
|
66
|
+
@abstractmethod
|
|
67
|
+
async def initialize_schema(self) -> None:
|
|
68
|
+
"""
|
|
69
|
+
Initialize database schema including indexes and constraints.
|
|
70
|
+
|
|
71
|
+
This should be idempotent and safe to call multiple times.
|
|
72
|
+
|
|
73
|
+
Raises:
|
|
74
|
+
SchemaError: If schema initialization fails
|
|
75
|
+
"""
|
|
76
|
+
pass
|
|
77
|
+
|
|
78
|
+
@abstractmethod
|
|
79
|
+
async def health_check(self) -> dict[str, Any]:
|
|
80
|
+
"""
|
|
81
|
+
Check backend health and return status information.
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
Dictionary with health check results:
|
|
85
|
+
- connected: bool
|
|
86
|
+
- backend_type: str
|
|
87
|
+
- version: str (if available)
|
|
88
|
+
- statistics: dict (optional)
|
|
89
|
+
"""
|
|
90
|
+
pass
|
|
91
|
+
|
|
92
|
+
@abstractmethod
|
|
93
|
+
def backend_name(self) -> str:
|
|
94
|
+
"""
|
|
95
|
+
Return the name of this backend implementation.
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
Backend name (e.g., "neo4j", "memgraph", "sqlite")
|
|
99
|
+
"""
|
|
100
|
+
pass
|
|
101
|
+
|
|
102
|
+
@abstractmethod
|
|
103
|
+
def supports_fulltext_search(self) -> bool:
|
|
104
|
+
"""
|
|
105
|
+
Check if this backend supports full-text search.
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
True if full-text search is supported
|
|
109
|
+
"""
|
|
110
|
+
pass
|
|
111
|
+
|
|
112
|
+
@abstractmethod
|
|
113
|
+
def supports_transactions(self) -> bool:
|
|
114
|
+
"""
|
|
115
|
+
Check if this backend supports ACID transactions.
|
|
116
|
+
|
|
117
|
+
Returns:
|
|
118
|
+
True if transactions are supported
|
|
119
|
+
"""
|
|
120
|
+
pass
|
|
121
|
+
|
|
122
|
+
async def __aenter__(self):
|
|
123
|
+
"""Async context manager entry."""
|
|
124
|
+
await self.connect()
|
|
125
|
+
return self
|
|
126
|
+
|
|
127
|
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
128
|
+
"""Async context manager exit."""
|
|
129
|
+
await self.disconnect()
|
|
130
|
+
return False
|
|
131
|
+
|
|
132
|
+
# Compatibility methods for legacy MemoryDatabase interface
|
|
133
|
+
async def execute_write_query(
|
|
134
|
+
self,
|
|
135
|
+
query: str,
|
|
136
|
+
parameters: Optional[dict[str, Any]] = None
|
|
137
|
+
) -> list[dict[str, Any]]:
|
|
138
|
+
"""
|
|
139
|
+
Execute a write query (compatibility wrapper for execute_query).
|
|
140
|
+
|
|
141
|
+
This method provides compatibility with the legacy Neo4jConnection interface
|
|
142
|
+
used by MemoryDatabase.
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
query: The Cypher query string
|
|
146
|
+
parameters: Query parameters for parameterized queries
|
|
147
|
+
|
|
148
|
+
Returns:
|
|
149
|
+
List of result records as dictionaries
|
|
150
|
+
"""
|
|
151
|
+
return await self.execute_query(query, parameters, write=True)
|
|
152
|
+
|
|
153
|
+
async def execute_read_query(
|
|
154
|
+
self,
|
|
155
|
+
query: str,
|
|
156
|
+
parameters: Optional[dict[str, Any]] = None
|
|
157
|
+
) -> list[dict[str, Any]]:
|
|
158
|
+
"""
|
|
159
|
+
Execute a read query (compatibility wrapper for execute_query).
|
|
160
|
+
|
|
161
|
+
This method provides compatibility with the legacy Neo4jConnection interface
|
|
162
|
+
used by MemoryDatabase.
|
|
163
|
+
|
|
164
|
+
Args:
|
|
165
|
+
query: The Cypher query string
|
|
166
|
+
parameters: Query parameters for parameterized queries
|
|
167
|
+
|
|
168
|
+
Returns:
|
|
169
|
+
List of result records as dictionaries
|
|
170
|
+
"""
|
|
171
|
+
return await self.execute_query(query, parameters, write=False)
|
|
172
|
+
|
|
173
|
+
async def close(self) -> None:
|
|
174
|
+
"""
|
|
175
|
+
Close the connection (compatibility wrapper for disconnect).
|
|
176
|
+
|
|
177
|
+
This method provides compatibility with the legacy Neo4jConnection interface.
|
|
178
|
+
"""
|
|
179
|
+
await self.disconnect()
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Cloud backend for MemoryGraph.
|
|
3
|
+
|
|
4
|
+
This is a placeholder for future cloud sync functionality.
|
|
5
|
+
When MEMORYGRAPH_API_KEY is set, this backend will sync
|
|
6
|
+
memories to the MemoryGraph cloud service.
|
|
7
|
+
|
|
8
|
+
NOTE: This backend is not yet implemented. Use Turso backend
|
|
9
|
+
for cloud persistence today.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from typing import Any, Optional
|
|
13
|
+
from .base import GraphBackend
|
|
14
|
+
from ..models import DatabaseConnectionError
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class CloudBackend(GraphBackend):
|
|
18
|
+
"""Placeholder for cloud backend implementation."""
|
|
19
|
+
|
|
20
|
+
def __init__(self, api_key: str, api_url: str = "https://api.memorygraph.dev"):
|
|
21
|
+
"""
|
|
22
|
+
Initialize cloud backend.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
api_key: MemoryGraph API key
|
|
26
|
+
api_url: MemoryGraph API endpoint URL
|
|
27
|
+
|
|
28
|
+
Raises:
|
|
29
|
+
NotImplementedError: Cloud backend not yet available
|
|
30
|
+
"""
|
|
31
|
+
self.api_key = api_key
|
|
32
|
+
self.api_url = api_url
|
|
33
|
+
|
|
34
|
+
raise NotImplementedError(
|
|
35
|
+
"Cloud backend coming soon. "
|
|
36
|
+
"For persistent cloud storage, use Turso backend: "
|
|
37
|
+
"pip install memorygraphMCP[turso] and set TURSO_DATABASE_URL"
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
async def connect(self) -> bool:
|
|
41
|
+
"""Not implemented."""
|
|
42
|
+
raise NotImplementedError("Cloud backend not yet available")
|
|
43
|
+
|
|
44
|
+
async def disconnect(self) -> None:
|
|
45
|
+
"""Not implemented."""
|
|
46
|
+
raise NotImplementedError("Cloud backend not yet available")
|
|
47
|
+
|
|
48
|
+
async def execute_query(
|
|
49
|
+
self,
|
|
50
|
+
query: str,
|
|
51
|
+
parameters: Optional[dict[str, Any]] = None,
|
|
52
|
+
write: bool = False,
|
|
53
|
+
) -> list[dict[str, Any]]:
|
|
54
|
+
"""Not implemented."""
|
|
55
|
+
raise NotImplementedError("Cloud backend not yet available")
|
|
56
|
+
|
|
57
|
+
async def initialize_schema(self) -> None:
|
|
58
|
+
"""Not implemented."""
|
|
59
|
+
raise NotImplementedError("Cloud backend not yet available")
|
|
60
|
+
|
|
61
|
+
async def health_check(self) -> dict[str, Any]:
|
|
62
|
+
"""Not implemented."""
|
|
63
|
+
raise NotImplementedError("Cloud backend not yet available")
|
|
64
|
+
|
|
65
|
+
def backend_name(self) -> str:
|
|
66
|
+
"""Return backend identifier."""
|
|
67
|
+
return "cloud"
|
|
68
|
+
|
|
69
|
+
def supports_fulltext_search(self) -> bool:
|
|
70
|
+
"""Not implemented."""
|
|
71
|
+
return False
|
|
72
|
+
|
|
73
|
+
def supports_transactions(self) -> bool:
|
|
74
|
+
"""Not implemented."""
|
|
75
|
+
return False
|