knowledgegraph-mcp
Version:
MCP server for enabling persistent knowledge storage for Claude through a knowledge graph with multiple storage backends
125 lines • 3.93 kB
TypeScript
import { StorageConfig } from './storage/types.js';
import { SearchOptions, PaginationOptions } from './search/types.js';
export interface Entity {
name: string;
entityType: string;
observations: string[];
tags?: string[];
}
export interface Relation {
from: string;
to: string;
relationType: string;
}
export interface KnowledgeGraph {
entities: Entity[];
relations: Relation[];
}
export interface PaginatedKnowledgeGraph {
entities: Entity[];
relations: Relation[];
pagination: {
currentPage: number;
pageSize: number;
totalCount: number;
totalPages: number;
hasNextPage: boolean;
hasPreviousPage: boolean;
};
}
export declare class KnowledgeGraphManager {
private storage;
private searchManager;
private config;
constructor(storageConfig?: StorageConfig);
private initializeStorage;
private initializeSearchManager;
private getStorageConfigFromEnv;
private loadGraph;
private saveGraph;
/**
* Close storage connections and cleanup resources
*/
close(): Promise<void>;
/**
* Health check for the storage provider
*/
healthCheck(): Promise<boolean>;
createEntities(entities: Entity[], project?: string): Promise<Entity[]>;
createRelations(relations: Relation[], project?: string): Promise<{
newRelations: Relation[];
skippedRelations: Array<{
relation: Relation;
reason: string;
}>;
totalRequested: number;
}>;
addObservations(observations: {
entityName: string;
observations: string[];
}[], project?: string): Promise<{
entityName: string;
addedObservations: string[];
}[]>;
deleteEntities(entityNames: string[], project?: string): Promise<void>;
deleteObservations(deletions: {
entityName: string;
observations: string[];
}[], project?: string): Promise<void>;
deleteRelations(relations: Relation[], project?: string): Promise<void>;
readGraph(project?: string): Promise<KnowledgeGraph>;
searchNodes(query: string | string[], optionsOrProject?: SearchOptions | {
exactTags?: string[];
tagMatchMode?: 'any' | 'all';
} | string, project?: string): Promise<KnowledgeGraph>;
private searchSingleQuery;
/**
* Paginated search function with database-level pagination when possible
*/
searchNodesPaginated(query: string | string[], pagination: PaginationOptions, optionsOrProject?: SearchOptions | {
exactTags?: string[];
tagMatchMode?: 'any' | 'all';
} | string, project?: string): Promise<PaginatedKnowledgeGraph>;
/**
* Apply pagination to a full KnowledgeGraph result (post-search pagination)
*/
private applyPostSearchPagination;
openNodes(names: string[], project?: string): Promise<KnowledgeGraph>;
/**
* Add tags to existing entities
*/
addTags(updates: {
entityName: string;
tags: string[];
}[], project?: string): Promise<{
entityName: string;
addedTags: string[];
}[]>;
/**
* Remove specific tags from entities
*/
removeTags(updates: {
entityName: string;
tags: string[];
}[], project?: string): Promise<{
entityName: string;
removedTags: string[];
}[]>;
/**
* Validate entities before creation to prevent database constraint violations
*/
private validateEntities;
/**
* Validate relations before creation to prevent database constraint violations
*/
private validateRelations;
/**
* Validate observation updates to prevent database constraint violations
*/
private validateObservationUpdates;
/**
* Helper method to build a filtered graph with relations
*/
private buildFilteredGraph;
}
//# sourceMappingURL=core.d.ts.map