@bytebase/dbhub 1.2.4 → 1.2.5

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.
@@ -1832,7 +1832,7 @@ var ConnectorManager = class {
1832
1832
  if (!lazySource) {
1833
1833
  if (sourceId) {
1834
1834
  throw new Error(
1835
- `Source '${sourceId}' not found. Available sources: ${this.sourceIds.join(", ")}`
1835
+ `Source '${sourceId}' not found. Available sources: ${this.getAvailableSourceIds().join(", ")}`
1836
1836
  );
1837
1837
  } else {
1838
1838
  throw new Error("No sources configured. Call connectWithSources() first.");
@@ -1871,6 +1871,7 @@ var ConnectorManager = class {
1871
1871
  const dsn = await this.buildConnectionDSN(source);
1872
1872
  console.error(` - ${sourceId}: ${redactDSN(dsn)}`);
1873
1873
  let actualDSN = dsn;
1874
+ let tunnel;
1874
1875
  if (source.ssh_host) {
1875
1876
  const sshConfigPath = getDefaultSSHConfigPath();
1876
1877
  let resolvedSSHConfig = null;
@@ -1914,7 +1915,7 @@ var ConnectorManager = class {
1914
1915
  const url = new URL(dsn);
1915
1916
  const targetHost = url.hostname;
1916
1917
  const targetPort = parseInt(url.port) || this.getDefaultPort(dsn);
1917
- const tunnel = new SSHTunnel();
1918
+ tunnel = new SSHTunnel();
1918
1919
  let tunnelInfo;
1919
1920
  try {
1920
1921
  tunnelInfo = await tunnel.establish(sshConfig, {
@@ -1962,7 +1963,19 @@ var ConnectorManager = class {
1962
1963
  if (source.collation) {
1963
1964
  config.collation = source.collation;
1964
1965
  }
1965
- await connector.connect(actualDSN, source.init_script, config);
1966
+ try {
1967
+ await connector.connect(actualDSN, source.init_script, config);
1968
+ } catch (error) {
1969
+ if (tunnel) {
1970
+ this.sshTunnels.delete(sourceId);
1971
+ try {
1972
+ await tunnel.close();
1973
+ } catch (closeError) {
1974
+ console.error(`Error closing SSH tunnel for source '${sourceId}':`, closeError);
1975
+ }
1976
+ }
1977
+ throw error;
1978
+ }
1966
1979
  this.connectors.set(sourceId, connector);
1967
1980
  if (!this.sourceIds.includes(sourceId)) {
1968
1981
  this.sourceIds.push(sourceId);
@@ -2012,7 +2025,7 @@ var ConnectorManager = class {
2012
2025
  if (!connector) {
2013
2026
  if (sourceId) {
2014
2027
  throw new Error(
2015
- `Source '${sourceId}' not found. Available sources: ${this.sourceIds.join(", ")}`
2028
+ `Source '${sourceId}' not found. Available sources: ${this.getAvailableSourceIds().join(", ")}`
2016
2029
  );
2017
2030
  } else {
2018
2031
  throw new Error("No sources connected. Call connectWithSources() first.");
@@ -2049,6 +2062,14 @@ var ConnectorManager = class {
2049
2062
  getSourceIds() {
2050
2063
  return [...this.sourceIds];
2051
2064
  }
2065
+ /**
2066
+ * Source IDs that can actually serve a request: connected, or registered for
2067
+ * lazy (re)connection on first use. Used for error messages so a source that
2068
+ * is neither is not reported as available.
2069
+ */
2070
+ getAvailableSourceIds() {
2071
+ return this.sourceIds.filter((id) => this.connectors.has(id) || this.lazySources.has(id));
2072
+ }
2052
2073
  /** Get all available source IDs */
2053
2074
  static getAvailableSourceIds() {
2054
2075
  if (!managerInstance) {
@@ -2126,7 +2147,7 @@ var ConnectorManager = class {
2126
2147
  error
2127
2148
  );
2128
2149
  } finally {
2129
- if (!this.isDisconnecting && this.sourceConfigs.has(sourceId)) {
2150
+ if (!this.isDisconnecting && this.connectors.has(sourceId)) {
2130
2151
  this.scheduleIamRefresh(source);
2131
2152
  }
2132
2153
  }
@@ -2153,7 +2174,14 @@ var ConnectorManager = class {
2153
2174
  if (this.isDisconnecting) {
2154
2175
  return;
2155
2176
  }
2156
- await this.connectSource(source);
2177
+ try {
2178
+ await this.connectSource(source);
2179
+ } catch (error) {
2180
+ if (!this.isDisconnecting && this.sourceConfigs.has(sourceId)) {
2181
+ this.lazySources.set(sourceId, source);
2182
+ }
2183
+ throw error;
2184
+ }
2157
2185
  }
2158
2186
  /**
2159
2187
  * Build a connection DSN, optionally replacing password with
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  resolveSourceConfigs,
19
19
  resolveTomlConfigPath,
20
20
  resolveTransport
21
- } from "./chunk-F5TPYAVO.js";
21
+ } from "./chunk-VDA5BVNE.js";
22
22
  import {
23
23
  allowedKeywords,
24
24
  getFirstKeyword,
@@ -1913,7 +1913,7 @@ See documentation for more details on configuring database connections.
1913
1913
  const sources = sourceConfigsData.sources;
1914
1914
  console.error(`Configuration source: ${sourceConfigsData.source}`);
1915
1915
  await connectorManager.connectWithSources(sources);
1916
- const { initializeToolRegistry: initializeToolRegistry2 } = await import("./registry-6ABK3M6V.js");
1916
+ const { initializeToolRegistry: initializeToolRegistry2 } = await import("./registry-UF3N2H4G.js");
1917
1917
  initializeToolRegistry2({
1918
1918
  sources: sourceConfigsData.sources,
1919
1919
  tools: sourceConfigsData.tools
@@ -2,7 +2,7 @@ import {
2
2
  ToolRegistry,
3
3
  getToolRegistry,
4
4
  initializeToolRegistry
5
- } from "./chunk-F5TPYAVO.js";
5
+ } from "./chunk-VDA5BVNE.js";
6
6
  import "./chunk-WVVMH6FJ.js";
7
7
  import "./chunk-MF6LSVWK.js";
8
8
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebase/dbhub",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
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": {