@jadchene/mcp-gateway-service 0.1.2 → 0.2.0
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 +274 -278
- package/README_zh.md +276 -280
- package/config.example.json +18 -19
- package/dist/config.js +0 -2
- package/dist/gateway-server.js +1 -1
- package/dist/index.js +1 -9
- package/dist/logger.js +1 -47
- package/dist/mcp/client.js +1 -1
- package/package.json +44 -44
package/dist/logger.js
CHANGED
|
@@ -1,26 +1,7 @@
|
|
|
1
|
-
import { appendFileSync, mkdirSync } from "node:fs";
|
|
2
|
-
import { join, resolve } from "node:path";
|
|
3
1
|
/**
|
|
4
2
|
* Provides a minimal structured logger that writes newline-delimited JSON to stderr.
|
|
5
3
|
*/
|
|
6
4
|
export class Logger {
|
|
7
|
-
/**
|
|
8
|
-
* Stores the optional log file path used in addition to stderr.
|
|
9
|
-
*/
|
|
10
|
-
logFilePath = null;
|
|
11
|
-
/**
|
|
12
|
-
* Tracks whether file logging already failed to avoid repeated fallback noise.
|
|
13
|
-
*/
|
|
14
|
-
fileLoggingErrorReported = false;
|
|
15
|
-
/**
|
|
16
|
-
* Updates the directory used for the gateway log file.
|
|
17
|
-
*/
|
|
18
|
-
setLogDirectory(directory) {
|
|
19
|
-
const absoluteDirectory = resolve(directory);
|
|
20
|
-
mkdirSync(absoluteDirectory, { recursive: true });
|
|
21
|
-
this.logFilePath = join(absoluteDirectory, "mcp-gateway.log");
|
|
22
|
-
this.fileLoggingErrorReported = false;
|
|
23
|
-
}
|
|
24
5
|
/**
|
|
25
6
|
* Logs one structured event.
|
|
26
7
|
*/
|
|
@@ -49,33 +30,6 @@ export class Logger {
|
|
|
49
30
|
event,
|
|
50
31
|
...details
|
|
51
32
|
};
|
|
52
|
-
|
|
53
|
-
process.stderr.write(line);
|
|
54
|
-
this.writeToFile(line);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Appends one log line to the configured log file when file logging is enabled.
|
|
58
|
-
*/
|
|
59
|
-
writeToFile(line) {
|
|
60
|
-
if (!this.logFilePath) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
try {
|
|
64
|
-
appendFileSync(this.logFilePath, line, "utf8");
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
if (this.fileLoggingErrorReported) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
this.fileLoggingErrorReported = true;
|
|
71
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
72
|
-
process.stderr.write(`${JSON.stringify({
|
|
73
|
-
timestamp: new Date().toISOString(),
|
|
74
|
-
level: "error",
|
|
75
|
-
event: "logger.file_write_failed",
|
|
76
|
-
message,
|
|
77
|
-
logFilePath: this.logFilePath
|
|
78
|
-
})}\n`);
|
|
79
|
-
}
|
|
33
|
+
process.stderr.write(`${JSON.stringify(payload)}\n`);
|
|
80
34
|
}
|
|
81
35
|
}
|
package/dist/mcp/client.js
CHANGED
package/package.json
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@jadchene/mcp-gateway-service",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A token-efficient MCP gateway that provides one unified entry point for multiple downstream MCP services.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"bin": {
|
|
8
|
-
"mcp-gateway-service": "dist/index.js"
|
|
9
|
-
},
|
|
10
|
-
"license": "MIT",
|
|
11
|
-
"author": "jadchene",
|
|
12
|
-
"scripts": {
|
|
13
|
-
"build": "tsc -p tsconfig.build.json",
|
|
14
|
-
"dev": "node --experimental-strip-types src/index.ts",
|
|
15
|
-
"start": "node dist/index.js",
|
|
16
|
-
"test": "node --test --experimental-strip-types test/**/*.test.ts",
|
|
17
|
-
"version": "node dist/index.js --version",
|
|
18
|
-
"prepare": "npm run build",
|
|
19
|
-
"prepublishOnly": "npm run build"
|
|
20
|
-
},
|
|
21
|
-
"files": [
|
|
22
|
-
"dist",
|
|
23
|
-
"skills",
|
|
24
|
-
"config.example.json",
|
|
25
|
-
"README.md",
|
|
26
|
-
"README_zh.md",
|
|
27
|
-
"LICENSE",
|
|
28
|
-
"scripts"
|
|
29
|
-
],
|
|
30
|
-
"keywords": [
|
|
31
|
-
"mcp",
|
|
32
|
-
"gateway",
|
|
33
|
-
"model context protocol",
|
|
34
|
-
"agent",
|
|
35
|
-
"token-efficient"
|
|
36
|
-
],
|
|
37
|
-
"engines": {
|
|
38
|
-
"node": ">=24.0.0"
|
|
39
|
-
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"@types/node": "^24.0.0",
|
|
42
|
-
"typescript": "^5.8.0"
|
|
43
|
-
}
|
|
44
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@jadchene/mcp-gateway-service",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "A token-efficient MCP gateway that provides one unified entry point for multiple downstream MCP services.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"mcp-gateway-service": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"author": "jadchene",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc -p tsconfig.build.json",
|
|
14
|
+
"dev": "node --experimental-strip-types src/index.ts",
|
|
15
|
+
"start": "node dist/index.js",
|
|
16
|
+
"test": "node --test --experimental-strip-types test/**/*.test.ts",
|
|
17
|
+
"version": "node dist/index.js --version",
|
|
18
|
+
"prepare": "npm run build",
|
|
19
|
+
"prepublishOnly": "npm run build"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"skills",
|
|
24
|
+
"config.example.json",
|
|
25
|
+
"README.md",
|
|
26
|
+
"README_zh.md",
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"scripts"
|
|
29
|
+
],
|
|
30
|
+
"keywords": [
|
|
31
|
+
"mcp",
|
|
32
|
+
"gateway",
|
|
33
|
+
"model context protocol",
|
|
34
|
+
"agent",
|
|
35
|
+
"token-efficient"
|
|
36
|
+
],
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=24.0.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^24.0.0",
|
|
42
|
+
"typescript": "^5.8.0"
|
|
43
|
+
}
|
|
44
|
+
}
|