@danielsimonjr/memory-mcp 0.7.2 → 0.47.1
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/dist/__tests__/edge-cases/edge-cases.test.js +406 -0
- package/dist/__tests__/file-path.test.js +5 -5
- package/dist/__tests__/integration/workflows.test.js +449 -0
- package/dist/__tests__/knowledge-graph.test.js +8 -3
- package/dist/__tests__/performance/benchmarks.test.js +413 -0
- package/dist/__tests__/unit/core/EntityManager.test.js +334 -0
- package/dist/__tests__/unit/core/GraphStorage.test.js +205 -0
- package/dist/__tests__/unit/core/RelationManager.test.js +274 -0
- package/dist/__tests__/unit/features/CompressionManager.test.js +350 -0
- package/dist/__tests__/unit/search/BasicSearch.test.js +311 -0
- package/dist/__tests__/unit/search/BooleanSearch.test.js +432 -0
- package/dist/__tests__/unit/search/FuzzySearch.test.js +448 -0
- package/dist/__tests__/unit/search/RankedSearch.test.js +379 -0
- package/dist/__tests__/unit/utils/levenshtein.test.js +77 -0
- package/dist/core/EntityManager.js +554 -0
- package/dist/core/GraphStorage.js +172 -0
- package/dist/core/KnowledgeGraphManager.js +423 -0
- package/dist/core/ObservationManager.js +129 -0
- package/dist/core/RelationManager.js +186 -0
- package/dist/core/TransactionManager.js +389 -0
- package/dist/core/index.js +9 -0
- package/dist/features/AnalyticsManager.js +222 -0
- package/dist/features/ArchiveManager.js +74 -0
- package/dist/features/BackupManager.js +311 -0
- package/dist/features/CompressionManager.js +291 -0
- package/dist/features/ExportManager.js +305 -0
- package/dist/features/HierarchyManager.js +219 -0
- package/dist/features/ImportExportManager.js +50 -0
- package/dist/features/ImportManager.js +328 -0
- package/dist/features/TagManager.js +210 -0
- package/dist/features/index.js +12 -0
- package/dist/index.js +13 -996
- package/dist/memory.jsonl +18 -0
- package/dist/search/BasicSearch.js +131 -0
- package/dist/search/BooleanSearch.js +283 -0
- package/dist/search/FuzzySearch.js +96 -0
- package/dist/search/RankedSearch.js +190 -0
- package/dist/search/SavedSearchManager.js +145 -0
- package/dist/search/SearchFilterChain.js +187 -0
- package/dist/search/SearchManager.js +305 -0
- package/dist/search/SearchSuggestions.js +57 -0
- package/dist/search/TFIDFIndexManager.js +217 -0
- package/dist/search/index.js +14 -0
- package/dist/server/MCPServer.js +52 -0
- package/dist/server/toolDefinitions.js +732 -0
- package/dist/server/toolHandlers.js +117 -0
- package/dist/types/analytics.types.js +6 -0
- package/dist/types/entity.types.js +7 -0
- package/dist/types/import-export.types.js +7 -0
- package/dist/types/index.js +12 -0
- package/dist/types/search.types.js +7 -0
- package/dist/types/tag.types.js +6 -0
- package/dist/utils/constants.js +128 -0
- package/dist/utils/dateUtils.js +89 -0
- package/dist/utils/entityUtils.js +108 -0
- package/dist/utils/errors.js +121 -0
- package/dist/utils/filterUtils.js +155 -0
- package/dist/utils/index.js +39 -0
- package/dist/utils/levenshtein.js +62 -0
- package/dist/utils/logger.js +33 -0
- package/dist/utils/paginationUtils.js +81 -0
- package/dist/utils/pathUtils.js +115 -0
- package/dist/utils/responseFormatter.js +55 -0
- package/dist/utils/schemas.js +184 -0
- package/dist/utils/searchCache.js +209 -0
- package/dist/utils/tagUtils.js +107 -0
- package/dist/utils/tfidf.js +90 -0
- package/dist/utils/validationHelper.js +99 -0
- package/dist/utils/validationUtils.js +109 -0
- package/package.json +82 -48
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation Utilities
|
|
3
|
+
*
|
|
4
|
+
* Helper functions for validating entities, relations, and other data structures.
|
|
5
|
+
*
|
|
6
|
+
* @module utils/validationUtils
|
|
7
|
+
*/
|
|
8
|
+
import { IMPORTANCE_RANGE } from './constants.js';
|
|
9
|
+
/**
|
|
10
|
+
* Type guard to check if value is a non-null object.
|
|
11
|
+
*/
|
|
12
|
+
function isObject(value) {
|
|
13
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Validate an entity object.
|
|
17
|
+
*
|
|
18
|
+
* Checks required fields and data types.
|
|
19
|
+
*
|
|
20
|
+
* @param entity - Entity to validate (unknown type for runtime validation)
|
|
21
|
+
* @returns Validation result
|
|
22
|
+
*/
|
|
23
|
+
export function validateEntity(entity) {
|
|
24
|
+
const errors = [];
|
|
25
|
+
if (!isObject(entity)) {
|
|
26
|
+
return { valid: false, errors: ['Entity must be an object'] };
|
|
27
|
+
}
|
|
28
|
+
if (!entity.name || typeof entity.name !== 'string' || entity.name.trim() === '') {
|
|
29
|
+
errors.push('Entity name is required and must be a non-empty string');
|
|
30
|
+
}
|
|
31
|
+
if (!entity.entityType || typeof entity.entityType !== 'string' || entity.entityType.trim() === '') {
|
|
32
|
+
errors.push('Entity type is required and must be a non-empty string');
|
|
33
|
+
}
|
|
34
|
+
if (!Array.isArray(entity.observations)) {
|
|
35
|
+
errors.push('Observations must be an array');
|
|
36
|
+
}
|
|
37
|
+
else if (!entity.observations.every((o) => typeof o === 'string')) {
|
|
38
|
+
errors.push('All observations must be strings');
|
|
39
|
+
}
|
|
40
|
+
if (entity.tags !== undefined) {
|
|
41
|
+
if (!Array.isArray(entity.tags)) {
|
|
42
|
+
errors.push('Tags must be an array');
|
|
43
|
+
}
|
|
44
|
+
else if (!entity.tags.every((t) => typeof t === 'string')) {
|
|
45
|
+
errors.push('All tags must be strings');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (entity.importance !== undefined) {
|
|
49
|
+
if (typeof entity.importance !== 'number') {
|
|
50
|
+
errors.push('Importance must be a number');
|
|
51
|
+
}
|
|
52
|
+
else if (!validateImportance(entity.importance)) {
|
|
53
|
+
errors.push('Importance must be between 0 and 10');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return { valid: errors.length === 0, errors };
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Validate a relation object.
|
|
60
|
+
*
|
|
61
|
+
* Checks required fields and data types.
|
|
62
|
+
*
|
|
63
|
+
* @param relation - Relation to validate (unknown type for runtime validation)
|
|
64
|
+
* @returns Validation result
|
|
65
|
+
*/
|
|
66
|
+
export function validateRelation(relation) {
|
|
67
|
+
const errors = [];
|
|
68
|
+
if (!isObject(relation)) {
|
|
69
|
+
return { valid: false, errors: ['Relation must be an object'] };
|
|
70
|
+
}
|
|
71
|
+
if (!relation.from || typeof relation.from !== 'string' || relation.from.trim() === '') {
|
|
72
|
+
errors.push('Relation "from" is required and must be a non-empty string');
|
|
73
|
+
}
|
|
74
|
+
if (!relation.to || typeof relation.to !== 'string' || relation.to.trim() === '') {
|
|
75
|
+
errors.push('Relation "to" is required and must be a non-empty string');
|
|
76
|
+
}
|
|
77
|
+
if (!relation.relationType || typeof relation.relationType !== 'string' || relation.relationType.trim() === '') {
|
|
78
|
+
errors.push('Relation type is required and must be a non-empty string');
|
|
79
|
+
}
|
|
80
|
+
return { valid: errors.length === 0, errors };
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Validate importance level (must be 0-10).
|
|
84
|
+
*
|
|
85
|
+
* @param importance - Importance value to validate
|
|
86
|
+
* @returns True if valid
|
|
87
|
+
*/
|
|
88
|
+
export function validateImportance(importance) {
|
|
89
|
+
return typeof importance === 'number'
|
|
90
|
+
&& !isNaN(importance)
|
|
91
|
+
&& importance >= IMPORTANCE_RANGE.MIN
|
|
92
|
+
&& importance <= IMPORTANCE_RANGE.MAX;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Validate an array of tags.
|
|
96
|
+
*
|
|
97
|
+
* @param tags - Tags array to validate (unknown type for runtime validation)
|
|
98
|
+
* @returns Validation result
|
|
99
|
+
*/
|
|
100
|
+
export function validateTags(tags) {
|
|
101
|
+
const errors = [];
|
|
102
|
+
if (!Array.isArray(tags)) {
|
|
103
|
+
return { valid: false, errors: ['Tags must be an array'] };
|
|
104
|
+
}
|
|
105
|
+
if (!tags.every((t) => typeof t === 'string' && t.trim() !== '')) {
|
|
106
|
+
errors.push('All tags must be non-empty strings');
|
|
107
|
+
}
|
|
108
|
+
return { valid: errors.length === 0, errors };
|
|
109
|
+
}
|
package/package.json
CHANGED
|
@@ -1,48 +1,82 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@danielsimonjr/memory-mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Enhanced MCP memory server with
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"author": "Daniel Simon Jr. (https://github.com/danielsimonjr)",
|
|
7
|
-
"homepage": "https://github.com/danielsimonjr/memory-mcp",
|
|
8
|
-
"bugs": "https://github.com/danielsimonjr/memory-mcp/issues",
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "https://github.com/danielsimonjr/memory-mcp.git"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"mcp",
|
|
15
|
-
"model-context-protocol",
|
|
16
|
-
"memory",
|
|
17
|
-
"knowledge-graph",
|
|
18
|
-
"enhanced",
|
|
19
|
-
"timestamps",
|
|
20
|
-
"tags",
|
|
21
|
-
"export",
|
|
22
|
-
"graphml",
|
|
23
|
-
"analytics"
|
|
24
|
-
],
|
|
25
|
-
"type": "module",
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@danielsimonjr/memory-mcp",
|
|
3
|
+
"version": "0.47.1",
|
|
4
|
+
"description": "Enhanced MCP memory server with hierarchies, compression, archiving, and 45 advanced tools",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Daniel Simon Jr. (https://github.com/danielsimonjr)",
|
|
7
|
+
"homepage": "https://github.com/danielsimonjr/memory-mcp",
|
|
8
|
+
"bugs": "https://github.com/danielsimonjr/memory-mcp/issues",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/danielsimonjr/memory-mcp.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"mcp",
|
|
15
|
+
"model-context-protocol",
|
|
16
|
+
"memory",
|
|
17
|
+
"knowledge-graph",
|
|
18
|
+
"enhanced",
|
|
19
|
+
"timestamps",
|
|
20
|
+
"tags",
|
|
21
|
+
"export",
|
|
22
|
+
"graphml",
|
|
23
|
+
"analytics"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./types": {
|
|
34
|
+
"types": "./dist/types/index.d.ts",
|
|
35
|
+
"import": "./dist/types/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./utils": {
|
|
38
|
+
"types": "./dist/utils/index.d.ts",
|
|
39
|
+
"import": "./dist/utils/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./core": {
|
|
42
|
+
"types": "./dist/core/index.d.ts",
|
|
43
|
+
"import": "./dist/core/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./search": {
|
|
46
|
+
"types": "./dist/search/index.d.ts",
|
|
47
|
+
"import": "./dist/search/index.js"
|
|
48
|
+
},
|
|
49
|
+
"./features": {
|
|
50
|
+
"types": "./dist/features/index.d.ts",
|
|
51
|
+
"import": "./dist/features/index.js"
|
|
52
|
+
},
|
|
53
|
+
"./server": {
|
|
54
|
+
"types": "./dist/server/MCPServer.d.ts",
|
|
55
|
+
"import": "./dist/server/MCPServer.js"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"bin": {
|
|
59
|
+
"mcp-server-memory": "dist/index.js"
|
|
60
|
+
},
|
|
61
|
+
"files": [
|
|
62
|
+
"dist"
|
|
63
|
+
],
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "tsc",
|
|
66
|
+
"prepare": "npm run build",
|
|
67
|
+
"watch": "tsc --watch",
|
|
68
|
+
"test": "vitest run --coverage",
|
|
69
|
+
"typecheck": "tsc --noEmit --noUnusedLocals --noUnusedParameters --strict"
|
|
70
|
+
},
|
|
71
|
+
"dependencies": {
|
|
72
|
+
"@modelcontextprotocol/sdk": "^1.21.1",
|
|
73
|
+
"zod": "^4.1.13"
|
|
74
|
+
},
|
|
75
|
+
"devDependencies": {
|
|
76
|
+
"@types/node": "^22",
|
|
77
|
+
"@vitest/coverage-v8": "^4.0.13",
|
|
78
|
+
"shx": "^0.4.0",
|
|
79
|
+
"typescript": "^5.6.2",
|
|
80
|
+
"vitest": "^4.0.13"
|
|
81
|
+
}
|
|
82
|
+
}
|