@smartergpt/lex-mcp 1.0.0

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.
Files changed (3) hide show
  1. package/README.md +72 -0
  2. package/index.mjs +108 -0
  3. package/package.json +36 -0
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # @smartergpt/lex-mcp
2
+
3
+ MCP server wrapper for [Lex](https://github.com/Guffawaffle/lex) episodic memory.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ npx @smartergpt/lex-mcp
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ ### VS Code / Copilot
14
+
15
+ Add to `.vscode/mcp.json`:
16
+
17
+ ```json
18
+ {
19
+ "servers": {
20
+ "lex": {
21
+ "command": "npx",
22
+ "args": ["@smartergpt/lex-mcp"],
23
+ "env": {
24
+ "LEX_WORKSPACE_ROOT": "${workspaceFolder}"
25
+ }
26
+ }
27
+ }
28
+ }
29
+ ```
30
+
31
+ ### Claude Desktop
32
+
33
+ Add to `claude_desktop_config.json`:
34
+
35
+ ```json
36
+ {
37
+ "mcpServers": {
38
+ "lex": {
39
+ "command": "npx",
40
+ "args": ["@smartergpt/lex-mcp"]
41
+ }
42
+ }
43
+ }
44
+ ```
45
+
46
+ ## Environment Variables
47
+
48
+ | Variable | Description | Default |
49
+ |----------|-------------|---------|
50
+ | `LEX_WORKSPACE_ROOT` | Workspace root directory | Current directory |
51
+ | `LEX_MEMORY_DB` | SQLite database path | `.smartergpt/lex/lex.db` |
52
+ | `LEX_DEBUG` | Enable debug logging | Off |
53
+
54
+ ## Tools
55
+
56
+ This MCP server provides 11 tools for episodic memory management:
57
+
58
+ - `frame_create` - Store episodic memory snapshot
59
+ - `frame_search` - Search frames by reference, branch, or ticket
60
+ - `frame_get` - Retrieve specific frame by ID
61
+ - `frame_list` - List recent frames with filtering
62
+ - `frame_validate` - Validate frame input (dry-run)
63
+ - `policy_check` - Validate code against policy rules
64
+ - `timeline_show` - Visual timeline of frame evolution
65
+ - `atlas_analyze` - Analyze code structure and dependencies
66
+ - `system_introspect` - Discover Lex capabilities and state
67
+ - `help` - Usage help and examples
68
+ - `hints_get` - Retrieve error recovery hints
69
+
70
+ ## Learn More
71
+
72
+ See the [Lex documentation](https://github.com/Guffawaffle/lex) for full details.
package/index.mjs ADDED
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @smartergpt/lex-mcp - MCP Server Entry Point
4
+ *
5
+ * Thin wrapper that starts the Lex MCP server over stdio.
6
+ * This package exists to provide a clean npx launch target for the MCP registry.
7
+ *
8
+ * Usage:
9
+ * npx @smartergpt/lex-mcp
10
+ *
11
+ * Environment Variables:
12
+ * LEX_WORKSPACE_ROOT - Workspace root directory (default: cwd)
13
+ * LEX_MEMORY_DB - SQLite database path (default: .smartergpt/lex/lex.db)
14
+ * LEX_DEBUG - Enable debug logging to stderr
15
+ */
16
+
17
+ import { MCPServer } from "@smartergpt/lex/mcp-server";
18
+ import { join } from "path";
19
+
20
+ // Workspace root defaults to current working directory
21
+ const repoRoot = process.env.LEX_WORKSPACE_ROOT || process.cwd();
22
+
23
+ // Set LEX_WORKSPACE_ROOT for modules that need it
24
+ if (!process.env.LEX_WORKSPACE_ROOT) {
25
+ process.env.LEX_WORKSPACE_ROOT = repoRoot;
26
+ }
27
+
28
+ // Database path defaults to .smartergpt/lex/lex.db in workspace root
29
+ const dbPath =
30
+ process.env.LEX_MEMORY_DB || join(repoRoot, ".smartergpt", "lex", "lex.db");
31
+
32
+ // Initialize MCP server
33
+ let mcpServer;
34
+ try {
35
+ mcpServer = new MCPServer(dbPath, repoRoot);
36
+ if (process.env.LEX_DEBUG) {
37
+ console.error(`[LEX-MCP] Server initialized: ${dbPath}`);
38
+ console.error(`[LEX-MCP] Workspace root: ${repoRoot}`);
39
+ }
40
+ } catch (error) {
41
+ console.error(`[LEX-MCP] Failed to initialize: ${error.message}`);
42
+ process.exit(1);
43
+ }
44
+
45
+ // MCP stdio protocol handler (JSON-RPC 2.0 over newline-delimited JSON)
46
+ process.stdin.setEncoding("utf8");
47
+ let buffer = "";
48
+
49
+ process.stdin.on("data", async (chunk) => {
50
+ buffer += chunk;
51
+ const lines = buffer.split("\n");
52
+ buffer = lines.pop() || "";
53
+
54
+ for (const line of lines) {
55
+ if (!line.trim()) continue;
56
+
57
+ let request;
58
+ try {
59
+ request = JSON.parse(line);
60
+ const response = await mcpServer.handleRequest(request);
61
+
62
+ // MCP protocol response format
63
+ if (response.error) {
64
+ console.log(
65
+ JSON.stringify({
66
+ jsonrpc: "2.0",
67
+ id: request.id,
68
+ error: response.error,
69
+ })
70
+ );
71
+ } else {
72
+ console.log(
73
+ JSON.stringify({
74
+ jsonrpc: "2.0",
75
+ id: request.id,
76
+ result: response,
77
+ })
78
+ );
79
+ }
80
+ } catch (error) {
81
+ console.log(
82
+ JSON.stringify({
83
+ jsonrpc: "2.0",
84
+ id: request?.id || null,
85
+ error: {
86
+ message: error.message,
87
+ code: error.code || "PARSE_ERROR",
88
+ },
89
+ })
90
+ );
91
+ }
92
+ }
93
+ });
94
+
95
+ // Graceful shutdown
96
+ process.on("SIGINT", () => {
97
+ if (mcpServer) mcpServer.close();
98
+ process.exit(0);
99
+ });
100
+
101
+ process.on("SIGTERM", () => {
102
+ if (mcpServer) mcpServer.close();
103
+ process.exit(0);
104
+ });
105
+
106
+ if (process.env.LEX_DEBUG) {
107
+ console.error("[LEX-MCP] Ready (stdio mode)");
108
+ }
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@smartergpt/lex-mcp",
3
+ "version": "1.0.0",
4
+ "description": "MCP server for Lex episodic memory - stdio transport wrapper",
5
+ "mcpName": "io.github.guffawaffle/lex",
6
+ "type": "module",
7
+ "bin": "./index.mjs",
8
+ "files": [
9
+ "index.mjs",
10
+ "README.md"
11
+ ],
12
+ "dependencies": {
13
+ "@smartergpt/lex": "^2.1.0"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/Guffawaffle/lex.git",
18
+ "directory": "lex-mcp"
19
+ },
20
+ "keywords": [
21
+ "mcp",
22
+ "model-context-protocol",
23
+ "lex",
24
+ "episodic-memory",
25
+ "ai-agents"
26
+ ],
27
+ "author": "Guffawaffle",
28
+ "license": "MIT",
29
+ "engines": {
30
+ "node": ">=18"
31
+ },
32
+ "homepage": "https://github.com/Guffawaffle/lex#readme",
33
+ "bugs": {
34
+ "url": "https://github.com/Guffawaffle/lex/issues"
35
+ }
36
+ }