@aiwerk/mcp-bridge 1.1.4 → 1.1.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.
- package/dist/src/config.js +2 -2
- package/dist/src/protocol.js +6 -1
- package/dist/src/transport-sse.js +7 -4
- package/package.json +1 -1
package/dist/src/config.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFileSync, existsSync, mkdirSync, writeFileSync, chmodSync } from "fs";
|
|
2
|
-
import { join } from "path";
|
|
2
|
+
import { join, extname } from "path";
|
|
3
3
|
import { homedir } from "os";
|
|
4
4
|
import { resolveEnvVars } from "./transport-base.js";
|
|
5
5
|
import { randomBytes } from "crypto";
|
|
@@ -101,7 +101,7 @@ export function getConfigDir(configPath) {
|
|
|
101
101
|
if (!configPath)
|
|
102
102
|
return DEFAULT_CONFIG_DIR;
|
|
103
103
|
// If path ends with separator or has no extension, treat as directory
|
|
104
|
-
if (configPath.endsWith("/") || configPath.endsWith("\\") || !configPath
|
|
104
|
+
if (configPath.endsWith("/") || configPath.endsWith("\\") || !extname(configPath)) {
|
|
105
105
|
return configPath;
|
|
106
106
|
}
|
|
107
107
|
return join(configPath, "..");
|
package/dist/src/protocol.js
CHANGED
|
@@ -36,7 +36,9 @@ export async function initializeProtocol(transport, version) {
|
|
|
36
36
|
export async function fetchToolsList(transport) {
|
|
37
37
|
const allTools = [];
|
|
38
38
|
let cursor;
|
|
39
|
-
|
|
39
|
+
const MAX_PAGES = 100;
|
|
40
|
+
let page = 0;
|
|
41
|
+
while (page++ < MAX_PAGES) {
|
|
40
42
|
const request = {
|
|
41
43
|
jsonrpc: "2.0",
|
|
42
44
|
method: "tools/list",
|
|
@@ -54,5 +56,8 @@ export async function fetchToolsList(transport) {
|
|
|
54
56
|
}
|
|
55
57
|
cursor = nextCursor;
|
|
56
58
|
}
|
|
59
|
+
if (page >= MAX_PAGES) {
|
|
60
|
+
console.warn("[mcp-bridge] Tool list pagination exceeded max pages, possible cursor loop");
|
|
61
|
+
}
|
|
57
62
|
return allTools;
|
|
58
63
|
}
|
|
@@ -64,6 +64,9 @@ export class SseTransport extends BaseTransport {
|
|
|
64
64
|
this.processEventLine(line, state);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
// Stream ended normally — server closed connection
|
|
68
|
+
this.logger.warn("[mcp-bridge] SSE stream ended, scheduling reconnect");
|
|
69
|
+
this.scheduleReconnect();
|
|
67
70
|
}
|
|
68
71
|
catch (error) {
|
|
69
72
|
if (error instanceof Error && error.name === 'AbortError')
|
|
@@ -74,12 +77,12 @@ export class SseTransport extends BaseTransport {
|
|
|
74
77
|
}
|
|
75
78
|
processEventLine(line, state) {
|
|
76
79
|
const trimmed = line.trim();
|
|
77
|
-
if (trimmed.startsWith("event:
|
|
78
|
-
state.event = trimmed.substring(
|
|
80
|
+
if (trimmed.startsWith("event:")) {
|
|
81
|
+
state.event = trimmed.substring(6).trim();
|
|
79
82
|
return;
|
|
80
83
|
}
|
|
81
|
-
if (trimmed.startsWith("data:
|
|
82
|
-
state.dataBuffer.push(trimmed.substring(
|
|
84
|
+
if (trimmed.startsWith("data:")) {
|
|
85
|
+
state.dataBuffer.push(trimmed.substring(5).trimStart());
|
|
83
86
|
return;
|
|
84
87
|
}
|
|
85
88
|
if (trimmed === "") {
|