@anvia/memgraph API reference ​
Client ​
class MemgraphClient implements AsyncDisposable {
constructor(options: MemgraphClientOptions)
managedKnowledgeGraph(options): ManagedMemgraphKnowledgeGraph
knowledgeGraph(options): MemgraphKnowledgeGraph
nativeDriver(): Driver
close(): Promise<void>
}Managed registrations expose provisioning, retrieval, exploration, replacement, and deletion. Existing registrations expose validation, retrieval, and exploration without mutation.
managedKnowledgeGraph() accepts either { name, schema, dimensions, similarity?, text?, fulltext? } or an explicit { name, schema, resources }. Without resources, labels and index names are derived from name and validated as ManagedMemgraphResources. ensure({ abortSignal? }) creates the missing constraints and indexes and then validates them; unlike the Neo4j adapter it takes no index timeout. ManagedMemgraphTextShorthand is true | false | { chunks?, entities? }. MemgraphVectorSimilarity covers 'cosine', 'euclidean', 'dotProduct', and 'inner-product'; the last two both map to Memgraph's inner-product metric.
The package also re-exports defineGraphSchema() and extractGraphFacts() from @anvia/graph, so an application that only needs extraction can import them from the adapter it already installed.
Standalone retrieval and exploration ​
retrieveGraphContext() and exploreGraph() run the same policies without going through a registration method:
const context = await retrieveGraphContext({
graph,
model,
query,
search,
traversal,
evidence,
retries,
abortSignal,
})
const view = await exploreGraph(graph, {
mode: 'overview',
maxNodes: 100,
maxRelationships: 200,
})retrieveGraphContext() accepts the same search, traversal, and evidence policy as graph.retrieve(); chunk evidence requires a managed registration — the graph's evidenceCapability must be 'chunks' — while existing registrations use { type: 'none' }. exploreGraph() accepts the shared overview and expand options and returns nodes, relationships, and truncation flags.
Portable integration ​
Import defineGraphSchema(), extractGraphFacts(), ingestGraphText(), ingestGraphDocuments(), prepareGraphDocuments(), and createGraphSearchTool() from @anvia/graph. The adapter's graph registrations implement the corresponding provider-neutral contracts, and defineMemgraphGraphSchema() re-exports defineGraphSchema() under a Memgraph-specific name.
Memgraph resource options describe labels plus chunk and entity vector/text indexes. Existing-graph seeds describe their node types and complete index definitions. Consult the published declarations for exact option and result fields.