sqlcipher-mcp-server 1.0.0 → 1.0.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.
package/README.md CHANGED
@@ -1,282 +1,210 @@
1
- # SQLCipher MCP Server
2
-
3
- An MCP (Model Context Protocol) server that provides read-only access to SQLCipher-encrypted SQLite databases. This server allows you to query encrypted SQLite databases using SQLCipher 3 default encryption settings.
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
- - Retrieve query results in a structured format
11
- - Use SQLCipher 3 default encryption settings
12
-
13
- ## Prerequisites
14
-
15
- - Node.js (v18 or higher)
16
- - npm or yarn package manager
17
- - Access to a SQLCipher-encrypted SQLite database file
18
- - Database password (will be provided via environment variable)
19
-
20
- ## Installation
21
-
22
- ### Option 1: Install from npm (Recommended)
23
-
24
- ```bash
25
- npm install -g sqlcipher-mcp-server
26
- ```
27
-
28
- Or install locally in your project:
29
-
30
- ```bash
31
- npm install sqlcipher-mcp-server
32
- ```
33
-
34
- ### Option 2: Install from source
35
-
36
- 1. Clone or download this repository
37
- 2. Install dependencies:
38
-
39
- ```bash
40
- npm install
41
- ```
42
-
43
- ## Configuration
44
-
45
- ### Environment Variable
46
-
47
- Set the `SQLCIPHER_PASSWORD` environment variable with your database password:
48
-
49
- **Windows (PowerShell):**
50
- ```powershell
51
- $env:SQLCIPHER_PASSWORD = "your_database_password"
52
- ```
53
-
54
- **Windows (Command Prompt):**
55
- ```cmd
56
- set SQLCIPHER_PASSWORD=your_database_password
57
- ```
58
-
59
- **Linux/macOS:**
60
- ```bash
61
- export SQLCIPHER_PASSWORD="your_database_password"
62
- ```
63
-
64
- **Permanent setup (recommended):**
65
- - Add the environment variable to your system settings
66
- - Or use a `.env` file with a tool like `dotenv` (requires additional setup)
67
-
68
- ## Usage
69
-
70
- ### Starting the Server
71
-
72
- The MCP server communicates via stdio (standard input/output). Start it with:
73
-
74
- ```bash
75
- npm start
76
- ```
77
-
78
- Or directly:
79
-
80
- ```bash
81
- node index.js
82
- ```
83
-
84
- ### MCP Client Configuration
85
-
86
- #### For Cursor IDE
87
-
88
- 1. **Install the package globally:**
89
- ```bash
90
- npm install -g sqlcipher-mcp-server
91
- ```
92
-
93
- 2. **Find the global installation path:**
94
- ```bash
95
- npm root -g
96
- ```
97
-
98
- 3. **Configure Cursor IDE:**
99
-
100
- Open Cursor's MCP settings file (location varies by OS):
101
- - **Windows**: `%APPDATA%\Cursor\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json`
102
- - **macOS**: `~/Library/Application Support/Cursor/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json`
103
- - **Linux**: `~/.config/Cursor/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json`
104
-
105
- Add this configuration:
106
- ```json
107
- {
108
- "mcpServers": {
109
- "sqlcipher": {
110
- "command": "node",
111
- "args": ["C:\\Users\\YourUsername\\AppData\\Roaming\\npm\\node_modules\\sqlcipher-mcp-server\\index.js"],
112
- "env": {
113
- "SQLCIPHER_PASSWORD": "your_database_password"
114
- }
115
- }
116
- }
117
- }
118
- ```
119
-
120
- **Note:** Replace the path with your actual global npm path from step 2.
121
-
122
- 4. **Restart Cursor IDE** for changes to take effect.
123
-
124
- #### Alternative: Using npx (no global installation)
125
-
126
- ```json
127
- {
128
- "mcpServers": {
129
- "sqlcipher": {
130
- "command": "npx",
131
- "args": ["-y", "sqlcipher-mcp-server"],
132
- "env": {
133
- "SQLCIPHER_PASSWORD": "your_database_password"
134
- }
135
- }
136
- }
137
- }
138
- ```
139
-
140
- #### For other MCP clients
141
-
142
- Configure your MCP client to use this server:
143
-
144
- ```json
145
- {
146
- "mcpServers": {
147
- "sqlcipher": {
148
- "command": "node",
149
- "args": ["path/to/sqlcipher-mcp-server/index.js"],
150
- "env": {
151
- "SQLCIPHER_PASSWORD": "your_database_password"
152
- }
153
- }
154
- }
155
- }
156
- ```
157
-
158
- For detailed integration instructions, see [PUBLISHING.md](./PUBLISHING.md).
159
-
160
- ### Available Tools
161
-
162
- #### `execute_query`
163
-
164
- Execute a SELECT query on a SQLCipher-encrypted database.
165
-
166
- **Parameters:**
167
- - `database_path` (string, required): Full path to the SQLCipher database file
168
- - `query` (string, required): SQL SELECT query to execute
169
-
170
- **Returns:**
171
- - Formatted text output with query results
172
- - JSON representation of results including:
173
- - `columns`: Array of column names
174
- - `rows`: Array of row objects
175
- - `rowCount`: Number of rows returned
176
-
177
- **Example Usage:**
178
-
179
- ```javascript
180
- // Example 1: Simple SELECT query
181
- {
182
- "tool": "execute_query",
183
- "arguments": {
184
- "database_path": "C:\\Users\\Username\\AppData\\Local\\AppName\\database.db",
185
- "query": "SELECT * FROM users LIMIT 10"
186
- }
187
- }
188
-
189
- // Example 2: SELECT with WHERE clause
190
- {
191
- "tool": "execute_query",
192
- "arguments": {
193
- "database_path": "C:\\Users\\Username\\AppData\\Local\\AppName\\database.db",
194
- "query": "SELECT id, name, email FROM users WHERE active = 1"
195
- }
196
- }
197
-
198
- // Example 3: SELECT with JOIN
199
- {
200
- "tool": "execute_query",
201
- "arguments": {
202
- "database_path": "C:\\Users\\Username\\AppData\\Local\\AppName\\database.db",
203
- "query": "SELECT u.name, o.order_id FROM users u JOIN orders o ON u.id = o.user_id"
204
- }
205
- }
206
- ```
207
-
208
- ## Security Features
209
-
210
- - **Read-Only Mode**: Only SELECT queries are allowed. INSERT, UPDATE, DELETE, and other modifying operations are blocked.
211
- - **Password Protection**: Database password is read from environment variable and never exposed in logs or error messages.
212
- - **Query Validation**: All queries are validated to ensure they are SELECT queries only.
213
- - **Error Handling**: Sensitive information is not exposed in error messages.
214
-
215
- ## Error Handling
216
-
217
- The server handles various error scenarios:
218
-
219
- - **Database file not found**: Returns clear error message
220
- - **Invalid password**: Returns generic error (doesn't expose password details)
221
- - **SQL syntax errors**: Returns specific syntax error messages
222
- - **Table/column not found**: Returns specific error messages
223
- - **Non-SELECT queries**: Returns error explaining read-only restriction
224
-
225
- ## Database Location
226
-
227
- The database file path should be provided each time you execute a query. Common locations for Windows applications:
228
-
229
- - `C:\Users\<Username>\AppData\Local\<AppName>\database.db`
230
- - `C:\Users\<Username>\AppData\Roaming\<AppName>\database.db`
231
- - `C:\ProgramData\<AppName>\database.db`
232
-
233
- ## Limitations
234
-
235
- - **Read-Only**: Only SELECT queries are supported
236
- - **Single Connection**: Each query opens and closes a new database connection
237
- - **Result Size**: Results are limited to 1000 rows for display (full results available in JSON)
238
- - **SQLCipher 3 Only**: Uses SQLCipher 3 default encryption settings
239
-
240
- ## Troubleshooting
241
-
242
- ### "Database password not found" Error
243
- - Ensure `SQLCIPHER_PASSWORD` environment variable is set
244
- - Restart your MCP client after setting the environment variable
245
- - Check that the environment variable is available to the Node.js process
246
-
247
- ### "Database file not found" Error
248
- - Verify the database path is correct
249
- - Use absolute paths instead of relative paths
250
- - Check file permissions
251
-
252
- ### "Invalid password" Error
253
- - Verify the password matches the one used to encrypt the database
254
- - Ensure SQLCipher 3 defaults are used (as this server expects)
255
- - Check for extra spaces or special characters in the password
256
-
257
- ### Connection Issues
258
- - Ensure the database file is not locked by another application
259
- - Verify the database file is a valid SQLCipher database
260
- - Check that SQLCipher 3 encryption was used (not SQLCipher 4)
261
-
262
- ## Development
263
-
264
- ### Project Structure
265
-
266
- ```
267
- MyMCP/
268
- ├── index.js # Main MCP server entry point
269
- ├── lib/
270
- │ └── database.js # Database connection and query logic
271
- ├── package.json # Project dependencies
272
- └── README.md # This file
273
- ```
274
-
275
- ### Dependencies
276
-
277
- - `@modelcontextprotocol/sdk`: MCP SDK for Node.js
278
- - `@journeyapps/sqlcipher`: SQLCipher bindings for Node.js
279
-
280
- ## License
281
-
282
- MIT
1
+ # SQLCipher MCP Server
2
+
3
+ An MCP (Model Context Protocol) server that provides read-only access to SQLCipher-encrypted SQLite databases. This server allows you to query encrypted SQLite databases using SQLCipher 3 default encryption settings.
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
+ - Retrieve query results in a structured format
11
+ - Use SQLCipher 3 default encryption settings
12
+
13
+ ## Prerequisites
14
+
15
+ - Node.js (v18 or higher)
16
+ - npm or yarn package manager
17
+ - Access to a SQLCipher-encrypted SQLite database file
18
+ - Database password (will be provided via environment variable)
19
+
20
+ ## Installation
21
+
22
+ 1. Clone or download this repository
23
+ 2. Install dependencies:
24
+
25
+ ```bash
26
+ npm install
27
+ ```
28
+
29
+ ## Configuration
30
+
31
+ ### Environment Variable
32
+
33
+ Set the `SQLCIPHER_PASSWORD` environment variable with your database password:
34
+
35
+ **Windows (PowerShell):**
36
+ ```powershell
37
+ $env:SQLCIPHER_PASSWORD = "your_database_password"
38
+ ```
39
+
40
+ **Windows (Command Prompt):**
41
+ ```cmd
42
+ set SQLCIPHER_PASSWORD=your_database_password
43
+ ```
44
+
45
+ **Linux/macOS:**
46
+ ```bash
47
+ export SQLCIPHER_PASSWORD="your_database_password"
48
+ ```
49
+
50
+ **Permanent setup (recommended):**
51
+ - Add the environment variable to your system settings
52
+ - Or use a `.env` file with a tool like `dotenv` (requires additional setup)
53
+
54
+ ## Usage
55
+
56
+ ### Starting the Server
57
+
58
+ The MCP server communicates via stdio (standard input/output). Start it with:
59
+
60
+ ```bash
61
+ npm start
62
+ ```
63
+
64
+ Or directly:
65
+
66
+ ```bash
67
+ node index.js
68
+ ```
69
+
70
+ ### MCP Client Configuration
71
+
72
+ Configure your MCP client to use this server. Example configuration:
73
+
74
+ ```json
75
+ {
76
+ "mcpServers": {
77
+ "sqlcipher": {
78
+ "command": "node",
79
+ "args": ["C:\\Repos\\MyMCP\\index.js"],
80
+ "env": {
81
+ "SQLCIPHER_PASSWORD": "your_database_password"
82
+ }
83
+ }
84
+ }
85
+ }
86
+ ```
87
+
88
+ ### Available Tools
89
+
90
+ #### `execute_query`
91
+
92
+ Execute a SELECT query on a SQLCipher-encrypted database.
93
+
94
+ **Parameters:**
95
+ - `database_path` (string, required): Full path to the SQLCipher database file
96
+ - `query` (string, required): SQL SELECT query to execute
97
+
98
+ **Returns:**
99
+ - Formatted text output with query results
100
+ - JSON representation of results including:
101
+ - `columns`: Array of column names
102
+ - `rows`: Array of row objects
103
+ - `rowCount`: Number of rows returned
104
+
105
+ **Example Usage:**
106
+
107
+ ```javascript
108
+ // Example 1: Simple SELECT query
109
+ {
110
+ "tool": "execute_query",
111
+ "arguments": {
112
+ "database_path": "C:\\Users\\Username\\AppData\\Local\\AppName\\database.db",
113
+ "query": "SELECT * FROM users LIMIT 10"
114
+ }
115
+ }
116
+
117
+ // Example 2: SELECT with WHERE clause
118
+ {
119
+ "tool": "execute_query",
120
+ "arguments": {
121
+ "database_path": "C:\\Users\\Username\\AppData\\Local\\AppName\\database.db",
122
+ "query": "SELECT id, name, email FROM users WHERE active = 1"
123
+ }
124
+ }
125
+
126
+ // Example 3: SELECT with JOIN
127
+ {
128
+ "tool": "execute_query",
129
+ "arguments": {
130
+ "database_path": "C:\\Users\\Username\\AppData\\Local\\AppName\\database.db",
131
+ "query": "SELECT u.name, o.order_id FROM users u JOIN orders o ON u.id = o.user_id"
132
+ }
133
+ }
134
+ ```
135
+
136
+ ## Security Features
137
+
138
+ - **Read-Only Mode**: Only SELECT queries are allowed. INSERT, UPDATE, DELETE, and other modifying operations are blocked.
139
+ - **Password Protection**: Database password is read from environment variable and never exposed in logs or error messages.
140
+ - **Query Validation**: All queries are validated to ensure they are SELECT queries only.
141
+ - **Error Handling**: Sensitive information is not exposed in error messages.
142
+
143
+ ## Error Handling
144
+
145
+ The server handles various error scenarios:
146
+
147
+ - **Database file not found**: Returns clear error message
148
+ - **Invalid password**: Returns generic error (doesn't expose password details)
149
+ - **SQL syntax errors**: Returns specific syntax error messages
150
+ - **Table/column not found**: Returns specific error messages
151
+ - **Non-SELECT queries**: Returns error explaining read-only restriction
152
+
153
+ ## Database Location
154
+
155
+ The database file path should be provided each time you execute a query. Common locations for Windows applications:
156
+
157
+ - `C:\Users\<Username>\AppData\Local\<AppName>\database.db`
158
+ - `C:\Users\<Username>\AppData\Roaming\<AppName>\database.db`
159
+ - `C:\ProgramData\<AppName>\database.db`
160
+
161
+ ## Limitations
162
+
163
+ - **Read-Only**: Only SELECT queries are supported
164
+ - **Single Connection**: Each query opens and closes a new database connection
165
+ - **Result Size**: Results are limited to 1000 rows for display (full results available in JSON)
166
+ - **SQLCipher 3 Only**: Uses SQLCipher 3 default encryption settings
167
+
168
+ ## Troubleshooting
169
+
170
+ ### "Database password not found" Error
171
+ - Ensure `SQLCIPHER_PASSWORD` environment variable is set
172
+ - Restart your MCP client after setting the environment variable
173
+ - Check that the environment variable is available to the Node.js process
174
+
175
+ ### "Database file not found" Error
176
+ - Verify the database path is correct
177
+ - Use absolute paths instead of relative paths
178
+ - Check file permissions
179
+
180
+ ### "Invalid password" Error
181
+ - Verify the password matches the one used to encrypt the database
182
+ - Ensure SQLCipher 3 defaults are used (as this server expects)
183
+ - Check for extra spaces or special characters in the password
184
+
185
+ ### Connection Issues
186
+ - Ensure the database file is not locked by another application
187
+ - Verify the database file is a valid SQLCipher database
188
+ - Check that SQLCipher 3 encryption was used (not SQLCipher 4)
189
+
190
+ ## Development
191
+
192
+ ### Project Structure
193
+
194
+ ```
195
+ MyMCP/
196
+ ├── index.js # Main MCP server entry point
197
+ ├── lib/
198
+ │ └── database.js # Database connection and query logic
199
+ ├── package.json # Project dependencies
200
+ └── README.md # This file
201
+ ```
202
+
203
+ ### Dependencies
204
+
205
+ - `@modelcontextprotocol/sdk`: MCP SDK for Node.js
206
+ - `@journeyapps/sqlcipher`: SQLCipher bindings for Node.js
207
+
208
+ ## License
209
+
210
+ MIT