@dbx-app/mcp-server 0.4.26 → 0.4.28

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/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
  import { type Backend } from "@dbx-app/node-core";
4
4
  export declare const DBX_MCP_PACKAGE_VERSION: string;
5
- export declare const DBX_CONNECTION_TYPE_DESCRIPTION = "Database type: postgres, mysql, sqlite, rqlite, redis, duckdb, clickhouse, sqlserver, mongodb, oracle, elasticsearch, etcd, doris, starrocks, manticoresearch, milvus, qdrant, weaviate, chromadb, redshift, dameng, kingbase, highgo, vastbase, goldendb, databend, gaussdb, kwdb, yashandb, databricks, saphana, teradata, vertica, firebird, exasol, opengauss, oceanbase-oracle, questdb, gbase, h2, snowflake, trino, prestosql, hive, spark, db2, informix, influxdb, iris, neo4j, cassandra, bigquery, kylin, sundb, oscar, tdengine, iotdb, xugu, zookeeper, jdbc, access, mq";
5
+ export declare const DBX_CONNECTION_TYPE_DESCRIPTION = "Database type: postgres, mysql, sqlite, rqlite, cloudflare-d1, redis, duckdb, clickhouse, sqlserver, mongodb, oracle, elasticsearch, etcd, doris, starrocks, manticoresearch, milvus, qdrant, weaviate, chromadb, redshift, dameng, kingbase, highgo, vastbase, goldendb, databend, gaussdb, kwdb, yashandb, databricks, saphana, teradata, vertica, firebird, exasol, opengauss, oceanbase-oracle, questdb, gbase, h2, snowflake, trino, prestosql, hive, spark, db2, informix, influxdb, iris, neo4j, cassandra, bigquery, kylin, sundb, oscar, tdengine, iotdb, xugu, zookeeper, jdbc, access, mq";
6
6
  export declare function createDbxMcpServer(backend: Backend, options?: {
7
7
  isWebMode?: boolean;
8
8
  }): McpServer;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
4
  import { createRequire } from "node:module";
5
5
  import { z } from "zod";
6
- import { buildSchemaContext, createBackend, evaluateRedisCommandSafety, evaluateMongoAggregateSafety, evaluateSqlSafety, formatCell, formatSchemaContext, isMainModule, mdTable, notifyReload, parseMongoAggregateCommand, postBridge, sqlSafetyFromEnv, splitSqlStatements, } from "@dbx-app/node-core";
6
+ import { buildSchemaContext, createBackend, evaluateRedisCommandSafety, evaluateMongoAggregateSafety, evaluateSqlSafety, formatCell, formatSchemaContext, isMainModule, mdTable, notifyReload, parseMongoAggregateCommand, assessProductionSql, isLikelyMongoMutation, isProductionDatabase, postBridge, sqlSafetyFromEnv, splitSqlStatements, } from "@dbx-app/node-core";
7
7
  const require = createRequire(import.meta.url);
8
8
  const packageJson = require("../package.json");
9
9
  export const DBX_MCP_PACKAGE_VERSION = packageJson.version ?? "0.0.0";
@@ -57,7 +57,7 @@ function formatRedisCommandValue(value) {
57
57
  function formatRedisCommandToolResult(result) {
58
58
  return text(`Command: ${result.command}\nSafety: ${result.safety}\n\n${formatRedisCommandValue(result.value)}`);
59
59
  }
60
- export const DBX_CONNECTION_TYPE_DESCRIPTION = "Database type: postgres, mysql, sqlite, rqlite, redis, duckdb, clickhouse, sqlserver, mongodb, oracle, elasticsearch, etcd, doris, starrocks, manticoresearch, milvus, qdrant, weaviate, chromadb, redshift, dameng, kingbase, highgo, vastbase, goldendb, databend, gaussdb, kwdb, yashandb, databricks, saphana, teradata, vertica, firebird, exasol, opengauss, oceanbase-oracle, questdb, gbase, h2, snowflake, trino, prestosql, hive, spark, db2, informix, influxdb, iris, neo4j, cassandra, bigquery, kylin, sundb, oscar, tdengine, iotdb, xugu, zookeeper, jdbc, access, mq";
60
+ export const DBX_CONNECTION_TYPE_DESCRIPTION = "Database type: postgres, mysql, sqlite, rqlite, cloudflare-d1, redis, duckdb, clickhouse, sqlserver, mongodb, oracle, elasticsearch, etcd, doris, starrocks, manticoresearch, milvus, qdrant, weaviate, chromadb, redshift, dameng, kingbase, highgo, vastbase, goldendb, databend, gaussdb, kwdb, yashandb, databricks, saphana, teradata, vertica, firebird, exasol, opengauss, oceanbase-oracle, questdb, gbase, h2, snowflake, trino, prestosql, hive, spark, db2, informix, influxdb, iris, neo4j, cassandra, bigquery, kylin, sundb, oscar, tdengine, iotdb, xugu, zookeeper, jdbc, access, mq";
61
61
  const FILE_CAPABLE_CONNECTION_TYPES = new Set(["sqlite", "duckdb", "access", "h2"]);
62
62
  function scopedValue(value) {
63
63
  const trimmed = value?.trim();
@@ -185,6 +185,13 @@ export function createDbxMcpServer(backend, options = {}) {
185
185
  const safety = evaluateSqlSafety(sql, { ...sqlSafetyFromEnv(), allowMultipleStatements: true });
186
186
  if (!safety.allowed)
187
187
  return toolError("SQL_BLOCKED", safety.reason ?? "SQL blocked.");
188
+ const production = assessProductionSql(sql, scopedConfig, database ?? scope.database ?? scopedConfig.database);
189
+ if (production.active && production.isMutation) {
190
+ return toolError("PRODUCTION_WRITE_BLOCKED", "MCP cannot execute writes against a production database. Return the SQL for a user to review and run in DBX.");
191
+ }
192
+ }
193
+ else if (isProductionDatabase(scopedConfig, database ?? scope.database ?? scopedConfig.database) && isLikelyMongoMutation(sql)) {
194
+ return toolError("PRODUCTION_WRITE_BLOCKED", "MCP cannot execute writes against a production database. Return the command for a user to review and run in DBX.");
188
195
  }
189
196
  // MongoDB shell commands don't fit the SQL safety evaluator; the backend
190
197
  // (node-core executeQuery) applies command-aware read/write gating.
@@ -222,6 +229,9 @@ export function createDbxMcpServer(backend, options = {}) {
222
229
  const safety = evaluateRedisCommandSafety(command, sqlSafetyFromEnv());
223
230
  if (!safety.allowed)
224
231
  return toolError("REDIS_COMMAND_BLOCKED", safety.reason ?? "Redis command blocked.");
232
+ if (isProductionDatabase(scopedConfig, String(defaultRedisDb(scopedConfig, scope, db))) && safety.safety !== "allowed") {
233
+ return toolError("PRODUCTION_WRITE_BLOCKED", "MCP cannot execute write or dangerous Redis commands against a production database.");
234
+ }
225
235
  try {
226
236
  const result = await backend.executeRedisCommand(scopedConfig, defaultRedisDb(scopedConfig, scope, db), command, {
227
237
  skipSafetyCheck: safety.skipSafetyCheck,
@@ -258,11 +268,11 @@ export function createDbxMcpServer(backend, options = {}) {
258
268
  server.tool("dbx_add_connection", "Add a new database connection to DBX", {
259
269
  name: z.string().describe("Connection name"),
260
270
  db_type: z.string().describe(DBX_CONNECTION_TYPE_DESCRIPTION),
261
- host: z.string().describe("Database host"),
271
+ host: z.string().describe("Database host; for cloudflare-d1, use the Cloudflare Account ID"),
262
272
  port: z.number().optional().describe("Database port (TDengine defaults to 6041, IoTDB defaults to 6667, XuguDB defaults to 5138)"),
263
273
  username: z.string().default("").describe("Username"),
264
- password: z.string().default("").describe("Password"),
265
- database: z.string().optional().describe("Default database name"),
274
+ password: z.string().default("").describe("Password; for cloudflare-d1, use the API Token"),
275
+ database: z.string().optional().describe("Default database name; for cloudflare-d1, use the D1 Database ID"),
266
276
  ssl: z.boolean().default(false).describe("Enable SSL"),
267
277
  driver_profile: z.string().optional().describe("Driver profile (e.g. 'gbase8a', 'gbase8s')"),
268
278
  }, async ({ name, db_type, host, port, username, password, database, ssl, driver_profile }) => {
@@ -272,6 +282,7 @@ export function createDbxMcpServer(backend, options = {}) {
272
282
  const DEFAULT_PORTS = {
273
283
  kwdb: 26257,
274
284
  rqlite: 4001,
285
+ "cloudflare-d1": 443,
275
286
  tdengine: 6041,
276
287
  oscar: 2003,
277
288
  iotdb: 6667,
@@ -406,6 +417,17 @@ export function createDbxMcpServer(backend, options = {}) {
406
417
  if (!safety.allowed)
407
418
  return toolError("SQL_BLOCKED", safety.reason ?? "SQL blocked.");
408
419
  }
420
+ if (config?.db_type === "mongodb") {
421
+ if (isProductionDatabase(config, database ?? scope.database ?? config.database) && isLikelyMongoMutation(sql)) {
422
+ return toolError("PRODUCTION_WRITE_BLOCKED", "MCP cannot send writes against a production database to DBX.");
423
+ }
424
+ }
425
+ else {
426
+ const production = assessProductionSql(sql, config, database ?? scope.database ?? config.database);
427
+ if (production.active && production.isMutation) {
428
+ return toolError("PRODUCTION_WRITE_BLOCKED", "MCP cannot send writes against a production database to DBX.");
429
+ }
430
+ }
409
431
  // MongoDB shell commands bypass the SQL safety evaluator; pass MCP
410
432
  // safety flags to the desktop executor for command-aware gating.
411
433
  return bridgeRequest("/execute-query", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbx-app/mcp-server",
3
- "version": "0.4.26",
3
+ "version": "0.4.28",
4
4
  "description": "MCP server for DBX — query databases from Claude Code, Cursor, and other AI agents",
5
5
  "keywords": [
6
6
  "ai-agent",
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "@modelcontextprotocol/sdk": "^1.12.1",
32
32
  "zod": "^3.25.20",
33
- "@dbx-app/node-core": "^0.4.26"
33
+ "@dbx-app/node-core": "^0.4.28"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "^22.15.21",
package/server.json CHANGED
@@ -6,12 +6,12 @@
6
6
  "url": "https://github.com/t8y2/dbx",
7
7
  "source": "github"
8
8
  },
9
- "version": "0.4.26",
9
+ "version": "0.4.28",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "identifier": "@dbx-app/mcp-server",
14
- "version": "0.4.26",
14
+ "version": "0.4.28",
15
15
  "transport": {
16
16
  "type": "stdio"
17
17
  }