@proofline/mcp 0.1.4 → 0.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/bridge.js +16 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proofline/mcp",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Connect coding agents to Proofline's hosted MCP tools over stdio",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
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: AbortSignal.timeout(30_000),
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
- const response = await post(frame, config, protocol, notification);
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) ||