db4app-mcp-server 0.1.6 → 0.1.8

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/README.md CHANGED
@@ -39,7 +39,7 @@ npx db4app-mcp-server
39
39
  "command": "npx",
40
40
  "args": [
41
41
  "-y",
42
- "db4app-mcp-server"
42
+ "db4app-mcp-server@0.1.6"
43
43
  ],
44
44
  "env": {
45
45
  "MCP_POSTGRES_URL": "postgres://postgres:YOUR_AUTH_TOKEN@YOUR_CONNECTION_ID.pg.db4.app",
@@ -80,7 +80,7 @@ npx db4app-mcp-server
80
80
  "command": "npx",
81
81
  "args": [
82
82
  "-y",
83
- "db4app-mcp-server"
83
+ "db4app-mcp-server@0.1.6"
84
84
  ],
85
85
  "env": {
86
86
  "MCP_POSTGRES_URL": "postgres://postgres:YOUR_AUTH_TOKEN@YOUR_CONNECTION_ID.pg.db4.app",
package/dist/index.js CHANGED
@@ -14682,8 +14682,15 @@ function getClient(postgresUrl) {
14682
14682
  return client;
14683
14683
  }
14684
14684
  async function ensureConnected(client) {
14685
- if (client._ending || client._ending === void 0) {
14686
- await client.connect();
14685
+ if (client._connected || client._ending) {
14686
+ return;
14687
+ }
14688
+ if (!client._connected) {
14689
+ const connectPromise = client.connect();
14690
+ const timeoutPromise = new Promise(
14691
+ (_, reject) => setTimeout(() => reject(new Error("Postgres connection timed out after 10 seconds")), 1e4)
14692
+ );
14693
+ await Promise.race([connectPromise, timeoutPromise]);
14687
14694
  }
14688
14695
  }
14689
14696
  var mcpServer = new McpServer({
@@ -14865,12 +14872,32 @@ async function generateEmbedding(text, embeddingUrl, model) {
14865
14872
  }
14866
14873
  let response;
14867
14874
  try {
14875
+ const controller = new AbortController();
14876
+ const timeoutId = setTimeout(() => controller.abort(), 3e4);
14868
14877
  response = await fetch(url, {
14869
14878
  method: "POST",
14870
14879
  headers: { "content-type": "application/json" },
14871
- body: JSON.stringify(requestBody)
14880
+ body: JSON.stringify(requestBody),
14881
+ signal: controller.signal
14872
14882
  });
14883
+ clearTimeout(timeoutId);
14873
14884
  } catch (fetchError) {
14885
+ if (fetchError.name === "AbortError") {
14886
+ throw new Error(
14887
+ `Embedding request timed out after 30 seconds. This usually means:
14888
+ 1. LM Studio is not responding (check if it's running)
14889
+ 2. The model is not an embedding model (you need an embedding model, not a chat model)
14890
+ 3. The embedding endpoint URL is incorrect
14891
+
14892
+ Current URL: ${url}
14893
+ Model: ${model || DEFAULT_EMBEDDING_MODEL || "not specified"}
14894
+
14895
+ Troubleshooting:
14896
+ - Make sure LM Studio headless server is running
14897
+ - Load an EMBEDDING model (e.g., "BAAI/bge-small-en-v1.5", "text-embedding-qwen3-embedding-4b")
14898
+ - Check the embedding endpoint URL (default: http://localhost:1234/v1/embeddings)`
14899
+ );
14900
+ }
14874
14901
  const baseMessage = fetchError instanceof TypeError && fetchError.message.includes("fetch") ? `Failed to connect to LM Studio embedding endpoint at ${url}` : `Network error calling LM Studio embedding API: ${fetchError instanceof Error ? fetchError.message : String(fetchError)}`;
14875
14902
  const suggestion = `
14876
14903
 
@@ -14900,12 +14927,23 @@ Troubleshooting:
14900
14927
  }
14901
14928
  throw new Error("Unexpected embedding response format from LM Studio");
14902
14929
  }
14903
- async function executeSql(postgresUrl, sql, params = []) {
14930
+ async function executeSql(postgresUrl, sql, params = [], timeoutMs = 3e4) {
14904
14931
  const client = getClient(postgresUrl);
14905
14932
  try {
14906
14933
  await ensureConnected(client);
14907
- console.log("[MCP] Executing SQL:", { postgresUrl: postgresUrl.replace(/:[^:@]+@/, ":****@"), sql: sql.substring(0, 100) + "..." });
14908
- const result = await client.query(sql, params);
14934
+ const hasLargeArray = params.some((p) => Array.isArray(p) && p.length > 1e3);
14935
+ const timeout = hasLargeArray ? 6e4 : timeoutMs;
14936
+ console.log("[MCP] Executing SQL:", {
14937
+ postgresUrl: postgresUrl.replace(/:[^:@]+@/, ":****@"),
14938
+ sql: sql.substring(0, 100) + "...",
14939
+ hasLargeArray,
14940
+ timeout: `${timeout}ms`
14941
+ });
14942
+ const queryPromise = client.query(sql, params);
14943
+ const timeoutPromise = new Promise(
14944
+ (_, reject) => setTimeout(() => reject(new Error(`Postgres query timed out after ${timeout / 1e3} seconds`)), timeout)
14945
+ );
14946
+ const result = await Promise.race([queryPromise, timeoutPromise]);
14909
14947
  return {
14910
14948
  columns: result.fields?.map((f) => f.name) ?? [],
14911
14949
  rows: result.rows ?? [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "db4app-mcp-server",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "MCP server for db4.app - enables LLMs to interact with browser-based Postgres databases via Model Context Protocol",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",