db-mcp 1.0.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/LICENSE +21 -0
- package/README.md +860 -0
- package/dist/adapters/DatabaseAdapter.d.ts +141 -0
- package/dist/adapters/DatabaseAdapter.d.ts.map +1 -0
- package/dist/adapters/DatabaseAdapter.js +131 -0
- package/dist/adapters/DatabaseAdapter.js.map +1 -0
- package/dist/adapters/sqlite/SchemaManager.d.ts +58 -0
- package/dist/adapters/sqlite/SchemaManager.d.ts.map +1 -0
- package/dist/adapters/sqlite/SchemaManager.js +187 -0
- package/dist/adapters/sqlite/SchemaManager.js.map +1 -0
- package/dist/adapters/sqlite/SqliteAdapter.d.ts +161 -0
- package/dist/adapters/sqlite/SqliteAdapter.d.ts.map +1 -0
- package/dist/adapters/sqlite/SqliteAdapter.js +741 -0
- package/dist/adapters/sqlite/SqliteAdapter.js.map +1 -0
- package/dist/adapters/sqlite/index.d.ts +9 -0
- package/dist/adapters/sqlite/index.d.ts.map +1 -0
- package/dist/adapters/sqlite/index.js +8 -0
- package/dist/adapters/sqlite/index.js.map +1 -0
- package/dist/adapters/sqlite/json-utils.d.ts +100 -0
- package/dist/adapters/sqlite/json-utils.d.ts.map +1 -0
- package/dist/adapters/sqlite/json-utils.js +274 -0
- package/dist/adapters/sqlite/json-utils.js.map +1 -0
- package/dist/adapters/sqlite/output-schemas.d.ts +1187 -0
- package/dist/adapters/sqlite/output-schemas.d.ts.map +1 -0
- package/dist/adapters/sqlite/output-schemas.js +1337 -0
- package/dist/adapters/sqlite/output-schemas.js.map +1 -0
- package/dist/adapters/sqlite/prompts.d.ts +13 -0
- package/dist/adapters/sqlite/prompts.d.ts.map +1 -0
- package/dist/adapters/sqlite/prompts.js +605 -0
- package/dist/adapters/sqlite/prompts.js.map +1 -0
- package/dist/adapters/sqlite/resources.d.ts +13 -0
- package/dist/adapters/sqlite/resources.d.ts.map +1 -0
- package/dist/adapters/sqlite/resources.js +251 -0
- package/dist/adapters/sqlite/resources.js.map +1 -0
- package/dist/adapters/sqlite/tools/admin.d.ts +14 -0
- package/dist/adapters/sqlite/tools/admin.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/admin.js +788 -0
- package/dist/adapters/sqlite/tools/admin.js.map +1 -0
- package/dist/adapters/sqlite/tools/core.d.ts +25 -0
- package/dist/adapters/sqlite/tools/core.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/core.js +359 -0
- package/dist/adapters/sqlite/tools/core.js.map +1 -0
- package/dist/adapters/sqlite/tools/fts.d.ts +13 -0
- package/dist/adapters/sqlite/tools/fts.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/fts.js +347 -0
- package/dist/adapters/sqlite/tools/fts.js.map +1 -0
- package/dist/adapters/sqlite/tools/geo.d.ts +14 -0
- package/dist/adapters/sqlite/tools/geo.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/geo.js +252 -0
- package/dist/adapters/sqlite/tools/geo.js.map +1 -0
- package/dist/adapters/sqlite/tools/index.d.ts +30 -0
- package/dist/adapters/sqlite/tools/index.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/index.js +61 -0
- package/dist/adapters/sqlite/tools/index.js.map +1 -0
- package/dist/adapters/sqlite/tools/json-helpers.d.ts +14 -0
- package/dist/adapters/sqlite/tools/json-helpers.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/json-helpers.js +477 -0
- package/dist/adapters/sqlite/tools/json-helpers.js.map +1 -0
- package/dist/adapters/sqlite/tools/json-operations.d.ts +14 -0
- package/dist/adapters/sqlite/tools/json-operations.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/json-operations.js +839 -0
- package/dist/adapters/sqlite/tools/json-operations.js.map +1 -0
- package/dist/adapters/sqlite/tools/stats.d.ts +15 -0
- package/dist/adapters/sqlite/tools/stats.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/stats.js +1219 -0
- package/dist/adapters/sqlite/tools/stats.js.map +1 -0
- package/dist/adapters/sqlite/tools/text.d.ts +14 -0
- package/dist/adapters/sqlite/tools/text.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/text.js +1141 -0
- package/dist/adapters/sqlite/tools/text.js.map +1 -0
- package/dist/adapters/sqlite/tools/vector.d.ts +14 -0
- package/dist/adapters/sqlite/tools/vector.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/vector.js +613 -0
- package/dist/adapters/sqlite/tools/vector.js.map +1 -0
- package/dist/adapters/sqlite/tools/virtual.d.ts +13 -0
- package/dist/adapters/sqlite/tools/virtual.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/virtual.js +930 -0
- package/dist/adapters/sqlite/tools/virtual.js.map +1 -0
- package/dist/adapters/sqlite/types.d.ts +207 -0
- package/dist/adapters/sqlite/types.d.ts.map +1 -0
- package/dist/adapters/sqlite/types.js +186 -0
- package/dist/adapters/sqlite/types.js.map +1 -0
- package/dist/adapters/sqlite-native/NativeSqliteAdapter.d.ts +163 -0
- package/dist/adapters/sqlite-native/NativeSqliteAdapter.d.ts.map +1 -0
- package/dist/adapters/sqlite-native/NativeSqliteAdapter.js +748 -0
- package/dist/adapters/sqlite-native/NativeSqliteAdapter.js.map +1 -0
- package/dist/adapters/sqlite-native/index.d.ts +11 -0
- package/dist/adapters/sqlite-native/index.d.ts.map +1 -0
- package/dist/adapters/sqlite-native/index.js +11 -0
- package/dist/adapters/sqlite-native/index.js.map +1 -0
- package/dist/adapters/sqlite-native/tools/spatialite.d.ts +19 -0
- package/dist/adapters/sqlite-native/tools/spatialite.d.ts.map +1 -0
- package/dist/adapters/sqlite-native/tools/spatialite.js +628 -0
- package/dist/adapters/sqlite-native/tools/spatialite.js.map +1 -0
- package/dist/adapters/sqlite-native/tools/transactions.d.ts +12 -0
- package/dist/adapters/sqlite-native/tools/transactions.d.ts.map +1 -0
- package/dist/adapters/sqlite-native/tools/transactions.js +255 -0
- package/dist/adapters/sqlite-native/tools/transactions.js.map +1 -0
- package/dist/adapters/sqlite-native/tools/window.d.ts +12 -0
- package/dist/adapters/sqlite-native/tools/window.d.ts.map +1 -0
- package/dist/adapters/sqlite-native/tools/window.js +370 -0
- package/dist/adapters/sqlite-native/tools/window.js.map +1 -0
- package/dist/auth/AuthorizationServerDiscovery.d.ts +90 -0
- package/dist/auth/AuthorizationServerDiscovery.d.ts.map +1 -0
- package/dist/auth/AuthorizationServerDiscovery.js +204 -0
- package/dist/auth/AuthorizationServerDiscovery.js.map +1 -0
- package/dist/auth/OAuthResourceServer.d.ts +65 -0
- package/dist/auth/OAuthResourceServer.d.ts.map +1 -0
- package/dist/auth/OAuthResourceServer.js +121 -0
- package/dist/auth/OAuthResourceServer.js.map +1 -0
- package/dist/auth/TokenValidator.d.ts +60 -0
- package/dist/auth/TokenValidator.d.ts.map +1 -0
- package/dist/auth/TokenValidator.js +235 -0
- package/dist/auth/TokenValidator.js.map +1 -0
- package/dist/auth/errors.d.ts +74 -0
- package/dist/auth/errors.d.ts.map +1 -0
- package/dist/auth/errors.js +133 -0
- package/dist/auth/errors.js.map +1 -0
- package/dist/auth/index.d.ts +13 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +15 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/middleware.d.ts +81 -0
- package/dist/auth/middleware.d.ts.map +1 -0
- package/dist/auth/middleware.js +291 -0
- package/dist/auth/middleware.js.map +1 -0
- package/dist/auth/scopes.d.ts +136 -0
- package/dist/auth/scopes.d.ts.map +1 -0
- package/dist/auth/scopes.js +349 -0
- package/dist/auth/scopes.js.map +1 -0
- package/dist/auth/types.d.ts +257 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +8 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +236 -0
- package/dist/cli.js.map +1 -0
- package/dist/constants/ServerInstructions.d.ts +45 -0
- package/dist/constants/ServerInstructions.d.ts.map +1 -0
- package/dist/constants/ServerInstructions.js +356 -0
- package/dist/constants/ServerInstructions.js.map +1 -0
- package/dist/filtering/ToolConstants.d.ts +34 -0
- package/dist/filtering/ToolConstants.d.ts.map +1 -0
- package/dist/filtering/ToolConstants.js +174 -0
- package/dist/filtering/ToolConstants.js.map +1 -0
- package/dist/filtering/ToolFilter.d.ts +82 -0
- package/dist/filtering/ToolFilter.d.ts.map +1 -0
- package/dist/filtering/ToolFilter.js +296 -0
- package/dist/filtering/ToolFilter.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/server/McpServer.d.ts +61 -0
- package/dist/server/McpServer.d.ts.map +1 -0
- package/dist/server/McpServer.js +270 -0
- package/dist/server/McpServer.js.map +1 -0
- package/dist/transports/http.d.ts +134 -0
- package/dist/transports/http.d.ts.map +1 -0
- package/dist/transports/http.js +516 -0
- package/dist/transports/http.js.map +1 -0
- package/dist/transports/index.d.ts +5 -0
- package/dist/transports/index.d.ts.map +1 -0
- package/dist/transports/index.js +5 -0
- package/dist/transports/index.js.map +1 -0
- package/dist/types/index.d.ts +380 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +68 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/annotations.d.ts +44 -0
- package/dist/utils/annotations.d.ts.map +1 -0
- package/dist/utils/annotations.js +77 -0
- package/dist/utils/annotations.js.map +1 -0
- package/dist/utils/errors.d.ts +155 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +329 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/identifiers.d.ts +121 -0
- package/dist/utils/identifiers.d.ts.map +1 -0
- package/dist/utils/identifiers.js +319 -0
- package/dist/utils/identifiers.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/insightsManager.d.ts +39 -0
- package/dist/utils/insightsManager.d.ts.map +1 -0
- package/dist/utils/insightsManager.js +63 -0
- package/dist/utils/insightsManager.js.map +1 -0
- package/dist/utils/logger.d.ts +189 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +394 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/progress-utils.d.ts +54 -0
- package/dist/utils/progress-utils.d.ts.map +1 -0
- package/dist/utils/progress-utils.js +74 -0
- package/dist/utils/progress-utils.js.map +1 -0
- package/dist/utils/resourceAnnotations.d.ts +36 -0
- package/dist/utils/resourceAnnotations.d.ts.map +1 -0
- package/dist/utils/resourceAnnotations.js +57 -0
- package/dist/utils/resourceAnnotations.js.map +1 -0
- package/dist/utils/where-clause.d.ts +41 -0
- package/dist/utils/where-clause.d.ts.map +1 -0
- package/dist/utils/where-clause.js +116 -0
- package/dist/utils/where-clause.js.map +1 -0
- package/package.json +83 -0
- package/server.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,860 @@
|
|
|
1
|
+
# db-mcp (SQLite MCP Server)
|
|
2
|
+
|
|
3
|
+
**Last Updated February 4, 2026**
|
|
4
|
+
|
|
5
|
+
**SQLite MCP Server** with HTTP/SSE Transport, OAuth 2.1 authentication, smart tool filtering, granular access control, 122 specialized tools, 8 resources, and 10 prompts. Available in WASM and better-sqlite3 variants.
|
|
6
|
+
|
|
7
|
+
> **v1.0.0** - Production-ready SQLite MCP Server with full feature support.
|
|
8
|
+
|
|
9
|
+
[](https://github.com/neverinfamous/db-mcp)
|
|
10
|
+
[](https://www.npmjs.com/package/db-mcp)
|
|
11
|
+
[](https://hub.docker.com/r/writenotenow/db-mcp)
|
|
12
|
+
[](https://opensource.org/licenses/MIT)
|
|
13
|
+

|
|
14
|
+
[](https://registry.modelcontextprotocol.io/v0/servers?search=io.github.neverinfamous/db-mcp)
|
|
15
|
+
[](SECURITY.md)
|
|
16
|
+
[](https://github.com/neverinfamous/db-mcp)
|
|
17
|
+
|
|
18
|
+
**[Wiki](https://github.com/neverinfamous/db-mcp/wiki)** • **[Changelog](CHANGELOG.md)** • **[Security](SECURITY.md)**
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 📋 Table of Contents
|
|
23
|
+
|
|
24
|
+
### Quick Start
|
|
25
|
+
|
|
26
|
+
- [✅ Quick Test - Verify Everything Works](#-quick-test---verify-everything-works)
|
|
27
|
+
- [🚀 Quick Start](#-quick-start)
|
|
28
|
+
- [⚡ Install to Cursor IDE](#-install-to-cursor-ide)
|
|
29
|
+
- [🎛️ Tool Filtering](#️-tool-filtering) ⭐ **Important for IDE users**
|
|
30
|
+
|
|
31
|
+
### Configuration & Usage
|
|
32
|
+
|
|
33
|
+
- [📊 Tool Categories](#-tool-categories)
|
|
34
|
+
- [📚 MCP Client Configuration](#-mcp-client-configuration)
|
|
35
|
+
|
|
36
|
+
### Features & Resources
|
|
37
|
+
|
|
38
|
+
- [🔥 Core Capabilities](#-core-capabilities)
|
|
39
|
+
- [🔐 OAuth 2.1 Implementation](#-oauth-21-implementation)
|
|
40
|
+
- [🏆 Why Choose db-mcp?](#-why-choose-db-mcp)
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## ✅ Quick Test - Verify Everything Works
|
|
45
|
+
|
|
46
|
+
**Test the server in 30 seconds!**
|
|
47
|
+
|
|
48
|
+
Build and run:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm run build
|
|
52
|
+
|
|
53
|
+
# Option 1: Native backend (better-sqlite3)
|
|
54
|
+
node dist/cli.js --transport stdio --sqlite-native :memory:
|
|
55
|
+
|
|
56
|
+
# Option 2: WASM backend (sql.js)
|
|
57
|
+
node dist/cli.js --transport stdio --sqlite :memory:
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Expected output (native):
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
[db-mcp] Starting MCP server...
|
|
64
|
+
[db-mcp] Registered adapter: Native SQLite Adapter (better-sqlite3) (sqlite:default)
|
|
65
|
+
[db-mcp] Server started successfully
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Expected output (WASM):
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
[db-mcp] Starting MCP server...
|
|
72
|
+
[db-mcp] Registered adapter: WASM SQLite Adapter (sql.js) (sqlite:default)
|
|
73
|
+
[db-mcp] Server started successfully
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Run the test suite:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm run test
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 🛡️ Security Features
|
|
83
|
+
|
|
84
|
+
- ✅ **SQL Injection Prevention** - Parameter binding on all queries
|
|
85
|
+
- ✅ **OAuth 2.1 Authentication** - RFC 9728/8414 compliant
|
|
86
|
+
- ✅ **Scope-based Authorization** - Granular read/write/admin access
|
|
87
|
+
- ✅ **Strict TypeScript** - Full type safety with no `any` types
|
|
88
|
+
|
|
89
|
+
[⬆️ Back to Table of Contents](#-table-of-contents)
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 🚀 Quick Start
|
|
94
|
+
|
|
95
|
+
### Option 1: Docker (Recommended)
|
|
96
|
+
|
|
97
|
+
Pull and run instantly:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
docker pull writenotenow/db-mcp:latest
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Run with volume mount:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
docker run -i --rm \
|
|
107
|
+
-v $(pwd):/workspace \
|
|
108
|
+
writenotenow/db-mcp:latest \
|
|
109
|
+
--sqlite-native /workspace/database.db
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Option 2: Node.js Installation
|
|
113
|
+
|
|
114
|
+
Clone the repository:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
git clone https://github.com/neverinfamous/db-mcp.git
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Navigate to directory:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
cd db-mcp
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Install dependencies:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
npm install
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Build the project:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
npm run build
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Run the server:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Native backend (better-sqlite3) - Full features, requires Node.js native build
|
|
142
|
+
node dist/cli.js --transport stdio --sqlite-native ./database.db
|
|
143
|
+
|
|
144
|
+
# WASM backend (sql.js) - Cross-platform, no compilation required
|
|
145
|
+
node dist/cli.js --transport stdio --sqlite ./database.db
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
> **Backend Choice:** Use `--sqlite-native` for full features (122 tools, transactions, window functions, SpatiaLite). Use `--sqlite` for WASM mode (102 tools, no native dependencies).
|
|
149
|
+
|
|
150
|
+
[⬆️ Back to Table of Contents](#-table-of-contents)
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## ⚡ Install to Cursor IDE
|
|
155
|
+
|
|
156
|
+
### One-Click Installation
|
|
157
|
+
|
|
158
|
+
Click the button below to install directly into Cursor:
|
|
159
|
+
|
|
160
|
+
[](cursor://anysphere.cursor-deeplink/mcp/install?name=db-mcp-sqlite&config=eyJkYi1tY3Atc3FsaXRlIjp7ImFyZ3MiOlsicnVuIiwiLWkiLCItLXJtIiwiLXYiLCIkKHB3ZCk6L3dvcmtzcGFjZSIsIndyaXRlbm90ZW5vdy9kYi1tY3A6bGF0ZXN0IiwiLS1zcWxpdGUtbmF0aXZlIiwiL3dvcmtzcGFjZS9kYXRhYmFzZS5kYiJdLCJjb21tYW5kIjoiZG9ja2VyIn19)
|
|
161
|
+
|
|
162
|
+
Or copy this deep link:
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
cursor://anysphere.cursor-deeplink/mcp/install?name=db-mcp-sqlite&config=eyJkYi1tY3Atc3FsaXRlIjp7ImFyZ3MiOlsicnVuIiwiLWkiLCItLXJtIiwiLXYiLCIkKHB3ZCk6L3dvcmtzcGFjZSIsIndyaXRlbm90ZW5vdy9kYi1tY3A6bGF0ZXN0IiwiLS1zcWxpdGUtbmF0aXZlIiwiL3dvcmtzcGFjZS9kYXRhYmFzZS5kYiJdLCJjb21tYW5kIjoiZG9ja2VyIn19
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Prerequisites
|
|
169
|
+
|
|
170
|
+
- ✅ Docker installed and running (for Docker method)
|
|
171
|
+
- ✅ Node.js 24+ (LTS) (for local installation)
|
|
172
|
+
|
|
173
|
+
[⬆️ Back to Table of Contents](#-table-of-contents)
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## 🎛️ Tool Filtering
|
|
178
|
+
|
|
179
|
+
> [!IMPORTANT]
|
|
180
|
+
> **AI-enabled IDEs like Cursor have tool limits.** With 122 tools in the native backend, you must use tool filtering to stay within limits. Use **shortcuts** or specify **groups** to enable only what you need.
|
|
181
|
+
|
|
182
|
+
### Quick Start: Recommended Configurations
|
|
183
|
+
|
|
184
|
+
#### Option 1: Starter (48 tools) ⭐ Recommended
|
|
185
|
+
|
|
186
|
+
Core + JSON + Text. Best for general development.
|
|
187
|
+
|
|
188
|
+
```json
|
|
189
|
+
{
|
|
190
|
+
"mcpServers": {
|
|
191
|
+
"db-mcp-sqlite": {
|
|
192
|
+
"command": "node",
|
|
193
|
+
"args": [
|
|
194
|
+
"C:/path/to/db-mcp/dist/cli.js",
|
|
195
|
+
"--transport",
|
|
196
|
+
"stdio",
|
|
197
|
+
"--sqlite-native",
|
|
198
|
+
"C:/path/to/database.db",
|
|
199
|
+
"--tool-filter",
|
|
200
|
+
"starter"
|
|
201
|
+
]
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
#### Option 2: Analytics (50 tools)
|
|
208
|
+
|
|
209
|
+
Core + JSON + Stats + Window functions. For data analysis.
|
|
210
|
+
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"args": [
|
|
214
|
+
"--transport",
|
|
215
|
+
"stdio",
|
|
216
|
+
"--sqlite-native",
|
|
217
|
+
"C:/path/to/database.db",
|
|
218
|
+
"--tool-filter",
|
|
219
|
+
"analytics"
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
#### Option 3: Search (36 tools)
|
|
225
|
+
|
|
226
|
+
Core + Text + FTS5 + Vector. For search workloads.
|
|
227
|
+
|
|
228
|
+
```json
|
|
229
|
+
{
|
|
230
|
+
"args": [
|
|
231
|
+
"--transport",
|
|
232
|
+
"stdio",
|
|
233
|
+
"--sqlite-native",
|
|
234
|
+
"C:/path/to/database.db",
|
|
235
|
+
"--tool-filter",
|
|
236
|
+
"search"
|
|
237
|
+
]
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
#### Option 4: Custom Groups
|
|
242
|
+
|
|
243
|
+
Specify exactly the groups you need:
|
|
244
|
+
|
|
245
|
+
```json
|
|
246
|
+
{
|
|
247
|
+
"args": [
|
|
248
|
+
"--transport",
|
|
249
|
+
"stdio",
|
|
250
|
+
"--sqlite-native",
|
|
251
|
+
"C:/path/to/database.db",
|
|
252
|
+
"--tool-filter",
|
|
253
|
+
"core,json,stats"
|
|
254
|
+
]
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
### Shortcuts (Predefined Bundles)
|
|
261
|
+
|
|
262
|
+
> **Note:** Native includes transactions (7), window functions (6), and SpatiaLite (7) not available in WASM.
|
|
263
|
+
|
|
264
|
+
| Shortcut | WASM | Native | + Built-in | What's Included |
|
|
265
|
+
| ----------- | ------ | ------ | ---------- | ------------------ |
|
|
266
|
+
| `starter` | **48** | **48** | +3 | Core, JSON, Text |
|
|
267
|
+
| `analytics` | 44 | 50 | +3 | Core, JSON, Stats |
|
|
268
|
+
| `search` | 36 | 36 | +3 | Core, Text, Vector |
|
|
269
|
+
| `spatial` | 23 | 30 | +3 | Core, Geo, Vector |
|
|
270
|
+
| `minimal` | 8 | 8 | +3 | Core only |
|
|
271
|
+
| `full` | 102 | 122 | +3 | Everything enabled |
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
### Tool Groups (7 Available)
|
|
276
|
+
|
|
277
|
+
> **Note:** +3 built-in tools (server_info, server_health, list_adapters) are always included.
|
|
278
|
+
|
|
279
|
+
| Group | WASM | Native | + Built-in | Description |
|
|
280
|
+
| -------- | ---- | ------ | ---------- | ---------------------------------------- |
|
|
281
|
+
| `core` | 8 | 8 | +3 | Basic CRUD, schema, tables |
|
|
282
|
+
| `json` | 23 | 23 | +3 | JSON/JSONB operations, analysis |
|
|
283
|
+
| `text` | 13 | 17 | +3 | Text processing + FTS5 + advanced search |
|
|
284
|
+
| `stats` | 13 | 19 | +3 | Statistical analysis (+ window funcs) |
|
|
285
|
+
| `vector` | 11 | 11 | +3 | Embeddings, similarity search |
|
|
286
|
+
| `admin` | 26 | 33 | +3 | Backup, restore, virtual tables, pragma |
|
|
287
|
+
| `geo` | 4 | 11 | +3 | Geospatial + SpatiaLite (Native only) |
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
### Syntax Reference
|
|
292
|
+
|
|
293
|
+
| Prefix | Target | Example | Effect |
|
|
294
|
+
| -------- | -------- | --------------- | --------------------------------------------- |
|
|
295
|
+
| _(none)_ | Shortcut | `starter` | **Whitelist Mode:** Enable ONLY this shortcut |
|
|
296
|
+
| _(none)_ | Group | `core` | **Whitelist Mode:** Enable ONLY this group |
|
|
297
|
+
| `+` | Group | `+vector` | Add tools from this group to current set |
|
|
298
|
+
| `-` | Group | `-admin` | Remove tools in this group from current set |
|
|
299
|
+
| `+` | Tool | `+fuzzy_search` | Add one specific tool |
|
|
300
|
+
| `-` | Tool | `-drop_table` | Remove one specific tool |
|
|
301
|
+
|
|
302
|
+
**Examples:**
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
# Use a shortcut
|
|
306
|
+
--tool-filter "starter"
|
|
307
|
+
|
|
308
|
+
# Combine groups (whitelist mode)
|
|
309
|
+
--tool-filter "core,json,text,fts5"
|
|
310
|
+
|
|
311
|
+
# Extend a shortcut
|
|
312
|
+
--tool-filter "starter,+stats"
|
|
313
|
+
|
|
314
|
+
# Exclude from a shortcut
|
|
315
|
+
--tool-filter "starter,-fts5"
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
**Legacy Syntax (still supported):**
|
|
319
|
+
If you start with a negative filter (e.g., `-vector,-geo`), it assumes you want to start with _all_ tools enabled and then subtract.
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
# Legacy: start with all, exclude some
|
|
323
|
+
--tool-filter "-stats,-vector,-geo,-backup,-monitoring,-transactions,-window"
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
[⬆️ Back to Table of Contents](#-table-of-contents)
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## 📊 Tool Categories
|
|
331
|
+
|
|
332
|
+
| Category | WASM | Native | Description |
|
|
333
|
+
| --------------------- | ------- | ------- | ---------------------------------------------- |
|
|
334
|
+
| Core Database | 8 | 8 | CRUD, schema, indexes, views |
|
|
335
|
+
| JSON Helpers | 8 | 8 | Simplified JSON operations, schema analysis |
|
|
336
|
+
| JSON Operations | 15 | 15 | Full JSON manipulation, JSONB support |
|
|
337
|
+
| Text Processing | 13 | 13 | Regex, fuzzy, phonetic, advanced search |
|
|
338
|
+
| FTS5 Full-Text Search | 4 | 4 | Create, search, rebuild, optimize |
|
|
339
|
+
| Statistical Analysis | 13 | 19 | Stats, outliers, regression + window functions |
|
|
340
|
+
| Virtual Tables | 13 | 13 | CSV, R-Tree, series, views, vacuum, dbstat |
|
|
341
|
+
| Vector/Semantic | 11 | 11 | Embeddings, similarity search |
|
|
342
|
+
| Geospatial | 4 | 11 | Distance, bounding box + SpatiaLite GIS |
|
|
343
|
+
| Admin/PRAGMA | 13 | 20 | Backup, restore, pragmas, transactions |
|
|
344
|
+
| **Total** | **102** | **122** | |
|
|
345
|
+
|
|
346
|
+
### SQLite Backend Options
|
|
347
|
+
|
|
348
|
+
Choose between two SQLite backends based on your needs:
|
|
349
|
+
|
|
350
|
+
| Feature | WASM (sql.js) | Native (better-sqlite3) |
|
|
351
|
+
| ------------------------- | ----------------- | ----------------------------- |
|
|
352
|
+
| **Tools Available** | 102 | **122** |
|
|
353
|
+
| **Transactions** | ❌ | ✅ 7 tools |
|
|
354
|
+
| **Window Functions** | ❌ | ✅ 6 tools |
|
|
355
|
+
| **FTS5 Full-Text Search** | ⚠️ Limited | ✅ Full |
|
|
356
|
+
| **JSON1 Extension** | ⚠️ Limited | ✅ Full |
|
|
357
|
+
| **Cross-platform** | ✅ No compilation | Requires Node.js native build |
|
|
358
|
+
| **In-memory DBs** | ✅ | ✅ |
|
|
359
|
+
| **File-based DBs** | ✅ | ✅ |
|
|
360
|
+
|
|
361
|
+
Transaction Tools (7) - Native Only
|
|
362
|
+
|
|
363
|
+
| Tool | Description |
|
|
364
|
+
| -------------------------------- | ----------------------------------------------------- |
|
|
365
|
+
| `sqlite_transaction_begin` | Start transaction (deferred/immediate/exclusive mode) |
|
|
366
|
+
| `sqlite_transaction_commit` | Commit current transaction |
|
|
367
|
+
| `sqlite_transaction_rollback` | Rollback current transaction |
|
|
368
|
+
| `sqlite_transaction_savepoint` | Create a savepoint |
|
|
369
|
+
| `sqlite_transaction_release` | Release a savepoint |
|
|
370
|
+
| `sqlite_transaction_rollback_to` | Rollback to a savepoint |
|
|
371
|
+
| `sqlite_transaction_execute` | Execute multiple statements atomically |
|
|
372
|
+
|
|
373
|
+
Window Function Tools (6) - Native Only
|
|
374
|
+
|
|
375
|
+
| Tool | Description |
|
|
376
|
+
| ----------------------------- | ----------------------------------------------------- |
|
|
377
|
+
| `sqlite_window_row_number` | Assign sequential row numbers |
|
|
378
|
+
| `sqlite_window_rank` | Calculate RANK/DENSE_RANK/PERCENT_RANK |
|
|
379
|
+
| `sqlite_window_lag_lead` | Access previous or next row values |
|
|
380
|
+
| `sqlite_window_running_total` | Calculate cumulative sums |
|
|
381
|
+
| `sqlite_window_moving_avg` | Calculate rolling averages |
|
|
382
|
+
| `sqlite_window_ntile` | Divide rows into N buckets (quartiles, deciles, etc.) |
|
|
383
|
+
|
|
384
|
+
### SQLite Extensions
|
|
385
|
+
|
|
386
|
+
SQLite supports both **built-in** extensions (compiled into better-sqlite3) and **loadable** extensions (require separate binaries).
|
|
387
|
+
|
|
388
|
+
#### Built-in Extensions (work out of box)
|
|
389
|
+
|
|
390
|
+
| Extension | Purpose | Status |
|
|
391
|
+
| ---------- | ----------------------------------- | ---------------- |
|
|
392
|
+
| **FTS5** | Full-text search with BM25 ranking | ✅ Always loaded |
|
|
393
|
+
| **JSON1** | JSON functions (json_extract, etc.) | ✅ Always loaded |
|
|
394
|
+
| **R-Tree** | Spatial indexing for bounding boxes | ✅ Always loaded |
|
|
395
|
+
|
|
396
|
+
#### Loadable Extensions (require installation)
|
|
397
|
+
|
|
398
|
+
| Extension | Purpose | Tools | CLI Flag |
|
|
399
|
+
| -------------- | ------------------------- | ----- | -------------- |
|
|
400
|
+
| **CSV** | CSV virtual tables | 2 | `--csv` |
|
|
401
|
+
| **SpatiaLite** | Advanced GIS capabilities | 7 | `--spatialite` |
|
|
402
|
+
|
|
403
|
+
#### Installing Extensions
|
|
404
|
+
|
|
405
|
+
**CSV Extension:**
|
|
406
|
+
|
|
407
|
+
```bash
|
|
408
|
+
# Download precompiled binary or compile from SQLite source:
|
|
409
|
+
# https://www.sqlite.org/csv.html
|
|
410
|
+
|
|
411
|
+
# Set environment variable:
|
|
412
|
+
export CSV_EXTENSION_PATH=/path/to/csv.so # Linux
|
|
413
|
+
export CSV_EXTENSION_PATH=/path/to/csv.dll # Windows
|
|
414
|
+
|
|
415
|
+
# Or use CLI flag:
|
|
416
|
+
db-mcp --sqlite-native ./data.db --csv
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
**SpatiaLite Extension:**
|
|
420
|
+
|
|
421
|
+
```bash
|
|
422
|
+
# Linux (apt):
|
|
423
|
+
sudo apt install libspatialite-dev
|
|
424
|
+
|
|
425
|
+
# macOS (Homebrew):
|
|
426
|
+
brew install libspatialite
|
|
427
|
+
|
|
428
|
+
# Windows: Download from https://www.gaia-gis.it/gaia-sins/
|
|
429
|
+
|
|
430
|
+
# Set environment variable:
|
|
431
|
+
export SPATIALITE_PATH=/path/to/mod_spatialite.so
|
|
432
|
+
|
|
433
|
+
# Or use CLI flag:
|
|
434
|
+
db-mcp --sqlite-native ./data.db --spatialite
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
> **Note:** Extension binaries must match your platform and architecture. The server searches common paths automatically, or use the `CSV_EXTENSION_PATH` / `SPATIALITE_PATH` environment variables for custom locations.
|
|
438
|
+
|
|
439
|
+
### 📁 Resources (8)
|
|
440
|
+
|
|
441
|
+
MCP resources provide read-only access to database metadata:
|
|
442
|
+
|
|
443
|
+
| Resource | URI | Description | Min Config |
|
|
444
|
+
| --------------------- | ------------------------------ | --------------------------------- | ------------- |
|
|
445
|
+
| `sqlite_schema` | `sqlite://schema` | Full database schema | `minimal` |
|
|
446
|
+
| `sqlite_tables` | `sqlite://tables` | List all tables | `minimal` |
|
|
447
|
+
| `sqlite_table_schema` | `sqlite://table/{name}/schema` | Schema for a specific table | `minimal` |
|
|
448
|
+
| `sqlite_indexes` | `sqlite://indexes` | All indexes in the database | `minimal` |
|
|
449
|
+
| `sqlite_views` | `sqlite://views` | All views in the database | `core,admin` |
|
|
450
|
+
| `sqlite_health` | `sqlite://health` | Database health and status | _(read-only)_ |
|
|
451
|
+
| `sqlite_meta` | `sqlite://meta` | Database metadata and PRAGMAs | `core,admin` |
|
|
452
|
+
| `sqlite_insights` | `memo://insights` | Business insights memo (analysis) | `core,admin` |
|
|
453
|
+
|
|
454
|
+
> **Efficiency Tip:** Resources are always **readable** regardless of tool configuration. The "Min Config" column shows the smallest configuration that provides tools to **act on** what the resource exposes. Use `--tool-filter "core,admin"` (~18 tools) instead of `full` (102+) when you only need resource-related functionality.
|
|
455
|
+
|
|
456
|
+
### 💬 Prompts (10)
|
|
457
|
+
|
|
458
|
+
MCP prompts provide AI-assisted database workflows:
|
|
459
|
+
|
|
460
|
+
| Prompt | Description |
|
|
461
|
+
| ------------------------------- | ------------------------------------------------ |
|
|
462
|
+
| `sqlite_explain_schema` | Explain database structure and relationships |
|
|
463
|
+
| `sqlite_query_builder` | Help construct SQL queries for common operations |
|
|
464
|
+
| `sqlite_data_analysis` | Analyze data patterns and provide insights |
|
|
465
|
+
| `sqlite_optimization` | Analyze and suggest database optimizations |
|
|
466
|
+
| `sqlite_migration` | Help create database migration scripts |
|
|
467
|
+
| `sqlite_debug_query` | Debug SQL queries that aren't working |
|
|
468
|
+
| `sqlite_documentation` | Generate documentation for the database schema |
|
|
469
|
+
| `sqlite_summarize_table` | Intelligent table analysis and summary |
|
|
470
|
+
| `sqlite_hybrid_search_workflow` | Hybrid FTS5 + vector search workflow |
|
|
471
|
+
| `sqlite_demo` | Interactive demo of MCP capabilities |
|
|
472
|
+
|
|
473
|
+
[⬆️ Back to Table of Contents](#-table-of-contents)
|
|
474
|
+
|
|
475
|
+
---
|
|
476
|
+
|
|
477
|
+
## ⚡ Performance Tuning
|
|
478
|
+
|
|
479
|
+
Schema metadata is cached to reduce repeated queries during tool/resource invocations.
|
|
480
|
+
|
|
481
|
+
| Variable | Default | Description |
|
|
482
|
+
| ----------------------- | ------- | -------------------------------------------------- |
|
|
483
|
+
| `METADATA_CACHE_TTL_MS` | `5000` | Cache TTL for schema metadata (milliseconds) |
|
|
484
|
+
| `LOG_LEVEL` | `info` | Log verbosity: `debug`, `info`, `warning`, `error` |
|
|
485
|
+
|
|
486
|
+
> **Tip:** Lower `METADATA_CACHE_TTL_MS` for development (e.g., `1000`), or increase it for production with stable schemas (e.g., `60000` = 1 min). Schema cache is automatically invalidated on DDL operations (CREATE/ALTER/DROP).
|
|
487
|
+
|
|
488
|
+
[⬆️ Back to Table of Contents](#-table-of-contents)
|
|
489
|
+
|
|
490
|
+
---
|
|
491
|
+
|
|
492
|
+
## 📚 MCP Client Configuration
|
|
493
|
+
|
|
494
|
+
### Cursor IDE (Native Backend)
|
|
495
|
+
|
|
496
|
+
```json
|
|
497
|
+
{
|
|
498
|
+
"mcpServers": {
|
|
499
|
+
"db-mcp-sqlite": {
|
|
500
|
+
"command": "node",
|
|
501
|
+
"args": [
|
|
502
|
+
"C:/path/to/db-mcp/dist/cli.js",
|
|
503
|
+
"--transport",
|
|
504
|
+
"stdio",
|
|
505
|
+
"--sqlite-native",
|
|
506
|
+
"C:/path/to/your/database.db"
|
|
507
|
+
]
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
### Cursor IDE (WASM Backend)
|
|
514
|
+
|
|
515
|
+
```json
|
|
516
|
+
{
|
|
517
|
+
"mcpServers": {
|
|
518
|
+
"db-mcp-sqlite": {
|
|
519
|
+
"command": "node",
|
|
520
|
+
"args": [
|
|
521
|
+
"C:/path/to/db-mcp/dist/cli.js",
|
|
522
|
+
"--transport",
|
|
523
|
+
"stdio",
|
|
524
|
+
"--sqlite",
|
|
525
|
+
"C:/path/to/your/database.db"
|
|
526
|
+
]
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
### Claude Desktop (Native)
|
|
533
|
+
|
|
534
|
+
```json
|
|
535
|
+
{
|
|
536
|
+
"mcpServers": {
|
|
537
|
+
"db-mcp-sqlite": {
|
|
538
|
+
"command": "node",
|
|
539
|
+
"args": [
|
|
540
|
+
"/path/to/db-mcp/dist/cli.js",
|
|
541
|
+
"--transport",
|
|
542
|
+
"stdio",
|
|
543
|
+
"--sqlite-native",
|
|
544
|
+
"/path/to/database.db"
|
|
545
|
+
]
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
### Claude Desktop (WASM)
|
|
552
|
+
|
|
553
|
+
```json
|
|
554
|
+
{
|
|
555
|
+
"mcpServers": {
|
|
556
|
+
"db-mcp-sqlite": {
|
|
557
|
+
"command": "node",
|
|
558
|
+
"args": [
|
|
559
|
+
"/path/to/db-mcp/dist/cli.js",
|
|
560
|
+
"--transport",
|
|
561
|
+
"stdio",
|
|
562
|
+
"--sqlite",
|
|
563
|
+
"/path/to/database.db"
|
|
564
|
+
]
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
### Native with Extensions (CSV + SpatiaLite)
|
|
571
|
+
|
|
572
|
+
To enable loadable extensions, add CLI flags and set environment variables for extension paths:
|
|
573
|
+
|
|
574
|
+
**Windows:**
|
|
575
|
+
|
|
576
|
+
```json
|
|
577
|
+
{
|
|
578
|
+
"mcpServers": {
|
|
579
|
+
"db-mcp-sqlite": {
|
|
580
|
+
"command": "node",
|
|
581
|
+
"args": [
|
|
582
|
+
"C:/path/to/db-mcp/dist/cli.js",
|
|
583
|
+
"--transport",
|
|
584
|
+
"stdio",
|
|
585
|
+
"--sqlite-native",
|
|
586
|
+
"C:/path/to/database.db",
|
|
587
|
+
"--csv",
|
|
588
|
+
"--spatialite",
|
|
589
|
+
"--tool-filter",
|
|
590
|
+
"starter"
|
|
591
|
+
],
|
|
592
|
+
"env": {
|
|
593
|
+
"SPATIALITE_PATH": "C:/path/to/extensions/mod_spatialite.dll"
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
**Linux/macOS:**
|
|
601
|
+
|
|
602
|
+
```json
|
|
603
|
+
{
|
|
604
|
+
"mcpServers": {
|
|
605
|
+
"db-mcp-sqlite": {
|
|
606
|
+
"command": "node",
|
|
607
|
+
"args": [
|
|
608
|
+
"/path/to/db-mcp/dist/cli.js",
|
|
609
|
+
"--transport",
|
|
610
|
+
"stdio",
|
|
611
|
+
"--sqlite-native",
|
|
612
|
+
"/path/to/database.db",
|
|
613
|
+
"--csv",
|
|
614
|
+
"--spatialite",
|
|
615
|
+
"--tool-filter",
|
|
616
|
+
"starter"
|
|
617
|
+
],
|
|
618
|
+
"env": {
|
|
619
|
+
"CSV_EXTENSION_PATH": "/path/to/extensions/csv.so",
|
|
620
|
+
"SPATIALITE_PATH": "/usr/lib/x86_64-linux-gnu/mod_spatialite.so"
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
> **Note:** Extension flags (`--csv`, `--spatialite`) are only available with the native backend (`--sqlite-native`). Set environment variables if extensions are not in standard system paths.
|
|
628
|
+
|
|
629
|
+
### Docker with Claude Desktop
|
|
630
|
+
|
|
631
|
+
```json
|
|
632
|
+
{
|
|
633
|
+
"mcpServers": {
|
|
634
|
+
"db-mcp-sqlite": {
|
|
635
|
+
"command": "docker",
|
|
636
|
+
"args": [
|
|
637
|
+
"run",
|
|
638
|
+
"-i",
|
|
639
|
+
"--rm",
|
|
640
|
+
"-v",
|
|
641
|
+
"/path/to/project:/workspace",
|
|
642
|
+
"writenotenow/db-mcp:latest",
|
|
643
|
+
"--sqlite-native",
|
|
644
|
+
"/workspace/database.db"
|
|
645
|
+
]
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
### In-Memory Database
|
|
652
|
+
|
|
653
|
+
Use `:memory:` for a temporary in-memory database:
|
|
654
|
+
|
|
655
|
+
```json
|
|
656
|
+
{
|
|
657
|
+
"args": ["--transport", "stdio", "--sqlite-native", ":memory:"]
|
|
658
|
+
}
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
### HTTP/SSE Transport (Remote Access)
|
|
662
|
+
|
|
663
|
+
For remote access, web-based clients, or MCP Inspector testing, run the server in HTTP mode:
|
|
664
|
+
|
|
665
|
+
```bash
|
|
666
|
+
node dist/cli.js --transport http --port 3000 --sqlite-native ./database.db
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
**Endpoints:**
|
|
670
|
+
|
|
671
|
+
| Endpoint | Description |
|
|
672
|
+
| ------------- | --------------------------------------------- |
|
|
673
|
+
| `GET /` | Server info and available endpoints |
|
|
674
|
+
| `POST /mcp` | JSON-RPC requests (initialize, tools/call) |
|
|
675
|
+
| `GET /mcp` | SSE stream for server-to-client notifications |
|
|
676
|
+
| `DELETE /mcp` | Session termination |
|
|
677
|
+
| `GET /health` | Health check (always public) |
|
|
678
|
+
|
|
679
|
+
**Session Management:** The server uses stateful sessions by default. Include the `mcp-session-id` header (returned from initialization) in subsequent requests for session continuity.
|
|
680
|
+
|
|
681
|
+
#### Stateless Mode (Serverless)
|
|
682
|
+
|
|
683
|
+
For serverless deployments (AWS Lambda, Cloudflare Workers, Vercel), use stateless mode:
|
|
684
|
+
|
|
685
|
+
```bash
|
|
686
|
+
node dist/cli.js --transport http --port 3000 --stateless --sqlite-native :memory:
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
| Mode | Progress Notifications | SSE Streaming | Serverless |
|
|
690
|
+
| ------------------------- | ---------------------- | ------------- | ---------- |
|
|
691
|
+
| Stateful (default) | ✅ Yes | ✅ Yes | ⚠️ Complex |
|
|
692
|
+
| Stateless (`--stateless`) | ❌ No | ❌ No | ✅ Native |
|
|
693
|
+
|
|
694
|
+
[⬆️ Back to Table of Contents](#-table-of-contents)
|
|
695
|
+
|
|
696
|
+
---
|
|
697
|
+
|
|
698
|
+
## 🔥 Core Capabilities
|
|
699
|
+
|
|
700
|
+
- 📊 **Statistical Analysis** - Descriptive stats, percentiles, time series analysis
|
|
701
|
+
- 🔍 **Advanced Text Processing** - Regex, fuzzy matching, phonetic search, similarity
|
|
702
|
+
- 🧠 **Vector/Semantic Search** - AI-native embeddings, cosine similarity, hybrid search
|
|
703
|
+
- 🗺️ **Geospatial Operations** - Distance calculations, bounding boxes, spatial queries
|
|
704
|
+
- 🔐 **Transaction Safety** - Full ACID compliance with savepoints (native backend)
|
|
705
|
+
- 🎛️ **122 Specialized Tools** - Complete database administration and analytics suite
|
|
706
|
+
|
|
707
|
+
### 🏢 Enterprise Features
|
|
708
|
+
|
|
709
|
+
- 🔐 **OAuth 2.1 Authentication** - RFC 9728/8414 compliant token-based authentication
|
|
710
|
+
- 🛡️ **Tool Filtering** - Control which database operations are exposed
|
|
711
|
+
- 👥 **Access Control** - Granular scopes for read-only, write, and admin access
|
|
712
|
+
- 🎯 **Full-Text Search (FTS5)** - Advanced search with BM25 ranking
|
|
713
|
+
- ⚡ **Window Functions** - Row numbers, rankings, running totals, moving averages
|
|
714
|
+
|
|
715
|
+
[⬆️ Back to Table of Contents](#-table-of-contents)
|
|
716
|
+
|
|
717
|
+
---
|
|
718
|
+
|
|
719
|
+
## 🔐 OAuth 2.1 Implementation
|
|
720
|
+
|
|
721
|
+
| Component | Status | Description |
|
|
722
|
+
| --------------------------- | ------ | ------------------------------------------------ |
|
|
723
|
+
| Protected Resource Metadata | ✅ | RFC 9728 `/.well-known/oauth-protected-resource` |
|
|
724
|
+
| Auth Server Discovery | ✅ | RFC 8414 metadata discovery with caching |
|
|
725
|
+
| Token Validation | ✅ | JWT validation with JWKS support |
|
|
726
|
+
| Scope Enforcement | ✅ | Granular `read`, `write`, `admin` scopes |
|
|
727
|
+
| HTTP Transport | ✅ | Streamable HTTP with OAuth middleware |
|
|
728
|
+
|
|
729
|
+
### Supported Scopes
|
|
730
|
+
|
|
731
|
+
| Scope | Description |
|
|
732
|
+
| -------------------- | -------------------------------------- |
|
|
733
|
+
| `read` | Read-only access to all databases |
|
|
734
|
+
| `write` | Read and write access to all databases |
|
|
735
|
+
| `admin` | Full administrative access |
|
|
736
|
+
| `db:{name}` | Access to specific database only |
|
|
737
|
+
| `table:{db}:{table}` | Access to specific table only |
|
|
738
|
+
|
|
739
|
+
### Keycloak Integration
|
|
740
|
+
|
|
741
|
+
See [docs/KEYCLOAK_SETUP.md](docs/KEYCLOAK_SETUP.md) for setting up Keycloak as your OAuth provider.
|
|
742
|
+
|
|
743
|
+
### Quick Start with OAuth
|
|
744
|
+
|
|
745
|
+
**1. Start the server with OAuth enabled:**
|
|
746
|
+
|
|
747
|
+
```bash
|
|
748
|
+
# Set environment variables
|
|
749
|
+
export KEYCLOAK_URL=http://localhost:8080
|
|
750
|
+
export KEYCLOAK_REALM=db-mcp
|
|
751
|
+
export KEYCLOAK_CLIENT_ID=db-mcp-server
|
|
752
|
+
|
|
753
|
+
# Start server with HTTP transport and OAuth
|
|
754
|
+
node dist/cli.js --transport http --port 3000 --sqlite-native ./database.db
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
**2. Get an access token from Keycloak:**
|
|
758
|
+
|
|
759
|
+
```bash
|
|
760
|
+
# Using cURL
|
|
761
|
+
curl -X POST "http://localhost:8080/realms/db-mcp/protocol/openid-connect/token" \
|
|
762
|
+
-H "Content-Type: application/x-www-form-urlencoded" \
|
|
763
|
+
-d "client_id=db-mcp-server" \
|
|
764
|
+
-d "client_secret=YOUR_SECRET" \
|
|
765
|
+
-d "username=testuser" \
|
|
766
|
+
-d "password=YOUR_PASSWORD" \
|
|
767
|
+
-d "grant_type=password" \
|
|
768
|
+
-d "scope=openid read write"
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
**3. Make authenticated MCP requests:**
|
|
772
|
+
|
|
773
|
+
```bash
|
|
774
|
+
# Initialize session with Bearer token
|
|
775
|
+
curl -X POST "http://localhost:3000/mcp" \
|
|
776
|
+
-H "Content-Type: application/json" \
|
|
777
|
+
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
|
|
778
|
+
-d '{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{}},"id":1}'
|
|
779
|
+
```
|
|
780
|
+
|
|
781
|
+
> **Note:** OAuth is automatically enabled when running in HTTP mode with OAuth environment variables configured. The `/.well-known/oauth-protected-resource` endpoint provides RFC 9728 metadata for client discovery.
|
|
782
|
+
|
|
783
|
+
[⬆️ Back to Table of Contents](#-table-of-contents)
|
|
784
|
+
|
|
785
|
+
---
|
|
786
|
+
|
|
787
|
+
## 🏆 Why Choose db-mcp?
|
|
788
|
+
|
|
789
|
+
✅ **TypeScript Native** - Full type safety with strict mode, no `any` types
|
|
790
|
+
✅ **122 Specialized Tools** - Most comprehensive SQLite MCP server available
|
|
791
|
+
✅ **OAuth 2.1 Built-in** - Enterprise-grade authentication out of the box
|
|
792
|
+
✅ **Dual Backends** - WASM for portability, native for performance
|
|
793
|
+
✅ **Tool Filtering** - Stay within AI IDE tool limits with preset configurations
|
|
794
|
+
✅ **Window Functions** - Advanced analytics with ROW_NUMBER, RANK, LAG/LEAD
|
|
795
|
+
✅ **Transaction Support** - Full ACID compliance with savepoints
|
|
796
|
+
✅ **Modern Architecture** - Built on MCP SDK with clean, modular design
|
|
797
|
+
✅ **Active Development** - Regular updates and improvements
|
|
798
|
+
|
|
799
|
+
[⬆️ Back to Table of Contents](#-table-of-contents)
|
|
800
|
+
|
|
801
|
+
---
|
|
802
|
+
|
|
803
|
+
## 📈 Project Stats
|
|
804
|
+
|
|
805
|
+
- **122 Tools** in native backend (102 in WASM)
|
|
806
|
+
- **13 Tool Groups** for flexible filtering
|
|
807
|
+
- **Strict TypeScript** with full type coverage
|
|
808
|
+
- **Multi-platform** support (Windows, Linux, macOS)
|
|
809
|
+
- **Docker images** available for easy deployment
|
|
810
|
+
- **OAuth 2.1** RFC-compliant authentication
|
|
811
|
+
- **Active development** with regular updates
|
|
812
|
+
|
|
813
|
+
[⬆️ Back to Table of Contents](#-table-of-contents)
|
|
814
|
+
|
|
815
|
+
---
|
|
816
|
+
|
|
817
|
+
## Configuration
|
|
818
|
+
|
|
819
|
+
### Environment Variables
|
|
820
|
+
|
|
821
|
+
Copy `.env.example` to `.env` and configure:
|
|
822
|
+
|
|
823
|
+
```bash
|
|
824
|
+
KEYCLOAK_URL=http://localhost:8080
|
|
825
|
+
KEYCLOAK_REALM=db-mcp
|
|
826
|
+
KEYCLOAK_CLIENT_ID=db-mcp-server
|
|
827
|
+
KEYCLOAK_CLIENT_SECRET=your_secret_here
|
|
828
|
+
DBMCP_PORT=3000
|
|
829
|
+
DBMCP_OAUTH_ENABLED=true
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
### JSON Configuration
|
|
833
|
+
|
|
834
|
+
See `config/db-mcp.keycloak.json` for a complete example.
|
|
835
|
+
|
|
836
|
+
---
|
|
837
|
+
|
|
838
|
+
## 🚧 Planned Improvements
|
|
839
|
+
|
|
840
|
+
_No pending improvements. All features are up-to-date._
|
|
841
|
+
|
|
842
|
+
---
|
|
843
|
+
|
|
844
|
+
## Contributing
|
|
845
|
+
|
|
846
|
+
Contributions are welcome! Please read our [Contributing Guidelines](CONTRIBUTING.md) before submitting a pull request.
|
|
847
|
+
|
|
848
|
+
## Security
|
|
849
|
+
|
|
850
|
+
For security concerns, please see our [Security Policy](SECURITY.md).
|
|
851
|
+
|
|
852
|
+
> **⚠️ Never commit credentials** - Store secrets in `.env` (gitignored)
|
|
853
|
+
|
|
854
|
+
## License
|
|
855
|
+
|
|
856
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
857
|
+
|
|
858
|
+
## Code of Conduct
|
|
859
|
+
|
|
860
|
+
Please read our [Code of Conduct](CODE_OF_CONDUCT.md) before participating in this project.
|