sqlcipher-mcp-server 1.0.3 → 1.0.4-debug.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.
- package/index.js +32 -0
- package/package.json +1 -1
- package/src/server/mcp-server.js +86 -10
package/index.js
CHANGED
|
@@ -5,10 +5,42 @@
|
|
|
5
5
|
* Provides read-only access to SQLCipher-encrypted SQLite databases via MCP
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
// #region agent log
|
|
9
|
+
fetch('http://127.0.0.1:7245/ingest/ba5ae969-895e-4c8c-9b24-3b774e2457b2',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'index.js:8',message:'Script started',data:{cwd:process.cwd(),argv:process.argv.slice(0,3)},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});
|
|
10
|
+
// #endregion
|
|
11
|
+
|
|
12
|
+
// #region agent log
|
|
13
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
14
|
+
fetch('http://127.0.0.1:7245/ingest/ba5ae969-895e-4c8c-9b24-3b774e2457b2',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'index.js:12',message:'Unhandled promise rejection',data:{reason:reason?.message||String(reason),stack:reason?.stack,name:reason?.name},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'B'})}).catch(()=>{});
|
|
15
|
+
console.error('Unhandled rejection:', reason);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
process.on('uncaughtException', (error) => {
|
|
19
|
+
fetch('http://127.0.0.1:7245/ingest/ba5ae969-895e-4c8c-9b24-3b774e2457b2',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'index.js:17',message:'Uncaught exception',data:{error:error?.message,stack:error?.stack,name:error?.name},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'B'})}).catch(()=>{});
|
|
20
|
+
console.error('Uncaught exception:', error);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
process.on('exit', (code) => {
|
|
25
|
+
fetch('http://127.0.0.1:7245/ingest/ba5ae969-895e-4c8c-9b24-3b774e2457b2',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'index.js:22',message:'Process exiting',data:{code},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'B'})}).catch(()=>{});
|
|
26
|
+
});
|
|
27
|
+
// #endregion
|
|
28
|
+
|
|
29
|
+
// #region agent log
|
|
30
|
+
fetch('http://127.0.0.1:7245/ingest/ba5ae969-895e-4c8c-9b24-3b774e2457b2',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'index.js:26',message:'Before import startMcpServer',data:{},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});
|
|
31
|
+
// #endregion
|
|
32
|
+
|
|
8
33
|
import { startMcpServer } from './src/server/mcp-server.js';
|
|
9
34
|
|
|
35
|
+
// #region agent log
|
|
36
|
+
fetch('http://127.0.0.1:7245/ingest/ba5ae969-895e-4c8c-9b24-3b774e2457b2',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'index.js:30',message:'Import completed, calling startMcpServer',data:{startMcpServer:!!startMcpServer},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});
|
|
37
|
+
// #endregion
|
|
38
|
+
|
|
10
39
|
// Start the server
|
|
11
40
|
startMcpServer().catch((error) => {
|
|
41
|
+
// #region agent log
|
|
42
|
+
fetch('http://127.0.0.1:7245/ingest/ba5ae969-895e-4c8c-9b24-3b774e2457b2',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'index.js:35',message:'startMcpServer catch handler',data:{error:error?.message,stack:error?.stack,name:error?.name},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});
|
|
43
|
+
// #endregion
|
|
12
44
|
console.error('Fatal error starting server:', error);
|
|
13
45
|
process.exit(1);
|
|
14
46
|
});
|
package/package.json
CHANGED
package/src/server/mcp-server.js
CHANGED
|
@@ -31,19 +31,35 @@ export function createMcpServer() {
|
|
|
31
31
|
}
|
|
32
32
|
);
|
|
33
33
|
|
|
34
|
-
// Register list tools handler
|
|
34
|
+
// Register list tools handler with error handling
|
|
35
35
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
36
|
-
|
|
36
|
+
try {
|
|
37
|
+
return await handleListTools();
|
|
38
|
+
} catch (error) {
|
|
39
|
+
// #region agent log
|
|
40
|
+
fetch('http://127.0.0.1:7245/ingest/ba5ae969-895e-4c8c-9b24-3b774e2457b2',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'mcp-server.js:36',message:'ListTools handler error',data:{error:error?.message,stack:error?.stack},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});
|
|
41
|
+
// #endregion
|
|
42
|
+
console.error('Error in ListTools handler:', error);
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
37
45
|
});
|
|
38
46
|
|
|
39
|
-
// Register tool execution handler
|
|
47
|
+
// Register tool execution handler with error handling
|
|
40
48
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
try {
|
|
50
|
+
const { name, arguments: args } = request.params;
|
|
51
|
+
|
|
52
|
+
if (name === 'execute_query') {
|
|
53
|
+
return await handleExecuteQuery(args);
|
|
54
|
+
} else {
|
|
55
|
+
return handleUnknownTool(name);
|
|
56
|
+
}
|
|
57
|
+
} catch (error) {
|
|
58
|
+
// #region agent log
|
|
59
|
+
fetch('http://127.0.0.1:7245/ingest/ba5ae969-895e-4c8c-9b24-3b774e2457b2',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'mcp-server.js:48',message:'CallTool handler error',data:{error:error?.message,stack:error?.stack},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});
|
|
60
|
+
// #endregion
|
|
61
|
+
console.error('Error in CallTool handler:', error);
|
|
62
|
+
throw error;
|
|
47
63
|
}
|
|
48
64
|
});
|
|
49
65
|
|
|
@@ -55,6 +71,10 @@ export function createMcpServer() {
|
|
|
55
71
|
* @returns {Promise<void>}
|
|
56
72
|
*/
|
|
57
73
|
export async function startMcpServer() {
|
|
74
|
+
// #region agent log
|
|
75
|
+
fetch('http://127.0.0.1:7245/ingest/ba5ae969-895e-4c8c-9b24-3b774e2457b2',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'mcp-server.js:57',message:'startMcpServer entry',data:{},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});
|
|
76
|
+
// #endregion
|
|
77
|
+
|
|
58
78
|
// Check configuration and log warnings
|
|
59
79
|
const warnings = getConfigurationWarnings();
|
|
60
80
|
if (warnings.length > 0) {
|
|
@@ -63,14 +83,70 @@ export async function startMcpServer() {
|
|
|
63
83
|
console.error('Configuration loaded: Database path and password set via environment variables.');
|
|
64
84
|
}
|
|
65
85
|
|
|
86
|
+
// #region agent log
|
|
87
|
+
fetch('http://127.0.0.1:7245/ingest/ba5ae969-895e-4c8c-9b24-3b774e2457b2',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'mcp-server.js:67',message:'Before createMcpServer',data:{},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});
|
|
88
|
+
// #endregion
|
|
89
|
+
|
|
66
90
|
// Create server
|
|
67
91
|
const server = createMcpServer();
|
|
68
92
|
|
|
93
|
+
// #region agent log
|
|
94
|
+
fetch('http://127.0.0.1:7245/ingest/ba5ae969-895e-4c8c-9b24-3b774e2457b2',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'mcp-server.js:72',message:'Before transport creation',data:{server:!!server},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'C'})}).catch(()=>{});
|
|
95
|
+
// #endregion
|
|
96
|
+
|
|
69
97
|
// Create stdio transport
|
|
70
98
|
const transport = new StdioServerTransport();
|
|
71
99
|
|
|
100
|
+
// #region agent log
|
|
101
|
+
fetch('http://127.0.0.1:7245/ingest/ba5ae969-895e-4c8c-9b24-3b774e2457b2',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'mcp-server.js:77',message:'Before server.connect()',data:{transport:!!transport},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});
|
|
102
|
+
// #endregion
|
|
103
|
+
|
|
104
|
+
// Add error handler for transport errors
|
|
105
|
+
transport.onerror = (error) => {
|
|
106
|
+
// #region agent log
|
|
107
|
+
fetch('http://127.0.0.1:7245/ingest/ba5ae969-895e-4c8c-9b24-3b774e2457b2',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'mcp-server.js:89',message:'Transport error',data:{error:error?.message,stack:error?.stack},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});
|
|
108
|
+
// #endregion
|
|
109
|
+
console.error('Transport error:', error);
|
|
110
|
+
};
|
|
111
|
+
|
|
72
112
|
// Connect server to transport
|
|
73
|
-
|
|
113
|
+
try {
|
|
114
|
+
await server.connect(transport);
|
|
115
|
+
|
|
116
|
+
// #region agent log
|
|
117
|
+
fetch('http://127.0.0.1:7245/ingest/ba5ae969-895e-4c8c-9b24-3b774e2457b2',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'mcp-server.js:96',message:'server.connect() completed',data:{},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});
|
|
118
|
+
// #endregion
|
|
119
|
+
} catch (connectError) {
|
|
120
|
+
// #region agent log
|
|
121
|
+
fetch('http://127.0.0.1:7245/ingest/ba5ae969-895e-4c8c-9b24-3b774e2457b2',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'mcp-server.js:99',message:'server.connect() error',data:{error:connectError?.message,stack:connectError?.stack,name:connectError?.name},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});
|
|
122
|
+
// #endregion
|
|
123
|
+
throw connectError;
|
|
124
|
+
}
|
|
74
125
|
|
|
75
126
|
console.error('SQLCipher MCP Server running on stdio');
|
|
127
|
+
|
|
128
|
+
// #region agent log
|
|
129
|
+
fetch('http://127.0.0.1:7245/ingest/ba5ae969-895e-4c8c-9b24-3b774e2457b2',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'mcp-server.js:106',message:'startMcpServer exit - server started',data:{},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});
|
|
130
|
+
// #endregion
|
|
131
|
+
|
|
132
|
+
// Keep the process alive - the stdio transport should handle this, but ensure we don't exit
|
|
133
|
+
// Keep stdin open to prevent the process from exiting
|
|
134
|
+
process.stdin.resume();
|
|
135
|
+
|
|
136
|
+
// Handle stdin end event (when client disconnects)
|
|
137
|
+
process.stdin.on('end', () => {
|
|
138
|
+
// #region agent log
|
|
139
|
+
fetch('http://127.0.0.1:7245/ingest/ba5ae969-895e-4c8c-9b24-3b774e2457b2',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'mcp-server.js:111',message:'stdin ended',data:{},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});
|
|
140
|
+
// #endregion
|
|
141
|
+
// When stdin ends, exit gracefully
|
|
142
|
+
process.exit(0);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Handle errors on stdin
|
|
146
|
+
process.stdin.on('error', (error) => {
|
|
147
|
+
// #region agent log
|
|
148
|
+
fetch('http://127.0.0.1:7245/ingest/ba5ae969-895e-4c8c-9b24-3b774e2457b2',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'mcp-server.js:118',message:'stdin error',data:{error:error?.message},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});
|
|
149
|
+
// #endregion
|
|
150
|
+
console.error('Stdin error:', error);
|
|
151
|
+
});
|
|
76
152
|
}
|