Skip to main content
Glama
set-connection-timeout.jsโ€ข1.27 kB
import { timing } from "./timing"; const DEFER_EVENT_LISTENER_TIME = 1000; export const setConnectionTimeout = (request, reject, timeoutInMs = 0) => { if (!timeoutInMs) { return -1; } const registerTimeout = (offset) => { const timeoutId = timing.setTimeout(() => { request.destroy(); reject(Object.assign(new Error(`@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ${timeoutInMs} ms.`), { name: "TimeoutError", })); }, timeoutInMs - offset); const doWithSocket = (socket) => { if (socket?.connecting) { socket.on("connect", () => { timing.clearTimeout(timeoutId); }); } else { timing.clearTimeout(timeoutId); } }; if (request.socket) { doWithSocket(request.socket); } else { request.on("socket", doWithSocket); } }; if (timeoutInMs < 2000) { registerTimeout(0); return 0; } return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME); };

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/consigcody94/office-whisperer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server