mcp-proxy 6.4.2 → 6.4.4
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/bin/mcp-proxy.mjs +28 -6
- package/dist/bin/mcp-proxy.mjs.map +1 -1
- package/dist/index.mjs +169 -145
- package/dist/index.mjs.map +1 -1
- package/dist/{stdio-CvFTizsx.mjs → stdio-BmURZCbz.mjs} +1557 -749
- package/dist/stdio-BmURZCbz.mjs.map +1 -0
- package/jsr.json +1 -1
- package/package.json +2 -2
- package/src/JSONFilterTransform.test.ts +47 -2
- package/src/JSONFilterTransform.ts +41 -8
- package/src/bin/mcp-proxy.ts +2 -3
- package/src/fixtures/noisy-stdout-server.ts +70 -0
- package/src/proxyServer.test.ts +2 -4
- package/src/startHTTPServer.test.ts +18 -51
- package/src/startStdioServer.ts +2 -3
- package/dist/stdio-CvFTizsx.mjs.map +0 -1
package/dist/bin/mcp-proxy.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { D as __toESM, E as __commonJSMin, a as startHTTPServer, i as Client, n as serializeMessage, o as proxyServer, r as Server, t as ReadBuffer, w as InMemoryEventStore } from "../stdio-
|
|
2
|
+
import { D as __toESM, E as __commonJSMin, a as startHTTPServer, i as Client, n as serializeMessage, o as proxyServer, r as Server, t as ReadBuffer, w as InMemoryEventStore } from "../stdio-BmURZCbz.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { basename, dirname, extname, join, normalize, relative, resolve } from "path";
|
|
5
5
|
import { format, inspect } from "util";
|
|
@@ -4844,8 +4844,12 @@ var yargs_default = Yargs;
|
|
|
4844
4844
|
//#endregion
|
|
4845
4845
|
//#region src/JSONFilterTransform.ts
|
|
4846
4846
|
/**
|
|
4847
|
-
*
|
|
4848
|
-
*
|
|
4847
|
+
* Extracts JSON-RPC messages from a stream that may contain non-JSON output.
|
|
4848
|
+
*
|
|
4849
|
+
* Lines that start with '{' are passed through as-is. Lines that contain '{'
|
|
4850
|
+
* but have a non-JSON prefix (e.g. Python warnings prepended to a JSON message)
|
|
4851
|
+
* have the prefix stripped and the JSON portion extracted. Lines with no '{'
|
|
4852
|
+
* are dropped entirely.
|
|
4849
4853
|
*/
|
|
4850
4854
|
var JSONFilterTransform = class extends Transform {
|
|
4851
4855
|
buffer = "";
|
|
@@ -4853,7 +4857,8 @@ var JSONFilterTransform = class extends Transform {
|
|
|
4853
4857
|
super({ objectMode: false });
|
|
4854
4858
|
}
|
|
4855
4859
|
_flush(callback) {
|
|
4856
|
-
|
|
4860
|
+
const json = extractJson(this.buffer);
|
|
4861
|
+
if (json !== null) callback(null, Buffer.from(json));
|
|
4857
4862
|
else callback(null, null);
|
|
4858
4863
|
}
|
|
4859
4864
|
_transform(chunk, _encoding, callback) {
|
|
@@ -4862,8 +4867,11 @@ var JSONFilterTransform = class extends Transform {
|
|
|
4862
4867
|
this.buffer = lines.pop() || "";
|
|
4863
4868
|
const jsonLines = [];
|
|
4864
4869
|
const nonJsonLines = [];
|
|
4865
|
-
for (const line of lines)
|
|
4866
|
-
|
|
4870
|
+
for (const line of lines) {
|
|
4871
|
+
const json = extractJson(line);
|
|
4872
|
+
if (json !== null) jsonLines.push(json);
|
|
4873
|
+
else if (line.trim().length > 0) nonJsonLines.push(line);
|
|
4874
|
+
}
|
|
4867
4875
|
if (nonJsonLines.length > 0) console.warn("[mcp-proxy] ignoring non-JSON output", nonJsonLines);
|
|
4868
4876
|
if (jsonLines.length > 0) {
|
|
4869
4877
|
const output = jsonLines.join("\n") + "\n";
|
|
@@ -4871,6 +4879,20 @@ var JSONFilterTransform = class extends Transform {
|
|
|
4871
4879
|
} else callback(null, null);
|
|
4872
4880
|
}
|
|
4873
4881
|
};
|
|
4882
|
+
/**
|
|
4883
|
+
* Extracts the JSON portion from a line that may have a non-JSON prefix.
|
|
4884
|
+
* Returns null if the line contains no '{'.
|
|
4885
|
+
*/
|
|
4886
|
+
function extractJson(line) {
|
|
4887
|
+
const trimmed = line.trim();
|
|
4888
|
+
if (trimmed.length === 0) return null;
|
|
4889
|
+
const braceIndex = trimmed.indexOf("{");
|
|
4890
|
+
if (braceIndex === -1) return null;
|
|
4891
|
+
if (braceIndex === 0) return trimmed;
|
|
4892
|
+
const jsonPart = trimmed.slice(braceIndex);
|
|
4893
|
+
console.warn("[mcp-proxy] stripped non-JSON prefix from output:", trimmed.slice(0, braceIndex));
|
|
4894
|
+
return jsonPart;
|
|
4895
|
+
}
|
|
4874
4896
|
|
|
4875
4897
|
//#endregion
|
|
4876
4898
|
//#region src/StdioClientTransport.ts
|