@bytebase/dbhub 1.2.0 → 1.2.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.
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>DBHub - Minimal Database MCP Server</title>
8
- <script type="module" crossorigin src="/assets/index-DOZ5HOZ9.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-BdBaFSHd.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-BJ-1UrcV.css">
10
10
  </head>
11
11
  <body>
@@ -2,9 +2,9 @@ import {
2
2
  ToolRegistry,
3
3
  getToolRegistry,
4
4
  initializeToolRegistry
5
- } from "./chunk-CUBIR72I.js";
5
+ } from "./chunk-F5TPYAVO.js";
6
6
  import "./chunk-WVVMH6FJ.js";
7
- import "./chunk-WIQ4DWGY.js";
7
+ import "./chunk-MF6LSVWK.js";
8
8
  export {
9
9
  ToolRegistry,
10
10
  getToolRegistry,
@@ -4,13 +4,13 @@ import {
4
4
  import {
5
5
  SQLRowLimiter,
6
6
  closeQuietly
7
- } from "./chunk-RSB7DPO2.js";
7
+ } from "./chunk-6QETXS44.js";
8
8
  import {
9
9
  ConnectorRegistry,
10
10
  SafeURL,
11
11
  obfuscateDSNPassword,
12
12
  splitSQLStatements
13
- } from "./chunk-WIQ4DWGY.js";
13
+ } from "./chunk-MF6LSVWK.js";
14
14
 
15
15
  // src/connectors/sqlite/suppress-experimental-warning.ts
16
16
  var installed = false;
@@ -334,17 +334,20 @@ var SQLiteConnector = class _SQLiteConnector {
334
334
  let processedStatement = statements[0];
335
335
  const trimmedStatement = statements[0].toLowerCase().trim();
336
336
  const isReadStatement = trimmedStatement.startsWith("select") || trimmedStatement.startsWith("with") || trimmedStatement.startsWith("explain") || trimmedStatement.startsWith("analyze") || trimmedStatement.startsWith("pragma") && (trimmedStatement.includes("table_info") || trimmedStatement.includes("index_info") || trimmedStatement.includes("index_list") || trimmedStatement.includes("foreign_key_list"));
337
+ let probeApplied = false;
337
338
  if (options.maxRows) {
338
- processedStatement = SQLRowLimiter.applyMaxRows(processedStatement, options.maxRows);
339
+ const rewrite = SQLRowLimiter.applyMaxRowsWithTruncationProbe(
340
+ processedStatement,
341
+ options.maxRows
342
+ );
343
+ processedStatement = rewrite.sql;
344
+ probeApplied = rewrite.probeApplied;
339
345
  }
340
346
  if (isReadStatement) {
341
- if (parameters && parameters.length > 0) {
342
- const rows = this.prepare(processedStatement).all(...parameters);
343
- return { resultSets: [{ sql: statements[0], rows, rowCount: rows.length }] };
344
- } else {
345
- const rows = this.prepare(processedStatement).all();
346
- return { resultSets: [{ sql: statements[0], rows, rowCount: rows.length }] };
347
- }
347
+ const rows = parameters && parameters.length > 0 ? this.prepare(processedStatement).all(...parameters) : this.prepare(processedStatement).all();
348
+ const resultSet = { sql: statements[0], rows, rowCount: rows.length };
349
+ SQLRowLimiter.flagTruncation(resultSet, options.maxRows, probeApplied);
350
+ return { resultSets: [resultSet] };
348
351
  } else {
349
352
  let result;
350
353
  if (parameters && parameters.length > 0) {
@@ -382,9 +385,14 @@ var SQLiteConnector = class _SQLiteConnector {
382
385
  if (options.readonly) {
383
386
  this.db.exec("PRAGMA query_only = ON");
384
387
  }
385
- const processedStatement = SQLRowLimiter.applyMaxRows(statement, options.maxRows);
388
+ const { sql: processedStatement, probeApplied } = SQLRowLimiter.applyMaxRowsWithTruncationProbe(
389
+ statement,
390
+ options.maxRows
391
+ );
386
392
  const rows = this.prepare(processedStatement).all();
387
- resultSets.push({ sql: statement, rows, rowCount: rows.length });
393
+ const resultSet = { sql: statement, rows, rowCount: rows.length };
394
+ SQLRowLimiter.flagTruncation(resultSet, options.maxRows, probeApplied);
395
+ resultSets.push(resultSet);
388
396
  }
389
397
  return { resultSets };
390
398
  }
@@ -3,7 +3,7 @@ import {
3
3
  sqlServerDynamicSqlPattern,
4
4
  sqlServerPassThroughKeywords,
5
5
  sqlServerPassThroughPattern
6
- } from "./chunk-PBN2UXB5.js";
6
+ } from "./chunk-IQRBLAB4.js";
7
7
  import {
8
8
  isDriverNotInstalled
9
9
  } from "./chunk-WVVMH6FJ.js";
@@ -14,14 +14,14 @@ import {
14
14
  import {
15
15
  SQLRowLimiter,
16
16
  closeQuietly
17
- } from "./chunk-RSB7DPO2.js";
17
+ } from "./chunk-6QETXS44.js";
18
18
  import {
19
19
  ConnectorRegistry,
20
20
  SafeURL,
21
21
  obfuscateDSNPassword,
22
22
  splitSQLStatements,
23
23
  stripCommentsAndStrings
24
- } from "./chunk-WIQ4DWGY.js";
24
+ } from "./chunk-MF6LSVWK.js";
25
25
 
26
26
  // src/connectors/sqlserver/index.ts
27
27
  import sql from "mssql";
@@ -562,12 +562,24 @@ var _SQLServerConnector = class _SQLServerConnector {
562
562
  }
563
563
  try {
564
564
  let processedSQL = sqlQuery;
565
+ let probeApplied = false;
565
566
  if (options.maxRows) {
566
- processedSQL = SQLRowLimiter.applyMaxRowsForSQLServer(sqlQuery, options.maxRows);
567
+ const rewrite = SQLRowLimiter.applyMaxRowsForSQLServerWithTruncationProbe(
568
+ sqlQuery,
569
+ options.maxRows
570
+ );
571
+ processedSQL = rewrite.sql;
572
+ probeApplied = rewrite.probeApplied;
567
573
  }
568
574
  const isSingleStatement = splitSQLStatements(processedSQL, "sqlserver").length === 1;
569
575
  if (options.readonly) {
570
- return await this.executeReadOnly(processedSQL, parameters, isSingleStatement);
576
+ return await this.executeReadOnly(
577
+ processedSQL,
578
+ parameters,
579
+ isSingleStatement ? sqlQuery : void 0,
580
+ options.maxRows,
581
+ probeApplied
582
+ );
571
583
  }
572
584
  const request = this.connection.request();
573
585
  const messages = [];
@@ -585,12 +597,16 @@ var _SQLServerConnector = class _SQLServerConnector {
585
597
  );
586
598
  _SQLServerConnector.bindParameters(request, parameters);
587
599
  const result = await request.query(processedSQL);
600
+ const resultSets = _SQLServerConnector.buildResultSets(
601
+ result.recordsets,
602
+ result.rowsAffected,
603
+ isSingleStatement ? sqlQuery : void 0
604
+ );
605
+ if (resultSets.length > 0) {
606
+ SQLRowLimiter.flagTruncation(resultSets[0], options.maxRows, probeApplied);
607
+ }
588
608
  return {
589
- resultSets: _SQLServerConnector.buildResultSets(
590
- result.recordsets,
591
- result.rowsAffected,
592
- isSingleStatement ? processedSQL : void 0
593
- ),
609
+ resultSets,
594
610
  ...messages.length > 0 ? { messages } : {}
595
611
  };
596
612
  } catch (error) {
@@ -718,7 +734,7 @@ var _SQLServerConnector = class _SQLServerConnector {
718
734
  * Dangerous constructs are rejected before the transaction opens; see
719
735
  * assertNoReadOnlyEscapes.
720
736
  */
721
- async executeReadOnly(processedSQL, parameters, isSingleStatement) {
737
+ async executeReadOnly(processedSQL, parameters, sourceSql, maxRows, probeApplied) {
722
738
  this.assertNoReadOnlyEscapes(processedSQL, { transactionControl: true });
723
739
  const transaction = new sql.Transaction(this.connection);
724
740
  await transaction.begin();
@@ -754,12 +770,16 @@ var _SQLServerConnector = class _SQLServerConnector {
754
770
  }
755
771
  }
756
772
  }
773
+ const resultSets = _SQLServerConnector.buildResultSets(
774
+ result.recordsets,
775
+ result.rowsAffected,
776
+ sourceSql
777
+ );
778
+ if (resultSets.length > 0) {
779
+ SQLRowLimiter.flagTruncation(resultSets[0], maxRows, probeApplied);
780
+ }
757
781
  return {
758
- resultSets: _SQLServerConnector.buildResultSets(
759
- result.recordsets,
760
- result.rowsAffected,
761
- isSingleStatement ? processedSQL : void 0
762
- ),
782
+ resultSets,
763
783
  ...messages.length > 0 ? { messages } : {}
764
784
  };
765
785
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebase/dbhub",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "mcpName": "io.github.bytebase/dbhub",
5
5
  "description": "Minimal, token-efficient Database MCP Server for PostgreSQL, MySQL, SQL Server, SQLite, MariaDB",
6
6
  "repository": {
@@ -55,6 +55,7 @@
55
55
  "zod": "^4.2.0"
56
56
  },
57
57
  "optionalDependencies": {
58
+ "@aws-sdk/credential-providers": "^3.1001.0",
58
59
  "@aws-sdk/rds-signer": "^3.1001.0",
59
60
  "@azure/identity": "^4.8.0",
60
61
  "mariadb": "^3.4.0",