@proofline/mcp 0.1.4 → 0.1.6
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 +1 -1
- package/package.json +1 -1
- package/src/bridge.js +16 -2
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ The server keeps model and repository text wrapped as `untrusted_text`. Treat it
|
|
|
50
50
|
|
|
51
51
|
The bridge accepts newline-delimited JSON-RPC on stdin and writes only protocol responses to stdout. Diagnostics go to stderr. The bridge forwards one request at a time and never retries. A failed mutation may have committed; inspect its state before making another request.
|
|
52
52
|
|
|
53
|
-
The bridge supports Proofline's stateless JSON transport with protocol `2025-11-25`. Initialize, then send `notifications/initialized` before calling tools. The bridge limits input frames to 8 KiB, responses to 8 MiB, and requests to
|
|
53
|
+
The bridge supports Proofline's stateless JSON transport with protocol `2025-11-25`. Initialize, then send `notifications/initialized` before calling tools. The bridge limits input frames to 8 KiB, responses to 8 MiB, and requests to 35 seconds. A timed-out request returns a correlated JSON-RPC `-32000` error (`data.category: "timeout"`) without ending the bridge, so no restart is needed; because the call may still have run on the server, read state before repeating a write. It refuses redirects, SSE, and `MCP-Session-Id`. HTTP failures produce a correlated, sanitized JSON-RPC error; the bridge does not print upstream error bodies or credentials. HTTP refusals, timed-out notifications, and other transport failures exit 1. Clean input EOF exits 0.
|
|
54
54
|
|
|
55
55
|
## Development and releases
|
|
56
56
|
|
package/package.json
CHANGED
package/src/bridge.js
CHANGED
|
@@ -3,6 +3,8 @@ import { once } from "node:events";
|
|
|
3
3
|
export const PROTOCOL = "2025-11-25";
|
|
4
4
|
const REQUEST_LIMIT = 8192;
|
|
5
5
|
const RESPONSE_LIMIT = 8 * 1024 * 1024;
|
|
6
|
+
const REQUEST_TIMEOUT = 35_000;
|
|
7
|
+
const TRANSPORT_TIMEOUTS = new Set(["UND_ERR_CONNECT_TIMEOUT", "UND_ERR_HEADERS_TIMEOUT", "UND_ERR_BODY_TIMEOUT", "ETIMEDOUT"]);
|
|
6
8
|
const object = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
7
9
|
const identity = (value) => typeof value === "string" || Number.isSafeInteger(value);
|
|
8
10
|
|
|
@@ -56,11 +58,12 @@ async function send(output, message) {
|
|
|
56
58
|
|
|
57
59
|
async function post(frame, config, protocol, notification) {
|
|
58
60
|
let response;
|
|
61
|
+
const signal = AbortSignal.timeout(REQUEST_TIMEOUT);
|
|
59
62
|
try {
|
|
60
63
|
response = await fetch(`${config.origin}/mcp`, {
|
|
61
64
|
method: "POST",
|
|
62
65
|
redirect: "manual",
|
|
63
|
-
signal
|
|
66
|
+
signal,
|
|
64
67
|
headers: {
|
|
65
68
|
Authorization: `Bearer ${config.token}`,
|
|
66
69
|
"Content-Type": "application/json",
|
|
@@ -94,6 +97,9 @@ async function post(frame, config, protocol, notification) {
|
|
|
94
97
|
} catch { throw new BridgeError("response"); }
|
|
95
98
|
} catch (error) {
|
|
96
99
|
if (error instanceof BridgeError) throw error;
|
|
100
|
+
if (signal.aborted || TRANSPORT_TIMEOUTS.has(error.cause?.code ?? error.code)) {
|
|
101
|
+
throw new BridgeError("timeout");
|
|
102
|
+
}
|
|
97
103
|
throw new BridgeError("transport");
|
|
98
104
|
}
|
|
99
105
|
}
|
|
@@ -142,7 +148,15 @@ export async function bridge(input, output, diagnostic, config) {
|
|
|
142
148
|
notification = false;
|
|
143
149
|
continue;
|
|
144
150
|
}
|
|
145
|
-
|
|
151
|
+
let response;
|
|
152
|
+
try {
|
|
153
|
+
response = await post(frame, config, protocol, notification);
|
|
154
|
+
} catch (error) {
|
|
155
|
+
if (notification || !(error instanceof BridgeError) || error.category !== "timeout") throw error;
|
|
156
|
+
await send(output, failure(error, id));
|
|
157
|
+
id = null;
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
146
160
|
if (!notification) {
|
|
147
161
|
if (!object(response) || response.jsonrpc !== "2.0" || response.id !== id ||
|
|
148
162
|
("result" in response) === ("error" in response) ||
|