@aiwerk/mcp-bridge 1.1.1 → 1.1.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.
package/dist/src/config.js
CHANGED
|
@@ -53,11 +53,9 @@ function resolveConfigValue(value, extraEnv) {
|
|
|
53
53
|
* 4. Validate required fields
|
|
54
54
|
*/
|
|
55
55
|
export function loadConfig(options = {}) {
|
|
56
|
-
const configDir = options.configPath
|
|
57
|
-
? join(options.configPath, "..") // If a file path is given, derive directory
|
|
58
|
-
: DEFAULT_CONFIG_DIR;
|
|
56
|
+
const configDir = getConfigDir(options.configPath);
|
|
59
57
|
const configPath = options.configPath || join(DEFAULT_CONFIG_DIR, DEFAULT_CONFIG_FILE);
|
|
60
|
-
const envPath = join(
|
|
58
|
+
const envPath = join(configDir, DEFAULT_ENV_FILE);
|
|
61
59
|
if (!existsSync(configPath)) {
|
|
62
60
|
throw new Error(`Config file not found: ${configPath}\nRun 'mcp-bridge init' to set up.`);
|
|
63
61
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type { RouterToolHint, RouterServerStatus, RouterDispatchResponse, Router
|
|
|
7
7
|
export { convertJsonSchemaToTypeBox, createToolParameters, setTypeBoxLoader, setSchemaLogger } from "./schema-convert.js";
|
|
8
8
|
export { initializeProtocol, fetchToolsList, PACKAGE_VERSION } from "./protocol.js";
|
|
9
9
|
export { loadConfig, parseEnvFile, initConfigDir, getConfigDir } from "./config.js";
|
|
10
|
-
export type { Logger, McpServerConfig, McpClientConfig, McpTool, McpRequest, McpResponse, McpTransport, McpServerConnection, BridgeConfig, } from "./types.js";
|
|
10
|
+
export type { Logger, McpServerConfig, McpClientConfig, McpTool, McpRequest, McpCallRequest, McpResponse, McpTransport, McpServerConnection, BridgeConfig, } from "./types.js";
|
|
11
11
|
export { nextRequestId } from "./types.js";
|
|
12
12
|
export { pickRegisteredToolName } from "./tool-naming.js";
|
|
13
13
|
export { StandaloneServer } from "./standalone-server.js";
|
|
@@ -249,8 +249,13 @@ export class StandaloneServer {
|
|
|
249
249
|
async discoverDirectTools(force = false) {
|
|
250
250
|
if (this.directTools.length > 0 && !force)
|
|
251
251
|
return; // Already discovered
|
|
252
|
-
if (force)
|
|
252
|
+
if (force) {
|
|
253
253
|
this.directTools = [];
|
|
254
|
+
for (const [, conn] of this.directConnections) {
|
|
255
|
+
await conn.transport.disconnect().catch(() => { });
|
|
256
|
+
}
|
|
257
|
+
this.directConnections.clear();
|
|
258
|
+
}
|
|
254
259
|
const globalNames = new Set();
|
|
255
260
|
for (const [serverName, serverConfig] of Object.entries(this.config.servers)) {
|
|
256
261
|
try {
|
|
@@ -52,7 +52,7 @@ export class SseTransport extends BaseTransport {
|
|
|
52
52
|
const reader = response.body.getReader();
|
|
53
53
|
const decoder = new TextDecoder();
|
|
54
54
|
let buffer = "";
|
|
55
|
-
const state = { event: "", dataBuffer:
|
|
55
|
+
const state = { event: "", dataBuffer: [] };
|
|
56
56
|
while (true) {
|
|
57
57
|
const { done, value } = await reader.read();
|
|
58
58
|
if (done)
|
|
@@ -60,31 +60,19 @@ export class StreamableHttpTransport extends BaseTransport {
|
|
|
60
60
|
const dataLines = text.split('\n')
|
|
61
61
|
.filter((line) => line.startsWith('data:'))
|
|
62
62
|
.map((line) => line.substring(5).trim());
|
|
63
|
-
if (dataLines.length
|
|
64
|
-
for (const dl of dataLines) {
|
|
65
|
-
try {
|
|
66
|
-
const parsed = JSON.parse(dl);
|
|
67
|
-
if (parsed.id !== undefined) {
|
|
68
|
-
jsonResponse = parsed;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
this.handleMessage(parsed);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
catch { /* skip malformed lines */ }
|
|
75
|
-
}
|
|
76
|
-
if (!jsonResponse) {
|
|
77
|
-
jsonResponse = JSON.parse(dataLines[dataLines.length - 1]);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
63
|
+
if (dataLines.length === 0) {
|
|
81
64
|
throw new Error("No data lines in SSE response");
|
|
82
65
|
}
|
|
66
|
+
for (const dl of dataLines) {
|
|
67
|
+
try {
|
|
68
|
+
this.handleMessage(JSON.parse(dl));
|
|
69
|
+
}
|
|
70
|
+
catch { /* skip malformed lines */ }
|
|
71
|
+
}
|
|
83
72
|
}
|
|
84
73
|
else {
|
|
85
|
-
|
|
74
|
+
this.handleMessage(await response.json());
|
|
86
75
|
}
|
|
87
|
-
this.handleMessage(jsonResponse);
|
|
88
76
|
}
|
|
89
77
|
catch (error) {
|
|
90
78
|
clearTimeout(timeout);
|