@smartergpt/lex-mcp 2.2.0 → 2.5.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/index.mjs +25 -4
- package/package.json +8 -2
package/index.mjs
CHANGED
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { MCPServer } from "@smartergpt/lex/mcp-server";
|
|
18
|
-
import { join } from "path";
|
|
18
|
+
import { join, dirname } from "path";
|
|
19
|
+
import { mkdirSync } from "fs";
|
|
19
20
|
|
|
20
21
|
// Workspace root defaults to current working directory
|
|
21
22
|
const repoRoot = process.env.LEX_WORKSPACE_ROOT || process.cwd();
|
|
@@ -29,6 +30,13 @@ if (!process.env.LEX_WORKSPACE_ROOT) {
|
|
|
29
30
|
const dbPath =
|
|
30
31
|
process.env.LEX_MEMORY_DB || join(repoRoot, ".smartergpt", "lex", "lex.db");
|
|
31
32
|
|
|
33
|
+
// Ensure the database directory exists (first-time setup)
|
|
34
|
+
try {
|
|
35
|
+
mkdirSync(dirname(dbPath), { recursive: true });
|
|
36
|
+
} catch {
|
|
37
|
+
// Ignore — directory may already exist or be read-only
|
|
38
|
+
}
|
|
39
|
+
|
|
32
40
|
// Initialize MCP server
|
|
33
41
|
let mcpServer;
|
|
34
42
|
try {
|
|
@@ -42,6 +50,10 @@ try {
|
|
|
42
50
|
process.exit(1);
|
|
43
51
|
}
|
|
44
52
|
|
|
53
|
+
if (process.env.LEX_DEBUG) {
|
|
54
|
+
console.error(`[LEX-MCP] Ready (stdio mode)`);
|
|
55
|
+
}
|
|
56
|
+
|
|
45
57
|
// MCP stdio protocol handler (JSON-RPC 2.0 over newline-delimited JSON)
|
|
46
58
|
process.stdin.setEncoding("utf8");
|
|
47
59
|
let buffer = "";
|
|
@@ -57,6 +69,15 @@ process.stdin.on("data", async (chunk) => {
|
|
|
57
69
|
let request;
|
|
58
70
|
try {
|
|
59
71
|
request = JSON.parse(line);
|
|
72
|
+
|
|
73
|
+
// MCP notifications have no `id` — silently ignore them per spec
|
|
74
|
+
if (request.id === undefined || request.id === null) {
|
|
75
|
+
if (process.env.LEX_DEBUG) {
|
|
76
|
+
console.error(`[LEX-MCP] Notification: ${request.method}`);
|
|
77
|
+
}
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
|
|
60
81
|
const response = await mcpServer.handleRequest(request);
|
|
61
82
|
|
|
62
83
|
// MCP protocol response format
|
|
@@ -66,7 +87,7 @@ process.stdin.on("data", async (chunk) => {
|
|
|
66
87
|
jsonrpc: "2.0",
|
|
67
88
|
id: request.id,
|
|
68
89
|
error: response.error,
|
|
69
|
-
})
|
|
90
|
+
}),
|
|
70
91
|
);
|
|
71
92
|
} else {
|
|
72
93
|
console.log(
|
|
@@ -74,7 +95,7 @@ process.stdin.on("data", async (chunk) => {
|
|
|
74
95
|
jsonrpc: "2.0",
|
|
75
96
|
id: request.id,
|
|
76
97
|
result: response,
|
|
77
|
-
})
|
|
98
|
+
}),
|
|
78
99
|
);
|
|
79
100
|
}
|
|
80
101
|
} catch (error) {
|
|
@@ -86,7 +107,7 @@ process.stdin.on("data", async (chunk) => {
|
|
|
86
107
|
message: error.message,
|
|
87
108
|
code: error.code || "PARSE_ERROR",
|
|
88
109
|
},
|
|
89
|
-
})
|
|
110
|
+
}),
|
|
90
111
|
);
|
|
91
112
|
}
|
|
92
113
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartergpt/lex-mcp",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "MCP server for Lex episodic memory - stdio transport wrapper",
|
|
5
5
|
"mcpName": "dev.smartergpt/lex",
|
|
6
6
|
"type": "module",
|
|
@@ -9,8 +9,14 @@
|
|
|
9
9
|
"index.mjs",
|
|
10
10
|
"README.md"
|
|
11
11
|
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test:mcp": "node test-mcp-server.mjs --local --clean",
|
|
14
|
+
"test:mcp:verbose": "node test-mcp-server.mjs --local --clean --verbose",
|
|
15
|
+
"test:published": "node test-mcp-server.mjs --clean",
|
|
16
|
+
"link:local": "rm -rf node_modules/@smartergpt/lex && mkdir -p node_modules/@smartergpt && ln -s /srv/lex-mcp/lex node_modules/@smartergpt/lex"
|
|
17
|
+
},
|
|
12
18
|
"dependencies": {
|
|
13
|
-
"@smartergpt/lex": "^2.
|
|
19
|
+
"@smartergpt/lex": "^2.5.1"
|
|
14
20
|
},
|
|
15
21
|
"publishConfig": {
|
|
16
22
|
"access": "public",
|