oh-memos-mcp 3.1.2 → 3.1.3

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.
@@ -34,6 +34,39 @@
34
34
  *
35
35
  * 设计讨论见 docs/design/memory-retrieval-optimization.md。
36
36
  */
37
+ /**
38
+ * 取一条 source 的 content —— **同一个字段有两种线上形态**。
39
+ *
40
+ * 实测(3.1.2 上线后才暴露):
41
+ * `GET /memories/{cube}/{id}`(单条)→ `sources[0]` 是**对象** `{type,role,content}`
42
+ * `GET /memories`(列表) → `sources[0]` 是**JSON 字符串** `'{"type":...}'`
43
+ *
44
+ * 初版只处理对象那种,于是同源查找在列表数据上永远匹配不到 —— 原文能返回,
45
+ * 但「同源碎片」区块从不出现。单测用的 fixture 也只造了对象形态,所以测试全绿。
46
+ *
47
+ * 解析失败按无 content 处理,不抛:这是展示层,坏数据不该让 `memos_get` 失败。
48
+ */
49
+ function contentOf(entry) {
50
+ if (typeof entry === "string") {
51
+ // 列表端点的形态。不是 JSON 就当没有 —— 不去猜它是不是裸原文,
52
+ // 否则任何字符串都会被当成原文,把无关记忆归成同源。
53
+ if (!entry.trimStart().startsWith("{"))
54
+ return null;
55
+ try {
56
+ const parsed = JSON.parse(entry);
57
+ const c = parsed?.content;
58
+ return typeof c === "string" && c.trim() !== "" ? c : null;
59
+ }
60
+ catch {
61
+ return null;
62
+ }
63
+ }
64
+ if (entry && typeof entry === "object") {
65
+ const c = entry.content;
66
+ return typeof c === "string" && c.trim() !== "" ? c : null;
67
+ }
68
+ return null;
69
+ }
37
70
  /**
38
71
  * 取出逐字原文。
39
72
  *
@@ -48,11 +81,7 @@ export function verbatimOf(node) {
48
81
  ?.sources;
49
82
  if (!Array.isArray(sources) || sources.length === 0)
50
83
  return null;
51
- const first = sources[0];
52
- const content = first?.content;
53
- if (typeof content !== "string" || content.trim() === "")
54
- return null;
55
- return content;
84
+ return contentOf(sources[0]);
56
85
  }
57
86
  /**
58
87
  * 同源指纹。同一次写入切出的碎片共享它。
package/package.json CHANGED
@@ -1,68 +1,68 @@
1
- {
2
- "name": "oh-memos-mcp",
3
- "version": "3.1.2",
4
- "description": "MCP Server for oh-memos — Intelligent Memory Management (Node.js, no Python required)",
5
- "type": "module",
6
- "main": "dist/index.js",
7
- "bin": {
8
- "oh-memos-mcp": "dist/index.js"
9
- },
10
- "files": [
11
- "dist/**/*.js",
12
- "dist/**/*.d.ts",
13
- "README.md",
14
- "CHANGELOG.md",
15
- ".env.example"
16
- ],
17
- "scripts": {
18
- "build": "tsc",
19
- "dev": "tsx src/index.ts",
20
- "test": "vitest run",
21
- "test:protocol": "npm run build && node scripts/protocol-smoke.mjs && node scripts/protocol-v2-smoke.mjs",
22
- "test:protocol:v2": "npm run build && node scripts/protocol-v2-smoke.mjs",
23
- "test:lite-smoke": "npm run build && node scripts/lite-smoke-test.mjs",
24
- "test:spread-smoke": "npm run build && node scripts/spread-smoke-test.mjs",
25
- "test:host-env-smoke": "npm run build && node scripts/host-env-smoke.mjs",
26
- "schema:semantic": "npm run build && node scripts/schema-semantic-snapshot.mjs --check",
27
- "schema:semantic:freeze": "npm run build && node scripts/schema-semantic-snapshot.mjs --write",
28
- "test:pack": "node scripts/pack-contract.mjs",
29
- "test:watch": "vitest",
30
- "schema:budget": "npm run build && node scripts/schema-budget.mjs --check",
31
- "schema:budget:freeze": "npm run build && node scripts/schema-budget.mjs --write",
32
- "prepublishOnly": "npm run build"
33
- },
34
- "engines": {
35
- "node": ">=20.0.0"
36
- },
37
- "keywords": [
38
- "mcp",
39
- "memory",
40
- "memos",
41
- "claude",
42
- "ai",
43
- "knowledge-graph"
44
- ],
45
- "author": "xigou",
46
- "license": "MIT",
47
- "repository": {
48
- "type": "git",
49
- "url": "https://github.com/lsg1103275794/oh-memos.git",
50
- "directory": "mcp-server-node"
51
- },
52
- "bugs": {
53
- "url": "https://github.com/lsg1103275794/oh-memos/issues"
54
- },
55
- "homepage": "https://github.com/lsg1103275794/oh-memos/tree/main/mcp-server-node",
56
- "dependencies": {
57
- "@modelcontextprotocol/server": "^2.0.0",
58
- "dotenv": "^16.0.0",
59
- "zod": "^4.2.0"
60
- },
61
- "devDependencies": {
62
- "@modelcontextprotocol/client": "^2.0.0",
63
- "@types/node": "^22.0.0",
64
- "tsx": "^4.23.12",
65
- "typescript": "^5.5.0",
66
- "vitest": "3.2.7"
67
- }
68
- }
1
+ {
2
+ "name": "oh-memos-mcp",
3
+ "version": "3.1.3",
4
+ "description": "MCP Server for oh-memos — Intelligent Memory Management (Node.js, no Python required)",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "oh-memos-mcp": "dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist/**/*.js",
12
+ "dist/**/*.d.ts",
13
+ "README.md",
14
+ "CHANGELOG.md",
15
+ ".env.example"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "dev": "tsx src/index.ts",
20
+ "test": "vitest run",
21
+ "test:protocol": "npm run build && node scripts/protocol-smoke.mjs && node scripts/protocol-v2-smoke.mjs",
22
+ "test:protocol:v2": "npm run build && node scripts/protocol-v2-smoke.mjs",
23
+ "test:lite-smoke": "npm run build && node scripts/lite-smoke-test.mjs",
24
+ "test:spread-smoke": "npm run build && node scripts/spread-smoke-test.mjs",
25
+ "test:host-env-smoke": "npm run build && node scripts/host-env-smoke.mjs",
26
+ "schema:semantic": "npm run build && node scripts/schema-semantic-snapshot.mjs --check",
27
+ "schema:semantic:freeze": "npm run build && node scripts/schema-semantic-snapshot.mjs --write",
28
+ "test:pack": "node scripts/pack-contract.mjs",
29
+ "test:watch": "vitest",
30
+ "schema:budget": "npm run build && node scripts/schema-budget.mjs --check",
31
+ "schema:budget:freeze": "npm run build && node scripts/schema-budget.mjs --write",
32
+ "prepublishOnly": "npm run build"
33
+ },
34
+ "engines": {
35
+ "node": ">=20.0.0"
36
+ },
37
+ "keywords": [
38
+ "mcp",
39
+ "memory",
40
+ "memos",
41
+ "claude",
42
+ "ai",
43
+ "knowledge-graph"
44
+ ],
45
+ "author": "xigou",
46
+ "license": "MIT",
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "https://github.com/lsg1103275794/oh-memos.git",
50
+ "directory": "mcp-server-node"
51
+ },
52
+ "bugs": {
53
+ "url": "https://github.com/lsg1103275794/oh-memos/issues"
54
+ },
55
+ "homepage": "https://github.com/lsg1103275794/oh-memos/tree/main/mcp-server-node",
56
+ "dependencies": {
57
+ "@modelcontextprotocol/server": "^2.0.0",
58
+ "dotenv": "^16.0.0",
59
+ "zod": "^4.2.0"
60
+ },
61
+ "devDependencies": {
62
+ "@modelcontextprotocol/client": "^2.0.0",
63
+ "@types/node": "^22.0.0",
64
+ "tsx": "^4.23.12",
65
+ "typescript": "^5.5.0",
66
+ "vitest": "3.2.7"
67
+ }
68
+ }