@henrychong-ai/mcp-neo4j-knowledge-graph 1.0.0
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.
- package/LICENSE +21 -0
- package/README.md +718 -0
- package/dist/KnowledgeGraphManager.d.ts +215 -0
- package/dist/KnowledgeGraphManager.js +910 -0
- package/dist/KnowledgeGraphManager.js.map +1 -0
- package/dist/callToolHandler.d.ts +5 -0
- package/dist/callToolHandler.js +26 -0
- package/dist/callToolHandler.js.map +1 -0
- package/dist/cli/neo4j-setup.d.ts +52 -0
- package/dist/cli/neo4j-setup.js +258 -0
- package/dist/cli/neo4j-setup.js.map +1 -0
- package/dist/config/paths.d.ts +13 -0
- package/dist/config/paths.js +41 -0
- package/dist/config/paths.js.map +1 -0
- package/dist/config/storage.d.ts +35 -0
- package/dist/config/storage.js +52 -0
- package/dist/config/storage.js.map +1 -0
- package/dist/embeddings/DefaultEmbeddingService.d.ts +64 -0
- package/dist/embeddings/DefaultEmbeddingService.js +139 -0
- package/dist/embeddings/DefaultEmbeddingService.js.map +1 -0
- package/dist/embeddings/EmbeddingJobManager.d.ts +212 -0
- package/dist/embeddings/EmbeddingJobManager.js +545 -0
- package/dist/embeddings/EmbeddingJobManager.js.map +1 -0
- package/dist/embeddings/EmbeddingService.d.ts +96 -0
- package/dist/embeddings/EmbeddingService.js +44 -0
- package/dist/embeddings/EmbeddingService.js.map +1 -0
- package/dist/embeddings/EmbeddingServiceFactory.d.ts +72 -0
- package/dist/embeddings/EmbeddingServiceFactory.js +147 -0
- package/dist/embeddings/EmbeddingServiceFactory.js.map +1 -0
- package/dist/embeddings/OpenAIEmbeddingService.d.ts +73 -0
- package/dist/embeddings/OpenAIEmbeddingService.js +195 -0
- package/dist/embeddings/OpenAIEmbeddingService.js.map +1 -0
- package/dist/embeddings/config.d.ts +83 -0
- package/dist/embeddings/config.js +65 -0
- package/dist/embeddings/config.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +220 -0
- package/dist/index.js.map +1 -0
- package/dist/server/handlers/callToolHandler.d.ts +20 -0
- package/dist/server/handlers/callToolHandler.js +505 -0
- package/dist/server/handlers/callToolHandler.js.map +1 -0
- package/dist/server/handlers/listToolsHandler.d.ts +7 -0
- package/dist/server/handlers/listToolsHandler.js +511 -0
- package/dist/server/handlers/listToolsHandler.js.map +1 -0
- package/dist/server/handlers/toolHandlers/addObservations.d.ts +12 -0
- package/dist/server/handlers/toolHandlers/addObservations.js +99 -0
- package/dist/server/handlers/toolHandlers/addObservations.js.map +1 -0
- package/dist/server/handlers/toolHandlers/createEntities.d.ts +12 -0
- package/dist/server/handlers/toolHandlers/createEntities.js +20 -0
- package/dist/server/handlers/toolHandlers/createEntities.js.map +1 -0
- package/dist/server/handlers/toolHandlers/createRelations.d.ts +12 -0
- package/dist/server/handlers/toolHandlers/createRelations.js +20 -0
- package/dist/server/handlers/toolHandlers/createRelations.js.map +1 -0
- package/dist/server/handlers/toolHandlers/deleteEntities.d.ts +12 -0
- package/dist/server/handlers/toolHandlers/deleteEntities.js +20 -0
- package/dist/server/handlers/toolHandlers/deleteEntities.js.map +1 -0
- package/dist/server/handlers/toolHandlers/index.d.ts +8 -0
- package/dist/server/handlers/toolHandlers/index.js +9 -0
- package/dist/server/handlers/toolHandlers/index.js.map +1 -0
- package/dist/server/handlers/toolHandlers/readGraph.d.ts +12 -0
- package/dist/server/handlers/toolHandlers/readGraph.js +20 -0
- package/dist/server/handlers/toolHandlers/readGraph.js.map +1 -0
- package/dist/server/setup.d.ts +8 -0
- package/dist/server/setup.js +48 -0
- package/dist/server/setup.js.map +1 -0
- package/dist/storage/FileStorageProvider.d.ts +125 -0
- package/dist/storage/FileStorageProvider.js +322 -0
- package/dist/storage/FileStorageProvider.js.map +1 -0
- package/dist/storage/SearchResultCache.d.ts +102 -0
- package/dist/storage/SearchResultCache.js +258 -0
- package/dist/storage/SearchResultCache.js.map +1 -0
- package/dist/storage/StorageProvider.d.ts +171 -0
- package/dist/storage/StorageProvider.js +46 -0
- package/dist/storage/StorageProvider.js.map +1 -0
- package/dist/storage/StorageProviderFactory.d.ts +63 -0
- package/dist/storage/StorageProviderFactory.js +113 -0
- package/dist/storage/StorageProviderFactory.js.map +1 -0
- package/dist/storage/VectorStoreFactory.d.ts +43 -0
- package/dist/storage/VectorStoreFactory.js +41 -0
- package/dist/storage/VectorStoreFactory.js.map +1 -0
- package/dist/storage/neo4j/Neo4jConfig.d.ts +37 -0
- package/dist/storage/neo4j/Neo4jConfig.js +13 -0
- package/dist/storage/neo4j/Neo4jConfig.js.map +1 -0
- package/dist/storage/neo4j/Neo4jConnectionManager.d.ts +40 -0
- package/dist/storage/neo4j/Neo4jConnectionManager.js +58 -0
- package/dist/storage/neo4j/Neo4jConnectionManager.js.map +1 -0
- package/dist/storage/neo4j/Neo4jSchemaManager.d.ts +74 -0
- package/dist/storage/neo4j/Neo4jSchemaManager.js +224 -0
- package/dist/storage/neo4j/Neo4jSchemaManager.js.map +1 -0
- package/dist/storage/neo4j/Neo4jStorageProvider.d.ts +225 -0
- package/dist/storage/neo4j/Neo4jStorageProvider.js +1900 -0
- package/dist/storage/neo4j/Neo4jStorageProvider.js.map +1 -0
- package/dist/storage/neo4j/Neo4jVectorStore.d.ts +80 -0
- package/dist/storage/neo4j/Neo4jVectorStore.js +396 -0
- package/dist/storage/neo4j/Neo4jVectorStore.js.map +1 -0
- package/dist/types/entity-embedding.d.ts +156 -0
- package/dist/types/entity-embedding.js +2 -0
- package/dist/types/entity-embedding.js.map +1 -0
- package/dist/types/relation.d.ts +77 -0
- package/dist/types/relation.js +93 -0
- package/dist/types/relation.js.map +1 -0
- package/dist/types/temporalEntity.d.ts +55 -0
- package/dist/types/temporalEntity.js +66 -0
- package/dist/types/temporalEntity.js.map +1 -0
- package/dist/types/temporalRelation.d.ts +60 -0
- package/dist/types/temporalRelation.js +89 -0
- package/dist/types/temporalRelation.js.map +1 -0
- package/dist/types/vector-index.d.ts +48 -0
- package/dist/types/vector-index.js +2 -0
- package/dist/types/vector-index.js.map +1 -0
- package/dist/types/vector-store.d.ts +16 -0
- package/dist/types/vector-store.js +2 -0
- package/dist/types/vector-store.js.map +1 -0
- package/dist/utils/fs.d.ts +2 -0
- package/dist/utils/fs.js +3 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/logger.d.ts +10 -0
- package/dist/utils/logger.js +35 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import type { StorageProvider, SearchOptions } from '../StorageProvider.js';
|
|
2
|
+
import type { KnowledgeGraph } from '../../KnowledgeGraphManager.js';
|
|
3
|
+
import type { Relation } from '../../types/relation.js';
|
|
4
|
+
import type { EntityEmbedding, SemanticSearchOptions } from '../../types/entity-embedding.js';
|
|
5
|
+
import { Neo4jConnectionManager } from './Neo4jConnectionManager.js';
|
|
6
|
+
import { type Neo4jConfig } from './Neo4jConfig.js';
|
|
7
|
+
/**
|
|
8
|
+
* Configuration options for Neo4j storage provider
|
|
9
|
+
*/
|
|
10
|
+
export interface Neo4jStorageProviderOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Neo4j connection configuration
|
|
13
|
+
*/
|
|
14
|
+
config?: Partial<Neo4jConfig>;
|
|
15
|
+
/**
|
|
16
|
+
* Pre-configured connection manager (optional)
|
|
17
|
+
*/
|
|
18
|
+
connectionManager?: Neo4jConnectionManager;
|
|
19
|
+
/**
|
|
20
|
+
* Configuration for temporal confidence decay
|
|
21
|
+
*/
|
|
22
|
+
decayConfig?: {
|
|
23
|
+
/**
|
|
24
|
+
* Whether confidence decay is enabled
|
|
25
|
+
*/
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Number of days for confidence to decay by half (default: 30)
|
|
29
|
+
*/
|
|
30
|
+
halfLifeDays?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Minimum confidence threshold below which confidence won't decay (default: 0.1)
|
|
33
|
+
*/
|
|
34
|
+
minConfidence?: number;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Extended SemanticSearchOptions with additional properties needed for Neo4j
|
|
39
|
+
*/
|
|
40
|
+
interface Neo4jSemanticSearchOptions extends SemanticSearchOptions {
|
|
41
|
+
queryVector?: number[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Knowledge graph with optional diagnostics
|
|
45
|
+
*/
|
|
46
|
+
interface KnowledgeGraphWithDiagnostics extends KnowledgeGraph {
|
|
47
|
+
diagnostics?: Record<string, unknown>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A storage provider that uses Neo4j to store the knowledge graph
|
|
51
|
+
*/
|
|
52
|
+
export declare class Neo4jStorageProvider implements StorageProvider {
|
|
53
|
+
private connectionManager;
|
|
54
|
+
private schemaManager;
|
|
55
|
+
private readonly config;
|
|
56
|
+
private readonly decayConfig;
|
|
57
|
+
private vectorStore;
|
|
58
|
+
private embeddingService;
|
|
59
|
+
/**
|
|
60
|
+
* Create a new Neo4jStorageProvider
|
|
61
|
+
* @param options Configuration options
|
|
62
|
+
*/
|
|
63
|
+
constructor(options?: Neo4jStorageProviderOptions);
|
|
64
|
+
/**
|
|
65
|
+
* Get the connection manager (primarily for testing)
|
|
66
|
+
*/
|
|
67
|
+
getConnectionManager(): Neo4jConnectionManager;
|
|
68
|
+
/**
|
|
69
|
+
* Initialize Neo4j schema
|
|
70
|
+
*/
|
|
71
|
+
private initializeSchema;
|
|
72
|
+
/**
|
|
73
|
+
* Close Neo4j connections
|
|
74
|
+
*/
|
|
75
|
+
close(): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Convert a Neo4j node to an entity object
|
|
78
|
+
* @param node Neo4j node properties
|
|
79
|
+
* @returns Entity object
|
|
80
|
+
*/
|
|
81
|
+
private nodeToEntity;
|
|
82
|
+
/**
|
|
83
|
+
* Parse a Neo4j relationship into a relation object
|
|
84
|
+
* @param rel Relationship properties
|
|
85
|
+
* @param fromNode From node name
|
|
86
|
+
* @param toNode To node name
|
|
87
|
+
* @returns Relation object
|
|
88
|
+
*/
|
|
89
|
+
/**
|
|
90
|
+
* Parse a Neo4j relationship into a relation object
|
|
91
|
+
* @param rel Relationship properties
|
|
92
|
+
* @param fromNode From node name
|
|
93
|
+
* @param toNode To node name
|
|
94
|
+
* @returns Relation object
|
|
95
|
+
*/
|
|
96
|
+
private relationshipToRelation;
|
|
97
|
+
/**
|
|
98
|
+
* Load the complete knowledge graph from Neo4j
|
|
99
|
+
*/
|
|
100
|
+
loadGraph(): Promise<KnowledgeGraph>;
|
|
101
|
+
/**
|
|
102
|
+
* Save a complete knowledge graph to Neo4j (warning: this will overwrite existing data)
|
|
103
|
+
* @param graph The knowledge graph to save
|
|
104
|
+
*/
|
|
105
|
+
saveGraph(graph: KnowledgeGraph): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Search for nodes in the graph that match the query
|
|
108
|
+
* @param query The search query string
|
|
109
|
+
* @param options Optional search parameters
|
|
110
|
+
*/
|
|
111
|
+
searchNodes(query: string, options?: SearchOptions): Promise<KnowledgeGraph>;
|
|
112
|
+
/**
|
|
113
|
+
* Open specific nodes by their exact names
|
|
114
|
+
* @param names Array of node names to open
|
|
115
|
+
*/
|
|
116
|
+
openNodes(names: string[]): Promise<KnowledgeGraph>;
|
|
117
|
+
/**
|
|
118
|
+
* Create new entities in the knowledge graph
|
|
119
|
+
* @param entities Array of entities to create
|
|
120
|
+
*/
|
|
121
|
+
createEntities(entities: any[]): Promise<any[]>;
|
|
122
|
+
/**
|
|
123
|
+
* Create new relations between entities
|
|
124
|
+
* @param relations Array of relations to create
|
|
125
|
+
*/
|
|
126
|
+
createRelations(relations: Relation[]): Promise<Relation[]>;
|
|
127
|
+
/**
|
|
128
|
+
* Add observations to entities
|
|
129
|
+
* @param observations Array of objects with entity name and observation contents
|
|
130
|
+
*/
|
|
131
|
+
addObservations(observations: {
|
|
132
|
+
entityName: string;
|
|
133
|
+
contents: string[];
|
|
134
|
+
}[]): Promise<{
|
|
135
|
+
entityName: string;
|
|
136
|
+
addedObservations: string[];
|
|
137
|
+
}[]>;
|
|
138
|
+
/**
|
|
139
|
+
* Delete entities and their relations
|
|
140
|
+
* @param entityNames Array of entity names to delete
|
|
141
|
+
*/
|
|
142
|
+
deleteEntities(entityNames: string[]): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Delete observations from entities
|
|
145
|
+
* @param deletions Array of objects with entity name and observations to delete
|
|
146
|
+
*/
|
|
147
|
+
deleteObservations(deletions: {
|
|
148
|
+
entityName: string;
|
|
149
|
+
observations: string[];
|
|
150
|
+
}[]): Promise<void>;
|
|
151
|
+
/**
|
|
152
|
+
* Delete relations from the graph
|
|
153
|
+
* @param relations Array of relations to delete
|
|
154
|
+
*/
|
|
155
|
+
deleteRelations(relations: Relation[]): Promise<void>;
|
|
156
|
+
/**
|
|
157
|
+
* Get an entity by name
|
|
158
|
+
* @param entityName Name of the entity to retrieve
|
|
159
|
+
*/
|
|
160
|
+
getEntity(entityName: string): Promise<any | null>;
|
|
161
|
+
/**
|
|
162
|
+
* Get a specific relation by its source, target, and type
|
|
163
|
+
* @param from Source entity name
|
|
164
|
+
* @param to Target entity name
|
|
165
|
+
* @param type Relation type
|
|
166
|
+
*/
|
|
167
|
+
getRelation(from: string, to: string, type: string): Promise<Relation | null>;
|
|
168
|
+
/**
|
|
169
|
+
* Update an existing relation with new properties
|
|
170
|
+
* @param relation The relation with updated properties
|
|
171
|
+
*/
|
|
172
|
+
updateRelation(relation: Relation): Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
* Get the history of all versions of an entity
|
|
175
|
+
* @param entityName The name of the entity to retrieve history for
|
|
176
|
+
*/
|
|
177
|
+
getEntityHistory(entityName: string): Promise<any[]>;
|
|
178
|
+
/**
|
|
179
|
+
* Get the history of all versions of a relation
|
|
180
|
+
* @param from Source entity name
|
|
181
|
+
* @param to Target entity name
|
|
182
|
+
* @param relationType Type of the relation
|
|
183
|
+
*/
|
|
184
|
+
getRelationHistory(from: string, to: string, relationType: string): Promise<any[]>;
|
|
185
|
+
/**
|
|
186
|
+
* Get the state of the knowledge graph at a specific point in time
|
|
187
|
+
* @param timestamp The timestamp to get the graph state at
|
|
188
|
+
*/
|
|
189
|
+
getGraphAtTime(timestamp: number): Promise<KnowledgeGraph>;
|
|
190
|
+
/**
|
|
191
|
+
* Get the current knowledge graph with confidence decay applied to relations
|
|
192
|
+
* based on their age and the configured decay settings
|
|
193
|
+
*/
|
|
194
|
+
getDecayedGraph(): Promise<KnowledgeGraph>;
|
|
195
|
+
/**
|
|
196
|
+
* Store or update the embedding vector for an entity
|
|
197
|
+
* @param entityName The name of the entity to update
|
|
198
|
+
* @param embedding The embedding data to store
|
|
199
|
+
*/
|
|
200
|
+
updateEntityEmbedding(entityName: string, embedding: EntityEmbedding): Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* Get the embedding vector for an entity
|
|
203
|
+
* @param entityName The name of the entity
|
|
204
|
+
* @returns Promise resolving to the EntityEmbedding or null if not found
|
|
205
|
+
*/
|
|
206
|
+
getEntityEmbedding(entityName: string): Promise<EntityEmbedding | null>;
|
|
207
|
+
/**
|
|
208
|
+
* Find entities similar to a query vector
|
|
209
|
+
* @param queryVector The vector to compare against
|
|
210
|
+
* @param limit Maximum number of results to return
|
|
211
|
+
*/
|
|
212
|
+
findSimilarEntities(queryVector: number[], limit?: number): Promise<any[]>;
|
|
213
|
+
/**
|
|
214
|
+
* Search for entities using semantic search
|
|
215
|
+
* @param query The search query text
|
|
216
|
+
* @param options Search options including semantic search parameters
|
|
217
|
+
*/
|
|
218
|
+
semanticSearch(query: string, options?: SearchOptions & Neo4jSemanticSearchOptions): Promise<KnowledgeGraphWithDiagnostics>;
|
|
219
|
+
/**
|
|
220
|
+
* Direct diagnostic method to check Neo4j vector embeddings
|
|
221
|
+
* Bypasses all abstractions to query the database directly
|
|
222
|
+
*/
|
|
223
|
+
diagnoseVectorSearch(): Promise<Record<string, unknown>>;
|
|
224
|
+
}
|
|
225
|
+
export {};
|