@berthojoris/mcp-mysql-server 1.43.5 → 1.45.2

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.
Files changed (66) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/DOCUMENTATIONS.md +674 -508
  3. package/README.md +468 -376
  4. package/bin/mcp-mysql.js +214 -168
  5. package/dist/cache/queryCache.js +1 -1
  6. package/dist/config/config.js +2 -1
  7. package/dist/config/featureConfig.d.ts +5 -0
  8. package/dist/config/featureConfig.js +11 -13
  9. package/dist/config/runtimeConfig.d.ts +50 -0
  10. package/dist/config/runtimeConfig.js +173 -0
  11. package/dist/db/connection.d.ts +40 -1
  12. package/dist/db/connection.js +188 -22
  13. package/dist/mcp-server.js +248 -375
  14. package/dist/security/grantInspector.d.ts +5 -0
  15. package/dist/security/grantInspector.js +32 -0
  16. package/dist/security/securityLayer.d.ts +21 -2
  17. package/dist/security/securityLayer.js +151 -21
  18. package/dist/server/auditLogger.d.ts +24 -0
  19. package/dist/server/auditLogger.js +60 -0
  20. package/dist/server/auth.d.ts +56 -0
  21. package/dist/server/auth.js +274 -0
  22. package/dist/server/httpServer.d.ts +22 -0
  23. package/dist/server/httpServer.js +320 -0
  24. package/dist/server/rateLimiter.d.ts +15 -0
  25. package/dist/server/rateLimiter.js +41 -0
  26. package/dist/server/requestContext.d.ts +12 -0
  27. package/dist/server/requestContext.js +9 -0
  28. package/dist/tools/toolAnnotations.d.ts +4 -0
  29. package/dist/tools/toolAnnotations.js +73 -0
  30. package/dist/tools/toolArgumentValidation.js +22 -22
  31. package/dist/tools/toolRegistry.d.ts +1 -1
  32. package/dist/tools/toolRegistry.js +7 -1
  33. package/manifest.json +1 -1
  34. package/package.json +86 -78
  35. package/dist/auth/authService.d.ts +0 -29
  36. package/dist/auth/authService.js +0 -114
  37. package/dist/tools/backupRestoreTools.d.ts +0 -18
  38. package/dist/tools/backupRestoreTools.js +0 -70
  39. package/dist/tools/documentationGeneratorTools.d.ts +0 -145
  40. package/dist/tools/documentationGeneratorTools.js +0 -820
  41. package/dist/tools/forecastingTools.d.ts +0 -36
  42. package/dist/tools/forecastingTools.js +0 -256
  43. package/dist/tools/functionTools.d.ts +0 -87
  44. package/dist/tools/functionTools.js +0 -358
  45. package/dist/tools/indexRecommendationTools.d.ts +0 -50
  46. package/dist/tools/indexRecommendationTools.js +0 -451
  47. package/dist/tools/intelligentQueryTools.d.ts +0 -94
  48. package/dist/tools/intelligentQueryTools.js +0 -713
  49. package/dist/tools/performanceTools.d.ts +0 -76
  50. package/dist/tools/performanceTools.js +0 -505
  51. package/dist/tools/processTools.d.ts +0 -61
  52. package/dist/tools/processTools.js +0 -181
  53. package/dist/tools/queryVisualizationTools.d.ts +0 -22
  54. package/dist/tools/queryVisualizationTools.js +0 -155
  55. package/dist/tools/schemaDesignTools.d.ts +0 -67
  56. package/dist/tools/schemaDesignTools.js +0 -359
  57. package/dist/tools/schemaPatternTools.d.ts +0 -19
  58. package/dist/tools/schemaPatternTools.js +0 -253
  59. package/dist/tools/schemaVersioningTools.d.ts +0 -138
  60. package/dist/tools/schemaVersioningTools.js +0 -1008
  61. package/dist/tools/securityAuditTools.d.ts +0 -39
  62. package/dist/tools/securityAuditTools.js +0 -319
  63. package/dist/tools/smartDiscoveryTools.d.ts +0 -163
  64. package/dist/tools/smartDiscoveryTools.js +0 -750
  65. package/dist/tools/testDataTools.d.ts +0 -26
  66. package/dist/tools/testDataTools.js +0 -325
package/bin/mcp-mysql.js CHANGED
@@ -1,168 +1,214 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * MCP MySQL Server CLI
5
- * This script allows the MySQL MCP server to be run via NPX
6
- * It implements the Model Context Protocol using stdio transport
7
- */
8
-
9
- const dotenv = require("dotenv");
10
-
11
- dotenv.config();
12
-
13
- // Get MySQL connection string, permissions, and optional categories
14
- const args = process.argv.slice(2);
15
- const mysqlUrl = args.shift();
16
-
17
- let permissions;
18
- let categories;
19
-
20
- for (let i = 0; i < args.length; i++) {
21
- const arg = args[i];
22
-
23
- if (permissions === undefined) {
24
- permissions = arg;
25
- continue;
26
- }
27
-
28
- if (categories === undefined) {
29
- categories = arg;
30
- continue;
31
- }
32
- }
33
-
34
- if (!mysqlUrl) {
35
- console.error("Error: MySQL connection URL is required");
36
- console.error(
37
- "Usage: mcp-mysql mysql://user:password@host:port/dbname [permissions] [categories]",
38
- );
39
- console.error("");
40
- console.error("Examples:");
41
- console.error(" # All tools enabled (no filtering)");
42
- console.error(" mcp-mysql mysql://root:pass@localhost:3306/mydb");
43
- console.error("");
44
- console.error(" # Permission-based filtering only (Layer 1)");
45
- console.error(
46
- ' mcp-mysql mysql://root:pass@localhost:3306/mydb "list,read,utility"',
47
- );
48
- console.error("");
49
- console.error(
50
- " # Dual-layer: Permissions + Categories (fine-grained control)",
51
- );
52
- console.error(
53
- ' mcp-mysql mysql://root:pass@localhost:3306/mydb "list,read,utility" "database_discovery,custom_queries,analysis"',
54
- );
55
- console.error("");
56
- console.error("Permissions (Layer 1 - Broad Control):");
57
- console.error(
58
- " list, read, create, update, delete, execute, ddl, utility, transaction, procedure",
59
- );
60
- console.error("");
61
- console.error("Categories (Layer 2 - Fine-Grained Control, Optional):");
62
- console.error(
63
- " database_discovery, crud_operations, bulk_operations, custom_queries,",
64
- );
65
- console.error(
66
- " schema_management, utilities, transaction_management, stored_procedures,",
67
- );
68
- console.error(
69
- " views_management, triggers_management, index_management,",
70
- );
71
- console.error(
72
- " constraint_management, table_maintenance, query_optimization,",
73
- );
74
- console.error(
75
- " analysis, seed_operations",
76
- );
77
- console.error("");
78
- console.error("Filtering Logic:");
79
- console.error(
80
- " - If only permissions: All tools within those permissions enabled",
81
- );
82
- console.error(
83
- " - If permissions + categories: Only tools matching BOTH layers enabled",
84
- );
85
- console.error(" - If nothing specified: All tools enabled");
86
- process.exit(1);
87
- }
88
-
89
- // Parse the MySQL URL to extract connection details
90
- let connectionConfig;
91
- let database;
92
- try {
93
- const url = new URL(mysqlUrl);
94
-
95
- // Remove leading slash from pathname and make database optional
96
- database = url.pathname.replace(/^\//, "") || null;
97
-
98
- // Extract username and password from auth.
99
- // Both fields may be URL-encoded (e.g. "@" -> "%40"), so always decode
100
- // whatever the URL parser hands us, including when only one side is set.
101
- const decodeAuthField = (value) =>
102
- value ? decodeURIComponent(value) : value;
103
- const auth = {
104
- user: decodeAuthField(url.username) || "root",
105
- password: decodeAuthField(url.password) || "",
106
- };
107
-
108
- connectionConfig = {
109
- host: url.hostname,
110
- port: url.port || 3306,
111
- ...auth,
112
- ...(database ? { database } : {}),
113
- };
114
-
115
- // Set environment variables for the server
116
- process.env.DB_HOST = connectionConfig.host;
117
- process.env.DB_PORT = connectionConfig.port;
118
- process.env.DB_USER = connectionConfig.user;
119
- process.env.DB_PASSWORD = connectionConfig.password;
120
- if (database) {
121
- process.env.DB_NAME = database;
122
- }
123
- } catch (error) {
124
- console.error("Error parsing MySQL URL:", error.message);
125
- console.error(
126
- "Usage: npx @berthojoris/mcp-mysql-server mysql://user:password@host:port/dbname",
127
- );
128
- process.exit(1);
129
- }
130
-
131
- const dbMessage = database
132
- ? `${connectionConfig.host}:${connectionConfig.port}/${database}`
133
- : `${connectionConfig.host}:${connectionConfig.port} (no specific database selected)`;
134
-
135
- // Set permissions/categories as environment variables if provided
136
- if (permissions) {
137
- process.env.MCP_PERMISSIONS = permissions;
138
- console.error(`Permissions (Layer 1): ${permissions}`);
139
- }
140
-
141
- if (categories) {
142
- process.env.MCP_CATEGORIES = categories;
143
- console.error(`Categories (Layer 2): ${categories}`);
144
- }
145
-
146
- if (!permissions && !categories) {
147
- console.error("Access Control: All tools enabled (no filtering)");
148
- } else if (permissions && categories) {
149
- console.error("Filtering Mode: Dual-layer (Permissions + Categories)");
150
- } else if (permissions && !categories) {
151
- console.error("Filtering Mode: Permission-based only");
152
- } else if (!permissions && categories) {
153
- console.error("Filtering Mode: Category-only");
154
- }
155
-
156
- // Log to stderr (not stdout, which is used for MCP protocol)
157
- console.error(`Starting MySQL MCP server with connection to ${dbMessage}`);
158
-
159
- // Run the MCP server directly (no child process spawn)
160
- // This ensures proper stdio communication for MCP protocol
161
- try {
162
- // Directly require and execute the MCP server module
163
- // This avoids stdio forwarding issues with child processes
164
- require("../dist/mcp-server.js");
165
- } catch (error) {
166
- console.error("Error starting MCP server:", error.message);
167
- process.exit(1);
168
- }
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * MCP MySQL Server CLI
5
+ * This script allows the MySQL MCP server to be run via NPX
6
+ * It implements the Model Context Protocol using stdio transport (default)
7
+ * or, when enabled, the Streamable HTTP transport
8
+ */
9
+
10
+ const dotenv = require("dotenv");
11
+
12
+ dotenv.config();
13
+
14
+ // Transport flags map to environment variables; a flag overrides the variable.
15
+ // They are taken out first so they are never read as permissions/categories.
16
+ const FLAG_ENV = {
17
+ transport: "MCP_TRANSPORT",
18
+ host: "MCP_HTTP_HOST",
19
+ port: "MCP_HTTP_PORT",
20
+ };
21
+
22
+ const positional = [];
23
+ const rawArgs = process.argv.slice(2);
24
+ for (let i = 0; i < rawArgs.length; i++) {
25
+ const arg = rawArgs[i];
26
+ if (!arg.startsWith("--")) {
27
+ positional.push(arg);
28
+ continue;
29
+ }
30
+
31
+ if (arg === "--http" || arg === "--stdio") {
32
+ process.env.MCP_TRANSPORT = arg.slice(2);
33
+ continue;
34
+ }
35
+
36
+ const [flag, inlineValue] = arg.slice(2).split(/=(.*)/s);
37
+ const envName = FLAG_ENV[flag];
38
+ if (!envName) {
39
+ console.error(`Error: unknown option ${arg}`);
40
+ console.error("Options: --transport=stdio|http, --http, --stdio, --host=<addr>, --port=<n>");
41
+ process.exit(1);
42
+ }
43
+ const value = inlineValue !== undefined ? inlineValue : rawArgs[++i];
44
+ if (value === undefined || value === "") {
45
+ console.error(`Error: option --${flag} requires a value`);
46
+ process.exit(1);
47
+ }
48
+ process.env[envName] = value;
49
+ }
50
+
51
+ // Get MySQL connection string, permissions, and optional categories
52
+ const args = positional;
53
+ const mysqlUrl = args.shift();
54
+
55
+ let permissions;
56
+ let categories;
57
+
58
+ for (let i = 0; i < args.length; i++) {
59
+ const arg = args[i];
60
+
61
+ if (permissions === undefined) {
62
+ permissions = arg;
63
+ continue;
64
+ }
65
+
66
+ if (categories === undefined) {
67
+ categories = arg;
68
+ continue;
69
+ }
70
+ }
71
+
72
+ if (!mysqlUrl) {
73
+ console.error("Error: MySQL connection URL is required");
74
+ console.error(
75
+ "Usage: mcp-mysql mysql://user:password@host:port/dbname [permissions] [categories] [--transport=stdio|http] [--host=<addr>] [--port=<n>]",
76
+ );
77
+ console.error("");
78
+ console.error("Examples:");
79
+ console.error(" # Read-only default (list,read,utility)");
80
+ console.error(" mcp-mysql mysql://root:pass@localhost:3306/mydb");
81
+ console.error("");
82
+ console.error(" # Permission-based filtering only (Layer 1)");
83
+ console.error(
84
+ ' mcp-mysql mysql://root:pass@localhost:3306/mydb "list,read,utility"',
85
+ );
86
+ console.error("");
87
+ console.error(
88
+ " # Dual-layer: Permissions + Categories (fine-grained control)",
89
+ );
90
+ console.error(
91
+ ' mcp-mysql mysql://root:pass@localhost:3306/mydb "list,read,utility" "database_discovery,custom_queries,analysis"',
92
+ );
93
+ console.error("");
94
+ console.error("Permissions (Layer 1 - Broad Control):");
95
+ console.error(
96
+ " list, read, create, update, delete, execute, ddl, utility, transaction, procedure",
97
+ );
98
+ console.error("");
99
+ console.error("Categories (Layer 2 - Fine-Grained Control, Optional):");
100
+ console.error(
101
+ " database_discovery, crud_operations, bulk_operations, custom_queries,",
102
+ );
103
+ console.error(
104
+ " schema_management, utilities, transaction_management, stored_procedures,",
105
+ );
106
+ console.error(
107
+ " views_management, triggers_management, index_management,",
108
+ );
109
+ console.error(
110
+ " constraint_management, table_maintenance, query_optimization,",
111
+ );
112
+ console.error(
113
+ " analysis, seed_operations",
114
+ );
115
+ console.error("");
116
+ console.error("Filtering Logic:");
117
+ console.error(
118
+ " - If only permissions: All tools within those permissions enabled",
119
+ );
120
+ console.error(
121
+ " - If permissions + categories: Only tools matching BOTH layers enabled",
122
+ );
123
+ console.error(" - If nothing specified: Read-only default (list,read,utility)");
124
+ console.error("");
125
+ console.error("Transport (default stdio):");
126
+ console.error(
127
+ ' mcp-mysql mysql://reader:pass@localhost:3306/mydb "list,read,utility" --transport=http --port=3000',
128
+ );
129
+ console.error(
130
+ " Or set MCP_TRANSPORT=http. HTTP settings (auth, allowed hosts, limits): see DOCUMENTATIONS.md",
131
+ );
132
+ process.exit(1);
133
+ }
134
+
135
+ // Parse the MySQL URL to extract connection details
136
+ let connectionConfig;
137
+ let database;
138
+ try {
139
+ const url = new URL(mysqlUrl);
140
+
141
+ // Remove leading slash from pathname and make database optional
142
+ database = url.pathname.replace(/^\//, "") || null;
143
+
144
+ // Extract username and password from auth.
145
+ // Both fields may be URL-encoded (e.g. "@" -> "%40"), so always decode
146
+ // whatever the URL parser hands us, including when only one side is set.
147
+ const decodeAuthField = (value) =>
148
+ value ? decodeURIComponent(value) : value;
149
+ const auth = {
150
+ user: decodeAuthField(url.username) || "root",
151
+ password: decodeAuthField(url.password) || "",
152
+ };
153
+
154
+ connectionConfig = {
155
+ host: url.hostname,
156
+ port: url.port || 3306,
157
+ ...auth,
158
+ ...(database ? { database } : {}),
159
+ };
160
+
161
+ // Set environment variables for the server
162
+ process.env.DB_HOST = connectionConfig.host;
163
+ process.env.DB_PORT = connectionConfig.port;
164
+ process.env.DB_USER = connectionConfig.user;
165
+ process.env.DB_PASSWORD = connectionConfig.password;
166
+ if (database) {
167
+ process.env.DB_NAME = database;
168
+ }
169
+ } catch (error) {
170
+ console.error("Error parsing MySQL URL:", error.message);
171
+ console.error(
172
+ "Usage: npx @berthojoris/mcp-mysql-server mysql://user:password@host:port/dbname",
173
+ );
174
+ process.exit(1);
175
+ }
176
+
177
+ const dbMessage = database
178
+ ? `${connectionConfig.host}:${connectionConfig.port}/${database}`
179
+ : `${connectionConfig.host}:${connectionConfig.port} (no specific database selected)`;
180
+
181
+ // Set permissions/categories as environment variables if provided
182
+ if (permissions) {
183
+ process.env.MCP_PERMISSIONS = permissions;
184
+ console.error(`Permissions (Layer 1): ${permissions}`);
185
+ }
186
+
187
+ if (categories) {
188
+ process.env.MCP_CATEGORIES = categories;
189
+ console.error(`Categories (Layer 2): ${categories}`);
190
+ }
191
+
192
+ if (!permissions && !categories) {
193
+ console.error("Access Control: Read-only default (list,read,utility)");
194
+ } else if (permissions && categories) {
195
+ console.error("Filtering Mode: Dual-layer (Permissions + Categories)");
196
+ } else if (permissions && !categories) {
197
+ console.error("Filtering Mode: Permission-based only");
198
+ } else if (!permissions && categories) {
199
+ console.error("Filtering Mode: Category-only");
200
+ }
201
+
202
+ // Log to stderr (not stdout, which is used for MCP protocol)
203
+ console.error(`Starting MySQL MCP server with connection to ${dbMessage}`);
204
+
205
+ // Run the MCP server directly (no child process spawn)
206
+ // This ensures proper stdio communication for MCP protocol
207
+ try {
208
+ // Directly require and execute the MCP server module
209
+ // This avoids stdio forwarding issues with child processes
210
+ require("../dist/mcp-server.js");
211
+ } catch (error) {
212
+ console.error("Error starting MCP server:", error.message);
213
+ process.exit(1);
214
+ }
@@ -9,7 +9,7 @@ const crypto_1 = __importDefault(require("crypto"));
9
9
  * Default cache configuration
10
10
  */
11
11
  const DEFAULT_CONFIG = {
12
- enabled: true,
12
+ enabled: false, // Opt in with CACHE_ENABLED=true; writes by other clients are not detected
13
13
  ttlMs: 60000, // 1 minute default TTL
14
14
  maxSize: 100, // Maximum 100 cached queries
15
15
  maxMemoryMB: 50, // Maximum 50MB memory usage
@@ -12,7 +12,8 @@ exports.dbConfig = {
12
12
  port: parseInt(process.env.DB_PORT || '3306', 10),
13
13
  user: process.env.DB_USER || 'root',
14
14
  password: process.env.DB_PASSWORD || '',
15
- database: process.env.DB_NAME || 'mysql',
15
+ // Empty means no database selected; never default to the mysql system schema
16
+ database: process.env.DB_NAME || '',
16
17
  };
17
18
  exports.default = {
18
19
  database: exports.dbConfig,
@@ -43,6 +43,11 @@ export declare const toolCategoryMap: Record<string, ToolCategory>;
43
43
  * Map of tool names to their documentation categories (New Enhanced System)
44
44
  */
45
45
  export declare const toolDocCategoryMap: Record<string, DocCategory>;
46
+ /**
47
+ * Permissions used when neither permissions nor categories are configured.
48
+ * Read-only by default; write and schema access must be granted explicitly.
49
+ */
50
+ export declare const DEFAULT_PERMISSIONS = "list,read,utility";
46
51
  /**
47
52
  * Class to manage feature configuration based on runtime or environment variables
48
53
  * Supports dual-layer filtering:
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.featureConfig = exports.FeatureConfig = exports.toolDocCategoryMap = exports.toolCategoryMap = exports.DocCategory = exports.ToolCategory = void 0;
6
+ exports.featureConfig = exports.FeatureConfig = exports.DEFAULT_PERMISSIONS = exports.toolDocCategoryMap = exports.toolCategoryMap = exports.DocCategory = exports.ToolCategory = void 0;
7
7
  const dotenv_1 = __importDefault(require("dotenv"));
8
8
  // Load environment variables
9
9
  dotenv_1.default.config();
@@ -365,6 +365,11 @@ const legacyToDocCategoryMap = {
365
365
  transaction: [DocCategory.TRANSACTION_MANAGEMENT, DocCategory.SEED_OPERATIONS],
366
366
  procedure: [DocCategory.STORED_PROCEDURES],
367
367
  };
368
+ /**
369
+ * Permissions used when neither permissions nor categories are configured.
370
+ * Read-only by default; write and schema access must be granted explicitly.
371
+ */
372
+ exports.DEFAULT_PERMISSIONS = "list,read,utility";
368
373
  /**
369
374
  * Class to manage feature configuration based on runtime or environment variables
370
375
  * Supports dual-layer filtering:
@@ -403,12 +408,9 @@ class FeatureConfig {
403
408
  * Layer 2 (categories): Fine-grained control using documentation categories (optional)
404
409
  */
405
410
  parseConfig(permissionsStr, categoriesStr) {
406
- // If both are empty, enable all features
411
+ // If both are empty, fall back to the read-only default permissions
407
412
  if (!permissionsStr.trim() && !categoriesStr.trim()) {
408
- return {
409
- legacy: new Set(Object.values(ToolCategory)),
410
- doc: new Set(Object.values(DocCategory)),
411
- };
413
+ permissionsStr = exports.DEFAULT_PERMISSIONS;
412
414
  }
413
415
  // Parse Layer 1: Permissions (legacy categories)
414
416
  let legacySet = new Set();
@@ -504,11 +506,6 @@ class FeatureConfig {
504
506
  return (`Permission denied: This tool also requires '${missingPermission}' permission (Layer 1). ` +
505
507
  `Add '${missingPermission}' to the permissions argument.`);
506
508
  }
507
- const isAllEnabled = !this.originalPermissionsString.trim() &&
508
- !this.originalCategoriesString.trim();
509
- if (isAllEnabled) {
510
- return `Unknown error: All tools should be enabled but '${toolName}' was blocked.`;
511
- }
512
509
  // Build error message based on dual-layer or single-layer mode
513
510
  if (this.useDualLayer) {
514
511
  const hasPermission = legacyCategory
@@ -591,7 +588,8 @@ class FeatureConfig {
591
588
  */
592
589
  getConfigSnapshot() {
593
590
  return {
594
- permissions: this.originalPermissionsString || "all",
591
+ permissions: this.originalPermissionsString ||
592
+ (this.originalCategoriesString ? "all" : exports.DEFAULT_PERMISSIONS),
595
593
  categories: this.originalCategoriesString ||
596
594
  (this.useDualLayer ? "" : "derived from permissions"),
597
595
  filteringMode: this.getFilteringMode(),
@@ -605,7 +603,7 @@ class FeatureConfig {
605
603
  getFilteringMode() {
606
604
  if (!this.originalPermissionsString.trim() &&
607
605
  !this.originalCategoriesString.trim()) {
608
- return "No filtering (all tools enabled)";
606
+ return `Default read-only (${exports.DEFAULT_PERMISSIONS})`;
609
607
  }
610
608
  if (this.useDualLayer) {
611
609
  return "Dual-layer (Permissions + Categories)";
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Transport and protection settings. Everything here is opt-in: with no
3
+ * variables set the server runs over stdio with all protections disabled,
4
+ * exactly as before the HTTP transport existed.
5
+ */
6
+ export type TransportMode = "stdio" | "http";
7
+ export type HttpAuthMode = "none" | "token" | "oauth";
8
+ export interface OAuthConfig {
9
+ issuer: string;
10
+ audience: string;
11
+ jwksUri?: string;
12
+ requiredScopes: string[];
13
+ }
14
+ export interface HttpConfig {
15
+ host: string;
16
+ port: number;
17
+ path: string;
18
+ publicUrl?: string;
19
+ /** Public URL of the MCP endpoint (publicUrl + path), used as the OAuth resource id */
20
+ resourceUrl?: string;
21
+ auth: HttpAuthMode;
22
+ tokens: string[];
23
+ oauth?: OAuthConfig;
24
+ allowedHosts: string[];
25
+ allowedOrigins: string[];
26
+ trustProxy: boolean;
27
+ allowUnauthenticated: boolean;
28
+ maxSessions: number;
29
+ sessionIdleTimeoutMs: number;
30
+ maxBodyBytes: number;
31
+ }
32
+ export interface RuntimeConfig {
33
+ transport: TransportMode;
34
+ http: HttpConfig;
35
+ queryTimeoutMs: number;
36
+ rateLimitPerMinute: number;
37
+ maxResultBytes: number;
38
+ /** "off", "stderr", or a file path */
39
+ auditLog: string;
40
+ requireReadOnlyDbUser: boolean;
41
+ }
42
+ export declare const isLoopbackHost: (host: string) => boolean;
43
+ /**
44
+ * Parse settings from the environment. Throws with a readable message on
45
+ * invalid or unsafe combinations so the server refuses to start instead of
46
+ * running with a half-applied configuration.
47
+ */
48
+ export declare const loadRuntimeConfig: (env?: NodeJS.ProcessEnv) => RuntimeConfig;
49
+ /** Lazily loaded process-wide configuration. */
50
+ export declare const getRuntimeConfig: () => RuntimeConfig;