sqlcipher-mcp-server 1.0.4 → 2.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.
- package/README.md +433 -210
- package/package.json +1 -1
- package/src/config/constants.js +18 -40
- package/src/definitions/prompts.js +124 -0
- package/src/definitions/tools.js +363 -0
- package/src/handlers/http-handlers.js +576 -4
- package/src/handlers/mcp-handlers.js +558 -69
- package/src/handlers/prompt-handlers.js +601 -0
- package/src/server/http-server.js +52 -2
- package/src/server/mcp-server.js +208 -95
- package/src/services/database-service.js +395 -55
- package/src/utils/database-operations.js +967 -0
- package/src/utils/detectors.js +55 -0
- package/src/utils/formatters.js +470 -64
- package/src/utils/validators.js +147 -58
- package/lib/database.js +0 -216
package/README.md
CHANGED
|
@@ -1,210 +1,433 @@
|
|
|
1
|
-
# SQLCipher MCP Server
|
|
2
|
-
|
|
3
|
-
An MCP (Model Context Protocol) server that provides read-only access to
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
This MCP server enables you to:
|
|
8
|
-
- Connect to SQLCipher-encrypted SQLite databases
|
|
9
|
-
- Execute SELECT queries (read-only mode)
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
-
|
|
150
|
-
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
- `
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
-
|
|
165
|
-
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
1
|
+
# SQLCipher MCP Server
|
|
2
|
+
|
|
3
|
+
An MCP (Model Context Protocol) server that provides comprehensive read-only access to both encrypted (SQLCipher) and unencrypted SQLite databases. This server offers extensive tools for database exploration, schema analysis, query optimization, and data profiling.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This MCP server enables you to:
|
|
8
|
+
- Connect to both SQLCipher-encrypted and plain SQLite databases
|
|
9
|
+
- Execute SELECT queries (read-only mode)
|
|
10
|
+
- Explore database schemas and relationships
|
|
11
|
+
- Analyze table statistics and data quality
|
|
12
|
+
- Generate and optimize SQL queries
|
|
13
|
+
- Search for tables and columns across the database
|
|
14
|
+
- Use interactive prompts for common workflows
|
|
15
|
+
|
|
16
|
+
## Prerequisites
|
|
17
|
+
|
|
18
|
+
- Node.js (v18 or higher)
|
|
19
|
+
- npm or yarn package manager
|
|
20
|
+
- Access to a SQLCipher-encrypted SQLite database file
|
|
21
|
+
- Database password (will be provided via environment variable)
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
1. Clone or download this repository
|
|
26
|
+
2. Install dependencies:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Configuration
|
|
33
|
+
|
|
34
|
+
### Environment Variable
|
|
35
|
+
|
|
36
|
+
Set the `SQLCIPHER_PASSWORD` environment variable with your database password:
|
|
37
|
+
|
|
38
|
+
**Windows (PowerShell):**
|
|
39
|
+
```powershell
|
|
40
|
+
$env:SQLCIPHER_PASSWORD = "your_database_password"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Windows (Command Prompt):**
|
|
44
|
+
```cmd
|
|
45
|
+
set SQLCIPHER_PASSWORD=your_database_password
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Linux/macOS:**
|
|
49
|
+
```bash
|
|
50
|
+
export SQLCIPHER_PASSWORD="your_database_password"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Permanent setup (recommended):**
|
|
54
|
+
- Add the environment variable to your system settings
|
|
55
|
+
- Or use a `.env` file with a tool like `dotenv` (requires additional setup)
|
|
56
|
+
|
|
57
|
+
## Usage
|
|
58
|
+
|
|
59
|
+
### Starting the Server
|
|
60
|
+
|
|
61
|
+
The MCP server communicates via stdio (standard input/output). Start it with:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npm start
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Or directly:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
node index.js
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### MCP Client Configuration
|
|
74
|
+
|
|
75
|
+
Configure your MCP client to use this server. Example configuration:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"mcpServers": {
|
|
80
|
+
"sqlcipher": {
|
|
81
|
+
"command": "node",
|
|
82
|
+
"args": ["C:\\Repos\\MyMCP\\index.js"],
|
|
83
|
+
"env": {
|
|
84
|
+
"SQLCIPHER_PASSWORD": "your_database_password"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Available Tools
|
|
92
|
+
|
|
93
|
+
The server provides 18 comprehensive tools organized into 5 categories:
|
|
94
|
+
|
|
95
|
+
#### Schema Exploration Tools
|
|
96
|
+
|
|
97
|
+
##### `list_tables`
|
|
98
|
+
List all tables in the database with row counts and types.
|
|
99
|
+
|
|
100
|
+
**Parameters:**
|
|
101
|
+
- `database_path` (string, optional): Path to database file
|
|
102
|
+
- `table_names` (array, optional): Filter by specific table names
|
|
103
|
+
|
|
104
|
+
**Example:**
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"tool": "list_tables",
|
|
108
|
+
"arguments": {
|
|
109
|
+
"database_path": "C:\\path\\to\\database.db"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
##### `get_table_schema`
|
|
115
|
+
Get detailed schema for one or more tables including columns, types, constraints, foreign keys, and indexes.
|
|
116
|
+
|
|
117
|
+
**Parameters:**
|
|
118
|
+
- `database_path` (string, optional): Path to database file
|
|
119
|
+
- `table_name` (string or array, required): Table name(s)
|
|
120
|
+
|
|
121
|
+
**Example:**
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"tool": "get_table_schema",
|
|
125
|
+
"arguments": {
|
|
126
|
+
"table_name": "users"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
##### `list_columns`
|
|
132
|
+
List all columns in a table with their types and constraints.
|
|
133
|
+
|
|
134
|
+
**Parameters:**
|
|
135
|
+
- `database_path` (string, optional): Path to database file
|
|
136
|
+
- `table_name` (string, required): Table name
|
|
137
|
+
|
|
138
|
+
##### `get_foreign_keys`
|
|
139
|
+
Get foreign key relationships for a table or entire database.
|
|
140
|
+
|
|
141
|
+
**Parameters:**
|
|
142
|
+
- `database_path` (string, optional): Path to database file
|
|
143
|
+
- `table_name` (string, optional): Table name (omit for all relationships)
|
|
144
|
+
|
|
145
|
+
##### `get_indexes`
|
|
146
|
+
Get index information for a table or entire database.
|
|
147
|
+
|
|
148
|
+
**Parameters:**
|
|
149
|
+
- `database_path` (string, optional): Path to database file
|
|
150
|
+
- `table_name` (string, optional): Table name (omit for all indexes)
|
|
151
|
+
|
|
152
|
+
#### Database Metadata Tools
|
|
153
|
+
|
|
154
|
+
##### `get_database_info`
|
|
155
|
+
Get database metadata including SQLite version, size, page size, and encoding.
|
|
156
|
+
|
|
157
|
+
**Parameters:**
|
|
158
|
+
- `database_path` (string, optional): Path to database file
|
|
159
|
+
|
|
160
|
+
##### `get_table_info`
|
|
161
|
+
Get detailed information about a specific table including row count and column count.
|
|
162
|
+
|
|
163
|
+
**Parameters:**
|
|
164
|
+
- `database_path` (string, optional): Path to database file
|
|
165
|
+
- `table_name` (string, required): Table name
|
|
166
|
+
|
|
167
|
+
##### `test_connection`
|
|
168
|
+
Test database connection without executing queries.
|
|
169
|
+
|
|
170
|
+
**Parameters:**
|
|
171
|
+
- `database_path` (string, optional): Path to database file
|
|
172
|
+
|
|
173
|
+
#### Query Helper Tools
|
|
174
|
+
|
|
175
|
+
##### `execute_query`
|
|
176
|
+
Execute a SELECT query on the database.
|
|
177
|
+
|
|
178
|
+
**Parameters:**
|
|
179
|
+
- `database_path` (string, optional): Path to database file
|
|
180
|
+
- `query` (string, required): SQL SELECT query
|
|
181
|
+
|
|
182
|
+
**Example:**
|
|
183
|
+
```json
|
|
184
|
+
{
|
|
185
|
+
"tool": "execute_query",
|
|
186
|
+
"arguments": {
|
|
187
|
+
"query": "SELECT * FROM users LIMIT 10"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
##### `explain_query`
|
|
193
|
+
Get query execution plan for optimization analysis.
|
|
194
|
+
|
|
195
|
+
**Parameters:**
|
|
196
|
+
- `database_path` (string, optional): Path to database file
|
|
197
|
+
- `query` (string, required): SQL query to explain
|
|
198
|
+
|
|
199
|
+
##### `validate_query_syntax`
|
|
200
|
+
Validate SQL query syntax without executing it.
|
|
201
|
+
|
|
202
|
+
**Parameters:**
|
|
203
|
+
- `database_path` (string, optional): Path to database file
|
|
204
|
+
- `query` (string, required): SQL query to validate
|
|
205
|
+
|
|
206
|
+
##### `suggest_query`
|
|
207
|
+
Generate SQL query templates based on table schema and intent.
|
|
208
|
+
|
|
209
|
+
**Parameters:**
|
|
210
|
+
- `database_path` (string, optional): Path to database file
|
|
211
|
+
- `table_name` (string, optional): Table name
|
|
212
|
+
- `intent` (string, optional): Query intent ("count", "sample", "join", "aggregate", "search")
|
|
213
|
+
|
|
214
|
+
#### Data Analysis Tools
|
|
215
|
+
|
|
216
|
+
##### `get_table_statistics`
|
|
217
|
+
Get comprehensive statistics for a table including min, max, avg, and distinct counts.
|
|
218
|
+
|
|
219
|
+
**Parameters:**
|
|
220
|
+
- `database_path` (string, optional): Path to database file
|
|
221
|
+
- `table_name` (string, required): Table name
|
|
222
|
+
- `max_sample_size` (number, optional): Maximum rows to sample (default: 10000)
|
|
223
|
+
- `timeout_ms` (number, optional): Timeout in milliseconds (default: 30000)
|
|
224
|
+
|
|
225
|
+
##### `sample_table_data`
|
|
226
|
+
Get a sample of rows from a table for quick preview.
|
|
227
|
+
|
|
228
|
+
**Parameters:**
|
|
229
|
+
- `database_path` (string, optional): Path to database file
|
|
230
|
+
- `table_name` (string, required): Table name
|
|
231
|
+
- `limit` (number, optional): Number of rows (default: 10)
|
|
232
|
+
- `offset` (number, optional): Row offset (default: 0)
|
|
233
|
+
- `columns` (array, optional): Specific columns to include
|
|
234
|
+
|
|
235
|
+
##### `get_column_statistics`
|
|
236
|
+
Get detailed statistics for specific columns.
|
|
237
|
+
|
|
238
|
+
**Parameters:**
|
|
239
|
+
- `database_path` (string, optional): Path to database file
|
|
240
|
+
- `table_name` (string, required): Table name
|
|
241
|
+
- `column_name` (string or array, required): Column name(s)
|
|
242
|
+
- `max_sample_size` (number, optional): Maximum sample size (default: 10000)
|
|
243
|
+
|
|
244
|
+
#### Search and Discovery Tools
|
|
245
|
+
|
|
246
|
+
##### `search_tables`
|
|
247
|
+
Search for tables by name pattern using SQL LIKE syntax.
|
|
248
|
+
|
|
249
|
+
**Parameters:**
|
|
250
|
+
- `database_path` (string, optional): Path to database file
|
|
251
|
+
- `pattern` (string, required): SQL LIKE pattern (e.g., "user%")
|
|
252
|
+
|
|
253
|
+
##### `search_columns`
|
|
254
|
+
Search for columns across all tables by name pattern.
|
|
255
|
+
|
|
256
|
+
**Parameters:**
|
|
257
|
+
- `database_path` (string, optional): Path to database file
|
|
258
|
+
- `pattern` (string, required): SQL LIKE pattern (e.g., "%_id")
|
|
259
|
+
|
|
260
|
+
##### `find_related_tables`
|
|
261
|
+
Find tables related via foreign keys (incoming and outgoing).
|
|
262
|
+
|
|
263
|
+
**Parameters:**
|
|
264
|
+
- `database_path` (string, optional): Path to database file
|
|
265
|
+
- `table_name` (string, required): Table name
|
|
266
|
+
|
|
267
|
+
### Available Prompts
|
|
268
|
+
|
|
269
|
+
The server provides 7 interactive prompts for common workflows:
|
|
270
|
+
|
|
271
|
+
#### `explore_database_schema`
|
|
272
|
+
Comprehensive database schema exploration showing all tables and their structures.
|
|
273
|
+
|
|
274
|
+
**Arguments:**
|
|
275
|
+
- `database_path` (optional): Path to database file
|
|
276
|
+
|
|
277
|
+
#### `describe_table_structure`
|
|
278
|
+
Detailed table description including schema, relationships, and sample data.
|
|
279
|
+
|
|
280
|
+
**Arguments:**
|
|
281
|
+
- `database_path` (optional): Path to database file
|
|
282
|
+
- `table_name` (required): Table name
|
|
283
|
+
|
|
284
|
+
#### `find_data_relationships`
|
|
285
|
+
Discover and visualize foreign key relationships between tables.
|
|
286
|
+
|
|
287
|
+
**Arguments:**
|
|
288
|
+
- `database_path` (optional): Path to database file
|
|
289
|
+
- `table_name` (optional): Focus on specific table
|
|
290
|
+
|
|
291
|
+
#### `generate_query_template`
|
|
292
|
+
Generate SQL query templates based on table schema and intent.
|
|
293
|
+
|
|
294
|
+
**Arguments:**
|
|
295
|
+
- `database_path` (optional): Path to database file
|
|
296
|
+
- `table_name` (required): Table name
|
|
297
|
+
- `intent` (optional): Query intent
|
|
298
|
+
|
|
299
|
+
#### `optimize_query`
|
|
300
|
+
Analyze query execution plan and provide optimization suggestions.
|
|
301
|
+
|
|
302
|
+
**Arguments:**
|
|
303
|
+
- `database_path` (optional): Path to database file
|
|
304
|
+
- `query` (required): SQL query to optimize
|
|
305
|
+
|
|
306
|
+
#### `analyze_table_data`
|
|
307
|
+
Comprehensive data analysis including statistics and quality checks.
|
|
308
|
+
|
|
309
|
+
**Arguments:**
|
|
310
|
+
- `database_path` (optional): Path to database file
|
|
311
|
+
- `table_name` (required): Table name
|
|
312
|
+
|
|
313
|
+
#### `compare_tables`
|
|
314
|
+
Compare structure and statistics of two tables.
|
|
315
|
+
|
|
316
|
+
**Arguments:**
|
|
317
|
+
- `database_path` (optional): Path to database file
|
|
318
|
+
- `table1_name` (required): First table name
|
|
319
|
+
- `table2_name` (required): Second table name
|
|
320
|
+
|
|
321
|
+
## Features
|
|
322
|
+
|
|
323
|
+
### Database Support
|
|
324
|
+
- **Encrypted Databases**: Full support for SQLCipher-encrypted databases (SQLCipher 3)
|
|
325
|
+
- **Unencrypted Databases**: Also supports plain SQLite databases
|
|
326
|
+
- **Automatic Detection**: Gracefully handles both encrypted and unencrypted databases
|
|
327
|
+
|
|
328
|
+
### Output Formats
|
|
329
|
+
- **Dual Format**: All tools return both structured JSON and human-readable formatted text
|
|
330
|
+
- **Programmatic Access**: JSON format for integration with other tools
|
|
331
|
+
- **Human-Friendly**: Formatted text for easy reading and display
|
|
332
|
+
|
|
333
|
+
### Performance
|
|
334
|
+
- **Configurable Limits**: Set maximum sample sizes and timeouts for large tables
|
|
335
|
+
- **Efficient Queries**: Optimized database operations for fast response times
|
|
336
|
+
- **Batch Operations**: Support for batch operations on multiple tables/columns
|
|
337
|
+
|
|
338
|
+
## Security Features
|
|
339
|
+
|
|
340
|
+
- **Read-Only Mode**: Only SELECT queries and read-only PRAGMA statements are allowed
|
|
341
|
+
- **Password Protection**: Database password is read from environment variable and never exposed
|
|
342
|
+
- **Query Validation**: All queries are validated to prevent SQL injection
|
|
343
|
+
- **Strict Error Handling**: Clear error messages without exposing sensitive information
|
|
344
|
+
- **Input Sanitization**: Table and column names are validated to prevent injection attacks
|
|
345
|
+
|
|
346
|
+
## Error Handling
|
|
347
|
+
|
|
348
|
+
The server handles various error scenarios:
|
|
349
|
+
|
|
350
|
+
- **Database file not found**: Returns clear error message
|
|
351
|
+
- **Invalid password**: Returns generic error (doesn't expose password details)
|
|
352
|
+
- **SQL syntax errors**: Returns specific syntax error messages
|
|
353
|
+
- **Table/column not found**: Returns specific error messages
|
|
354
|
+
- **Non-SELECT queries**: Returns error explaining read-only restriction
|
|
355
|
+
|
|
356
|
+
## Database Location
|
|
357
|
+
|
|
358
|
+
The database file path should be provided each time you execute a query. Common locations for Windows applications:
|
|
359
|
+
|
|
360
|
+
- `C:\Users\<Username>\AppData\Local\<AppName>\database.db`
|
|
361
|
+
- `C:\Users\<Username>\AppData\Roaming\<AppName>\database.db`
|
|
362
|
+
- `C:\ProgramData\<AppName>\database.db`
|
|
363
|
+
|
|
364
|
+
## Limitations
|
|
365
|
+
|
|
366
|
+
- **Read-Only**: Only SELECT queries and read-only PRAGMA statements are supported
|
|
367
|
+
- **Single Connection**: Each tool call opens and closes a new database connection
|
|
368
|
+
- **Display Limits**: Results are limited to 1000 rows for display (full results available in JSON)
|
|
369
|
+
- **SQLCipher 3**: Encrypted databases must use SQLCipher 3 default encryption settings
|
|
370
|
+
- **No Caching**: All queries fetch fresh data from the database (no caching)
|
|
371
|
+
|
|
372
|
+
## Troubleshooting
|
|
373
|
+
|
|
374
|
+
### "Database password not found" Error
|
|
375
|
+
- Ensure `SQLCIPHER_PASSWORD` environment variable is set
|
|
376
|
+
- Restart your MCP client after setting the environment variable
|
|
377
|
+
- Check that the environment variable is available to the Node.js process
|
|
378
|
+
|
|
379
|
+
### "Database file not found" Error
|
|
380
|
+
- Verify the database path is correct
|
|
381
|
+
- Use absolute paths instead of relative paths
|
|
382
|
+
- Check file permissions
|
|
383
|
+
|
|
384
|
+
### "Invalid password" Error
|
|
385
|
+
- Verify the password matches the one used to encrypt the database
|
|
386
|
+
- Ensure SQLCipher 3 defaults are used (as this server expects)
|
|
387
|
+
- Check for extra spaces or special characters in the password
|
|
388
|
+
|
|
389
|
+
### Connection Issues
|
|
390
|
+
- Ensure the database file is not locked by another application
|
|
391
|
+
- Verify the database file is a valid SQLCipher database
|
|
392
|
+
- Check that SQLCipher 3 encryption was used (not SQLCipher 4)
|
|
393
|
+
|
|
394
|
+
## Development
|
|
395
|
+
|
|
396
|
+
### Project Structure
|
|
397
|
+
|
|
398
|
+
```
|
|
399
|
+
SQLLiteMCP/
|
|
400
|
+
├── index.js # Main MCP server entry point
|
|
401
|
+
├── server-http.js # HTTP test server entry point
|
|
402
|
+
├── lib/
|
|
403
|
+
│ └── database.js # Low-level database operations
|
|
404
|
+
├── src/
|
|
405
|
+
│ ├── config/
|
|
406
|
+
│ │ ├── constants.js # Tool and prompt definitions
|
|
407
|
+
│ │ └── environment.js # Environment variable management
|
|
408
|
+
│ ├── handlers/
|
|
409
|
+
│ │ ├── mcp-handlers.js # MCP tool handlers
|
|
410
|
+
│ │ ├── prompt-handlers.js # MCP prompt handlers
|
|
411
|
+
│ │ └── http-handlers.js # HTTP API handlers
|
|
412
|
+
│ ├── services/
|
|
413
|
+
│ │ └── database-service.js # Business logic layer
|
|
414
|
+
│ ├── utils/
|
|
415
|
+
│ │ ├── validators.js # Input validation
|
|
416
|
+
│ │ ├── formatters.js # Output formatting
|
|
417
|
+
│ │ ├── detectors.js # Database type detection
|
|
418
|
+
│ │ └── errors.js # Error handling
|
|
419
|
+
│ └── server/
|
|
420
|
+
│ ├── mcp-server.js # MCP server setup
|
|
421
|
+
│ └── http-server.js # HTTP server setup
|
|
422
|
+
├── package.json # Project dependencies
|
|
423
|
+
└── README.md # This file
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### Dependencies
|
|
427
|
+
|
|
428
|
+
- `@modelcontextprotocol/sdk`: MCP SDK for Node.js
|
|
429
|
+
- `@journeyapps/sqlcipher`: SQLCipher bindings for Node.js
|
|
430
|
+
|
|
431
|
+
## License
|
|
432
|
+
|
|
433
|
+
MIT
|