db-mcp 1.0.2 → 1.1.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/.gitattributes +2 -0
- package/LICENSE +1 -1
- package/README.md +244 -518
- package/dist/chunk-4IA3DB5C.js +135 -0
- package/dist/chunk-AOUL5SHS.js +930 -0
- package/dist/chunk-DWJXQEFA.js +13759 -0
- package/dist/chunk-DZQLDEQS.js +879 -0
- package/dist/chunk-S5IDDSSB.js +74 -0
- package/dist/chunk-Z2GFQU3G.js +363 -0
- package/dist/cli.d.ts +0 -7
- package/dist/cli.js +227 -183
- package/dist/http-VSB7DBJR.js +1541 -0
- package/dist/index.d.ts +842 -10
- package/dist/index.js +5 -17
- package/dist/sqlite-VHBA4ABV.js +600 -0
- package/dist/sqlite-native-D2LH5ZT7.js +2498 -0
- package/dist/worker-script.d.ts +2 -0
- package/dist/worker-script.js +126 -0
- package/package.json +26 -16
- package/playwright.config.ts +101 -0
- package/scripts/generate-server-instructions.ts +111 -0
- package/server.json +5 -6
- package/test-server/README.md +118 -0
- package/test-server/code-map.md +409 -0
- package/test-server/fixtures/sample.csv +6 -0
- package/test-server/reset-database.ps1 +373 -0
- package/test-server/sample.csv +11 -0
- package/test-server/test-agent-experience.md +243 -0
- package/test-server/test-database.sql +388 -0
- package/test-server/test-group-tools.md +861 -0
- package/test-server/test-help-resources.mjs +238 -0
- package/test-server/test-preflight.md +53 -0
- package/test-server/test-prompts.md +354 -0
- package/test-server/test-resources.md +245 -0
- package/test-server/test-tool-annotations.mjs +157 -0
- package/test-server/test-tools-advanced-1.md +517 -0
- package/test-server/test-tools-advanced-2.md +487 -0
- package/test-server/test-tools-codemode.md +629 -0
- package/test-server/test-tools.md +176 -0
- package/test-server/tool-reference.md +236 -0
- package/tsconfig.test.json +9 -0
- package/dist/adapters/DatabaseAdapter.d.ts +0 -141
- package/dist/adapters/DatabaseAdapter.d.ts.map +0 -1
- package/dist/adapters/DatabaseAdapter.js +0 -131
- package/dist/adapters/DatabaseAdapter.js.map +0 -1
- package/dist/adapters/sqlite/SchemaManager.d.ts +0 -58
- package/dist/adapters/sqlite/SchemaManager.d.ts.map +0 -1
- package/dist/adapters/sqlite/SchemaManager.js +0 -187
- package/dist/adapters/sqlite/SchemaManager.js.map +0 -1
- package/dist/adapters/sqlite/SqliteAdapter.d.ts +0 -161
- package/dist/adapters/sqlite/SqliteAdapter.d.ts.map +0 -1
- package/dist/adapters/sqlite/SqliteAdapter.js +0 -741
- package/dist/adapters/sqlite/SqliteAdapter.js.map +0 -1
- package/dist/adapters/sqlite/index.d.ts +0 -9
- package/dist/adapters/sqlite/index.d.ts.map +0 -1
- package/dist/adapters/sqlite/index.js +0 -8
- package/dist/adapters/sqlite/index.js.map +0 -1
- package/dist/adapters/sqlite/json-utils.d.ts +0 -100
- package/dist/adapters/sqlite/json-utils.d.ts.map +0 -1
- package/dist/adapters/sqlite/json-utils.js +0 -274
- package/dist/adapters/sqlite/json-utils.js.map +0 -1
- package/dist/adapters/sqlite/output-schemas.d.ts +0 -1187
- package/dist/adapters/sqlite/output-schemas.d.ts.map +0 -1
- package/dist/adapters/sqlite/output-schemas.js +0 -1337
- package/dist/adapters/sqlite/output-schemas.js.map +0 -1
- package/dist/adapters/sqlite/prompts.d.ts +0 -13
- package/dist/adapters/sqlite/prompts.d.ts.map +0 -1
- package/dist/adapters/sqlite/prompts.js +0 -605
- package/dist/adapters/sqlite/prompts.js.map +0 -1
- package/dist/adapters/sqlite/resources.d.ts +0 -13
- package/dist/adapters/sqlite/resources.d.ts.map +0 -1
- package/dist/adapters/sqlite/resources.js +0 -251
- package/dist/adapters/sqlite/resources.js.map +0 -1
- package/dist/adapters/sqlite/tools/admin.d.ts +0 -14
- package/dist/adapters/sqlite/tools/admin.d.ts.map +0 -1
- package/dist/adapters/sqlite/tools/admin.js +0 -788
- package/dist/adapters/sqlite/tools/admin.js.map +0 -1
- package/dist/adapters/sqlite/tools/core.d.ts +0 -25
- package/dist/adapters/sqlite/tools/core.d.ts.map +0 -1
- package/dist/adapters/sqlite/tools/core.js +0 -359
- package/dist/adapters/sqlite/tools/core.js.map +0 -1
- package/dist/adapters/sqlite/tools/fts.d.ts +0 -13
- package/dist/adapters/sqlite/tools/fts.d.ts.map +0 -1
- package/dist/adapters/sqlite/tools/fts.js +0 -347
- package/dist/adapters/sqlite/tools/fts.js.map +0 -1
- package/dist/adapters/sqlite/tools/geo.d.ts +0 -14
- package/dist/adapters/sqlite/tools/geo.d.ts.map +0 -1
- package/dist/adapters/sqlite/tools/geo.js +0 -252
- package/dist/adapters/sqlite/tools/geo.js.map +0 -1
- package/dist/adapters/sqlite/tools/index.d.ts +0 -30
- package/dist/adapters/sqlite/tools/index.d.ts.map +0 -1
- package/dist/adapters/sqlite/tools/index.js +0 -61
- package/dist/adapters/sqlite/tools/index.js.map +0 -1
- package/dist/adapters/sqlite/tools/json-helpers.d.ts +0 -14
- package/dist/adapters/sqlite/tools/json-helpers.d.ts.map +0 -1
- package/dist/adapters/sqlite/tools/json-helpers.js +0 -477
- package/dist/adapters/sqlite/tools/json-helpers.js.map +0 -1
- package/dist/adapters/sqlite/tools/json-operations.d.ts +0 -14
- package/dist/adapters/sqlite/tools/json-operations.d.ts.map +0 -1
- package/dist/adapters/sqlite/tools/json-operations.js +0 -839
- package/dist/adapters/sqlite/tools/json-operations.js.map +0 -1
- package/dist/adapters/sqlite/tools/stats.d.ts +0 -15
- package/dist/adapters/sqlite/tools/stats.d.ts.map +0 -1
- package/dist/adapters/sqlite/tools/stats.js +0 -1219
- package/dist/adapters/sqlite/tools/stats.js.map +0 -1
- package/dist/adapters/sqlite/tools/text.d.ts +0 -14
- package/dist/adapters/sqlite/tools/text.d.ts.map +0 -1
- package/dist/adapters/sqlite/tools/text.js +0 -1141
- package/dist/adapters/sqlite/tools/text.js.map +0 -1
- package/dist/adapters/sqlite/tools/vector.d.ts +0 -14
- package/dist/adapters/sqlite/tools/vector.d.ts.map +0 -1
- package/dist/adapters/sqlite/tools/vector.js +0 -613
- package/dist/adapters/sqlite/tools/vector.js.map +0 -1
- package/dist/adapters/sqlite/tools/virtual.d.ts +0 -13
- package/dist/adapters/sqlite/tools/virtual.d.ts.map +0 -1
- package/dist/adapters/sqlite/tools/virtual.js +0 -930
- package/dist/adapters/sqlite/tools/virtual.js.map +0 -1
- package/dist/adapters/sqlite/types.d.ts +0 -207
- package/dist/adapters/sqlite/types.d.ts.map +0 -1
- package/dist/adapters/sqlite/types.js +0 -186
- package/dist/adapters/sqlite/types.js.map +0 -1
- package/dist/adapters/sqlite-native/NativeSqliteAdapter.d.ts +0 -163
- package/dist/adapters/sqlite-native/NativeSqliteAdapter.d.ts.map +0 -1
- package/dist/adapters/sqlite-native/NativeSqliteAdapter.js +0 -748
- package/dist/adapters/sqlite-native/NativeSqliteAdapter.js.map +0 -1
- package/dist/adapters/sqlite-native/index.d.ts +0 -11
- package/dist/adapters/sqlite-native/index.d.ts.map +0 -1
- package/dist/adapters/sqlite-native/index.js +0 -11
- package/dist/adapters/sqlite-native/index.js.map +0 -1
- package/dist/adapters/sqlite-native/tools/spatialite.d.ts +0 -19
- package/dist/adapters/sqlite-native/tools/spatialite.d.ts.map +0 -1
- package/dist/adapters/sqlite-native/tools/spatialite.js +0 -628
- package/dist/adapters/sqlite-native/tools/spatialite.js.map +0 -1
- package/dist/adapters/sqlite-native/tools/transactions.d.ts +0 -12
- package/dist/adapters/sqlite-native/tools/transactions.d.ts.map +0 -1
- package/dist/adapters/sqlite-native/tools/transactions.js +0 -255
- package/dist/adapters/sqlite-native/tools/transactions.js.map +0 -1
- package/dist/adapters/sqlite-native/tools/window.d.ts +0 -12
- package/dist/adapters/sqlite-native/tools/window.d.ts.map +0 -1
- package/dist/adapters/sqlite-native/tools/window.js +0 -370
- package/dist/adapters/sqlite-native/tools/window.js.map +0 -1
- package/dist/auth/AuthorizationServerDiscovery.d.ts +0 -90
- package/dist/auth/AuthorizationServerDiscovery.d.ts.map +0 -1
- package/dist/auth/AuthorizationServerDiscovery.js +0 -204
- package/dist/auth/AuthorizationServerDiscovery.js.map +0 -1
- package/dist/auth/OAuthResourceServer.d.ts +0 -65
- package/dist/auth/OAuthResourceServer.d.ts.map +0 -1
- package/dist/auth/OAuthResourceServer.js +0 -121
- package/dist/auth/OAuthResourceServer.js.map +0 -1
- package/dist/auth/TokenValidator.d.ts +0 -60
- package/dist/auth/TokenValidator.d.ts.map +0 -1
- package/dist/auth/TokenValidator.js +0 -235
- package/dist/auth/TokenValidator.js.map +0 -1
- package/dist/auth/errors.d.ts +0 -74
- package/dist/auth/errors.d.ts.map +0 -1
- package/dist/auth/errors.js +0 -133
- package/dist/auth/errors.js.map +0 -1
- package/dist/auth/index.d.ts +0 -13
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/index.js +0 -15
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/middleware.d.ts +0 -81
- package/dist/auth/middleware.d.ts.map +0 -1
- package/dist/auth/middleware.js +0 -291
- package/dist/auth/middleware.js.map +0 -1
- package/dist/auth/scopes.d.ts +0 -136
- package/dist/auth/scopes.d.ts.map +0 -1
- package/dist/auth/scopes.js +0 -349
- package/dist/auth/scopes.js.map +0 -1
- package/dist/auth/types.d.ts +0 -257
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/types.js +0 -8
- package/dist/auth/types.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/constants/ServerInstructions.d.ts +0 -45
- package/dist/constants/ServerInstructions.d.ts.map +0 -1
- package/dist/constants/ServerInstructions.js +0 -356
- package/dist/constants/ServerInstructions.js.map +0 -1
- package/dist/filtering/ToolConstants.d.ts +0 -34
- package/dist/filtering/ToolConstants.d.ts.map +0 -1
- package/dist/filtering/ToolConstants.js +0 -174
- package/dist/filtering/ToolConstants.js.map +0 -1
- package/dist/filtering/ToolFilter.d.ts +0 -82
- package/dist/filtering/ToolFilter.d.ts.map +0 -1
- package/dist/filtering/ToolFilter.js +0 -296
- package/dist/filtering/ToolFilter.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/server/McpServer.d.ts +0 -61
- package/dist/server/McpServer.d.ts.map +0 -1
- package/dist/server/McpServer.js +0 -270
- package/dist/server/McpServer.js.map +0 -1
- package/dist/transports/http.d.ts +0 -134
- package/dist/transports/http.d.ts.map +0 -1
- package/dist/transports/http.js +0 -516
- package/dist/transports/http.js.map +0 -1
- package/dist/transports/index.d.ts +0 -5
- package/dist/transports/index.d.ts.map +0 -1
- package/dist/transports/index.js +0 -5
- package/dist/transports/index.js.map +0 -1
- package/dist/types/index.d.ts +0 -380
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -68
- package/dist/types/index.js.map +0 -1
- package/dist/utils/annotations.d.ts +0 -44
- package/dist/utils/annotations.d.ts.map +0 -1
- package/dist/utils/annotations.js +0 -77
- package/dist/utils/annotations.js.map +0 -1
- package/dist/utils/errors.d.ts +0 -155
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js +0 -329
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/identifiers.d.ts +0 -121
- package/dist/utils/identifiers.d.ts.map +0 -1
- package/dist/utils/identifiers.js +0 -319
- package/dist/utils/identifiers.js.map +0 -1
- package/dist/utils/index.d.ts +0 -7
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -7
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/insightsManager.d.ts +0 -39
- package/dist/utils/insightsManager.d.ts.map +0 -1
- package/dist/utils/insightsManager.js +0 -63
- package/dist/utils/insightsManager.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -189
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -394
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/progress-utils.d.ts +0 -54
- package/dist/utils/progress-utils.d.ts.map +0 -1
- package/dist/utils/progress-utils.js +0 -74
- package/dist/utils/progress-utils.js.map +0 -1
- package/dist/utils/resourceAnnotations.d.ts +0 -36
- package/dist/utils/resourceAnnotations.d.ts.map +0 -1
- package/dist/utils/resourceAnnotations.js +0 -57
- package/dist/utils/resourceAnnotations.js.map +0 -1
- package/dist/utils/where-clause.d.ts +0 -41
- package/dist/utils/where-clause.d.ts.map +0 -1
- package/dist/utils/where-clause.js +0 -116
- package/dist/utils/where-clause.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,845 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
* db-mcp
|
|
4
|
+
* db-mcp — Database Types
|
|
3
5
|
*
|
|
4
|
-
*
|
|
6
|
+
* Core database type definitions: connections, queries, schema,
|
|
7
|
+
* tables, columns, indexes, and constraints.
|
|
5
8
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Supported database types.
|
|
11
|
+
* This MCP server only supports SQLite. Other database types
|
|
12
|
+
* would require separate MCP server projects.
|
|
13
|
+
*/
|
|
14
|
+
type DatabaseType = "sqlite";
|
|
15
|
+
/**
|
|
16
|
+
* Database connection configuration
|
|
17
|
+
*/
|
|
18
|
+
interface DatabaseConfig {
|
|
19
|
+
/** Database type identifier */
|
|
20
|
+
type: DatabaseType;
|
|
21
|
+
/** Connection string (file path or ":memory:") */
|
|
22
|
+
connectionString?: string;
|
|
23
|
+
/** Additional database-specific options */
|
|
24
|
+
options?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Database connection health status
|
|
28
|
+
*/
|
|
29
|
+
interface HealthStatus {
|
|
30
|
+
connected: boolean;
|
|
31
|
+
latencyMs?: number;
|
|
32
|
+
version?: string;
|
|
33
|
+
details?: Record<string, unknown>;
|
|
34
|
+
error?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Query execution result
|
|
38
|
+
*/
|
|
39
|
+
interface QueryResult {
|
|
40
|
+
/** Rows returned (for SELECT queries) */
|
|
41
|
+
rows?: Record<string, unknown>[];
|
|
42
|
+
/** Number of rows affected (for INSERT/UPDATE/DELETE) */
|
|
43
|
+
rowsAffected?: number;
|
|
44
|
+
/** Last inserted ID (for INSERT with auto-increment) */
|
|
45
|
+
lastInsertId?: number | string;
|
|
46
|
+
/** Query execution time in milliseconds */
|
|
47
|
+
executionTimeMs?: number;
|
|
48
|
+
/** Column metadata */
|
|
49
|
+
columns?: ColumnInfo[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Column metadata information
|
|
53
|
+
*/
|
|
54
|
+
interface ColumnInfo {
|
|
55
|
+
name: string;
|
|
56
|
+
type: string;
|
|
57
|
+
nullable?: boolean;
|
|
58
|
+
primaryKey?: boolean;
|
|
59
|
+
defaultValue?: unknown;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Table information
|
|
63
|
+
*/
|
|
64
|
+
interface TableInfo {
|
|
65
|
+
name: string;
|
|
66
|
+
schema?: string;
|
|
67
|
+
type: "table" | "view" | "materialized_view";
|
|
68
|
+
rowCount?: number;
|
|
69
|
+
columns?: ColumnInfo[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Schema information for a database
|
|
73
|
+
*/
|
|
74
|
+
interface SchemaInfo {
|
|
75
|
+
tables: TableInfo[];
|
|
76
|
+
views?: TableInfo[];
|
|
77
|
+
indexes?: IndexInfo[];
|
|
78
|
+
constraints?: ConstraintInfo[];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Index information
|
|
82
|
+
*/
|
|
83
|
+
interface IndexInfo {
|
|
84
|
+
name: string;
|
|
85
|
+
tableName: string;
|
|
86
|
+
columns: string[];
|
|
87
|
+
unique: boolean;
|
|
88
|
+
type?: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Constraint information
|
|
92
|
+
*/
|
|
93
|
+
interface ConstraintInfo {
|
|
94
|
+
name: string;
|
|
95
|
+
tableName: string;
|
|
96
|
+
type: "primary_key" | "foreign_key" | "unique" | "check";
|
|
97
|
+
columns: string[];
|
|
98
|
+
referencedTable?: string;
|
|
99
|
+
referencedColumns?: string[];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* db-mcp — OAuth & Auth Types
|
|
104
|
+
*
|
|
105
|
+
* OAuth 2.1 configuration, scopes, token claims, and request context.
|
|
106
|
+
*/
|
|
107
|
+
/**
|
|
108
|
+
* OAuth 2.1 configuration
|
|
109
|
+
*/
|
|
110
|
+
interface OAuthConfig {
|
|
111
|
+
/** Enable OAuth authentication */
|
|
112
|
+
enabled: boolean;
|
|
113
|
+
/** Authorization server URL */
|
|
114
|
+
authorizationServerUrl?: string;
|
|
115
|
+
/** Token validation endpoint */
|
|
116
|
+
tokenEndpoint?: string;
|
|
117
|
+
/** JWKS URI for token verification */
|
|
118
|
+
jwksUri?: string;
|
|
119
|
+
/** Expected audience in tokens */
|
|
120
|
+
audience?: string;
|
|
121
|
+
/** Expected issuer in tokens */
|
|
122
|
+
issuer?: string;
|
|
123
|
+
/** Clock tolerance for token validation (seconds) */
|
|
124
|
+
clockTolerance?: number;
|
|
125
|
+
/** JWKS cache TTL (seconds) */
|
|
126
|
+
jwksCacheTtl?: number;
|
|
127
|
+
/** Paths that bypass authentication */
|
|
128
|
+
publicPaths?: string[];
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* OAuth scopes for access control
|
|
132
|
+
*/
|
|
133
|
+
type OAuthScope = "read" | "write" | "admin" | `db:${string}` | `table:${string}:${string}`;
|
|
134
|
+
/**
|
|
135
|
+
* Validated OAuth token claims
|
|
136
|
+
*/
|
|
137
|
+
interface TokenClaims {
|
|
138
|
+
/** Subject (user ID) */
|
|
139
|
+
sub: string;
|
|
140
|
+
/** Granted scopes */
|
|
141
|
+
scopes: OAuthScope[];
|
|
142
|
+
/** Token expiration time */
|
|
143
|
+
exp: number;
|
|
144
|
+
/** Token issued at time */
|
|
145
|
+
iat: number;
|
|
146
|
+
/** Token issuer */
|
|
147
|
+
iss?: string;
|
|
148
|
+
/** Token audience */
|
|
149
|
+
aud?: string | string[];
|
|
150
|
+
/** Additional claims */
|
|
151
|
+
[key: string]: unknown;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Request context with authentication info
|
|
155
|
+
*/
|
|
156
|
+
interface RequestContext {
|
|
157
|
+
/** Validated token claims (if authenticated) */
|
|
158
|
+
auth?: TokenClaims;
|
|
159
|
+
/** Raw access token */
|
|
160
|
+
accessToken?: string;
|
|
161
|
+
/** Request timestamp */
|
|
162
|
+
timestamp: Date;
|
|
163
|
+
/** Request ID for tracing */
|
|
164
|
+
requestId: string;
|
|
165
|
+
/**
|
|
166
|
+
* MCP Server instance for sending progress notifications.
|
|
167
|
+
* Only available when running in HTTP/SSE transport with stateful sessions.
|
|
168
|
+
*/
|
|
169
|
+
server?: unknown;
|
|
170
|
+
/**
|
|
171
|
+
* Progress token from client request _meta (MCP 2025-11-25).
|
|
172
|
+
* If present, the client has requested progress updates.
|
|
173
|
+
*/
|
|
174
|
+
progressToken?: string | number;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* db-mcp — MCP Server Types
|
|
179
|
+
*
|
|
180
|
+
* Configuration types for the MCP server: transport, port, host,
|
|
181
|
+
* database config references, and server-level options.
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Transport type for MCP communication
|
|
186
|
+
*/
|
|
187
|
+
type TransportType = "stdio" | "http" | "sse";
|
|
188
|
+
/**
|
|
189
|
+
* MCP Server configuration
|
|
190
|
+
*/
|
|
191
|
+
interface McpServerConfig {
|
|
192
|
+
/** Server name */
|
|
193
|
+
name: string;
|
|
194
|
+
/** Server version */
|
|
195
|
+
version: string;
|
|
196
|
+
/** Transport configuration */
|
|
197
|
+
transport: TransportType;
|
|
198
|
+
/** HTTP port (for http/sse transports) */
|
|
199
|
+
port?: number;
|
|
200
|
+
/** Host/IP to bind to (for http/sse transports, default: 0.0.0.0) */
|
|
201
|
+
host?: string;
|
|
202
|
+
/** Database configurations */
|
|
203
|
+
databases: DatabaseConfig[];
|
|
204
|
+
/** OAuth 2.1 configuration */
|
|
205
|
+
oauth?: OAuthConfig;
|
|
206
|
+
/** Simple bearer token for HTTP authentication (non-OAuth) */
|
|
207
|
+
authToken?: string;
|
|
208
|
+
/** Tool filtering configuration */
|
|
209
|
+
toolFilter?: string;
|
|
210
|
+
/**
|
|
211
|
+
* Enable stateless HTTP mode (no session management, no SSE streaming).
|
|
212
|
+
* Ideal for serverless deployments (Lambda, Workers, Vercel).
|
|
213
|
+
* Default: false (stateful mode with session management and SSE support)
|
|
214
|
+
*/
|
|
215
|
+
statelessHttp?: boolean;
|
|
216
|
+
enableHSTS?: boolean;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* db-mcp — Tool Filtering Types
|
|
221
|
+
*
|
|
222
|
+
* Tool groups, meta-groups, and filter configuration types.
|
|
223
|
+
*/
|
|
224
|
+
/**
|
|
225
|
+
* Tool group identifiers
|
|
226
|
+
*/
|
|
227
|
+
type ToolGroup = "core" | "json" | "text" | "stats" | "vector" | "admin" | "geo" | "introspection" | "migration" | "codemode";
|
|
228
|
+
/**
|
|
229
|
+
* Meta-group identifiers for common multi-group selections.
|
|
230
|
+
* These are shortcuts that expand to multiple ToolGroups.
|
|
231
|
+
*/
|
|
232
|
+
type MetaGroup = "starter" | "analytics" | "search" | "spatial" | "dev-schema" | "minimal" | "full";
|
|
233
|
+
/**
|
|
234
|
+
* Tool filter rule
|
|
235
|
+
*/
|
|
236
|
+
interface ToolFilterRule {
|
|
237
|
+
/** Rule type: include or exclude */
|
|
238
|
+
type: "include" | "exclude";
|
|
239
|
+
/** Target: group name or tool name */
|
|
240
|
+
target: string;
|
|
241
|
+
/** Whether target is a group (true) or individual tool (false) */
|
|
242
|
+
isGroup: boolean;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Parsed tool filter configuration
|
|
246
|
+
*/
|
|
247
|
+
interface ToolFilterConfig {
|
|
248
|
+
/** Original filter string */
|
|
249
|
+
raw: string;
|
|
250
|
+
/** Parsed rules in order */
|
|
251
|
+
rules: ToolFilterRule[];
|
|
252
|
+
/** Set of enabled tool groups after applying rules */
|
|
253
|
+
enabledGroups: Set<ToolGroup>;
|
|
254
|
+
/** Set of explicitly excluded tool names (base names without prefix) */
|
|
255
|
+
excludedTools: Set<string>;
|
|
256
|
+
/** Set of explicitly included tool names (base names without prefix) */
|
|
257
|
+
includedTools: Set<string>;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* db-mcp — Adapter Types
|
|
262
|
+
*
|
|
263
|
+
* Types for database adapter capabilities, tool/resource/prompt definitions,
|
|
264
|
+
* MCP icons, and tool annotations.
|
|
265
|
+
*/
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* MCP Icon Definition (MCP Spec 2025-11-25)
|
|
269
|
+
*
|
|
270
|
+
* Icons can be added to servers, tools, resources, and prompts for
|
|
271
|
+
* visual representation in client interfaces.
|
|
272
|
+
*/
|
|
273
|
+
interface McpIcon {
|
|
274
|
+
/** Icon source — URL or data URI */
|
|
275
|
+
src: string;
|
|
276
|
+
/** MIME type (e.g., 'image/svg+xml', 'image/png') */
|
|
277
|
+
mimeType?: string;
|
|
278
|
+
/** Size descriptors (e.g., ['48x48'], ['any']) */
|
|
279
|
+
sizes?: string[];
|
|
280
|
+
/** Theme hint: 'light' or 'dark' */
|
|
281
|
+
theme?: "light" | "dark";
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Tool annotations provide behavioral hints to clients
|
|
285
|
+
* following the MCP 2025-11-25 specification.
|
|
286
|
+
*/
|
|
287
|
+
interface ToolAnnotations {
|
|
288
|
+
/** Human-readable title for the tool */
|
|
289
|
+
title?: string;
|
|
290
|
+
/** If true, the tool is guaranteed not to modify any state */
|
|
291
|
+
readOnlyHint?: boolean;
|
|
292
|
+
/** If true, multiple identical requests have the same effect as a single request */
|
|
293
|
+
idempotentHint?: boolean;
|
|
294
|
+
/** If true, the operation is irreversible or causes significant data loss */
|
|
295
|
+
destructiveHint?: boolean;
|
|
296
|
+
/** If true, the tool interacts with external/"open world" systems (network, filesystem, etc.) */
|
|
297
|
+
openWorldHint?: boolean;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Capabilities supported by a database adapter
|
|
301
|
+
*/
|
|
302
|
+
interface AdapterCapabilities {
|
|
303
|
+
/** Supports JSON operations */
|
|
304
|
+
json: boolean;
|
|
305
|
+
/** Supports full-text search */
|
|
306
|
+
fullTextSearch: boolean;
|
|
307
|
+
/** Supports vector/embedding operations */
|
|
308
|
+
vector: boolean;
|
|
309
|
+
/** Supports geospatial operations */
|
|
310
|
+
geospatial: boolean;
|
|
311
|
+
/** Supports transactions */
|
|
312
|
+
transactions: boolean;
|
|
313
|
+
/** Supports prepared statements */
|
|
314
|
+
preparedStatements: boolean;
|
|
315
|
+
/** Supports connection pooling */
|
|
316
|
+
connectionPooling: boolean;
|
|
317
|
+
/** Additional capability flags */
|
|
318
|
+
[key: string]: boolean;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Tool definition for registration
|
|
322
|
+
*/
|
|
323
|
+
interface ToolDefinition {
|
|
324
|
+
/** Unique tool name */
|
|
325
|
+
name: string;
|
|
326
|
+
/** Human-readable description */
|
|
327
|
+
description: string;
|
|
328
|
+
/** Tool group for filtering */
|
|
329
|
+
group: ToolGroup;
|
|
330
|
+
/** Zod schema for input validation */
|
|
331
|
+
inputSchema: unknown;
|
|
332
|
+
/** Zod schema for output validation (MCP 2025-11-25) */
|
|
333
|
+
outputSchema?: unknown;
|
|
334
|
+
/** Required OAuth scopes */
|
|
335
|
+
requiredScopes?: OAuthScope[];
|
|
336
|
+
/** MCP tool annotations (behavioral hints) */
|
|
337
|
+
annotations?: ToolAnnotations;
|
|
338
|
+
/** MCP icons for visual representation (MCP 2025-11-25) */
|
|
339
|
+
icons?: McpIcon[];
|
|
340
|
+
/** Tool handler function */
|
|
341
|
+
handler: (params: unknown, context: RequestContext) => Promise<unknown>;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* MCP Resource Annotations (SDK 1.25+)
|
|
345
|
+
* Provides metadata hints about resource content to help clients
|
|
346
|
+
* manage and display resources appropriately.
|
|
347
|
+
*/
|
|
348
|
+
interface ResourceAnnotations {
|
|
349
|
+
/** Intended audience for the resource content */
|
|
350
|
+
audience?: ("user" | "assistant")[];
|
|
351
|
+
/** Priority hint for display ordering (0-1 range) */
|
|
352
|
+
priority?: number;
|
|
353
|
+
/** ISO 8601 timestamp of last modification for cache invalidation */
|
|
354
|
+
lastModified?: string;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Resource definition for MCP
|
|
358
|
+
*/
|
|
359
|
+
interface ResourceDefinition {
|
|
360
|
+
/** Resource URI template */
|
|
361
|
+
uri: string;
|
|
362
|
+
/** Human-readable name */
|
|
363
|
+
name: string;
|
|
364
|
+
/** Description */
|
|
365
|
+
description: string;
|
|
366
|
+
/** MIME type */
|
|
367
|
+
mimeType?: string;
|
|
368
|
+
/** MCP Resource Annotations for behavior hints */
|
|
369
|
+
annotations?: ResourceAnnotations;
|
|
370
|
+
/** MCP icons for visual representation (MCP 2025-11-25) */
|
|
371
|
+
icons?: McpIcon[];
|
|
372
|
+
/** Resource handler */
|
|
373
|
+
handler: (uri: string, context: RequestContext) => Promise<unknown>;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Prompt definition for MCP
|
|
377
|
+
*/
|
|
378
|
+
interface PromptDefinition {
|
|
379
|
+
/** Prompt name */
|
|
380
|
+
name: string;
|
|
381
|
+
/** Description */
|
|
382
|
+
description: string;
|
|
383
|
+
/** Argument definitions */
|
|
384
|
+
arguments?: {
|
|
385
|
+
name: string;
|
|
386
|
+
description: string;
|
|
387
|
+
required?: boolean;
|
|
388
|
+
}[];
|
|
389
|
+
/** MCP icons for visual representation (MCP 2025-11-25) */
|
|
390
|
+
icons?: McpIcon[];
|
|
391
|
+
/** Prompt handler */
|
|
392
|
+
handler: (args: Record<string, string>, context: RequestContext) => Promise<unknown>;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Error Categories
|
|
397
|
+
*
|
|
398
|
+
* Classification enum for all db-mcp errors.
|
|
399
|
+
*/
|
|
400
|
+
/**
|
|
401
|
+
* Error categories for classification and handling
|
|
402
|
+
*/
|
|
403
|
+
declare enum ErrorCategory {
|
|
404
|
+
/** Input validation failures (invalid names, paths, types) */
|
|
405
|
+
VALIDATION = "validation",
|
|
406
|
+
/** Database connection issues */
|
|
407
|
+
CONNECTION = "connection",
|
|
408
|
+
/** SQL execution errors */
|
|
409
|
+
QUERY = "query",
|
|
410
|
+
/** Authorization/permission failures */
|
|
411
|
+
PERMISSION = "permission",
|
|
412
|
+
/** Configuration/setup issues */
|
|
413
|
+
CONFIGURATION = "config",
|
|
414
|
+
/** Missing resources (tables, columns, views) */
|
|
415
|
+
RESOURCE = "resource",
|
|
416
|
+
/** Authentication failures (invalid credentials, expired tokens) */
|
|
417
|
+
AUTHENTICATION = "authentication",
|
|
418
|
+
/** Authorization failures (insufficient scope/permissions) */
|
|
419
|
+
AUTHORIZATION = "authorization",
|
|
420
|
+
/** Unexpected internal errors */
|
|
421
|
+
INTERNAL = "internal"
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Structured error response format
|
|
425
|
+
*/
|
|
426
|
+
interface ErrorResponse {
|
|
427
|
+
success: false;
|
|
428
|
+
error: string;
|
|
429
|
+
code: string;
|
|
430
|
+
category: ErrorCategory;
|
|
431
|
+
suggestion: string | undefined;
|
|
432
|
+
recoverable: boolean;
|
|
433
|
+
details: Record<string, unknown> | undefined;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Base Error Class
|
|
438
|
+
*
|
|
439
|
+
* DbMcpError provides enhanced diagnostics: category, code, suggestion,
|
|
440
|
+
* recoverable flag, and structured response conversion.
|
|
441
|
+
*/
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Base error class for db-mcp with enhanced diagnostics
|
|
445
|
+
*/
|
|
446
|
+
declare class DbMcpError extends Error {
|
|
447
|
+
/** Error category for classification */
|
|
448
|
+
readonly category: ErrorCategory;
|
|
449
|
+
/** Module-prefixed error code (e.g., DB_QUERY_FAILED) */
|
|
450
|
+
readonly code: string;
|
|
451
|
+
/** Actionable suggestion for resolving the error */
|
|
452
|
+
readonly suggestion: string | undefined;
|
|
453
|
+
/** Additional error details */
|
|
454
|
+
readonly details: Record<string, unknown> | undefined;
|
|
455
|
+
/** Whether the error is recoverable (can retry) */
|
|
456
|
+
readonly recoverable: boolean;
|
|
457
|
+
constructor(message: string, code: string, category: ErrorCategory, options?: {
|
|
458
|
+
suggestion?: string | undefined;
|
|
459
|
+
details?: Record<string, unknown> | undefined;
|
|
460
|
+
recoverable?: boolean | undefined;
|
|
461
|
+
cause?: Error | undefined;
|
|
462
|
+
});
|
|
463
|
+
/**
|
|
464
|
+
* Convert to structured response object
|
|
465
|
+
*/
|
|
466
|
+
toResponse(): ErrorResponse;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Specific Error Classes
|
|
471
|
+
*
|
|
472
|
+
* Typed error subclasses for each ErrorCategory.
|
|
473
|
+
*/
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Validation error for invalid inputs
|
|
477
|
+
*/
|
|
478
|
+
declare class ValidationError extends DbMcpError {
|
|
479
|
+
constructor(message: string, code?: string, options?: {
|
|
480
|
+
suggestion?: string | undefined;
|
|
481
|
+
details?: Record<string, unknown> | undefined;
|
|
482
|
+
cause?: Error | undefined;
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Connection error for database connectivity issues
|
|
487
|
+
*/
|
|
488
|
+
declare class ConnectionError extends DbMcpError {
|
|
489
|
+
constructor(message: string, code?: string, options?: {
|
|
490
|
+
suggestion?: string | undefined;
|
|
491
|
+
details?: Record<string, unknown> | undefined;
|
|
492
|
+
cause?: Error | undefined;
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Query error for SQL execution failures
|
|
497
|
+
*/
|
|
498
|
+
declare class QueryError extends DbMcpError {
|
|
499
|
+
constructor(message: string, code?: string, options?: {
|
|
500
|
+
suggestion?: string | undefined;
|
|
501
|
+
details?: Record<string, unknown> | undefined;
|
|
502
|
+
sql?: string | undefined;
|
|
503
|
+
cause?: Error | undefined;
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Authentication error (401-type: invalid credentials, expired tokens)
|
|
508
|
+
*/
|
|
509
|
+
declare class AuthenticationError extends DbMcpError {
|
|
510
|
+
constructor(message: string, code?: string, options?: {
|
|
511
|
+
suggestion?: string | undefined;
|
|
512
|
+
details?: Record<string, unknown> | undefined;
|
|
513
|
+
cause?: Error | undefined;
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Authorization error (403-type: insufficient permissions)
|
|
518
|
+
*/
|
|
519
|
+
declare class AuthorizationError extends DbMcpError {
|
|
520
|
+
constructor(message: string, code?: string, options?: {
|
|
521
|
+
suggestion?: string | undefined;
|
|
522
|
+
details?: Record<string, unknown> | undefined;
|
|
523
|
+
cause?: Error | undefined;
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* db-mcp - Database Adapter Interface
|
|
529
|
+
*
|
|
530
|
+
* Abstract base class for SQLite database adapters.
|
|
531
|
+
* Provides a consistent interface for SQLite database operations
|
|
532
|
+
* across WASM and native backend variants.
|
|
533
|
+
*
|
|
534
|
+
* Includes concrete default implementations for MCP registration
|
|
535
|
+
* (registerTool, registerResource, registerPrompt) that subclasses
|
|
536
|
+
* inherit. Override only if the adapter needs custom behavior.
|
|
537
|
+
*/
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Abstract base class for database adapters
|
|
541
|
+
*/
|
|
542
|
+
declare abstract class DatabaseAdapter {
|
|
543
|
+
/** Database type identifier */
|
|
544
|
+
abstract readonly type: DatabaseType;
|
|
545
|
+
/** Human-readable adapter name */
|
|
546
|
+
abstract readonly name: string;
|
|
547
|
+
/** Adapter version */
|
|
548
|
+
abstract readonly version: string;
|
|
549
|
+
/** Connection status */
|
|
550
|
+
protected connected: boolean;
|
|
551
|
+
/** Database configuration */
|
|
552
|
+
protected config: DatabaseConfig | null;
|
|
553
|
+
/**
|
|
554
|
+
* Connect to the database
|
|
555
|
+
* @param config - Database connection configuration
|
|
556
|
+
*/
|
|
557
|
+
abstract connect(config: DatabaseConfig): Promise<void>;
|
|
558
|
+
/**
|
|
559
|
+
* Disconnect from the database
|
|
560
|
+
*/
|
|
561
|
+
abstract disconnect(): Promise<void>;
|
|
562
|
+
/**
|
|
563
|
+
* Check if connected to the database
|
|
564
|
+
*/
|
|
565
|
+
isConnected(): boolean;
|
|
566
|
+
/**
|
|
567
|
+
* Get health status of the database connection
|
|
568
|
+
*/
|
|
569
|
+
abstract getHealth(): Promise<HealthStatus>;
|
|
570
|
+
/**
|
|
571
|
+
* Execute a read-only query (SELECT)
|
|
572
|
+
* @param sql - SQL query string
|
|
573
|
+
* @param params - Query parameters for prepared statements
|
|
574
|
+
*/
|
|
575
|
+
abstract executeReadQuery(sql: string, params?: unknown[]): Promise<QueryResult>;
|
|
576
|
+
/**
|
|
577
|
+
* Execute a write query (INSERT, UPDATE, DELETE)
|
|
578
|
+
* @param sql - SQL query string
|
|
579
|
+
* @param params - Query parameters for prepared statements
|
|
580
|
+
* @param skipValidation - Skip security validation (for trusted internal operations)
|
|
581
|
+
*/
|
|
582
|
+
abstract executeWriteQuery(sql: string, params?: unknown[], skipValidation?: boolean): Promise<QueryResult>;
|
|
583
|
+
/**
|
|
584
|
+
* Execute any query (for admin operations)
|
|
585
|
+
* @param sql - SQL query string
|
|
586
|
+
* @param params - Query parameters for prepared statements
|
|
587
|
+
*/
|
|
588
|
+
abstract executeQuery(sql: string, params?: unknown[]): Promise<QueryResult>;
|
|
589
|
+
/**
|
|
590
|
+
* Get full database schema information
|
|
591
|
+
*/
|
|
592
|
+
abstract getSchema(): Promise<SchemaInfo>;
|
|
593
|
+
/**
|
|
594
|
+
* List all tables in the database
|
|
595
|
+
*/
|
|
596
|
+
abstract listTables(): Promise<TableInfo[]>;
|
|
597
|
+
/**
|
|
598
|
+
* Describe a specific table's structure
|
|
599
|
+
* @param tableName - Name of the table
|
|
600
|
+
*/
|
|
601
|
+
abstract describeTable(tableName: string): Promise<TableInfo>;
|
|
602
|
+
/**
|
|
603
|
+
* List available schemas/databases
|
|
604
|
+
*/
|
|
605
|
+
abstract listSchemas(): Promise<string[]>;
|
|
606
|
+
/**
|
|
607
|
+
* Get adapter capabilities
|
|
608
|
+
*/
|
|
609
|
+
abstract getCapabilities(): AdapterCapabilities;
|
|
610
|
+
/**
|
|
611
|
+
* Get supported tool groups for this adapter
|
|
612
|
+
*/
|
|
613
|
+
abstract getSupportedToolGroups(): ToolGroup[];
|
|
614
|
+
/**
|
|
615
|
+
* Get all tool definitions for this adapter
|
|
616
|
+
*/
|
|
617
|
+
abstract getToolDefinitions(): ToolDefinition[];
|
|
618
|
+
/**
|
|
619
|
+
* Get all resource definitions for this adapter
|
|
620
|
+
*/
|
|
621
|
+
abstract getResourceDefinitions(): ResourceDefinition[];
|
|
622
|
+
/**
|
|
623
|
+
* Get all prompt definitions for this adapter
|
|
624
|
+
*/
|
|
625
|
+
abstract getPromptDefinitions(): PromptDefinition[];
|
|
626
|
+
/**
|
|
627
|
+
* Register tools with the MCP server
|
|
628
|
+
* @param server - MCP server instance
|
|
629
|
+
* @param filterConfig - Tool filter configuration
|
|
630
|
+
*/
|
|
631
|
+
registerTools(server: McpServer, filterConfig: ToolFilterConfig): void;
|
|
632
|
+
/**
|
|
633
|
+
* Register a single tool with the MCP server.
|
|
634
|
+
* Uses modern registerTool() API for MCP 2025-11-25 compliance.
|
|
635
|
+
* Subclasses may override for custom behavior.
|
|
636
|
+
*/
|
|
637
|
+
protected registerTool(server: McpServer, tool: ToolDefinition): void;
|
|
638
|
+
/**
|
|
639
|
+
* Register resources with the MCP server
|
|
640
|
+
*/
|
|
641
|
+
registerResources(server: McpServer): void;
|
|
642
|
+
/**
|
|
643
|
+
* Register a single resource with the MCP server.
|
|
644
|
+
* Handles both static resources and URI templates.
|
|
645
|
+
* Subclasses may override for custom behavior.
|
|
646
|
+
*/
|
|
647
|
+
protected registerResource(server: McpServer, resource: ResourceDefinition): void;
|
|
648
|
+
/**
|
|
649
|
+
* Register prompts with the MCP server
|
|
650
|
+
*/
|
|
651
|
+
registerPrompts(server: McpServer): void;
|
|
652
|
+
/**
|
|
653
|
+
* Register a single prompt with the MCP server.
|
|
654
|
+
* Subclasses may override for custom behavior.
|
|
655
|
+
*/
|
|
656
|
+
protected registerPrompt(server: McpServer, prompt: PromptDefinition): void;
|
|
657
|
+
/**
|
|
658
|
+
* Validate query for safety (SQL injection prevention)
|
|
659
|
+
* @param sql - SQL query to validate
|
|
660
|
+
* @param isReadOnly - Whether to enforce read-only restrictions
|
|
661
|
+
*/
|
|
662
|
+
protected validateQuery(sql: string, isReadOnly: boolean): void;
|
|
663
|
+
/**
|
|
664
|
+
* Create a request context for tool execution
|
|
665
|
+
* @param requestId Optional request ID for tracing
|
|
666
|
+
* @param server Optional MCP Server instance for progress notifications
|
|
667
|
+
* @param progressToken Optional progress token from client request _meta
|
|
668
|
+
*/
|
|
669
|
+
createContext(requestId?: string, server?: unknown, progressToken?: string | number): RequestContext;
|
|
670
|
+
/**
|
|
671
|
+
* Ensure the adapter is connected to the database.
|
|
672
|
+
* Throws ConnectionError if not connected.
|
|
673
|
+
* Subclasses may override to add additional checks (e.g., db instance null).
|
|
674
|
+
*/
|
|
675
|
+
protected ensureConnected(): void;
|
|
676
|
+
/**
|
|
677
|
+
* Get adapter info for logging/debugging
|
|
678
|
+
*/
|
|
679
|
+
getInfo(): Record<string, unknown>;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* db-mcp - Main MCP Server
|
|
684
|
+
*
|
|
685
|
+
* SQLite MCP server with OAuth 2.1 authentication,
|
|
686
|
+
* HTTP/SSE transport, and dynamic tool filtering.
|
|
687
|
+
*/
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Main db-mcp server class
|
|
691
|
+
*
|
|
692
|
+
* Manages database adapters, tool registration, and MCP protocol handling.
|
|
693
|
+
*/
|
|
694
|
+
declare class DbMcpServer {
|
|
695
|
+
private server;
|
|
696
|
+
private adapters;
|
|
697
|
+
private toolFilter;
|
|
698
|
+
private config;
|
|
699
|
+
constructor(config: McpServerConfig);
|
|
700
|
+
/**
|
|
701
|
+
* Register a database adapter
|
|
702
|
+
*/
|
|
703
|
+
registerAdapter(adapter: DatabaseAdapter, config: DatabaseConfig): Promise<void>;
|
|
704
|
+
/**
|
|
705
|
+
* Get an adapter by ID
|
|
706
|
+
*/
|
|
707
|
+
getAdapter(adapterId: string): DatabaseAdapter | undefined;
|
|
708
|
+
/**
|
|
709
|
+
* Get all registered adapters
|
|
710
|
+
*/
|
|
711
|
+
getAdapters(): Map<string, DatabaseAdapter>;
|
|
712
|
+
/**
|
|
713
|
+
* Register built-in server tools (health, info, etc.)
|
|
714
|
+
*/
|
|
715
|
+
private registerBuiltInTools;
|
|
716
|
+
/**
|
|
717
|
+
* Register sqlite://help resources for on-demand reference documentation.
|
|
718
|
+
* Always registers sqlite://help (gotchas). Group-specific help is filtered
|
|
719
|
+
* by the tool filter configuration.
|
|
720
|
+
*/
|
|
721
|
+
private registerHelpResources;
|
|
722
|
+
/**
|
|
723
|
+
* Start the server with the configured transport
|
|
724
|
+
*/
|
|
725
|
+
start(): Promise<void>;
|
|
726
|
+
/**
|
|
727
|
+
* Start server with stdio transport
|
|
728
|
+
*/
|
|
729
|
+
private startStdio;
|
|
730
|
+
/**
|
|
731
|
+
* Start server with HTTP transport (Streamable HTTP with SSE support)
|
|
732
|
+
*/
|
|
733
|
+
private startHttp;
|
|
734
|
+
/**
|
|
735
|
+
* Gracefully shut down the server
|
|
736
|
+
*/
|
|
737
|
+
shutdown(): Promise<void>;
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Create and configure a db-mcp server instance
|
|
741
|
+
*/
|
|
742
|
+
declare function createServer(config: McpServerConfig): DbMcpServer;
|
|
743
|
+
/**
|
|
744
|
+
* Default server configuration
|
|
745
|
+
*/
|
|
746
|
+
declare const DEFAULT_CONFIG: Partial<McpServerConfig>;
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* db-mcp - Tool Constants
|
|
750
|
+
*
|
|
751
|
+
* Defines the tool groups and meta-groups used for filtering.
|
|
752
|
+
*
|
|
753
|
+
* Actual tool groups (from code audit):
|
|
754
|
+
* core: 9 tools (core/queries.ts, core/tables.ts, core/indexes.ts)
|
|
755
|
+
* json: 23 tools (json-operations/crud+query+transform.ts, json-helpers/read+write.ts)
|
|
756
|
+
* text: 13 WASM / 17 Native (text/regex+formatting+search+validate.ts, fts.ts)
|
|
757
|
+
* stats: 13 WASM / 19 Native (stats/basic+advanced.ts, native: window.ts)
|
|
758
|
+
* vector: 11 tools (vector/storage+search+metadata.ts)
|
|
759
|
+
* admin: 26 WASM / 33 Native (admin/backup+verify+pragma.ts, virtual/views+vtable+extensions+analysis.ts, native: transactions.ts)
|
|
760
|
+
* geo: 4 WASM / 11 Native (geo.ts, native: spatialite/tools+analysis.ts)
|
|
761
|
+
* introspection: 9 tools (introspection/graph/tools.ts, analysis/constraints+risks+snapshot.ts, diagnostics/storage+indexes+query-plan.ts)
|
|
762
|
+
* migration: 6 tools (migration/tracking.ts) — opt-in
|
|
763
|
+
* codemode: 1 tool (codemode.ts)
|
|
764
|
+
* Total: 115 WASM / 139 Native tools
|
|
765
|
+
*
|
|
766
|
+
* Note: 3 built-in server tools (server_info, server_health, list_adapters)
|
|
767
|
+
* are always available regardless of filter settings.
|
|
768
|
+
*/
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* All valid tool groups
|
|
772
|
+
*/
|
|
773
|
+
declare const ALL_TOOL_GROUPS: ToolGroup[];
|
|
774
|
+
/**
|
|
775
|
+
* Tool groups - kept for backwards compatibility with scopes.ts
|
|
776
|
+
* The actual filtering uses the tool's 'group' property, not these lists.
|
|
777
|
+
*/
|
|
778
|
+
declare const TOOL_GROUPS: Record<ToolGroup, string[]>;
|
|
779
|
+
/**
|
|
780
|
+
* Meta-groups that expand to multiple tool groups.
|
|
781
|
+
* These provide shortcuts for common use cases.
|
|
782
|
+
*/
|
|
783
|
+
declare const META_GROUPS: Record<MetaGroup, ToolGroup[]>;
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* db-mcp - Tool Filtering System
|
|
787
|
+
*
|
|
788
|
+
* Parses and applies tool filter rules from environment variables.
|
|
789
|
+
* Compatible with postgres-mcp-server filtering syntax.
|
|
790
|
+
*
|
|
791
|
+
* Syntax:
|
|
792
|
+
* groupName → Enable only this group (whitelist mode)
|
|
793
|
+
* shortcut → Use a preset (starter, analytics, search, etc.)
|
|
794
|
+
* -group → Disable all tools in a group
|
|
795
|
+
* +group → Enable all tools in a group
|
|
796
|
+
* -tool → Disable a specific tool
|
|
797
|
+
* +tool → Enable a specific tool
|
|
798
|
+
*
|
|
799
|
+
* Mode Detection:
|
|
800
|
+
* - If first token starts with '-', start with ALL groups enabled (exclusion mode)
|
|
801
|
+
* - Otherwise, start with NO groups enabled (whitelist mode)
|
|
802
|
+
*
|
|
803
|
+
* Examples:
|
|
804
|
+
* "core,json" → Whitelist: only core and json groups
|
|
805
|
+
* "starter" → Preset: core + json + text groups
|
|
806
|
+
* "starter,-fts5" → Preset minus fts5 group
|
|
807
|
+
* "-vector,-geo" → Legacy: all groups except vector and geo
|
|
808
|
+
*/
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Parse a tool filter string into structured rules
|
|
812
|
+
*
|
|
813
|
+
* @param filterString - The filter string (e.g., "starter" or "-vector,-geo")
|
|
814
|
+
* @returns Parsed filter configuration with enabled groups
|
|
815
|
+
*/
|
|
816
|
+
declare function parseToolFilter(filterString: string | undefined): ToolFilterConfig;
|
|
817
|
+
/**
|
|
818
|
+
* Check if a tool is enabled based on filter configuration
|
|
819
|
+
* Uses the tool's group property for matching
|
|
820
|
+
*/
|
|
821
|
+
declare function isToolEnabled(tool: ToolDefinition, config: ToolFilterConfig): boolean;
|
|
822
|
+
/**
|
|
823
|
+
* Filter a list of tool definitions based on filter configuration
|
|
824
|
+
*/
|
|
825
|
+
declare function filterTools(tools: ToolDefinition[], config: ToolFilterConfig): ToolDefinition[];
|
|
826
|
+
/**
|
|
827
|
+
* Get the tool filter from environment variable
|
|
828
|
+
*/
|
|
829
|
+
declare function getToolFilterFromEnv(): ToolFilterConfig;
|
|
830
|
+
/**
|
|
831
|
+
* Generate a summary of the current filter configuration
|
|
832
|
+
*/
|
|
833
|
+
declare function getFilterSummary(config: ToolFilterConfig): string;
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Version Constants
|
|
837
|
+
*
|
|
838
|
+
* Single source of truth — reads from package.json at runtime.
|
|
839
|
+
*/
|
|
840
|
+
/** Server version from package.json */
|
|
841
|
+
declare const VERSION: string;
|
|
842
|
+
/** Package name from package.json */
|
|
843
|
+
declare const NAME: string;
|
|
844
|
+
|
|
845
|
+
export { ALL_TOOL_GROUPS, type AdapterCapabilities, AuthenticationError, AuthorizationError, type ColumnInfo, ConnectionError, type ConstraintInfo, DEFAULT_CONFIG, DatabaseAdapter, type DatabaseConfig, type DatabaseType, DbMcpError, DbMcpServer, type HealthStatus, type IndexInfo, META_GROUPS, type McpServerConfig, NAME, type OAuthConfig, type OAuthScope, type PromptDefinition, QueryError, type QueryResult, type RequestContext, type ResourceDefinition, type SchemaInfo, TOOL_GROUPS, type TableInfo, type TokenClaims, type ToolDefinition, type ToolFilterConfig, type ToolFilterRule, type ToolGroup, type TransportType, VERSION, ValidationError, createServer, filterTools, getFilterSummary, getToolFilterFromEnv, isToolEnabled, parseToolFilter };
|